diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 22 | ||||
| -rw-r--r-- | src/lua_core.c | 6 | ||||
| -rw-r--r-- | src/models.c | 11 |
3 files changed, 37 insertions, 2 deletions
@@ -495,6 +495,28 @@ int lcoreClearBackground( lua_State *L ) { } /* +> RL_BeginDrawing() + +Setup canvas ( framebuffer ) to start drawing +*/ +int lcoreBeginDrawing( lua_State *L ) { + BeginDrawing(); + + return 1; +} + +/* +> RL_EndDrawing() + +End canvas drawing and swap buffers ( double buffering ) +*/ +int lcoreEndDrawing( lua_State *L ) { + EndDrawing(); + + return 1; +} + +/* > success = RL_BeginBlendMode( int mode ) Begin blending mode ( BLEND_ALPHA, BLEND_ADDITIVE, BLEND_MULTIPLIED... ) diff --git a/src/lua_core.c b/src/lua_core.c index 42b3f22..d7204f5 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -228,6 +228,10 @@ bool luaCallMain() { /* If web, set path to resources folder. */ #ifdef EMSCRIPTEN sprintf( path, "resources/main.lua" ); + /* Alternatively look for main. Could be precompiled binary file. */ + if ( !FileExists( path ) ) { + sprintf( path, "resources/main" ); + } #else sprintf( path, "%smain.lua", state->exePath ); /* Alternatively look for main. Could be precompiled binary file. */ @@ -347,6 +351,8 @@ void luaRegister() { lua_register( L, "RL_IsCursorOnScreen", lcoreIsCursorOnScreen ); /* Drawing. */ lua_register( L, "RL_ClearBackground", lcoreClearBackground ); + lua_register( L, "RL_BeginDrawing", lcoreBeginDrawing ); + lua_register( L, "RL_EndDrawing", lcoreEndDrawing ); lua_register( L, "RL_BeginBlendMode", lcoreBeginBlendMode ); lua_register( L, "RL_EndBlendMode", lcoreEndBlendMode ); lua_register( L, "RL_BeginScissorMode", lcoreBeginScissorMode ); diff --git a/src/models.c b/src/models.c index 17683b8..f105991 100644 --- a/src/models.c +++ b/src/models.c @@ -939,7 +939,14 @@ int lmodelsGenMeshHeightmap( lua_State *L ) { } Vector3 size = uluaGetVector3( L ); lua_pop( L, 1 ); - Image *heightmap = state->images[ lua_tointeger( L, -1 ) ]; + size_t imageId = lua_tointeger( L, -1 ); + + if ( !validImage( imageId ) ) { + lua_pushboolean( L, false ); + return 1; + } + + Image *heightmap = state->images[ imageId ]; int i = 0; for ( i = 0; i < state->meshCount; i++ ) { @@ -1112,7 +1119,7 @@ int lmodelsDrawMesh( lua_State *L ) { return 1; } -/* TODO Needs shader to work. Test it when we have shaders. */ +/* TODO Not testet. */ /* > success = RL_DrawMeshInstanced( Mesh mesh, Material material, Matrix{} transforms, int instances ) |
