Window events.
This commit is contained in:
@@ -705,14 +705,22 @@ RL.GLFW_RELEASE=0
|
||||
RL.GLFW_PRESS=1
|
||||
RL.GLFW_REPEAT=2
|
||||
|
||||
-- Globals - Event
|
||||
-- Globals - Window
|
||||
|
||||
RL.EVENT_KEY=0
|
||||
RL.EVENT_CHAR=1
|
||||
RL.EVENT_MOUSE_BUTTON=2
|
||||
RL.EVENT_MOUSE_CURSOR_POS=3
|
||||
RL.EVENT_MOUSE_SCROLL=4
|
||||
RL.EVENT_CURSOR_ENTER=5
|
||||
RL.EVENT_WINDOW_SIZE=0
|
||||
RL.EVENT_WINDOW_MAXIMIZE=1
|
||||
RL.EVENT_WINDOW_ICONYFY=2
|
||||
RL.EVENT_WINDOW_FOCUS=3
|
||||
RL.EVENT_WINDOW_DROP=4
|
||||
|
||||
-- Globals - Input
|
||||
|
||||
RL.EVENT_KEY=5
|
||||
RL.EVENT_CHAR=6
|
||||
RL.EVENT_MOUSE_BUTTON=7
|
||||
RL.EVENT_MOUSE_CURSOR_POS=8
|
||||
RL.EVENT_MOUSE_SCROLL=9
|
||||
RL.EVENT_CURSOR_ENTER=10
|
||||
-- Core - Window
|
||||
|
||||
---Check if window has been initialized successfully
|
||||
|
||||
@@ -17,9 +17,9 @@ KEY CHANGES:
|
||||
- ADDED: rlgl Framebuffer management (fbo) functions
|
||||
- ADDED: rlgl Framebuffer state functions
|
||||
- ADDED: rlgl Textures management functions
|
||||
- ADDED: Texture and RenderTexture can be given as tables
|
||||
- ADDED: Camera2D and Camera3D can be given as tables
|
||||
- ADDED: Camera2D and Camera3D can be given as tables
|
||||
- ADDED: Texture and RenderTexture can be referenced as tables
|
||||
- ADDED: Camera2D and Camera3D can be referenced as tables
|
||||
- ADDED: Camera2D and Camera3D can be referenced as tables
|
||||
- ADDED: rlgl New defines
|
||||
- ADDED: rlgl Textures state functions
|
||||
- ADDED: rlgl Some Render batch management functions
|
||||
@@ -33,6 +33,7 @@ KEY CHANGES:
|
||||
- ADDED: rlgl Vertex buffers state.
|
||||
- ADDED: rlgl Shader state.
|
||||
- ADDED: RL.event function with input events.
|
||||
- ADDED: Window events.
|
||||
|
||||
Detailed changes:
|
||||
- FIXED: uluaGetRay was looking for integers instead of tables
|
||||
@@ -96,6 +97,7 @@ Detailed changes:
|
||||
- ADDED: GetTextureId
|
||||
- ADDED: ImageDrawCircleLines
|
||||
- ADDED: ImageBlurGaussian
|
||||
- ADDED: Values for API.md
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Release: ReiLua version 0.4.0 Using Raylib 4.2
|
||||
|
||||
3
devnotes
3
devnotes
@@ -1,6 +1,4 @@
|
||||
Current {
|
||||
* Events
|
||||
* Window events
|
||||
* rlgl
|
||||
* Vertex buffers management
|
||||
* Matrix state management
|
||||
@@ -12,6 +10,7 @@ Backlog {
|
||||
* New type validators.
|
||||
* Platformer example physics process for true framerate independence.
|
||||
* Extend color lib functionality.
|
||||
* Global descriptions for API.
|
||||
|
||||
* IsWaveReady and other Is* ready functions.
|
||||
* Text
|
||||
|
||||
@@ -105,17 +105,6 @@ apiFile:write( "\n> function RL.event( event )\n\n"..FUNC_DESC.event.."\n\n---\n
|
||||
apiFile:write( "\n> function RL.log( logLevel, message )\n\n"..FUNC_DESC.log.."\n\n---\n" )
|
||||
apiFile:write( "\n> function RL.exit()\n\n"..FUNC_DESC.exit.."\n\n---\n" )
|
||||
|
||||
-- Events.
|
||||
|
||||
apiFile:write( "\n## Events\n" )
|
||||
apiFile:write( "\nEvent content in RL.event.\n" )
|
||||
apiFile:write( "\n---\n> { type: RL.EVENT_KEY, int key, int scancode, int action, int mods }\n\n GLFW3 Keyboard Callback, runs on key pressed.\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_CHAR, int key }\n\n GLFW3 Char Key Callback, runs on key pressed (get char value).\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_MOUSE_BUTTON, int button, int action, int mods }\n\n GLFW3 Mouse Button Callback, runs on mouse button pressed.\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_MOUSE_CURSOR_POS, number x, number y }\n\n GLFW3 Cursor Position Callback, runs on mouse move.\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_MOUSE_SCROLL, number xoffset, number yoffset }\n\n GLFW3 Srolling Callback, runs on mouse wheel.\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_CURSOR_ENTER, int enter }\n\n GLFW3 Cursor Enter Callback, cursor enters client area.\n\n---\n" )
|
||||
|
||||
luaApiFile:write( "-- Put this file into your project folder to provide annotations when using Lua language server.\n\n" )
|
||||
luaApiFile:write( "RL={}\n\n" )
|
||||
luaApiFile:write( "-- Functions.\n\n" )
|
||||
@@ -156,21 +145,24 @@ repeat
|
||||
-- Remove comma from the end.
|
||||
local globalName = lineSplit[2]:sub( 1, -2 )
|
||||
|
||||
apiFile:write( "\n"..globalName.."\n" )
|
||||
local value = RL[ globalName ]
|
||||
|
||||
globalName = "RL."..globalName
|
||||
|
||||
globalVariableCount = globalVariableCount + 1
|
||||
|
||||
if value == nil then
|
||||
luaApiFile:write( globalName.."=nil\n" )
|
||||
apiFile:write( "\n"..globalName.." = nil\n" )
|
||||
luaApiFile:write( "RL."..globalName.."=nil\n" )
|
||||
elseif type( value ) == "table" then
|
||||
-- All tables are colors.
|
||||
luaApiFile:write( globalName.."={"
|
||||
apiFile:write( globalName.." = { "
|
||||
..math.tointeger( value[1] )..", "..math.tointeger( value[2] )..", "
|
||||
..math.tointeger( value[3] )..", "..math.tointeger( value[4] ).." }\n" )
|
||||
luaApiFile:write( "RL."..globalName.."={"
|
||||
..math.tointeger( value[1] )..","..math.tointeger( value[2] )..","
|
||||
..math.tointeger( value[3] )..","..math.tointeger( value[4] ).."}\n" )
|
||||
else
|
||||
luaApiFile:write( globalName.."="..value.."\n" )
|
||||
apiFile:write( globalName.." = "..value.."\n" )
|
||||
luaApiFile:write( "RL."..globalName.."="..value.."\n" )
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -261,6 +253,24 @@ apiFile:write( "\n> NPatchInfo = { { 0, 0, 24, 24 }, 8, 8, 8, 8, NPATCH_NINE_PAT
|
||||
apiFile:write( "\n> ModelAnimations = ModelAnimationsId\n\
|
||||
int id. ModelAnimations\n\n---\n" )
|
||||
|
||||
-- Events.
|
||||
|
||||
apiFile:write( "\n## Events\n" )
|
||||
apiFile:write( "\nContent of event table received by RL.event.\n" )
|
||||
apiFile:write( "\n### Window events\n" )
|
||||
apiFile:write( "\n---\n> { type: RL.EVENT_WINDOW_SIZE, int width, int height }\n\n WindowSize Callback, runs when window is resized.\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_WINDOW_MAXIMIZE, int maximized }\n\n Window Maximize Callback, runs when window is maximized.\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_WINDOW_ICONYFY, int iconified }\n\n WindowIconify Callback, runs when window is minimized/restored.\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_WINDOW_FOCUS, int focused }\n\n WindowFocus Callback, runs when window get/lose focus.\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_WINDOW_DROP, int count, string{} paths }\n\n Window Drop Callback, runs when drop files into window.\n\n---\n" )
|
||||
apiFile:write( "\n### Input events\n" )
|
||||
apiFile:write( "\n---\n> { type: RL.EVENT_KEY, int key, int scancode, int action, int mods }\n\n Keyboard Callback, runs on key pressed.\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_CHAR, int key }\n\n Char Key Callback, runs on key pressed (get char value).\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_MOUSE_BUTTON, int button, int action, int mods }\n\n Mouse Button Callback, runs on mouse button pressed.\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_MOUSE_CURSOR_POS, number x, number y }\n\n Cursor Position Callback, runs on mouse move.\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_MOUSE_SCROLL, number xoffset, number yoffset }\n\n Srolling Callback, runs on mouse wheel.\n\n---\n" )
|
||||
apiFile:write( "\n> { type RL.EVENT_CURSOR_ENTER, int enter }\n\n Cursor Enter Callback, cursor enters client area.\n\n---\n" )
|
||||
|
||||
if separate then
|
||||
apiFile:close()
|
||||
end
|
||||
|
||||
@@ -4,11 +4,22 @@ local cursorIn = 0
|
||||
|
||||
function RL.init()
|
||||
RL.SetWindowTitle( "Events" )
|
||||
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )
|
||||
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||
end
|
||||
|
||||
local function getEventType( event )
|
||||
if event.type == RL.EVENT_KEY then
|
||||
if event.type == RL.EVENT_WINDOW_SIZE then
|
||||
return "Window Size"
|
||||
elseif event.type == RL.EVENT_WINDOW_MAXIMIZE then
|
||||
return "Window Maximized"
|
||||
elseif event.type == RL.EVENT_WINDOW_ICONYFY then
|
||||
return "Window Iconyfy"
|
||||
elseif event.type == RL.EVENT_WINDOW_FOCUS then
|
||||
return "Window Focus"
|
||||
elseif event.type == RL.EVENT_WINDOW_DROP then
|
||||
return "Window Drop"
|
||||
elseif event.type == RL.EVENT_KEY then
|
||||
return "Key"
|
||||
elseif event.type == RL.EVENT_CHAR then
|
||||
return "Char"
|
||||
@@ -50,7 +61,20 @@ end
|
||||
function RL.event( event )
|
||||
text = "Event: "..getEventType( event ).."\n"
|
||||
|
||||
if event.type == RL.EVENT_KEY then
|
||||
if event.type == RL.EVENT_WINDOW_SIZE then
|
||||
text = text.."width: "..event.width.." height: "..event.height
|
||||
elseif event.type == RL.EVENT_WINDOW_MAXIMIZE then
|
||||
text = text.."maximized: "..event.maximized
|
||||
elseif event.type == RL.EVENT_WINDOW_ICONYFY then
|
||||
text = text.."iconified: "..event.iconified
|
||||
elseif event.type == RL.EVENT_WINDOW_FOCUS then
|
||||
text = text.."focused: "..event.focused
|
||||
elseif event.type == RL.EVENT_WINDOW_DROP then
|
||||
text = text.."count: "..event.count.."\n"
|
||||
for _, path in ipairs( event.paths ) do
|
||||
text = text..path.."\n"
|
||||
end
|
||||
elseif event.type == RL.EVENT_KEY then
|
||||
text = text.."key: "..event.key.." scancode: "..event.scancode.." action: "..getAction( event.action ).." mods: "..event.mods
|
||||
text = text .."\nkeyName: "..keyName( event.key )
|
||||
elseif event.type == RL.EVENT_CHAR then
|
||||
@@ -62,7 +86,7 @@ function RL.event( event )
|
||||
elseif event.type == RL.EVENT_MOUSE_CURSOR_POS then
|
||||
text = text.."x: "..event.x.." y: "..event.y
|
||||
elseif event.type == RL.EVENT_MOUSE_SCROLL then
|
||||
text = text.."yoffset: "..event.yoffset.." yoffset: "..event.yoffset
|
||||
text = text.."xoffset: "..event.xoffset.." yoffset: "..event.yoffset
|
||||
elseif event.type == RL.EVENT_CURSOR_ENTER then
|
||||
text = text.."enter: "..event.enter
|
||||
cursorIn = event.enter
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
enum EventType { EVENT_KEY, EVENT_CHAR, EVENT_MOUSE_BUTTON, EVENT_MOUSE_CURSOR_POS, EVENT_MOUSE_SCROLL, EVENT_CURSOR_ENTER };
|
||||
enum EventType {
|
||||
EVENT_WINDOW_SIZE,
|
||||
EVENT_WINDOW_MAXIMIZE,
|
||||
EVENT_WINDOW_ICONYFY,
|
||||
EVENT_WINDOW_FOCUS,
|
||||
EVENT_WINDOW_DROP,
|
||||
EVENT_KEY,
|
||||
EVENT_CHAR,
|
||||
EVENT_MOUSE_BUTTON,
|
||||
EVENT_MOUSE_CURSOR_POS,
|
||||
EVENT_MOUSE_SCROLL,
|
||||
EVENT_CURSOR_ENTER
|
||||
};
|
||||
|
||||
void defineGlobals();
|
||||
void logCustom( int logLevel, const char *text, va_list args );
|
||||
|
||||
@@ -80,6 +80,13 @@ typedef struct {
|
||||
size_t lightCount;
|
||||
size_t lightAlloc;
|
||||
/* Raylib GLFW input callback events. */
|
||||
/* Window events. */
|
||||
GLFWwindowsizefun raylibWindowSizeCallback;
|
||||
GLFWwindowmaximizefun raylibWindowMaximizeCallback;
|
||||
GLFWwindowiconifyfun raylibWindowIconifyCallback;
|
||||
GLFWwindowfocusfun raylibWindowFocusCallback;
|
||||
GLFWdropfun raylibWindowDropCallback;
|
||||
/* Input events. */
|
||||
GLFWkeyfun raylibKeyCallback;
|
||||
GLFWcharfun raylibCharCallback;
|
||||
GLFWmousebuttonfun raylibMouseButtonCallback;
|
||||
|
||||
183
src/lua_core.c
183
src/lua_core.c
@@ -618,7 +618,13 @@ void defineGlobals() {
|
||||
assignGlobalInt( GLFW_RELEASE, "GLFW_RELEASE" );
|
||||
assignGlobalInt( GLFW_PRESS, "GLFW_PRESS" );
|
||||
assignGlobalInt( GLFW_REPEAT, "GLFW_REPEAT" );
|
||||
/* Event types. */
|
||||
/* Window Events. */
|
||||
assignGlobalInt( EVENT_WINDOW_SIZE, "EVENT_WINDOW_SIZE" );
|
||||
assignGlobalInt( EVENT_WINDOW_MAXIMIZE, "EVENT_WINDOW_MAXIMIZE" );
|
||||
assignGlobalInt( EVENT_WINDOW_ICONYFY, "EVENT_WINDOW_ICONYFY" );
|
||||
assignGlobalInt( EVENT_WINDOW_FOCUS, "EVENT_WINDOW_FOCUS" );
|
||||
assignGlobalInt( EVENT_WINDOW_DROP, "EVENT_WINDOW_DROP" );
|
||||
/* Input Events. */
|
||||
assignGlobalInt( EVENT_KEY, "EVENT_KEY" );
|
||||
assignGlobalInt( EVENT_CHAR, "EVENT_CHAR" );
|
||||
assignGlobalInt( EVENT_MOUSE_BUTTON, "EVENT_MOUSE_BUTTON" );
|
||||
@@ -672,6 +678,159 @@ void logCustom( int logLevel, const char *text, va_list args ) {
|
||||
lua_pop( L, -1 );
|
||||
}
|
||||
|
||||
/* Window events. */
|
||||
|
||||
static void windowSizeEvent( GLFWwindow *window, int width, int height ) {
|
||||
/* Pass through to raylib callback. */
|
||||
state->raylibWindowSizeCallback( window, width, height );
|
||||
|
||||
lua_State *L = state->luaState;
|
||||
|
||||
lua_pushcfunction( L, luaTraceback );
|
||||
int tracebackidx = lua_gettop( L );
|
||||
|
||||
lua_getglobal( L, "RL" );
|
||||
lua_getfield( L, -1, "event" );
|
||||
|
||||
if ( lua_isfunction( L, -1 ) ) {
|
||||
lua_createtable( L, 3, 0 );
|
||||
lua_pushinteger( L, EVENT_WINDOW_SIZE );
|
||||
lua_setfield( L, -2, "type" );
|
||||
lua_pushinteger( L, width );
|
||||
lua_setfield( L, -2, "width" );
|
||||
lua_pushinteger( L, height );
|
||||
lua_setfield( L, -2, "height" );
|
||||
|
||||
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||
state->run = false;
|
||||
}
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
}
|
||||
|
||||
#if !defined( PLATFORM_WEB )
|
||||
|
||||
static void windowMaximizeEvent( GLFWwindow *window, int maximized ) {
|
||||
/* Pass through to raylib callback. */
|
||||
state->raylibWindowMaximizeCallback( window, maximized );
|
||||
|
||||
lua_State *L = state->luaState;
|
||||
|
||||
lua_pushcfunction( L, luaTraceback );
|
||||
int tracebackidx = lua_gettop( L );
|
||||
|
||||
lua_getglobal( L, "RL" );
|
||||
lua_getfield( L, -1, "event" );
|
||||
|
||||
if ( lua_isfunction( L, -1 ) ) {
|
||||
lua_createtable( L, 2, 0 );
|
||||
lua_pushinteger( L, EVENT_WINDOW_MAXIMIZE );
|
||||
lua_setfield( L, -2, "type" );
|
||||
lua_pushinteger( L, maximized );
|
||||
lua_setfield( L, -2, "maximized" );
|
||||
|
||||
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||
state->run = false;
|
||||
}
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void windowIconyfyEvent( GLFWwindow *window, int iconified ) {
|
||||
/* Pass through to raylib callback. */
|
||||
state->raylibWindowIconifyCallback( window, iconified );
|
||||
|
||||
lua_State *L = state->luaState;
|
||||
|
||||
lua_pushcfunction( L, luaTraceback );
|
||||
int tracebackidx = lua_gettop( L );
|
||||
|
||||
lua_getglobal( L, "RL" );
|
||||
lua_getfield( L, -1, "event" );
|
||||
|
||||
if ( lua_isfunction( L, -1 ) ) {
|
||||
lua_createtable( L, 2, 0 );
|
||||
lua_pushinteger( L, EVENT_WINDOW_ICONYFY );
|
||||
lua_setfield( L, -2, "type" );
|
||||
lua_pushinteger( L, iconified );
|
||||
lua_setfield( L, -2, "iconified" );
|
||||
|
||||
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||
state->run = false;
|
||||
}
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
}
|
||||
|
||||
static void windowFocusEvent( GLFWwindow *window, int focused ) {
|
||||
/* Pass through to raylib callback. */
|
||||
state->raylibWindowFocusCallback( window, focused );
|
||||
|
||||
lua_State *L = state->luaState;
|
||||
|
||||
lua_pushcfunction( L, luaTraceback );
|
||||
int tracebackidx = lua_gettop( L );
|
||||
|
||||
lua_getglobal( L, "RL" );
|
||||
lua_getfield( L, -1, "event" );
|
||||
|
||||
if ( lua_isfunction( L, -1 ) ) {
|
||||
lua_createtable( L, 2, 0 );
|
||||
lua_pushinteger( L, EVENT_WINDOW_FOCUS );
|
||||
lua_setfield( L, -2, "type" );
|
||||
lua_pushinteger( L, focused );
|
||||
lua_setfield( L, -2, "focused" );
|
||||
|
||||
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||
state->run = false;
|
||||
}
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
}
|
||||
|
||||
static void windowDropEvent( GLFWwindow *window, int count, const char **paths ) {
|
||||
/* Pass through to raylib callback. */
|
||||
state->raylibWindowDropCallback( window, count, paths );
|
||||
|
||||
lua_State *L = state->luaState;
|
||||
|
||||
lua_pushcfunction( L, luaTraceback );
|
||||
int tracebackidx = lua_gettop( L );
|
||||
|
||||
lua_getglobal( L, "RL" );
|
||||
lua_getfield( L, -1, "event" );
|
||||
|
||||
if ( lua_isfunction( L, -1 ) ) {
|
||||
lua_createtable( L, 3, 0 );
|
||||
lua_pushinteger( L, EVENT_WINDOW_DROP );
|
||||
lua_setfield( L, -2, "type" );
|
||||
lua_pushinteger( L, count );
|
||||
lua_setfield( L, -2, "count" );
|
||||
|
||||
lua_createtable( L, count, 0 );
|
||||
|
||||
for ( int i = 0; i < count; ++i ) {
|
||||
lua_pushstring( L, paths[i] );
|
||||
lua_rawseti( L, -2, i+1 );
|
||||
}
|
||||
lua_setfield( L, -2, "paths" );
|
||||
|
||||
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||
state->run = false;
|
||||
}
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
}
|
||||
|
||||
/* Input events. */
|
||||
|
||||
static void keyInputEvent( GLFWwindow* window, int key, int scancode, int action, int mods ) {
|
||||
/* Pass through to raylib callback. */
|
||||
state->raylibKeyCallback( window, key, scancode, action, mods );
|
||||
@@ -700,8 +859,6 @@ static void keyInputEvent( GLFWwindow* window, int key, int scancode, int action
|
||||
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||
state->run = false;
|
||||
lua_pop( L, -1 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
@@ -729,8 +886,6 @@ static void charInputEvent( GLFWwindow* window, unsigned int key ) {
|
||||
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||
state->run = false;
|
||||
lua_pop( L, -1 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
@@ -762,8 +917,6 @@ static void mouseButtonInputEvent( GLFWwindow* window, int button, int action, i
|
||||
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||
state->run = false;
|
||||
lua_pop( L, -1 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
@@ -793,8 +946,6 @@ static void mouseCursorPosInputEvent( GLFWwindow* window, double x, double y ) {
|
||||
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||
state->run = false;
|
||||
lua_pop( L, -1 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
@@ -824,8 +975,6 @@ static void mouseScrollInputEvent( GLFWwindow* window, double xoffset, double yo
|
||||
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||
state->run = false;
|
||||
lua_pop( L, -1 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
@@ -853,8 +1002,6 @@ static void cursorEnterInputEvent( GLFWwindow* window, int enter ) {
|
||||
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||
state->run = false;
|
||||
lua_pop( L, -1 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
@@ -927,6 +1074,16 @@ bool luaCallMain() {
|
||||
/* Apply custom callback here. */
|
||||
SetTraceLogCallback( logCustom );
|
||||
|
||||
/* Window events. */
|
||||
state->raylibWindowSizeCallback = glfwSetWindowSizeCallback( GetWindowHandle(), windowSizeEvent );
|
||||
#if !defined( PLATFORM_WEB )
|
||||
state->raylibWindowMaximizeCallback = glfwSetWindowMaximizeCallback( GetWindowHandle(), windowMaximizeEvent );
|
||||
#endif
|
||||
state->raylibWindowIconifyCallback = glfwSetWindowIconifyCallback( GetWindowHandle(), windowIconyfyEvent );
|
||||
state->raylibWindowFocusCallback = glfwSetWindowFocusCallback( GetWindowHandle(), windowFocusEvent );
|
||||
state->raylibWindowDropCallback = glfwSetDropCallback( GetWindowHandle(), windowDropEvent );
|
||||
|
||||
/* Input events. */
|
||||
state->raylibKeyCallback = glfwSetKeyCallback( GetWindowHandle(), keyInputEvent );
|
||||
state->raylibCharCallback = glfwSetCharCallback( GetWindowHandle(), charInputEvent );
|
||||
state->raylibMouseButtonCallback = glfwSetMouseButtonCallback( GetWindowHandle(), mouseButtonInputEvent );
|
||||
|
||||
Reference in New Issue
Block a user