Files
reilua-enhanced/include/state.h
Indrajith K L f185f2c31a Fix SEGV crash: Initialize window and font in stateInit()
- Move window initialization and font loading to stateInit()
- Window now opens before splash screens (required for rendering)
- Custom font loaded in stateInit for splash screen use
- Remove RL.config() call from luaCallMain() (window already initialized)
- Remove stateContextInit() call (initialization now done in stateInit)
- Add hasWindow, customFontLoaded, resolution fields to State
- Fix memory management for custom font in stateFree()

This matches the ReiLua-JamVersion architecture where the window
is opened early so splash screens can render properly.
2025-11-03 18:04:54 +05:30

57 lines
1.7 KiB
C

#pragma once
#if defined PLATFORM_DESKTOP_SDL2 || defined PLATFORM_DESKTOP_SDL3
#define PLATFORM_SDL_EVENT_QUEUE_LEN 128
#endif
typedef struct {
char* basePath;
bool run;
bool hasWindow;
bool gcUnload;
bool customFontLoaded;
Vector2 resolution;
int lineSpacing; /* We need to store copy here since raylib has it in static. */
Vector2 mouseOffset;
Vector2 mouseScale;
lua_State* luaState;
int logLevelInvalid;
Font defaultFont;
Font guiFont;
Material defaultMaterial;
Texture defaultTexture;
Texture shapesTexture;
int* RLGLcurrentShaderLocs;
/* Events. */
#ifdef PLATFORM_DESKTOP
/* Window events. */
GLFWwindowsizefun raylibWindowSizeCallback;
GLFWwindowmaximizefun raylibWindowMaximizeCallback;
GLFWwindowiconifyfun raylibWindowIconifyCallback;
GLFWwindowfocusfun raylibWindowFocusCallback;
GLFWdropfun raylibWindowDropCallback;
/* Input events. */
GLFWkeyfun raylibKeyCallback;
GLFWcharfun raylibCharCallback;
GLFWmousebuttonfun raylibMouseButtonCallback;
GLFWcursorposfun raylibMouseCursorPosCallback;
GLFWscrollfun raylibMouseScrollCallback;
GLFWcursorenterfun raylibCursorEnterCallback;
GLFWjoystickfun raylibJoystickCallback;
/* NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 */
GLFWpentabletdatafun glfwTabletDataCallback;
GLFWpentabletcursorfun glfwTabletCursorCallback;
GLFWpentabletproximityfun glfwTabletProximityCallback;
#elif defined PLATFORM_DESKTOP_SDL2 || defined PLATFORM_DESKTOP_SDL3
int SDL_eventQueueLen;
SDL_Event* SDL_eventQueue;
#endif
} State;
extern State* state;
bool stateInit( int argn, const char** argc, const char* basePath );
void stateContextInit();
void stateInitInterpret( int argn, const char** argc );
void stateFree();