summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjussi2023-11-29 19:52:47 +0200
committerjussi2023-11-29 19:52:47 +0200
commit8882d2ff2c4c77c08a5c5b0931a70ff906ecbdb5 (patch)
tree1ec267213ed205af75fcc02c46f45c05e01fa7bb /src
parent4ff1b1dcb9f52a2642feabda38c8c135aac6c599 (diff)
downloadreilua-enhanced-8882d2ff2c4c77c08a5c5b0931a70ff906ecbdb5.tar.gz
reilua-enhanced-8882d2ff2c4c77c08a5c5b0931a70ff906ecbdb5.tar.bz2
reilua-enhanced-8882d2ff2c4c77c08a5c5b0931a70ff906ecbdb5.zip
Platform web.
Diffstat (limited to 'src')
-rw-r--r--src/core.c2
-rw-r--r--src/gl.c2
-rw-r--r--src/lua_core.c24
-rw-r--r--src/platforms/core_desktop.c26
-rw-r--r--src/platforms/core_desktop_sdl.c26
-rw-r--r--src/platforms/core_web.c20
6 files changed, 70 insertions, 30 deletions
diff --git a/src/core.c b/src/core.c
index 2d7d7a1..06e21d6 100644
--- a/src/core.c
+++ b/src/core.c
@@ -14,8 +14,8 @@ static int getBufferElementSize( Buffer *buffer ) {
case BUFFER_INT: return sizeof( int );
case BUFFER_FLOAT: return sizeof( float );
case BUFFER_DOUBLE: return sizeof( double );
- default: 1;
}
+ return 1;
}
void unloadBuffer( Buffer *buffer ) {
diff --git a/src/gl.c b/src/gl.c
index 8f915ca..5bb99ce 100644
--- a/src/gl.c
+++ b/src/gl.c
@@ -15,6 +15,7 @@ Copy a block of pixels from one framebuffer object to another.
Use -1 RenderTexture for window framebuffer
*/
int lglBlitFramebuffer( lua_State *L ) {
+#if defined( PLATFORM_DESKTOP ) || defined( PLATFORM_DESKTOP_SDL )
if ( !( lua_isuserdata( L, 1 ) || lua_isnil( L, 1 ) ) || !( lua_isuserdata( L, 2 ) || lua_isnil( L, 2 ) ) ) {
TraceLog( state->logLevelInvalid, "%s", "Argument needs to be RenderTexture or nil" );
lua_pushnil( L );
@@ -52,4 +53,5 @@ int lglBlitFramebuffer( lua_State *L ) {
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 );
return 1;
+#endif
}
diff --git a/src/lua_core.c b/src/lua_core.c
index a777bc4..56162c1 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -18,6 +18,8 @@
#include "platforms/core_desktop.c"
#elif PLATFORM_DESKTOP_SDL
#include "platforms/core_desktop_sdl.c"
+#elif PLATFORM_WEB
+ #include "platforms/core_web.c"
#endif
/* Define types. */
@@ -28,6 +30,7 @@ static int gcBuffer( lua_State *L ) {
Buffer *buffer = luaL_checkudata( L, 1, "Buffer" );
unloadBuffer( buffer );
}
+ return 0;
}
static void defineBuffer() {
@@ -46,6 +49,7 @@ static int gcImage( lua_State *L ) {
Image *image = luaL_checkudata( L, 1, "Image" );
UnloadImage( *image );
}
+ return 0;
}
static void defineImage() {
@@ -64,6 +68,7 @@ static int gcTexture( lua_State *L ) {
Texture *texture = luaL_checkudata( L, 1, "Texture" );
UnloadTexture( *texture );
}
+ return 0;
}
static void defineTexture() {
@@ -83,6 +88,7 @@ static int gcRenderTexture( lua_State *L ) {
RenderTexture *renderTexture = luaL_checkudata( L, 1, "RenderTexture" );
UnloadRenderTexture( *renderTexture );
}
+ return 0;
}
static void defineRenderTexture() {
@@ -119,6 +125,7 @@ static int gcShader( lua_State *L ) {
Shader *shader = luaL_checkudata( L, 1, "Shader" );
UnloadShader( *shader );
}
+ return 0;
}
static void defineShader() {
@@ -137,6 +144,7 @@ static int gcFont( lua_State *L ) {
Font *font = luaL_checkudata( L, 1, "Font" );
UnloadFont( *font );
}
+ return 0;
}
static void defineFont() {
@@ -155,6 +163,7 @@ static int gcWave( lua_State *L ) {
Wave *wave = luaL_checkudata( L, 1, "Wave" );
UnloadWave( *wave );
}
+ return 0;
}
static void defineWave() {
@@ -173,6 +182,7 @@ static int gcSound( lua_State *L ) {
Sound *sound = luaL_checkudata( L, 1, "Sound" );
UnloadSound( *sound );
}
+ return 0;
}
static void defineSound() {
@@ -191,6 +201,7 @@ static int gcMusic( lua_State *L ) {
Music *music = luaL_checkudata( L, 1, "Music" );
UnloadMusicStream( *music );
}
+ return 0;
}
static void defineMusic() {
@@ -219,6 +230,7 @@ static int gcMaterial( lua_State *L ) {
/* Custom UnloadMaterial since we don't want to free Shaders or Textures. */
unloadMaterial( material );
}
+ return 0;
}
static void defineMaterial() {
@@ -237,6 +249,7 @@ static int gcMesh( lua_State *L ) {
Mesh *mesh = luaL_checkudata( L, 1, "Mesh" );
UnloadMesh( *mesh );
}
+ return 0;
}
static void defineMesh() {
@@ -256,6 +269,7 @@ static int gcModel( lua_State *L ) {
UnloadModel( *model );
// UnloadModelKeepMeshes( *model );
}
+ return 0;
}
static void defineModel() {
@@ -274,6 +288,7 @@ static int gcModelAnimation( lua_State *L ) {
ModelAnimation *modelAnimation = luaL_checkudata( L, 1, "ModelAnimation" );
UnloadModelAnimation( *modelAnimation );
}
+ return 0;
}
static void defineModelAnimation() {
@@ -1030,11 +1045,11 @@ bool luaCallMain() {
char path[ STRING_LEN ] = { '\0' };
/* If web, set path to resources folder. */
-#ifdef EMSCRIPTEN
- snprintf( path, STRING_LEN, "resources/main.lua" );
+#ifdef PLATFORM_WEB
+ snprintf( path, STRING_LEN, "main.lua" );
/* Alternatively look for main. Could be precompiled binary file. */
if ( !FileExists( path ) ) {
- snprintf( path, STRING_LEN, "resources/main" );
+ snprintf( path, STRING_LEN, "main" );
}
#else
snprintf( path, STRING_LEN, "%smain.lua", state->exePath );
@@ -1055,8 +1070,6 @@ bool luaCallMain() {
/* Apply custom callback here. */
SetTraceLogCallback( logCustom );
- platformRegisterEvents();
-
lua_getglobal( L, "RL" );
lua_getfield( L, -1, "init" );
@@ -1077,6 +1090,7 @@ bool luaCallMain() {
}
void luaCallProcess() {
+
#ifdef PLATFORM_DESKTOP_SDL
platformSendEvents();
#endif
diff --git a/src/platforms/core_desktop.c b/src/platforms/core_desktop.c
index 614062d..d2c595e 100644
--- a/src/platforms/core_desktop.c
+++ b/src/platforms/core_desktop.c
@@ -3,7 +3,7 @@
#include "core.h"
#include "platforms/core_desktop.h"
-static void platformDefineGlobals() {
+void platformDefineGlobals() {
lua_State *L = state->luaState;
lua_getglobal( L, "RL" );
@@ -87,17 +87,6 @@ int lcoreGetKeyScancode( lua_State *L ) {
return 1;
}
-static void luaPlatformRegister() {
- lua_State *L = state->luaState;
- lua_getglobal( L, "RL" );
-
- /* Input-related functions: keyboard. */
- assingGlobalFunction( "GetKeyName", lcoreGetKeyName );
- assingGlobalFunction( "GetKeyScancode", lcoreGetKeyScancode );
-
- lua_pop( L, -1 );
-}
-
/* Events. */
/*
@@ -649,3 +638,16 @@ static void platformRegisterEvents() {
// state->glfwtabletCursorCallback = glfwSetPenTabletCursorCallback( penTabletCursorEvent );
// state->glfwtabletProximityCallback = glfwSetPenTabletProximityCallback( penTabletProximityEvent );
}
+
+void luaPlatformRegister() {
+ lua_State *L = state->luaState;
+ lua_getglobal( L, "RL" );
+
+ /* Input-related functions: keyboard. */
+ assingGlobalFunction( "GetKeyName", lcoreGetKeyName );
+ assingGlobalFunction( "GetKeyScancode", lcoreGetKeyScancode );
+
+ lua_pop( L, -1 );
+
+ platformRegisterEvents();
+}
diff --git a/src/platforms/core_desktop_sdl.c b/src/platforms/core_desktop_sdl.c
index f1483e5..9ad1c58 100644
--- a/src/platforms/core_desktop_sdl.c
+++ b/src/platforms/core_desktop_sdl.c
@@ -3,7 +3,7 @@
#include "core.h"
#include "platforms/core_desktop_sdl.h"
-static void platformDefineGlobals() {
+void platformDefineGlobals() {
lua_State *L = state->luaState;
lua_getglobal( L, "RL" );
@@ -111,17 +111,6 @@ int lcoreGetScancodeFromKey( lua_State *L ) {
return 1;
}
-static void luaPlatformRegister() {
- lua_State *L = state->luaState;
- lua_getglobal( L, "RL" );
-
- /* Input-related functions: keyboard. */
- assingGlobalFunction( "GetKeyName", lcoreGetKeyName );
- assingGlobalFunction( "GetScancodeFromKey", lcoreGetScancodeFromKey );
-
- lua_pop( L, -1 );
-}
-
/* Events. */
/*
@@ -555,3 +544,16 @@ Event occurs an event of type SDL_DOLLARGESTURE or SDL_DOLLARRECORD is reported.
}
state->SDL_eventQueueLen = 0;
}
+
+void luaPlatformRegister() {
+ lua_State *L = state->luaState;
+ lua_getglobal( L, "RL" );
+
+ /* Input-related functions: keyboard. */
+ assingGlobalFunction( "GetKeyName", lcoreGetKeyName );
+ assingGlobalFunction( "GetScancodeFromKey", lcoreGetScancodeFromKey );
+
+ lua_pop( L, -1 );
+
+ platformRegisterEvents()
+}
diff --git a/src/platforms/core_web.c b/src/platforms/core_web.c
new file mode 100644
index 0000000..24d3bf2
--- /dev/null
+++ b/src/platforms/core_web.c
@@ -0,0 +1,20 @@
+#include "main.h"
+#include "lua_core.h"
+#include "core.h"
+
+void platformDefineGlobals() {
+ lua_State *L = state->luaState;
+
+ lua_getglobal( L, "RL" );
+/*DOC_DEFINES_START*/
+/*DOC_DEFINES_END*/
+ lua_pop( L, -1 );
+}
+
+/* Functions. */
+
+/* Events. */
+
+void luaPlatformRegister() {
+ return;
+}