Build option for Lua events that is off by default.

This commit is contained in:
jussi
2024-02-10 21:06:09 +02:00
parent eda4eacfce
commit 6557a2ebca
11 changed files with 29 additions and 13 deletions

View File

@@ -12,6 +12,7 @@ set( CMAKE_C_STANDARD 99 ) # Requires C99 standard
option( SHARED "Build using dynamic libraries." off ) option( SHARED "Build using dynamic libraries." off )
option( LUAJIT "Use LuaJIT." off ) option( LUAJIT "Use LuaJIT." off )
option( LUA_EVENTS "Enable Lua event callbacks (RL.event)." off )
enum_option( PLATFORM "Desktop;Desktop_SDL;Web" "Platform to build for." ) enum_option( PLATFORM "Desktop;Desktop_SDL;Web" "Platform to build for." )
@@ -33,6 +34,10 @@ elseif( PLATFORM STREQUAL "Web" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WEB" ) set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WEB" )
endif() endif()
if( LUA_EVENTS )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLUA_EVENTS" )
endif()
if( PLATFORM STREQUAL "Web" ) if( PLATFORM STREQUAL "Web" )
target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/web/libraylib.a ) target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/web/libraylib.a )
target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/web/liblua.a ) target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/web/liblua.a )
@@ -77,7 +82,7 @@ else() # Desktop
target_link_libraries( ${PROJECT_NAME} ${SDL2_LIBRARIES} ) target_link_libraries( ${PROJECT_NAME} ${SDL2_LIBRARIES} )
endif() endif()
if( DRM ) # Mainly for Raspberry Pi if( DRM ) # For Raspberry Pi
# target_link_libraries( ${PROJECT_NAME} GLESv2 EGL drm gbm rt bcm_host m dl pthread ) # target_link_libraries( ${PROJECT_NAME} GLESv2 EGL drm gbm rt bcm_host m dl pthread )
# target_link_libraries( ${PROJECT_NAME} GLESv2 EGL drm gbm pthread rt m dl ) # target_link_libraries( ${PROJECT_NAME} GLESv2 EGL drm gbm pthread rt m dl )
target_link_libraries( ${PROJECT_NAME} raylib GLESv2 EGL pthread rt m gbm drm dl atomic ) target_link_libraries( ${PROJECT_NAME} raylib GLESv2 EGL pthread rt m gbm drm dl atomic )
@@ -87,6 +92,8 @@ else() # Desktop
elseif( APPLE ) elseif( APPLE )
set( CMAKE_C_COMPILER "clang" ) set( CMAKE_C_COMPILER "clang" )
# TODO Linking to sdl2.
target_link_libraries( ${PROJECT_NAME} "-framework IOKit" ) target_link_libraries( ${PROJECT_NAME} "-framework IOKit" )
target_link_libraries( ${PROJECT_NAME} "-framework Cocoa" ) target_link_libraries( ${PROJECT_NAME} "-framework Cocoa" )
target_link_libraries( ${PROJECT_NAME} "-framework OpenGL" ) target_link_libraries( ${PROJECT_NAME} "-framework OpenGL" )

View File

@@ -36,6 +36,7 @@ KEY CHANGES:
- ADDED: Text codepoints management functions. - ADDED: Text codepoints management functions.
- ADDED: Rune, UTF8 lib. - ADDED: Rune, UTF8 lib.
- CHANGE: Raygui styles include properties, texture and font. - CHANGE: Raygui styles include properties, texture and font.
- ADDED: Build option for Lua events that is off by default.
DETAILED CHANGES: DETAILED CHANGES:
- REMOVED: DrawLineBezierQuad, DrawLineBezierCubic. - REMOVED: DrawLineBezierQuad, DrawLineBezierCubic.

View File

