summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjussi2024-05-20 15:45:31 +0300
committerjussi2024-05-20 15:45:31 +0300
commit9edaf7a47b02bd351c400f0c6aec517884449551 (patch)
treecf7019c08a033cb0b3739cdbcbb40b7c55fbad89
parente84be852546aecf3e151fd8bb92db88a068c1ea1 (diff)
downloadreilua-enhanced-9edaf7a47b02bd351c400f0c6aec517884449551.tar.gz
reilua-enhanced-9edaf7a47b02bd351c400f0c6aec517884449551.tar.bz2
reilua-enhanced-9edaf7a47b02bd351c400f0c6aec517884449551.zip
Use GetApplicationDirectory instead of GetWorkingDirectory for basePath if no path argument given.
-rw-r--r--API.md6
-rw-r--r--ReiLua_API.lua6
-rw-r--r--changelog1
-rw-r--r--include/state.h4
-rw-r--r--src/core.c2
-rw-r--r--src/gl.c4
-rw-r--r--src/lua_core.c4
-rw-r--r--src/main.c13
-rw-r--r--src/state.c8
9 files changed, 25 insertions, 23 deletions
diff --git a/API.md b/API.md
index 36927e6..c7f17d8 100644
--- a/API.md
+++ b/API.md
@@ -5385,9 +5385,9 @@ Note: angle must be provided in radians
> RL.Camera3DPitch( camera3D camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp )
Rotates the camera around it's right vector, pitch is "looking up and down"
- - lockView prevents camera overrotation (aka "somersaults")
- - rotateAroundTarget defines if rotation is around target or around it's position
- - rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE)
+- lockView prevents camera overrotation (aka "somersaults")
+- rotateAroundTarget defines if rotation is around target or around it's position
+- rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE)
NOTE: angle must be provided in radians
---
diff --git a/ReiLua_API.lua b/ReiLua_API.lua
index ef5ac23..35b0778 100644
--- a/ReiLua_API.lua
+++ b/ReiLua_API.lua
@@ -2559,9 +2559,9 @@ function RL.Camera3DMoveToTarget( camera, delta ) end
function RL.Camera3DYaw( camera, angle, rotateAroundTarget ) end
---Rotates the camera around it's right vector, pitch is "looking up and down"
---- - lockView prevents camera overrotation (aka "somersaults")
---- - rotateAroundTarget defines if rotation is around target or around it's position
---- - rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE)
+---- lockView prevents camera overrotation (aka "somersaults")
+---- rotateAroundTarget defines if rotation is around target or around it's position
+---- rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE)
---NOTE: angle must be provided in radians
---@param camera any
---@param angle number
diff --git a/changelog b/changelog
index c246182..db8008e 100644
--- a/changelog
+++ b/changelog
@@ -9,6 +9,7 @@ KEY CHANGES:
- ADDED OpenGL Stencil management functions.
- CHANGE: Object libraries like Vector2 optimizations. Separated table argument style for new and set methods.
Option for pre generated temp objects. There was a lot of overhead on old new method.
+ - CHANGE: Use GetApplicationDirectory instead of GetWorkingDirectory for basePath if no path argument given.
DETAILED CHANGES:
- ADDED: GetBufferElementSize and GetBufferLength.
diff --git a/include/state.h b/include/state.h
index 63ab870..016e1bc 100644
--- a/include/state.h
+++ b/include/state.h
@@ -5,7 +5,7 @@
#endif
typedef struct {
- char* exePath;
+ char* basePath;
bool hasWindow;
bool run;
bool gcUnload;
@@ -45,6 +45,6 @@ typedef struct {
extern State* state;
-bool stateInit( int argn, const char** argc, const char* exePath );
+bool stateInit( int argn, const char** argc, const char* basePath );
void stateInitInterpret( int argn, const char** argc );
void stateFree();
diff --git a/src/core.c b/src/core.c
index a687b2a..2146510 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1591,7 +1591,7 @@ Return game directory (where main.lua is located)
- Success return string
*/
int lcoreGetBasePath( lua_State* L ) {
- lua_pushstring( L, state->exePath );
+ lua_pushstring( L, state->basePath );
return 1;
}
diff --git a/src/gl.c b/src/gl.c
index 31c5293..ec27d3b 100644
--- a/src/gl.c
+++ b/src/gl.c
@@ -32,7 +32,7 @@ Copy a block of pixels from one framebuffer object to another.
Use nil RenderTexture for window framebuffer
*/
int lglBlitFramebuffer( lua_State* L ) {
-// #if defined( PLATFORM_DESKTOP ) || defined( PLATFORM_DESKTOP_SDL )
+#if defined( PLATFORM_DESKTOP ) || defined( PLATFORM_DESKTOP_SDL )
if ( !( lua_isuserdata( L, 1 ) || lua_isnil( L, 1 ) ) || !( lua_isuserdata( L, 2 ) || lua_isnil( L, 2 ) ) ) {
TraceLog( state->logLevelInvalid, "%s", "Argument needs to be RenderTexture or nil" );
lua_pushnil( L );
@@ -70,7 +70,7 @@ int lglBlitFramebuffer( lua_State* L ) {
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 );
return 1;
-// #endif
+#endif
}
/*
diff --git a/src/lua_core.c b/src/lua_core.c
index 633cb8b..6d89777 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -1160,10 +1160,10 @@ bool luaCallMain() {
snprintf( path, STRING_LEN, "main" );
}
#else
- snprintf( path, STRING_LEN, "%smain.lua", state->exePath );
+ snprintf( path, STRING_LEN, "%smain.lua", state->basePath );
/* Alternatively look for main. Could be precompiled binary file. */
if ( !FileExists( path ) ) {
- snprintf( path, STRING_LEN, "%smain", state->exePath );
+ snprintf( path, STRING_LEN, "%smain", state->basePath );
}
#endif
luaL_dofile( L, path );
diff --git a/src/main.c b/src/main.c
index 1dcac9c..95184cf 100644
--- a/src/main.c
+++ b/src/main.c
@@ -20,7 +20,7 @@ inline static void printVersion() {
}
int main( int argn, const char** argc ) {
- char exePath[ STRING_LEN ] = { '\0' };
+ char basePath[ STRING_LEN ] = { '\0' };
bool interpret_mode = false;
if ( 1 < argn ) {
@@ -36,15 +36,16 @@ int main( int argn, const char** argc ) {
interpret_mode = true;
if ( 2 < argn ) {
- sprintf( exePath, "%s/%s", GetWorkingDirectory(), argc[2] );
+ sprintf( basePath, "%s/%s", GetWorkingDirectory(), argc[2] );
}
}
else{
- sprintf( exePath, "%s/%s", GetWorkingDirectory(), argc[1] );
+ sprintf( basePath, "%s/%s", GetWorkingDirectory(), argc[1] );
}
}
+ /* If no argument given, assume main.lua is in exe directory. */
else {
- sprintf( exePath, "%s/", GetWorkingDirectory() );
+ sprintf( basePath, "%s", GetApplicationDirectory() );
}
if ( interpret_mode ) {
@@ -54,7 +55,7 @@ int main( int argn, const char** argc ) {
lua_pushcfunction( L, luaTraceback );
int tracebackidx = lua_gettop( L );
- luaL_loadfile( L, exePath );
+ luaL_loadfile( L, basePath );
if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) {
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
@@ -63,7 +64,7 @@ int main( int argn, const char** argc ) {
}
else {
printVersion();
- stateInit( argn, argc, exePath );
+ stateInit( argn, argc, basePath );
state->run = luaCallMain();
while ( state->run ) {
diff --git a/src/state.c b/src/state.c
index ea737d4..52742e5 100644
--- a/src/state.c
+++ b/src/state.c
@@ -6,11 +6,11 @@
State* state;
-bool stateInit( int argn, const char** argc, const char* exePath ) {
+bool stateInit( int argn, const char** argc, const char* basePath ) {
state = malloc( sizeof( State ) );
- state->exePath = malloc( STRING_LEN * sizeof( char ) );
- strncpy( state->exePath, exePath, STRING_LEN - 1 );
+ state->basePath = malloc( STRING_LEN * sizeof( char ) );
+ strncpy( state->basePath, basePath, STRING_LEN - 1 );
state->hasWindow = true;
state->run = true;
@@ -65,7 +65,7 @@ void stateFree() {
#ifdef PLATFORM_DESKTOP_SDL
free( state->SDL_eventQueue );
#endif
- free( state->exePath );
+ free( state->basePath );
free( state->RLGLcurrentShaderLocs );
free( state );
}