RL_LoadFontEx.
This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -9,7 +9,7 @@
|
|||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/build/ReiLua",
|
"program": "${workspaceFolder}/build/ReiLua",
|
||||||
"args": ["/examples/image_draw/"],
|
"args": ["/examples/instancing/"],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"environment": [],
|
"environment": [],
|
||||||
|
|||||||
14
API.md
14
API.md
@@ -3698,6 +3698,15 @@ Load font from file into GPU memory ( VRAM )
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
> 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
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
> font = RL_LoadFontFromImage( Image image, Color key, int firstChar )
|
> font = RL_LoadFontFromImage( Image image, Color key, int firstChar )
|
||||||
|
|
||||||
Load font from Image ( XNA style )
|
Load font from Image ( XNA style )
|
||||||
@@ -3926,10 +3935,9 @@ Draw a plane XZ
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> 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.
|
Draw 3D textured quad. ( Texture coordinates opengl style 0.0 - 1.0 ).
|
||||||
Note! Could be replaced something like "DrawPlaneTextureRec"
|
|
||||||
|
|
||||||
- Failure return false
|
- Failure return false
|
||||||
- Success return true
|
- Success return true
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ KEY CHANGES:
|
|||||||
- ADDED: ReiLuaGui.
|
- ADDED: ReiLuaGui.
|
||||||
- ADDED: ReiLuaGui Examples.
|
- ADDED: ReiLuaGui Examples.
|
||||||
- ADDED: Draw Mesh Instanced Example.
|
- ADDED: Draw Mesh Instanced Example.
|
||||||
|
- CHANGED: RL_DrawQuad3DTexture now takes vertex colors instead of just single color.
|
||||||
|
|
||||||
Detailed changes:
|
Detailed changes:
|
||||||
ADDED: Help argument.
|
ADDED: Help argument.
|
||||||
@@ -24,3 +25,4 @@ FIXED: RL_DrawEllipse and RL_DrawEllipseLines expecting wrong arguments.
|
|||||||
ADDED: RL_IsPathFile.
|
ADDED: RL_IsPathFile.
|
||||||
ADDED: RL_SetMaterialShader.
|
ADDED: RL_SetMaterialShader.
|
||||||
ADDED: RL_GetFileLength.
|
ADDED: RL_GetFileLength.
|
||||||
|
ADDED: RL_LoadFontEx.
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ local winScale = 4
|
|||||||
local framebuffer = -1
|
local framebuffer = -1
|
||||||
|
|
||||||
local TILE_SIZE = 32
|
local TILE_SIZE = 32
|
||||||
|
local TILE_VERTEX_COLORS = { WHITE, WHITE, WHITE, WHITE }
|
||||||
|
|
||||||
local FLOOR = 1
|
local FLOOR = 1
|
||||||
local CEILING = 2
|
local CEILING = 2
|
||||||
@@ -105,22 +106,22 @@ function draw()
|
|||||||
-- Floor and ceiling.
|
-- Floor and ceiling.
|
||||||
for x = 0, 3 do
|
for x = 0, 3 do
|
||||||
for y = 0, 10 do
|
for y = 0, 10 do
|
||||||
RL_DrawQuad3DTexture( texture, getTileVer( x, y, FLOOR ), getTexCoords( 1, 0 ), WHITE )
|
RL_DrawQuad3DTexture( texture, getTileVer( x, y, FLOOR ), getTexCoords( 1, 0 ), TILE_VERTEX_COLORS )
|
||||||
RL_DrawQuad3DTexture( texture, getTileVer( x, y, CEILING ), getTexCoords( 2, 0 ), WHITE )
|
RL_DrawQuad3DTexture( texture, getTileVer( x, y, CEILING ), getTexCoords( 2, 0 ), TILE_VERTEX_COLORS )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Walls.
|
-- Walls.
|
||||||
RL_DrawQuad3DTexture( texture, getTileVer( 0, 0, WALL_N ), getTexCoords( 0, 0 ), WHITE )
|
RL_DrawQuad3DTexture( texture, getTileVer( 0, 0, WALL_N ), getTexCoords( 0, 0 ), TILE_VERTEX_COLORS )
|
||||||
RL_DrawQuad3DTexture( texture, getTileVer( 1, 0, WALL_N ), getTexCoords( 0, 2 ), WHITE )
|
RL_DrawQuad3DTexture( texture, getTileVer( 1, 0, WALL_N ), getTexCoords( 0, 2 ), TILE_VERTEX_COLORS )
|
||||||
RL_DrawQuad3DTexture( texture, getTileVer( 2, 0, WALL_N ), getTexCoords( 2, 2 ), WHITE )
|
RL_DrawQuad3DTexture( texture, getTileVer( 2, 0, WALL_N ), getTexCoords( 2, 2 ), TILE_VERTEX_COLORS )
|
||||||
RL_DrawQuad3DTexture( texture, getTileVer( 3, 0, WALL_N ), getTexCoords( 0, 0 ), WHITE )
|
RL_DrawQuad3DTexture( texture, getTileVer( 3, 0, WALL_N ), getTexCoords( 0, 0 ), TILE_VERTEX_COLORS )
|
||||||
|
|
||||||
for x = 0, 3 do
|
for x = 0, 3 do
|
||||||
RL_DrawQuad3DTexture( texture, getTileVer( x, 10, WALL_S ), getTexCoords( 0, 0 ), WHITE )
|
RL_DrawQuad3DTexture( texture, getTileVer( x, 10, WALL_S ), getTexCoords( 0, 0 ), TILE_VERTEX_COLORS )
|
||||||
end
|
end
|
||||||
for y = 0, 10 do
|
for y = 0, 10 do
|
||||||
RL_DrawQuad3DTexture( texture, getTileVer( 0, y, WALL_W ), getTexCoords( 0, 0 ), WHITE )
|
RL_DrawQuad3DTexture( texture, getTileVer( 0, y, WALL_W ), getTexCoords( 0, 0 ), TILE_VERTEX_COLORS )
|
||||||
RL_DrawQuad3DTexture( texture, getTileVer( 3, y, WALL_E ), getTexCoords( 0, 0 ), WHITE )
|
RL_DrawQuad3DTexture( texture, getTileVer( 3, y, WALL_E ), getTexCoords( 0, 0 ), TILE_VERTEX_COLORS )
|
||||||
end
|
end
|
||||||
|
|
||||||
drawSprites()
|
drawSprites()
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 5.9 KiB |
@@ -4,6 +4,7 @@
|
|||||||
bool validFont( size_t id );
|
bool validFont( size_t id );
|
||||||
/* Loading. */
|
/* Loading. */
|
||||||
int ltextLoadFont( lua_State *L );
|
int ltextLoadFont( lua_State *L );
|
||||||
|
int ltextLoadFontEx( lua_State *L );
|
||||||
int ltextLoadFontFromImage( lua_State *L );
|
int ltextLoadFontFromImage( lua_State *L );
|
||||||
int ltextUnloadFont( lua_State *L );
|
int ltextUnloadFont( lua_State *L );
|
||||||
/* Drawing. */
|
/* Drawing. */
|
||||||
|
|||||||
@@ -1062,6 +1062,7 @@ void luaRegister() {
|
|||||||
/* Text. */
|
/* Text. */
|
||||||
/* Loading. */
|
/* Loading. */
|
||||||
lua_register( L, "RL_LoadFont", ltextLoadFont );
|
lua_register( L, "RL_LoadFont", ltextLoadFont );
|
||||||
|
lua_register( L, "RL_LoadFontEx", ltextLoadFontEx );
|
||||||
lua_register( L, "RL_LoadFontFromImage", ltextLoadFontFromImage );
|
lua_register( L, "RL_LoadFontFromImage", ltextLoadFontFromImage );
|
||||||
lua_register( L, "RL_UnloadFont", ltextUnloadFont );
|
lua_register( L, "RL_UnloadFont", ltextUnloadFont );
|
||||||
/* Drawing. */
|
/* Drawing. */
|
||||||
|
|||||||
27
src/models.c
27
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.
|
Draw 3D textured quad. ( Texture coordinates opengl style 0.0 - 1.0 ).
|
||||||
Note! Could be replaced something like "DrawPlaneTextureRec"
|
|
||||||
|
|
||||||
- Failure return false
|
- Failure return false
|
||||||
- Success return true
|
- Success return true
|
||||||
*/
|
*/
|
||||||
int lmodelDrawQuad3DTexture( lua_State *L ) {
|
int lmodelDrawQuad3DTexture( lua_State *L ) {
|
||||||
if ( !lua_isnumber( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
|
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 );
|
lua_pushboolean( L, false );
|
||||||
return 1;
|
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 );
|
lua_pop( L, 1 );
|
||||||
|
|
||||||
/* TexCoords. */
|
/* TexCoords. */
|
||||||
Vector2 texcoords[4] = { 0 };
|
Vector2 texcoords[4] = { 0 };
|
||||||
|
|
||||||
int t = lua_gettop( L ), i = 0;
|
t = lua_gettop( L ), i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
@@ -621,10 +633,9 @@ int lmodelDrawQuad3DTexture( lua_State *L ) {
|
|||||||
rlSetTexture( texturesGetSourceTexture( texId )->id );
|
rlSetTexture( texturesGetSourceTexture( texId )->id );
|
||||||
|
|
||||||
rlBegin( RL_QUADS );
|
rlBegin( RL_QUADS );
|
||||||
rlColor4ub( color.r, color.g, color.b, color.a );
|
|
||||||
|
|
||||||
for ( i = 0; i < 4; ++i ) {
|
for ( i = 0; i < 4; ++i ) {
|
||||||
rlTexCoord2f( texcoords[i].x, texcoords[i].y );
|
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 );
|
rlVertex3f( vertices[i].x, vertices[i].y, vertices[i].z );
|
||||||
}
|
}
|
||||||
rlEnd();
|
rlEnd();
|
||||||
|
|||||||
29
src/text.c
29
src/text.c
@@ -62,6 +62,35 @@ int ltextLoadFont( lua_State *L ) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> 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 )
|
> font = RL_LoadFontFromImage( Image image, Color key, int firstChar )
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user