diff options
| author | jussi | 2023-02-06 23:03:39 +0200 |
|---|---|---|
| committer | jussi | 2023-02-06 23:03:39 +0200 |
| commit | db957a8181497a25e52328882e6e0f98d6551d0b (patch) | |
| tree | 583aa051b304c04457d8eba4e7ec238c04b5dcd7 /src | |
| parent | 7e61bffe5f313599423ad3cf88b0e44329de7dd2 (diff) | |
| download | reilua-enhanced-db957a8181497a25e52328882e6e0f98d6551d0b.tar.gz reilua-enhanced-db957a8181497a25e52328882e6e0f98d6551d0b.tar.bz2 reilua-enhanced-db957a8181497a25e52328882e6e0f98d6551d0b.zip | |
RL_LoadFontEx.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 2 | ||||
| -rw-r--r-- | src/lua_core.c | 1 | ||||
| -rw-r--r-- | src/models.c | 27 | ||||
| -rw-r--r-- | src/text.c | 29 |
4 files changed, 50 insertions, 9 deletions
@@ -1247,7 +1247,7 @@ int lcoreSetShaderValue( lua_State *L ) { } int uniformType = lua_tointeger( L, -1 ); lua_pop( L, 1 ); - + /* Read values. */ size_t valueCount = uluaGetTableLen( L ); float floats[ valueCount ]; diff --git a/src/lua_core.c b/src/lua_core.c index 1033c74..7056f40 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -1062,6 +1062,7 @@ void luaRegister() { /* Text. */ /* Loading. */ lua_register( L, "RL_LoadFont", ltextLoadFont ); + lua_register( L, "RL_LoadFontEx", ltextLoadFontEx ); lua_register( L, "RL_LoadFontFromImage", ltextLoadFontFromImage ); lua_register( L, "RL_UnloadFont", ltextUnloadFont ); /* Drawing. */ diff --git a/src/models.c b/src/models.c index f2f7f2e..6258f81 100644 --- a/src/models.c +++ b/src/models.c @@ -558,27 +558,39 @@ int lmodelsDrawPlane( lua_State *L ) { } /* -> success = RL_DrawQuad3DTexture( texture, Vector3{} vertices, Vector2{} texCoords, Color color ) +> success = RL_DrawQuad3DTexture( texture, Vector3{} vertices, Vector2{} texCoords, Color{} colors ) -Draw 3D quad texture using vertices and texture coordinates. Texture coordinates opengl style 0.0 - 1.0. -Note! Could be replaced something like "DrawPlaneTextureRec" +Draw 3D textured quad. ( Texture coordinates opengl style 0.0 - 1.0 ). - Failure return false - Success return true */ int lmodelDrawQuad3DTexture( lua_State *L ) { if ( !lua_isnumber( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { - TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_DrawQuad3DTexture( texture, Vector3{} vertices, Vector2{} texCoords, Color color )" ); + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_DrawQuad3DTexture( texture, Vector3{} vertices, Vector2{} texCoords, Color{} colors )" ); lua_pushboolean( L, false ); return 1; } - Color color = uluaGetColor( L ); + + /* Colors. */ + Color colors[4] = { 0 }; + + int t = lua_gettop( L ), i = 0; + lua_pushnil( L ); + + while ( lua_next( L, t ) != 0 ) { + if ( lua_istable( L, -1 ) && i < 4 ) { + colors[i] = uluaGetColor( L ); + } + i++; + lua_pop( L, 1 ); + } lua_pop( L, 1 ); /* TexCoords. */ Vector2 texcoords[4] = { 0 }; - int t = lua_gettop( L ), i = 0; + t = lua_gettop( L ), i = 0; lua_pushnil( L ); while ( lua_next( L, t ) != 0 ) { @@ -621,10 +633,9 @@ int lmodelDrawQuad3DTexture( lua_State *L ) { rlSetTexture( texturesGetSourceTexture( texId )->id ); rlBegin( RL_QUADS ); - rlColor4ub( color.r, color.g, color.b, color.a ); - for ( i = 0; i < 4; ++i ) { rlTexCoord2f( texcoords[i].x, texcoords[i].y ); + rlColor4ub( colors[i].r, colors[i].g, colors[i].b, colors[i].a ); rlVertex3f( vertices[i].x, vertices[i].y, vertices[i].z ); } rlEnd(); @@ -63,6 +63,35 @@ int ltextLoadFont( lua_State *L ) { } /* +> font = RL_LoadFontEx( string fileName, int fontSize ) + +Load font from file with extended parameters. Loading the default character set + +- Failure return -1 +- Success return int +*/ +int ltextLoadFontEx( lua_State *L ) { + if ( !lua_isstring( L, -2 ) || !lua_isnumber( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_LoadFontEx( string fileName, int fontSize )" ); + lua_pushinteger( L, -1 ); + return 1; + } + int i = 0; + + for ( i = 0; i < state->fontCount; i++ ) { + if ( state->fonts[i] == NULL ) { + break; + } + } + state->fonts[i] = malloc( sizeof( Font ) ); + *state->fonts[i] = LoadFontEx( lua_tostring( L, -2 ), lua_tointeger( L, - 1 ), NULL, 0 ); + lua_pushinteger( L, i ); + checkFontRealloc( i ); + + return 1; +} + +/* > font = RL_LoadFontFromImage( Image image, Color key, int firstChar ) Load font from Image ( XNA style ) |
