From 0df40e2ac080364bcebd4fe0445b814230545477 Mon Sep 17 00:00:00 2001 From: jussi Date: Sun, 29 Oct 2023 15:21:10 +0200 Subject: Shapes, RLGL, Math, Gui and Easings to new style. --- src/rlgl.c | 979 ++++++++++++++----------------------------------------------- 1 file changed, 216 insertions(+), 763 deletions(-) (limited to 'src/rlgl.c') diff --git a/src/rlgl.c b/src/rlgl.c index d13defe..c277948 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -8,23 +8,14 @@ */ /* -> success = RL.rlMatrixMode( int mode ) +> RL.rlMatrixMode( int mode ) Choose the current matrix to be transformed - -- Failure return false -- Success return true */ int lrlglMatrixMode( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlMatrixMode( int mode )" ); - lua_pushboolean( L, false ); - return 1; - } - rlMatrixMode( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlMatrixMode( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -61,87 +52,53 @@ int lrlglLoadIdentity( lua_State *L ) { } /* -> success = RL.rlTranslatef( Vector3 translation ) +> RL.rlTranslatef( Vector3 translation ) Multiply the current matrix by a translation matrix - -- Failure return false -- Success return true */ int lrlglTranslatef( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlTranslatef( Vector3 translation )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 translation = uluaGetVector3Index( L, 1 ); rlTranslatef( translation.x, translation.y, translation.z ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlRotatef( float angle, Vector3 rotation ) +> RL.rlRotatef( float angle, Vector3 rotation ) Multiply the current matrix by a rotation matrix - -- Failure return false -- Success return true */ int lrlglRotatef( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlRotatef( float angle, Vector3 rotation )" ); - lua_pushboolean( L, false ); - return 1; - } - float angle = lua_tonumber( L, 1 ); + float angle = luaL_checknumber( L, 1 ); Vector3 rotation = uluaGetVector3Index( L, 2 ); rlRotatef( angle, rotation.x, rotation.y, rotation.z ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlScalef( Vector3 scale ) +> RL.rlScalef( Vector3 scale ) Multiply the current matrix by a scaling matrix - -- Failure return false -- Success return true */ int lrlglScalef( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlScalef( Vector3 scale )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 scale = uluaGetVector3Index( L, 1 ); rlScalef( scale.x, scale.y, scale.z ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlMultMatrixf( Matrix matrix ) +> RL.rlMultMatrixf( Matrix matrix ) Multiply the current matrix by another matrix - -- Failure return false -- Success return true */ int lrlglMultMatrixf( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlMultMatrixf( Matrix matrix )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix matrix = uluaGetMatrixIndex( L, 1 ); + float matf[16] = { matrix.m0, matrix.m4, matrix.m8, matrix.m12, matrix.m1, matrix.m5, matrix.m9, matrix.m13, @@ -149,88 +106,58 @@ int lrlglMultMatrixf( lua_State *L ) { matrix.m3, matrix.m7, matrix.m11, matrix.m15 }; rlMultMatrixf( matf ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlFrustum( float left, float right, float bottom, float top, float znear, float zfar ) +> RL.rlFrustum( float left, float right, float bottom, float top, float znear, float zfar ) Multiply the current matrix by a perspective matrix generated by parameters - -- Failure return false -- Success return true */ int lrlglFrustum( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlFrustum( float left, float right, float bottom, float top, float znear, float zfar )" ); - lua_pushboolean( L, false ); - return 1; - } - double left = lua_tonumber( L, 1 ); - double right = lua_tonumber( L, 2 ); - double bottom = lua_tonumber( L, 3 ); - double top = lua_tonumber( L, 4 ); - double znear = lua_tonumber( L, 5 ); - double zfar = lua_tonumber( L, 6 ); + double left = luaL_checknumber( L, 1 ); + double right = luaL_checknumber( L, 2 ); + double bottom = luaL_checknumber( L, 3 ); + double top = luaL_checknumber( L, 4 ); + double znear = luaL_checknumber( L, 5 ); + double zfar = luaL_checknumber( L, 6 ); rlFrustum( left, right, bottom, top, znear, zfar ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlOrtho( float left, float right, float bottom, float top, float znear, float zfar ) +> RL.rlOrtho( float left, float right, float bottom, float top, float znear, float zfar ) Multiply the current matrix by an orthographic matrix generated by parameters - -- Failure return false -- Success return true */ int lrlglOrtho( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlOrtho( float left, float right, float bottom, float top, float znear, float zfar )" ); - lua_pushboolean( L, false ); - return 1; - } - double left = lua_tonumber( L, 1 ); - double right = lua_tonumber( L, 2 ); - double bottom = lua_tonumber( L, 3 ); - double top = lua_tonumber( L, 4 ); - double znear = lua_tonumber( L, 5 ); - double zfar = lua_tonumber( L, 6 ); + double left = luaL_checknumber( L, 1 ); + double right = luaL_checknumber( L, 2 ); + double bottom = luaL_checknumber( L, 3 ); + double top = luaL_checknumber( L, 4 ); + double znear = luaL_checknumber( L, 5 ); + double zfar = luaL_checknumber( L, 6 ); rlOrtho( left, right, bottom, top, znear, zfar ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlViewport( Rectangle viewport ) +> RL.rlViewport( Rectangle viewport ) -Set the viewport area ( transformation from normalized device coordinates to window coordinates ) +Set the viewport area (transformation from normalized device coordinates to window coordinates) NOTE: We store current viewport dimensions - -- Failure return false -- Success return true */ int lrlglViewport( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlViewport( Rectangle viewport )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle rect = uluaGetRectangleIndex( L, 1 ); rlViewport( rect.x, rect.y, rect.width, rect.height ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -238,23 +165,14 @@ int lrlglViewport( lua_State *L ) { */ /* -> success = RL.rlBegin( int mode ) +> RL.rlBegin( int mode ) -Initialize drawing mode ( how to organize vertex ) - -- Failure return false -- Success return true +Initialize drawing mode (how to organize vertex) */ int lrlglBegin( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlBegin( int mode )" ); - lua_pushboolean( L, false ); - return 1; - } - rlBegin( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlBegin( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -269,157 +187,94 @@ int lrlglEnd( lua_State *L ) { } /* -> success = RL.rlVertex2f( Vector2 position ) - -Define one vertex ( position ) +> RL.rlVertex2f( Vector2 position ) -- Failure return false -- Success return true +Define one vertex (position) */ int lrlglVertex2f( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlVertex2f( Vector2 position )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 position = uluaGetVector2Index( L, 1 ); rlVertex2f( position.x, position.y ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlVertex3f( Vector3 position ) - -Define one vertex ( position ) +> RL.rlVertex3f( Vector3 position ) -- Failure return false -- Success return true +Define one vertex (position) */ int lrlglVertex3f( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlVertex3f( Vector3 position )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 position = uluaGetVector3Index( L, 1 ); rlVertex3f( position.x, position.y, position.z ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlTexCoord2f( Vector2 texCoord ) +> RL.rlTexCoord2f( Vector2 texCoord ) -Define one vertex ( texture coordinate ) - 2 float - -- Failure return false -- Success return true +Define one vertex (texture coordinate) - 2 float */ int lrlglTexCoord2f( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlTexCoord2f( Vector2 texCoord )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 texCoord = uluaGetVector2Index( L, 1 ); rlTexCoord2f( texCoord.x, texCoord.y ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlNormal3f( Vector3 normal ) +> RL.rlNormal3f( Vector3 normal ) -Define one vertex ( normal ) - 3 float - -- Failure return false -- Success return true +Define one vertex (normal) - 3 float */ int lrlglNormal3f( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlNormal3f( Vector3 normal )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 normal = uluaGetVector3Index( L, 1 ); rlNormal3f( normal.x, normal.y, normal.z ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlColor4ub( Color color ) - -Define one vertex ( color ) - 4 byte +> RL.rlColor4ub( Color color ) -- Failure return false -- Success return true +Define one vertex (color) - 4 byte */ int lrlglColor4ub( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlColor4ub( Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Color color = uluaGetColorIndex( L, 1 ); rlColor4ub( color.r, color.g, color.b, color.a ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlColor3f( Vector3 color ) +> RL.rlColor3f( Vector3 color ) -Define one vertex ( color ) - 3 float - -- Failure return false -- Success return true +Define one vertex (color) - 3 float */ int lrlglColor3f( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlColor3f( Vector3 color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 color = uluaGetVector3Index( L, 1 ); rlColor3f( color.x, color.y, color.z ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlColor4f( Vector4 color ) +> RL.rlColor4f( Vector4 color ) -Define one vertex ( color ) - 4 float - -- Failure return false -- Success return true +Define one vertex (color) - 4 float */ int lrlglColor4f( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlColor4f( Vector4 color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector4 color = uluaGetVector4Index( L, 1 ); rlColor4f( color.x, color.y, color.z, color.w ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -429,18 +284,12 @@ int lrlglColor4f( lua_State *L ) { /* > supported = RL.rlEnableVertexArray( int vaoId ) -Enable vertex array ( VAO, if supported ) +Enable vertex array (VAO, if supported) -- Failure return nil - Success return bool */ int lrlglEnableVertexArray( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableVertexArray( int vaoId )" ); - lua_pushnil( L ); - return 1; - } - lua_pushboolean( L, rlEnableVertexArray( lua_tointeger( L, 1 ) ) ); + lua_pushboolean( L, rlEnableVertexArray( luaL_checkinteger( L, 1 ) ) ); return 1; } @@ -448,7 +297,7 @@ int lrlglEnableVertexArray( lua_State *L ) { /* > RL.rlDisableVertexArray() -Disable vertex array ( VAO, if supported ) +Disable vertex array (VAO, if supported) */ int lrlglDisableVertexArray( lua_State *L ) { rlDisableVertexArray(); @@ -457,29 +306,23 @@ int lrlglDisableVertexArray( lua_State *L ) { } /* -> success = RL.rlEnableVertexBuffer( int id ) +> RL.rlEnableVertexBuffer( int id ) -Enable vertex buffer ( VBO ) +Enable vertex buffer (VBO) - Failure return false - Success return true */ int lrlglEnableVertexBuffer( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableVertexBuffer( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableVertexBuffer( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableVertexBuffer( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* > RL.rlDisableVertexBuffer() -Disable vertex buffer ( VBO ) +Disable vertex buffer (VBO) */ int lrlglDisableVertexBuffer( lua_State *L ) { rlDisableVertexBuffer(); @@ -488,29 +331,20 @@ int lrlglDisableVertexBuffer( lua_State *L ) { } /* -> success = RL.rlEnableVertexBufferElement( int id ) - -Enable vertex buffer element ( VBO element ) +> RL.rlEnableVertexBufferElement( int id ) -- Failure return false -- Success return true +Enable vertex buffer element (VBO element) */ int lrlglEnableVertexBufferElement( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableVertexBufferElement( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableVertexBufferElement( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableVertexBufferElement( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* > RL.rlDisableVertexBufferElement() -Disable vertex buffer element ( VBO element ) +Disable vertex buffer element (VBO element) */ int lrlglDisableVertexBufferElement( lua_State *L ) { rlDisableVertexBufferElement(); @@ -519,43 +353,25 @@ int lrlglDisableVertexBufferElement( lua_State *L ) { } /* -> success = RL.rlEnableVertexAttribute( int index ) +> RL.rlEnableVertexAttribute( int index ) Enable vertex attribute index - -- Failure return false -- Success return true */ int lrlglEnableVertexAttribute( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableVertexAttribute( int index )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableVertexAttribute( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableVertexAttribute( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* -> success = RL.rlDisableVertexAttribute( int index ) +> RL.rlDisableVertexAttribute( int index ) Disable vertex attribute index - -- Failure return false -- Success return true */ int lrlglDisableVertexAttribute( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlDisableVertexAttribute( int index )" ); - lua_pushboolean( L, false ); - return 1; - } - rlDisableVertexAttribute( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlDisableVertexAttribute( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -563,43 +379,25 @@ int lrlglDisableVertexAttribute( lua_State *L ) { */ /* -> success = RL.rlActiveTextureSlot( int slot ) +> RL.rlActiveTextureSlot( int slot ) Select and active a texture slot - -- Failure return false -- Success return true */ int lrlglActiveTextureSlot( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlActiveTextureSlot( int slot )" ); - lua_pushboolean( L, false ); - return 1; - } - rlActiveTextureSlot( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlActiveTextureSlot( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* -> success = RL.rlEnableTexture( int id ) +> RL.rlEnableTexture( int id ) Enable texture - -- Failure return false -- Success return true */ int lrlglEnableTexture( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableTexture( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableTexture( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableTexture( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -614,23 +412,14 @@ int lrlglDisableTexture( lua_State *L ) { } /* -> success = RL.rlEnableTextureCubemap( int id ) +> RL.rlEnableTextureCubemap( int id ) Enable texture cubemap - -- Failure return false -- Success return true */ int lrlglEnableTextureCubemap( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableTextureCubemap( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableTextureCubemap( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableTextureCubemap( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -645,51 +434,33 @@ int lrlglDisableTextureCubemap( lua_State *L ) { } /* -> success = RL.rlTextureParameters( int id, int param, int value ) +> RL.rlTextureParameters( int id, int param, int value ) -Set texture parameters ( filter, wrap ) - -- Failure return false -- Success return true +Set texture parameters (filter, wrap) */ int lrlglTextureParameters( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlTextureParameters( int id, int param, int value )" ); - lua_pushboolean( L, false ); - return 1; - } - unsigned int id = lua_tointeger( L, 1 ); - int param = lua_tointeger( L, 2 ); - int value = lua_tointeger( L, 3 ); + unsigned int id = luaL_checkinteger( L, 1 ); + int param = luaL_checkinteger( L, 2 ); + int value = luaL_checkinteger( L, 3 ); rlTextureParameters( id, param, value ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlCubemapParameters( int id, int param, int value ) - -Set cubemap parameters ( filter, wrap ) +> RL.rlCubemapParameters( int id, int param, int value ) -- Failure return false -- Success return true +Set cubemap parameters (filter, wrap) */ int lrlglCubemapParameters( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlCubemapParameters( int id, int param, int value )" ); - lua_pushboolean( L, false ); - return 1; - } - unsigned int id = lua_tointeger( L, 1 ); - int param = lua_tointeger( L, 2 ); - int value = lua_tointeger( L, 3 ); + unsigned int id = luaL_checkinteger( L, 1 ); + int param = luaL_checkinteger( L, 2 ); + int value = luaL_checkinteger( L, 3 ); rlCubemapParameters( id, param, value ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -697,23 +468,14 @@ int lrlglCubemapParameters( lua_State *L ) { */ /* -> success = RL.rlEnableShader( int id ) +> RL.rlEnableShader( int id ) Enable shader program - -- Failure return false -- Success return true */ int lrlglEnableShader( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableShader( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableShader( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableShader( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -732,23 +494,14 @@ int lrlglDisableShader( lua_State *L ) { */ /* -> success = RL.rlEnableFramebuffer( int id ) +> RL.rlEnableFramebuffer( int id ) Enable render texture (fbo) - -- Failure return false -- Success return true */ int lrlglEnableFramebuffer( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableFramebuffer( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableFramebuffer( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableFramebuffer( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -763,23 +516,14 @@ int lrlglDisableFramebuffer( lua_State *L ) { } /* -> success = RL.rlActiveDrawBuffers( int count ) +> RL.rlActiveDrawBuffers( int count ) Activate multiple draw color buffers - -- Failure return false -- Success return true */ int lrlglActiveDrawBuffers( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlActiveDrawBuffers( int count )" ); - lua_pushboolean( L, false ); - return 1; - } - rlActiveDrawBuffers( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlActiveDrawBuffers( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -875,23 +619,14 @@ int lrlglDisableBackfaceCulling( lua_State *L ) { } /* -> success = RL.rlSetCullFace( int mode ) +> RL.rlSetCullFace( int mode ) Set face culling mode - -- Failure return false -- Success return true */ int lrlglSetCullFace( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetCullFace( int mode )" ); - lua_pushboolean( L, false ); - return 1; - } - rlSetCullFace( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlSetCullFace( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -917,25 +652,16 @@ int lrlglDisableScissorTest( lua_State *L ) { } /* -> success = RL.rlScissor( Rectangle area ) +> RL.rlScissor( Rectangle area ) Scissor test - -- Failure return false -- Success return true */ int lrlglScissor( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlScissor( Rectangle area )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle area = uluaGetRectangleIndex( L, 1 ); rlScissor( area.x, area.y, area.width, area.height ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -961,23 +687,14 @@ int lrlglDisableWireMode( lua_State *L ) { } /* -> success = RL.rlSetLineWidth( float width ) +> RL.rlSetLineWidth( float width ) Set the line drawing width - -- Failure return false -- Success return true */ int lrlglSetLineWidth( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetLineWidth( float width )" ); - lua_pushboolean( L, false ); - return 1; - } - rlSetLineWidth( lua_tonumber( L, 1 ) ); - lua_pushboolean( L, true ); + rlSetLineWidth( luaL_checknumber( L, 1 ) ); - return 1; + return 0; } /* @@ -1051,31 +768,22 @@ int lrlglIsStereoRenderEnabled( lua_State *L ) { } /* -> success = RL.rlClearColor( Color color ) +> RL.rlClearColor( Color color ) Clear color buffer with color - -- Failure return false -- Success return true */ int lrlglClearColor( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlClearColor( Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Color color = uluaGetColorIndex( L, 1 ); rlClearColor( color.r, color.g, color.b, color.a ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* > RL.rlClearScreenBuffers() -Clear used screen buffers ( color and depth ) +Clear used screen buffers (color and depth) */ int lrlglClearScreenBuffers( lua_State *L ) { rlClearScreenBuffers(); @@ -1095,75 +803,47 @@ int lrlglCheckErrors( lua_State *L ) { } /* -> success = RL.rlSetBlendMode( int mode ) +> RL.rlSetBlendMode( int mode ) Set blending mode - -- Failure return false -- Success return true */ int lrlglSetBlendMode( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetBlendMode( int mode )" ); - lua_pushboolean( L, false ); - return 1; - } - rlSetBlendMode( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlSetBlendMode( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* -> success = RL.rlSetBlendFactors( int glSrcFactor, int glDstFactor, int glEquation ) - -Set blending mode factor and equation ( using OpenGL factors ) +> RL.rlSetBlendFactors( int glSrcFactor, int glDstFactor, int glEquation ) -- Failure return false -- Success return true +Set blending mode factor and equation (using OpenGL factors) */ int lrlglSetBlendFactors( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetBlendFactors( int glSrcFactor, int glDstFactor, int glEquation )" ); - lua_pushboolean( L, false ); - return 1; - } - int glSrcFactor = lua_tointeger( L, 1 ); - int glDstFactor = lua_tointeger( L, 2 ); - int glEquation = lua_tointeger( L, 3 ); + int glSrcFactor = luaL_checkinteger( L, 1 ); + int glDstFactor = luaL_checkinteger( L, 2 ); + int glEquation = luaL_checkinteger( L, 3 ); rlSetBlendFactors( glSrcFactor, glDstFactor, glEquation ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlSetBlendFactorsSeparate( int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha ) +> RL.rlSetBlendFactorsSeparate( int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha ) -Set blending mode factors and equations separately ( using OpenGL factors ) - -- Failure return false -- Success return true +Set blending mode factors and equations separately (using OpenGL factors) */ int lrlglSetBlendFactorsSeparate( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetBlendFactorsSeparate( int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha )" ); - lua_pushboolean( L, false ); - return 1; - } - int glSrcRGB = lua_tointeger( L, 1 ); - int glDstRGB = lua_tointeger( L, 2 ); - int glSrcAlpha = lua_tointeger( L, 3 ); - int glDstAlpha = lua_tointeger( L, 4 ); - int glEqRGB = lua_tointeger( L, 5 ); - int glEqAlpha = lua_tointeger( L, 6 ); + int glSrcRGB = luaL_checkinteger( L, 1 ); + int glDstRGB = luaL_checkinteger( L, 2 ); + int glSrcAlpha = luaL_checkinteger( L, 3 ); + int glDstAlpha = luaL_checkinteger( L, 4 ); + int glEqRGB = luaL_checkinteger( L, 5 ); + int glEqAlpha = luaL_checkinteger( L, 6 ); rlSetBlendFactorsSeparate( glSrcRGB, glDstRGB, glSrcAlpha, glDstAlpha, glEqRGB, glEqAlpha ); - lua_pushboolean( L, true ); - return 1; + return 0; } @@ -1204,38 +884,23 @@ int lrlglDrawRenderBatchActive( lua_State *L ) { Check internal buffer overflow for a given number of vertex and force a rlRenderBatch draw call if required -- Failure return nil - Success return bool */ int lrlglCheckRenderBatchLimit( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlCheckRenderBatchLimit( int vCount )" ); - lua_pushnil( L ); - return 1; - } - lua_pushboolean( L, rlCheckRenderBatchLimit( lua_tointeger( L, 1 ) ) ); + lua_pushboolean( L, rlCheckRenderBatchLimit( luaL_checkinteger( L, 1 ) ) ); return 1; } /* -> success = RL.rlSetTexture( int id ) +> RL.rlSetTexture( int id ) Set current texture for render batch and check buffers limits - -- Failure return false -- Success return true */ int lrlglSetTexture( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetTexture( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlSetTexture( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlSetTexture( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -1260,17 +925,11 @@ int lrlglLoadVertexArray( lua_State *L ) { Load a vertex buffer attribute -- Failure return -1 - Success return int */ int lrlglLoadVertexBuffer( lua_State *L ) { - if ( !lua_isuserdata( L, 1 ) || !lua_isboolean( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlLoadVertexBuffer( Buffer buffer, bool dynamic )" ); - lua_pushinteger( L, -1 ); - return 1; - } Buffer *buffer = luaL_checkudata( L, 1, "Buffer" ); - bool dynamic = lua_tointeger( L, 2 ); + bool dynamic = luaL_checkinteger( L, 2 ); lua_pushinteger( L, rlLoadVertexBuffer( buffer->data, buffer->size, dynamic ) ); @@ -1282,17 +941,11 @@ int lrlglLoadVertexBuffer( lua_State *L ) { Load a new attributes element buffer -- Failure return -1 - Success return int */ int lrlglLoadVertexBufferElement( lua_State *L ) { - if ( !lua_isuserdata( L, 1 ) || !lua_isboolean( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlLoadVertexBufferElement( Buffer buffer, bool dynamic )" ); - lua_pushinteger( L, -1 ); - return 1; - } Buffer *buffer = luaL_checkudata( L, 1, "Buffer" ); - bool dynamic = lua_tointeger( L, 2 ); + bool dynamic = luaL_checkinteger( L, 2 ); lua_pushinteger( L, rlLoadVertexBufferElement( buffer->data, buffer->size, dynamic ) ); @@ -1300,160 +953,97 @@ int lrlglLoadVertexBufferElement( lua_State *L ) { } /* -> success = RL.rlUpdateVertexBuffer( int bufferId, Buffer buffer, int offset ) +> RL.rlUpdateVertexBuffer( int bufferId, Buffer buffer, int offset ) Update GPU buffer with new data - -- Failure return false -- Success return true */ int lrlglUpdateVertexBuffer( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isuserdata( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUpdateVertexBuffer( int bufferId, Buffer buffer, int offset )" ); - lua_pushboolean( L, false ); - return 1; - } - int bufferId = lua_tointeger( L, 1 ); + int bufferId = luaL_checkinteger( L, 1 ); Buffer *buffer = luaL_checkudata( L, 2, "Buffer" ); - int offset = lua_tointeger( L, 3 ); + int offset = luaL_checkinteger( L, 3 ); rlUpdateVertexBuffer( bufferId, buffer->data, buffer->size, offset ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlUpdateVertexBufferElements( int id, Buffer buffer, int offset ) +> RL.rlUpdateVertexBufferElements( int id, Buffer buffer, int offset ) Update vertex buffer elements with new data - -- Failure return false -- Success return true */ int lrlglUpdateVertexBufferElements( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isuserdata( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUpdateVertexBufferElements( int id, Buffer buffer, int offset )" ); - lua_pushboolean( L, false ); - return 1; - } - int bufferId = lua_tointeger( L, 1 ); + int bufferId = luaL_checkinteger( L, 1 ); Buffer *buffer = luaL_checkudata( L, 2, "Buffer" ); - int offset = lua_tointeger( L, 3 ); + int offset = luaL_checkinteger( L, 3 ); rlUpdateVertexBufferElements( bufferId, buffer->data, buffer->size, offset ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlUnloadVertexArray( int vaoId ) +> RL.rlUnloadVertexArray( int vaoId ) Unload vertex array object (VAO) - -- Failure return false -- Success return true */ int lrlglUnloadVertexArray( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUnloadVertexArray( int vaoId )" ); - lua_pushboolean( L, false ); - return 1; - } - rlUnloadVertexArray( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlUnloadVertexArray( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* -> success = RL.rlUnloadVertexBuffer( int vboId ) +> RL.rlUnloadVertexBuffer( int vboId ) Unload vertex buffer (VBO) - -- Failure return false -- Success return true */ int lrlglUnloadVertexBuffer( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUnloadVertexBuffer( int vboId )" ); - lua_pushboolean( L, false ); - return 1; - } - rlUnloadVertexBuffer( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlUnloadVertexBuffer( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* -> success = RL.rlSetVertexAttribute( int index, int compSize, int type, bool normalized, int stride, int pointer ) +> RL.rlSetVertexAttribute( int index, int compSize, int type, bool normalized, int stride, int pointer ) Set vertex attribute - -- Failure return false -- Success return true */ int lrlglSetVertexAttribute( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isboolean( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetVertexAttribute( int index, int compSize, int type, bool normalized, int stride, int pointer )" ); - lua_pushboolean( L, false ); - return 1; - } - int index = lua_tointeger( L, 1 ); - int compSize = lua_tointeger( L, 2 ); - int type = lua_tointeger( L, 3 ); + int index = luaL_checkinteger( L, 1 ); + int compSize = luaL_checkinteger( L, 2 ); + int type = luaL_checkinteger( L, 3 ); bool normalized = lua_toboolean( L, 4 ); - int stride = lua_tointeger( L, 5 ); - int pointer = lua_tointeger( L, 6 ); + int stride = luaL_checkinteger( L, 5 ); + int pointer = luaL_checkinteger( L, 6 ); rlSetVertexAttribute( index, compSize, type, normalized, stride, &pointer ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlSetVertexAttributeDivisor( int index, int divisor ) +> RL.rlSetVertexAttributeDivisor( int index, int divisor ) Set vertex attribute divisor - -- Failure return false -- Success return true */ int lrlglSetVertexAttributeDivisor( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetVertexAttributeDivisor( int index, int divisor )" ); - lua_pushboolean( L, false ); - return 1; - } - unsigned int index = (unsigned int)lua_tointeger( L, 1 ); - int divisor = lua_tointeger( L, 2 ); + unsigned int index = (unsigned int)luaL_checkinteger( L, 1 ); + int divisor = luaL_checkinteger( L, 2 ); rlSetVertexAttributeDivisor( index, divisor ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlSetVertexAttributeDefault( int locIndex, float{} value, int attribType ) +> RL.rlSetVertexAttributeDefault( int locIndex, float{} value, int attribType ) Set vertex attribute default value - -- Failure return false -- Success return true */ int lrlglSetVertexAttributeDefault( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetVertexAttributeDefault( int locIndex, float{} value, int attribType )" ); - lua_pushboolean( L, false ); - return 1; - } - int locIndex = lua_tointeger( L, 1 ); - int attribType = lua_tointeger( L, 3 ); + int locIndex = luaL_checkinteger( L, 1 ); + int attribType = luaL_checkinteger( L, 3 ); int count = uluaGetTableLenIndex( L, 2 ); float value[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; @@ -1462,110 +1052,73 @@ int lrlglSetVertexAttributeDefault( lua_State *L ) { lua_pushnil( L ); while ( lua_next( L, t ) != 0 ) { - value[i] = lua_tonumber( L, -1 ); + value[i] = luaL_checknumber( L, -1 ); lua_pop( L, 1 ); i++; } rlSetVertexAttributeDefault( locIndex, value, attribType, count ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlDrawVertexArray( int offset, int count ) +> RL.rlDrawVertexArray( int offset, int count ) Draw vertex array - -- Failure return false -- Success return true */ int lrlglDrawVertexArray( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlDrawVertexArray( int offset, int count )" ); - lua_pushboolean( L, false ); - return 1; - } - int offset = lua_tointeger( L, 1 ); - int count = lua_tointeger( L, 2 ); + int offset = luaL_checkinteger( L, 1 ); + int count = luaL_checkinteger( L, 2 ); rlDrawVertexArray( offset, count ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlDrawVertexArrayElements( int offset, int count, Buffer buffer ) +> RL.rlDrawVertexArrayElements( int offset, int count, Buffer buffer ) Draw vertex array elements - -- Failure return false -- Success return true */ int lrlglDrawVertexArrayElements( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isuserdata( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlDrawVertexArrayElements( int offset, int count, Buffer buffer )" ); - lua_pushboolean( L, false ); - return 1; - } - int offset = lua_tointeger( L, 1 ); - int count = lua_tointeger( L, 2 ); + int offset = luaL_checkinteger( L, 1 ); + int count = luaL_checkinteger( L, 2 ); Buffer *buffer = luaL_checkudata( L, 3, "Buffer" ); rlDrawVertexArrayElements( offset, count, buffer->data ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlDrawVertexArrayInstanced( int offset, int count, int instances ) +> RL.rlDrawVertexArrayInstanced( int offset, int count, int instances ) Draw vertex array instanced - -- Failure return false -- Success return true */ int lrlglDrawVertexArrayInstanced( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlDrawVertexArrayInstanced( int offset, int count, int instances )" ); - lua_pushboolean( L, false ); - return 1; - } - int offset = lua_tointeger( L, 1 ); - int count = lua_tointeger( L, 2 ); - int instances = lua_tointeger( L, 3 ); + int offset = luaL_checkinteger( L, 1 ); + int count = luaL_checkinteger( L, 2 ); + int instances = luaL_checkinteger( L, 3 ); rlDrawVertexArrayInstanced( offset, count, instances ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlDrawVertexArrayElementsInstanced( int offset, int count, Buffer buffer, int instances ) +> RL.rlDrawVertexArrayElementsInstanced( int offset, int count, Buffer buffer, int instances ) Draw vertex array elements instanced - -- Failure return false -- Success return true */ int lrlglDrawVertexArrayElementsInstanced( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isuserdata( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlDrawVertexArrayElementsInstanced( int offset, int count, Buffer buffer, int instances )" ); - lua_pushboolean( L, false ); - return 1; - } - int offset = lua_tointeger( L, 1 ); - int count = lua_tointeger( L, 2 ); + int offset = luaL_checkinteger( L, 1 ); + int count = luaL_checkinteger( L, 2 ); Buffer *buffer = luaL_checkudata( L, 3, "Buffer" ); - int instances = lua_tointeger( L, 4 ); + int instances = luaL_checkinteger( L, 4 ); rlDrawVertexArrayElementsInstanced( offset, count, buffer->data, instances ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -1577,18 +1130,12 @@ int lrlglDrawVertexArrayElementsInstanced( lua_State *L ) { Load texture in GPU -- Failure return -1 - Success return int */ int lrlglLoadTexture( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlLoadTexture( Vector2 size, int format, int mipmapCount )" ); - lua_pushinteger( L, -1 ); - return 1; - } Vector2 size = uluaGetVector2Index( L, 1 ); - int format = lua_tointeger( L, 2 ); - int mipmapCount = lua_tointeger( L, 3 ); + int format = luaL_checkinteger( L, 2 ); + int mipmapCount = luaL_checkinteger( L, 3 ); lua_pushinteger( L, rlLoadTexture( NULL, size.x, size.y, format, mipmapCount ) ); @@ -1598,17 +1145,11 @@ int lrlglLoadTexture( lua_State *L ) { /* > id = RL.rlLoadTextureDepth( Vector2 size, bool useRenderBuffer ) -Load depth texture/renderbuffer ( to be attached to fbo ) +Load depth texture/renderbuffer (to be attached to fbo) -- Failure return -1 - Success return int */ int lrlglLoadTextureDepth( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isboolean( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlLoadTextureDepth( Vector2 size, bool useRenderBuffer )" ); - lua_pushinteger( L, -1 ); - return 1; - } Vector2 size = uluaGetVector2Index( L, 1 ); bool useRenderBuffer = lua_toboolean( L, 2 ); @@ -1618,23 +1159,14 @@ int lrlglLoadTextureDepth( lua_State *L ) { } /* -> success = RL.rlUnloadTexture( int id ) +> RL.rlUnloadTexture( int id ) Unload texture from GPU memory - -- Failure return false -- Success return true */ int lrlglUnloadTexture( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUnloadTexture( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlUnloadTexture( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlUnloadTexture( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -1646,15 +1178,9 @@ int lrlglUnloadTexture( lua_State *L ) { Load an empty framebuffer -- Failure return -1 - Success return int */ int lrlglLoadFramebuffer( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlLoadFramebuffer( Vector2 size )" ); - lua_pushinteger( L, -1 ); - return 1; - } Vector2 size = uluaGetVector2Index( L, 1 ); lua_pushinteger( L, rlLoadFramebuffer( size.x, size.y ) ); @@ -1663,30 +1189,20 @@ int lrlglLoadFramebuffer( lua_State *L ) { } /* -> success = RL.rlFramebufferAttach( int fboId, int texId, int attachType, int texType, int mipLevel ) +> RL.rlFramebufferAttach( int fboId, int texId, int attachType, int texType, int mipLevel ) Attach texture/renderbuffer to a framebuffer - -- Failure return false -- Success return true */ int lrlglFramebufferAttach( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlFramebufferAttach( int fboId, int texId, int attachType, int texType, int mipLevel )" ); - lua_pushboolean( L, false ); - return 1; - } - unsigned int fboId = lua_tointeger( L, 1 ); - unsigned int texId = lua_tointeger( L, 2 ); - int attachType = lua_tointeger( L, 3 ); - int texType = lua_tointeger( L, 4 ); - int mipLevel = lua_tointeger( L, 5 ); + unsigned int fboId = luaL_checkinteger( L, 1 ); + unsigned int texId = luaL_checkinteger( L, 2 ); + int attachType = luaL_checkinteger( L, 3 ); + int texType = luaL_checkinteger( L, 4 ); + int mipLevel = luaL_checkinteger( L, 5 ); rlFramebufferAttach( fboId, texId, attachType, texType, mipLevel ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -1694,16 +1210,10 @@ int lrlglFramebufferAttach( lua_State *L ) { Verify framebuffer is complete -- Failure return nil - Success return bool */ int lrlglFramebufferComplete( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlFramebufferComplete( int id )" ); - lua_pushnil( L ); - return 1; - } - unsigned int id = lua_tointeger( L, 1 ); + unsigned int id = luaL_checkinteger( L, 1 ); lua_pushboolean( L, rlFramebufferComplete( id ) ); @@ -1711,25 +1221,16 @@ int lrlglFramebufferComplete( lua_State *L ) { } /* -> success = RL.rlUnloadFramebuffer( int id ) +> RL.rlUnloadFramebuffer( int id ) Delete framebuffer from GPU - -- Failure return nil -- Success return bool */ int lrlglUnloadFramebuffer( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUnloadFramebuffer( int id )" ); - lua_pushnil( L ); - return 1; - } - unsigned int id = lua_tointeger( L, 1 ); + unsigned int id = luaL_checkinteger( L, 1 ); rlUnloadFramebuffer( id ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -1803,16 +1304,10 @@ int lrlglGetMatrixTransform( lua_State *L ) { Get internal projection matrix for stereo render (selected eye) -- Failure return false - Success return Matrix */ int lrlglGetMatrixProjectionStereo( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlGetMatrixProjectionStereo( int eye )" ); - lua_pushboolean( L, false ); - return 1; - } - uluaPushMatrix( L, rlGetMatrixProjectionStereo( lua_tointeger( L, 1 ) ) ); + uluaPushMatrix( L, rlGetMatrixProjectionStereo( luaL_checkinteger( L, 1 ) ) ); return 1; } @@ -1822,96 +1317,54 @@ int lrlglGetMatrixProjectionStereo( lua_State *L ) { Get internal view offset matrix for stereo render (selected eye) -- Failure return false - Success return Matrix */ int lrlglGetMatrixViewOffsetStereo( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlGetMatrixViewOffsetStereo( int eye )" ); - lua_pushboolean( L, false ); - return 1; - } - uluaPushMatrix( L, rlGetMatrixViewOffsetStereo( lua_tointeger( L, 1 ) ) ); + uluaPushMatrix( L, rlGetMatrixViewOffsetStereo( luaL_checkinteger( L, 1 ) ) ); return 1; } /* -> success = RL.rlSetMatrixProjection( Matrix proj ) +> RL.rlSetMatrixProjection( Matrix proj ) Set a custom projection matrix (replaces internal projection matrix) - -- Failure return false -- Success return true */ int lrlglSetMatrixProjection( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetMatrixProjection( Matrix proj )" ); - lua_pushboolean( L, false ); - return 1; - } rlSetMatrixProjection( uluaGetMatrixIndex( L, 1 ) ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlSetMatrixModelview( Matrix view ) +> RL.rlSetMatrixModelview( Matrix view ) Set a custom modelview matrix (replaces internal modelview matrix) - -- Failure return false -- Success return true */ int lrlglSetMatrixModelview( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetMatrixModelview( Matrix view )" ); - lua_pushboolean( L, false ); - return 1; - } rlSetMatrixModelview( uluaGetMatrixIndex( L, 1 ) ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlSetMatrixProjectionStereo( Matrix right, Matrix left ) +> RL.rlSetMatrixProjectionStereo( Matrix right, Matrix left ) Set eyes projection matrices for stereo rendering - -- Failure return false -- Success return true */ int lrlglSetMatrixProjectionStereo( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetMatrixModelview( Matrix right, Matrix left )" ); - lua_pushboolean( L, false ); - return 1; - } rlSetMatrixProjectionStereo( uluaGetMatrixIndex( L, 1 ), uluaGetMatrixIndex( L, 2 ) ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlSetMatrixViewOffsetStereo( Matrix right, Matrix left ) +> RL.rlSetMatrixViewOffsetStereo( Matrix right, Matrix left ) Set eyes view offsets matrices for stereo rendering - -- Failure return false -- Success return true */ int lrlglSetMatrixViewOffsetStereo( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetMatrixViewOffsetStereo( Matrix right, Matrix left )" ); - lua_pushboolean( L, false ); - return 1; - } rlSetMatrixViewOffsetStereo( uluaGetMatrixIndex( L, 1 ), uluaGetMatrixIndex( L, 2 ) ); - lua_pushboolean( L, true ); - return 1; + return 0; } -- cgit v1.2.3