summaryrefslogtreecommitdiff
path: root/src/state.c
diff options
context:
space:
mode:
authorjussi2024-11-21 23:25:28 +0200
committerjussi2024-11-21 23:25:28 +0200
commitc9ebe23d6282e96b410dc7687e0be1c4f3ba1b4d (patch)
treedfd26a87fb2b2f702f77728b98a1e6c193684631 /src/state.c
parentd96e33bb1772c28f630de32e09201c0cdea6f896 (diff)
downloadreilua-enhanced-c9ebe23d6282e96b410dc7687e0be1c4f3ba1b4d.tar.gz
reilua-enhanced-c9ebe23d6282e96b410dc7687e0be1c4f3ba1b4d.tar.bz2
reilua-enhanced-c9ebe23d6282e96b410dc7687e0be1c4f3ba1b4d.zip
RL.config and InitWindow.
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/state.c b/src/state.c
index 9f3fb5a..fdfdbd0 100644
--- a/src/state.c
+++ b/src/state.c
@@ -8,46 +8,36 @@ State* state;
bool stateInit( int argn, const char** argc, const char* basePath ) {
state = malloc( sizeof( State ) );
-
state->basePath = malloc( STRING_LEN * sizeof( char ) );
strncpy( state->basePath, basePath, STRING_LEN - 1 );
-
- state->hasWindow = true;
- state->run = true;
- state->resolution = (Vector2){ 800, 600 };
state->luaState = NULL;
+ state->run = luaInit( argn, argc );;
state->logLevelInvalid = LOG_ERROR;
state->gcUnload = true;
state->lineSpacing = 15;
state->mouseOffset = (Vector2){ 0, 0 };
state->mouseScale = (Vector2){ 1, 1 };
- InitWindow( state->resolution.x, state->resolution.y, "ReiLua" );
+ return state->run;
+}
- if ( !IsWindowReady() ) {
- state->hasWindow = false;
- state->run = false;
- }
- if ( state->run ) {
- state->run = luaInit( argn, argc );
- }
+/* Init after InitWindow. (When there is OpenGL context.) */
+void stateContextInit() {
state->defaultFont = GetFontDefault();
state->guiFont = GuiGetFont();
state->defaultMaterial = LoadMaterialDefault();
state->defaultTexture = (Texture){ 1, 1, 1, 1, 7 };
state->shapesTexture = (Texture){ 1, 1, 1, 1, 7 };
state->RLGLcurrentShaderLocs = malloc( RL_MAX_SHADER_LOCATIONS * sizeof( int ) );
- int* defaultShaderLocs = rlGetShaderLocsDefault();
-
- for ( int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++ ) {
- state->RLGLcurrentShaderLocs[i] = defaultShaderLocs[i];
- }
#ifdef PLATFORM_DESKTOP_SDL
state->SDL_eventQueue = malloc( PLATFORM_SDL_EVENT_QUEUE_LEN * sizeof( SDL_Event ) );
state->SDL_eventQueueLen = 0;
#endif
+ int* defaultShaderLocs = rlGetShaderLocsDefault();
- return state->run;
+ for ( int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++ ) {
+ state->RLGLcurrentShaderLocs[i] = defaultShaderLocs[i];
+ }
}
void stateInitInterpret( int argn, const char** argc ) {
@@ -63,7 +53,7 @@ void stateFree() {
lua_close( state->luaState );
state->luaState = NULL;
}
- if ( state->hasWindow ) {
+ if ( IsWindowReady() ) {
CloseWindow();
}
#ifdef PLATFORM_DESKTOP_SDL