@@ -2,6 +2,9 @@ Current {
} }
Backlog { Backlog {
* Godot scene importer lib.
* Script to find unimplemented raylib functions. Should have list for fuctions that will not
be implemented.
* Raygui lib * Raygui lib
* Check if could remove flickering from changing draw order by making queue for order changing and only * Check if could remove flickering from changing draw order by making queue for order changing and only
change them after everything is drawn. change them after everything is drawn.
@@ -22,6 +25,7 @@ Backlog {
} }
Bugs { Bugs {
* glfwSet*Callback functions segfault on Windows. Should keep Lua events off.
} }
Needs Testing { Needs Testing {

View File

@@ -6,7 +6,7 @@ end
local Vector3 = require( "vector3" ) local Vector3 = require( "vector3" )
local Color = {} local Color = {}
Color.meta = { local metatable = {
__index = Color, __index = Color,
__tostring = function( c ) __tostring = function( c )
return "{"..math.floor( c.r )..", "..math.floor( c.g )..", "..math.floor( c.b )..", "..math.floor( c.a ).."}" return "{"..math.floor( c.r )..", "..math.floor( c.g )..", "..math.floor( c.b )..", "..math.floor( c.a ).."}"
@@ -57,7 +57,7 @@ function Color:new( r, g, b, a )
a = 255 a = 255
end end
local object = setmetatable( {}, Color.meta ) local object = setmetatable( {}, metatable )
object.r = r object.r = r
object.g = g object.g = g

View File

@@ -7,7 +7,7 @@ local Vector3 = require( "vector3" )
local Matrix = require( "matrix" ) local Matrix = require( "matrix" )
local Quaternion = {} local Quaternion = {}
Quaternion.meta = { local metatable = {
__index = Quaternion, __index = Quaternion,
__tostring = function( q ) __tostring = function( q )
return "{"..tostring( q.x )..", "..tostring( q.y )..", "..tostring( q.z )..", "..tostring( q.w ).."}" return "{"..tostring( q.x )..", "..tostring( q.y )..", "..tostring( q.z )..", "..tostring( q.w ).."}"
@@ -45,7 +45,7 @@ function Quaternion:new( x, y, z, w )
x, y, z, w = 0, 0, 0, 1 -- QuaternionIdentity. x, y, z, w = 0, 0, 0, 1 -- QuaternionIdentity.
end end
local object = setmetatable( {}, Quaternion.meta ) local object = setmetatable( {}, metatable )
object.x = x object.x = x
object.y = y object.y = y

View File

@@ -4,7 +4,7 @@ if table.unpack == nil then
end end
local Rune = {} local Rune = {}
Rune.meta = { local metatable = {
__index = Rune, __index = Rune,
__tostring = function( r ) __tostring = function( r )
return r.string return r.string
@@ -27,7 +27,7 @@ function Rune:new( string )
string = "" string = ""
end end
local object = setmetatable( {}, Rune.meta ) local object = setmetatable( {}, metatable )
object.string = string object.string = string

View File

@@ -4,7 +4,7 @@ if table.unpack == nil then
end end
local Vector2 = {} local Vector2 = {}
Vector2.meta = { local metatable = {
__index = Vector2, __index = Vector2,
__tostring = function( v ) __tostring = function( v )
return "{"..tostring( v.x )..", "..tostring( v.y ).."}" return "{"..tostring( v.x )..", "..tostring( v.y ).."}"
@@ -48,7 +48,7 @@ function Vector2:new( x, y )
x, y = 0, 0 x, y = 0, 0
end end
local object = setmetatable( {}, Vector2.meta ) local object = setmetatable( {}, metatable )
object.x = x object.x = x
object.y = y object.y = y

View File

@@ -6,7 +6,7 @@ end
local Vector2 = require( "vector2" ) local Vector2 = require( "vector2" )
local Vector3 = {} local Vector3 = {}
Vector3.meta = { local metatable = {
__index = Vector3, __index = Vector3,
__tostring = function( v ) __tostring = function( v )
return "{"..tostring( v.x )..", "..tostring( v.y )..", "..tostring( v.z ).."}" return "{"..tostring( v.x )..", "..tostring( v.y )..", "..tostring( v.z ).."}"
@@ -50,7 +50,7 @@ function Vector3:new( x, y, z )
x, y, z = 0, 0, 0 x, y, z = 0, 0, 0
end end
local object = setmetatable( {}, Vector3.meta ) local object = setmetatable( {}, metatable )
object.x = x object.x = x
object.y = y object.y = y

View File

@@ -1129,7 +1129,7 @@ bool luaCallMain() {
void luaCallProcess() { void luaCallProcess() {
#ifdef PLATFORM_DESKTOP_SDL #if defined PLATFORM_DESKTOP_SDL && defined LUA_EVENTS
platformSendEvents(); platformSendEvents();
#endif #endif
lua_State *L = state->luaState; lua_State *L = state->luaState;

View File

@@ -649,5 +649,7 @@ void luaPlatformRegister() {
lua_pop( L, -1 ); lua_pop( L, -1 );
#ifdef LUA_EVENTS
platformRegisterEvents(); platformRegisterEvents();
#endif
} }

View File

@@ -555,5 +555,7 @@ void luaPlatformRegister() {
lua_pop( L, -1 ); lua_pop( L, -1 );
platformRegisterEvents() #ifdef LUA_EVENTS
platformRegisterEvents();
#endif
} }