summaryrefslogtreecommitdiff
path: root/src/textures.c
diff options
context:
space:
mode:
authorjussi2022-03-24 17:10:35 +0200
committerjussi2022-03-24 17:10:35 +0200
commit3aa949f3f556a45a1d10f3b83e786562918dfa05 (patch)
tree29f56db116f76deb945dd26c8c08092d9958b351 /src/textures.c
parent26a11a4b7f32a6fc2d131e4c78fe1ca40cc6ac8a (diff)
downloadreilua-enhanced-3aa949f3f556a45a1d10f3b83e786562918dfa05.tar.gz
reilua-enhanced-3aa949f3f556a45a1d10f3b83e786562918dfa05.tar.bz2
reilua-enhanced-3aa949f3f556a45a1d10f3b83e786562918dfa05.zip
Image export functions.
Diffstat (limited to 'src/textures.c')
-rw-r--r--src/textures.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/textures.c b/src/textures.c
index 72d6c28..f278341 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -204,6 +204,56 @@ int ltexturesUnloadImage( lua_State *L ) {
}
/*
+> success = RL_ExportImage( Image image, string fileName )
+
+Export image data to file, returns true on success
+
+- Failure return nil
+- Success return bool
+*/
+int ltexturesExportImage( lua_State *L ) {
+ if ( !lua_isnumber( L, -2 ) || !lua_isstring( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_ExportImage( Image image, string fileName )" );
+ lua_pushnil( L );
+ return 1;
+ }
+ size_t id = lua_tointeger( L, -2 );
+
+ if ( !validImage( id ) ) {
+ lua_pushnil( L );
+ return 1;
+ }
+ lua_pushboolean( L, ExportImage( *state->images[ id ], lua_tostring( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
+> success = RL_ExportImageAsCode( Image image, string fileName )
+
+Export image as code file defining an array of bytes, returns true on success
+
+- Failure return nil
+- Success return bool
+*/
+int ltexturesExportImageAsCode( lua_State *L ) {
+ if ( !lua_isnumber( L, -2 ) || !lua_isstring( L, -1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_ExportImageAsCode( Image image, string fileName )" );
+ lua_pushnil( L );
+ return 1;
+ }
+ size_t id = lua_tointeger( L, -2 );
+
+ if ( !validImage( id ) ) {
+ lua_pushnil( L );
+ return 1;
+ }
+ lua_pushboolean( L, ExportImageAsCode( *state->images[ id ], lua_tostring( L, -1 ) ) );
+
+ return 1;
+}
+
+/*
> texture = RL_LoadTexture( string fileName )
Load texture from file into GPU memory ( VRAM )