summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjussi2023-08-24 20:19:13 +0300
committerjussi2023-08-24 20:19:13 +0300
commit6e17282197320bfc3af6a225fb3d9e13194022fa (patch)
treee0be6b9033481c99dd76f3791927a5e9080989b2 /src
parent3fc07a02d5213a88ebb555d3133af2746600cf61 (diff)
downloadreilua-enhanced-6e17282197320bfc3af6a225fb3d9e13194022fa.tar.gz
reilua-enhanced-6e17282197320bfc3af6a225fb3d9e13194022fa.tar.bz2
reilua-enhanced-6e17282197320bfc3af6a225fb3d9e13194022fa.zip
GetFontTexture.
Diffstat (limited to 'src')
-rw-r--r--src/lua_core.c15
-rw-r--r--src/text.c31
-rw-r--r--src/textures.c2
3 files changed, 44 insertions, 4 deletions
diff --git a/src/lua_core.c b/src/lua_core.c
index c831694..77564ee 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -1612,6 +1612,7 @@ void luaRegister() {
assingGlobalFunction( "GetFontBaseSize", ltextGetFontBaseSize );
assingGlobalFunction( "GetFontGlyphCount", ltextGetFontGlyphCount );
assingGlobalFunction( "GetFontGlyphPadding", ltextGetFontGlyphPadding );
+ assingGlobalFunction( "GetFontTexture", ltextGetFontTexture );
/* Audio. */
/* Audio device management. */
@@ -2959,6 +2960,20 @@ void uluaPushBoundingBox( lua_State *L, BoundingBox box ) {
lua_rawseti( L, -2, 2 );
}
+void uluaPushTexture( lua_State *L, Texture texture ) {
+ lua_createtable( L, 5, 0 );
+ lua_pushinteger( L, texture.id );
+ lua_setfield( L, -2, "id" );
+ lua_pushinteger( L, texture.width );
+ lua_setfield( L, -2, "width" );
+ lua_pushinteger( L, texture.height );
+ lua_setfield( L, -2, "height" );
+ lua_pushinteger( L, texture.mipmaps );
+ lua_setfield( L, -2, "mipmaps" );
+ lua_pushinteger( L, texture.format );
+ lua_setfield( L, -2, "format" );
+}
+
int uluaGetTableLen( lua_State *L ) {
return uluaGetTableLenIndex( L, lua_gettop( L ) );
}
diff --git a/src/text.c b/src/text.c
index bc14828..0339aa6 100644
--- a/src/text.c
+++ b/src/text.c
@@ -286,7 +286,7 @@ int ltextMeasureText( lua_State *L ) {
/*
> baseSize = RL.GetFontBaseSize( Font font )
-Get font baseSize
+Get font base size ( default chars height )
- Failure return false
- Success return int
@@ -311,7 +311,7 @@ int ltextGetFontBaseSize( lua_State *L ) {
/*
> glyphCount = RL.GetFontGlyphCount( Font font )
-Get font glyphCount
+Get font number of glyph characters
- Failure return false
- Success return int
@@ -336,7 +336,7 @@ int ltextGetFontGlyphCount( lua_State *L ) {
/*
> glyphPadding = RL.GetFontGlyphPadding( Font font )
-Get font glyphPadding
+Get font padding around the glyph characters
- Failure return false
- Success return int
@@ -357,3 +357,28 @@ int ltextGetFontGlyphPadding( lua_State *L ) {
return 1;
}
+
+/*
+> textureTable = RL.GetFontTexture( Font font )
+
+Get font texture atlas containing the glyphs. NOTE! Texture in table form.
+
+- Failure return false
+- Success return table
+*/
+int ltextGetFontTexture( lua_State *L ) {
+ if ( !lua_isnumber( L, 1 ) ) {
+ TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GetFontTexture( Font font )" );
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ size_t fontId = lua_tointeger( L, 1 );
+
+ if ( !validFont( fontId ) ) {
+ lua_pushboolean( L, false );
+ return 1;
+ }
+ uluaPushTexture( L, state->fonts[ fontId ]->texture );
+
+ return 1;
+}
diff --git a/src/textures.c b/src/textures.c
index c04179d..9fff0d1 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -2209,7 +2209,7 @@ int ltexturesGetTextureMipmaps( lua_State *L ) {
/*
> format = RL.GetTextureFormat( Texture2D texture )
-Get texture mipmaps. Mipmap levels, 1 by default
+Get texture data format ( PixelFormat type )
- Failure return false
- Success return int