blob: 228cbce9bbf7d0c91f788e109c33d6578682c741 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#include "main.h"
#include "state.h"
#include "lua_core.h"
#include "textures.h"
#include "models.h"
State *state;
bool stateInit( int argn, const char **argc, const char *exePath ) {
state = malloc( sizeof( State ) );
state->exePath = malloc( STRING_LEN * sizeof( char ) );
strncpy( state->exePath, exePath, STRING_LEN - 1 );
state->hasWindow = true;
state->run = true;
state->resolution = (Vector2){ 800, 600 };
state->luaState = NULL;
state->logLevelInvalid = LOG_ERROR;
#ifdef GC_UNLOAD
state->gcUnload = true;
#else
state->gcUnload = false;
#endif
InitWindow( state->resolution.x, state->resolution.y, "ReiLua" );
if ( !IsWindowReady() ) {
state->hasWindow = false;
state->run = false;
}
if ( state->run ) {
InitAudioDevice();
state->run = luaInit( argn, argc );
}
state->defaultFont = GetFontDefault();
state->defaultMaterial = LoadMaterialDefault();
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];
}
return state->run;
}
void stateInitInterpret( int argn, const char **argc ) {
state = malloc( sizeof( State ) );
luaInit( argn, argc );
}
void stateFree() {
if ( IsAudioDeviceReady() ) {
CloseAudioDevice();
}
if ( state->luaState != NULL ) {
lua_close( state->luaState );
state->luaState = NULL;
}
if ( state->hasWindow ) {
CloseWindow();
}
free( state->exePath );
free( state->RLGLcurrentShaderLocs );
free( state );
}
|