Use GetApplicationDirectory instead of GetWorkingDirectory for basePath if no path argument given.
This commit is contained in:
6
API.md
6
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
|
||||
|
||||
---
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
4
src/gl.c
4
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
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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 );
|
||||
|
||||
13
src/main.c
13
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 ) {
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user