diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lua_core.c | 50 | ||||
| -rw-r--r-- | src/state.c | 6 | ||||
| -rw-r--r-- | src/textures.c | 13 |
3 files changed, 19 insertions, 50 deletions
diff --git a/src/lua_core.c b/src/lua_core.c index 77564ee..15dfe70 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -44,10 +44,10 @@ static void assingGlobalFunction( const char *name, int ( *functionPtr )( lua_St lua_setfield( L, -2, name ); } -void defineGlobals() { +static void defineGlobals() { lua_State *L = state->luaState; - lua_newtable( state->luaState ); + lua_newtable( L ); lua_setglobal( L, "RL" ); lua_getglobal( L, "RL" ); @@ -637,7 +637,7 @@ void defineGlobals() { } // Custom logging funtion. -void logCustom( int logLevel, const char *text, va_list args ) { +static void logCustom( int logLevel, const char *text, va_list args ) { char string[ STRING_LEN ] = {'\0'}; char msg[ STRING_LEN ] = {'\0'}; @@ -1993,60 +1993,46 @@ bool isValidTexture( lua_State *L, int index, bool allowTable ) { if ( lua_isnumber( L, index ) ) { int id = lua_tointeger( L, index ); - if ( ( 0 <= id && id < state->textureCount && state->textures[ id ] != NULL ) ) { + if ( 0 <= id && id < state->textureCount && state->textures[ id ] != NULL ) { return true; } - else { - return false; - } } else if ( allowTable && lua_istable( L, index ) ) { return true; } - else { - TraceLog( state->logLevelInvalid, "%s", "Error. Invalid Texture." ); - return false; - } + TraceLog( state->logLevelInvalid, "%s", "Error. Invalid Texture." ); + return false; } bool isValidRenderTexture( lua_State *L, int index, bool allowTable ) { if ( lua_isnumber( L, index ) ) { int id = lua_tointeger( L, index ); - if ( ( 0 <= id && id < state->textureCount && state->textures[ id ] != NULL ) ) { + if ( 0 <= id && id < state->textureCount && state->textures[ id ] != NULL + && state->textures[ id ]->type == TEXTURE_TYPE_RENDER_TEXTURE ) { return true; } - else { - return false; - } } else if ( allowTable && lua_istable( L, index ) ) { return true; } - else { - TraceLog( state->logLevelInvalid, "%s", "Error. Invalid RenderTexture." ); - return false; - } + TraceLog( state->logLevelInvalid, "%s", "Error. Invalid RenderTexture." ); + return false; } bool isValidCamera2D( lua_State *L, int index, bool allowTable ) { if ( lua_isnumber( L, index ) ) { int id = lua_tointeger( L, index ); - if ( ( 0 <= id && id < state->camera2DCount && state->camera2Ds[ id ] != NULL ) ) { + if ( 0 <= id && id < state->camera2DCount && state->camera2Ds[ id ] != NULL ) { return true; } - else { - return false; - } } else if ( allowTable && lua_istable( L, index ) ) { return true; } - else { - TraceLog( state->logLevelInvalid, "%s", "Error. Invalid Camera2D." ); - return false; - } + TraceLog( state->logLevelInvalid, "%s", "Error. Invalid Camera2D." ); + return false; } bool isValidCamera3D( lua_State *L, int index, bool allowTable ) { @@ -2056,17 +2042,12 @@ bool isValidCamera3D( lua_State *L, int index, bool allowTable ) { if ( ( 0 <= id && id < state->camera3DCount && state->camera3Ds[ id ] != NULL ) ) { return true; } - else { - return false; - } } else if ( allowTable && lua_istable( L, index ) ) { return true; } - else { - TraceLog( state->logLevelInvalid, "%s", "Error. Invalid Camera3D." ); - return false; - } + TraceLog( state->logLevelInvalid, "%s", "Error. Invalid Camera3D." ); + return false; } /* Lua util functions. */ @@ -2082,7 +2063,6 @@ Color uluaGetColorIndex( lua_State *L, int index ) { TraceLog( state->logLevelInvalid, "%s", "Error. Wrong color value. Returning { 0, 0, 0, 255 }" ); return color; } - // int t = lua_gettop( L ), i = 0; int t = index, i = 0; lua_pushnil( L ); diff --git a/src/state.c b/src/state.c index 79812e9..2e1a50f 100644 --- a/src/state.c +++ b/src/state.c @@ -94,7 +94,6 @@ bool stateInit( const char *exePath ) { state->materials[i] = NULL; } } - InitWindow( state->resolution.x, state->resolution.y, "ReiLua" ); /* Has to be after InitWindod where opengl context is created. */ state->materials[0] = malloc( sizeof( Material ) ); @@ -123,13 +122,13 @@ void stateFree() { for ( int i = 0; i < state->imageCount; ++i ) { if ( state->images[i] != NULL ) { UnloadImage( *state->images[i] ); - // free( state->images[i] ); + free( state->images[i] ); } } for ( int i = 0; i < state->textureCount; ++i ) { if ( state->textures[i] != NULL ) { texturesFreeTexture(i); - // free( state->textures[i] ); + free( state->textures[i] ); } } for ( int i = 0; i < state->fontCount; ++i ) { @@ -209,7 +208,6 @@ void stateFree() { } } #endif - if ( IsAudioDeviceReady() ) { CloseAudioDevice(); } diff --git a/src/textures.c b/src/textures.c index 9fff0d1..29c8476 100644 --- a/src/textures.c +++ b/src/textures.c @@ -102,6 +102,7 @@ void texturesFreeTexture( size_t id ) { state->textures[id] = NULL; } } + /* ## Textures - Image Loading */ @@ -1329,7 +1330,6 @@ int ltexturesImageClearBackground( lua_State *L ) { lua_pushboolean( L, false ); return 1; } - ImageClearBackground( state->images[ imageId ], color ); lua_pushboolean( L, true ); @@ -1358,7 +1358,6 @@ int ltexturesImageDrawPixel( lua_State *L ) { lua_pushboolean( L, false ); return 1; } - ImageDrawPixelV( state->images[ imageId ], position, color ); lua_pushboolean( L, true ); @@ -1388,7 +1387,6 @@ int ltexturesImageDrawLine( lua_State *L ) { lua_pushboolean( L, false ); return 1; } - ImageDrawLineV( state->images[ imageId ], start, end, color ); lua_pushboolean( L, true ); @@ -1418,7 +1416,6 @@ int ltexturesImageDrawCircle( lua_State *L ) { lua_pushboolean( L, false ); return 1; } - ImageDrawCircleV( state->images[ imageId ], center, radius, color ); lua_pushboolean( L, true ); @@ -1448,7 +1445,6 @@ int ltexturesImageDrawCircleLines( lua_State *L ) { lua_pushboolean( L, false ); return 1; } - ImageDrawCircleLinesV( state->images[ imageId ], center, radius, color ); lua_pushboolean( L, true ); @@ -1477,7 +1473,6 @@ int ltexturesImageDrawRectangle( lua_State *L ) { lua_pushboolean( L, false ); return 1; } - ImageDrawRectangleRec( state->images[ imageId ], rec, color ); lua_pushboolean( L, true ); @@ -1507,7 +1502,6 @@ int ltexturesImageDrawRectangleLines( lua_State *L ) { lua_pushboolean( L, false ); return 1; } - ImageDrawRectangleLines( state->images[ imageId ], rec, thick, color ); lua_pushboolean( L, true ); @@ -1530,7 +1524,7 @@ int ltexturesImageDraw( lua_State *L ) { return 1; } size_t imageDstId = lua_tointeger( L, 1 ); - size_t imageSrcId = lua_tointeger( L, 2); + size_t imageSrcId = lua_tointeger( L, 2 ); Rectangle srcRec = uluaGetRectangleIndex( L, 3 ); Rectangle dstRec = uluaGetRectangleIndex( L, 4 ); Color tint = uluaGetColorIndex( L, 5 ); @@ -1539,7 +1533,6 @@ int ltexturesImageDraw( lua_State *L ) { lua_pushboolean( L, false ); return 1; } - ImageDraw( state->images[ imageDstId ], *state->images[ imageSrcId ], srcRec, dstRec, tint ); lua_pushboolean( L, true ); @@ -1572,7 +1565,6 @@ int ltexturesImageDrawTextEx( lua_State *L ) { lua_pushboolean( L, false ); return 1; } - ImageDrawTextEx( state->images[ imageId ], *state->fonts[ fontId ], lua_tostring( L, 3 ), position, fontSize, spacing, tint ); lua_pushboolean( L, true ); @@ -1603,7 +1595,6 @@ int ltexturesGetImageSize( lua_State *L ) { lua_pushnil( L ); return 1; } - Image *image = state->images[ imageId ]; uluaPushVector2( L, (Vector2){ image->width, image->height } ); |
