summaryrefslogtreecommitdiff
path: root/src/state.c
diff options
context:
space:
mode:
authorjussi2023-10-29 13:21:42 +0200
committerjussi2023-10-29 13:21:42 +0200
commit76911d45a879838047b2845cd6124e9ca3af083a (patch)
tree2ff82956451818faaa8956fa2af543fc32646a03 /src/state.c
parentfd49d806cf1f54fb86c3ed7b9db499f473a3ef1d (diff)
downloadreilua-enhanced-76911d45a879838047b2845cd6124e9ca3af083a.tar.gz
reilua-enhanced-76911d45a879838047b2845cd6124e9ca3af083a.tar.bz2
reilua-enhanced-76911d45a879838047b2845cd6124e9ca3af083a.zip
New object types for all types.
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/state.c b/src/state.c
index b6de876..6102a2d 100644
--- a/src/state.c
+++ b/src/state.c
@@ -17,37 +17,8 @@ bool stateInit( int argn, const char **argc, const char *exePath ) {
state->resolution = (Vector2){ 800, 600 };
state->luaState = NULL;
state->logLevelInvalid = LOG_ERROR;
- /* Meshes. */
- state->meshAlloc = ALLOC_PAGE_SIZE;
- state->meshCount = 0;
- state->meshes = malloc( state->meshAlloc * sizeof( Mesh* ) );
- /* Materials. */
- state->materialAlloc = ALLOC_PAGE_SIZE;
- state->materialCount = 1;
- state->materials = malloc( state->materialAlloc * sizeof( Material* ) );
- /* Models. */
- state->modelAlloc = ALLOC_PAGE_SIZE;
- state->modelCount = 0;
- state->models = malloc( state->modelAlloc * sizeof( Model* ) );
- /* ModelsAnimations. */
- state->animationAlloc = ALLOC_PAGE_SIZE;
- state->animationCount = 0;
- state->animations = malloc( state->animationAlloc * sizeof( ModelAnimations* ) );
- for ( int i = 0; i < ALLOC_PAGE_SIZE; i++ ) {
- state->meshes[i] = NULL;
- state->models[i] = NULL;
- state->animations[i] = NULL;
-
- /* The ones we want to save the first. */
- if ( 0 < i ) {
- state->materials[i] = NULL;
- }
- }
InitWindow( state->resolution.x, state->resolution.y, "ReiLua" );
- /* Has to be after InitWindod where opengl context is created. */
- state->materials[0] = malloc( sizeof( Material ) );
- *state->materials[0] = LoadMaterialDefault();
if ( !IsWindowReady() ) {
state->hasWindow = false;
@@ -67,36 +38,6 @@ void stateInitInterpret( int argn, const char **argc ) {
}
void stateFree() {
- for ( int i = 0; i < state->modelCount; ++i ) {
- if ( state->models[i] != NULL ) {
- //TODO Test if UnloadModel causes segfaults on exit.
- UnloadModelKeepMeshes( *state->models[i] );
- // UnloadModel( *state->models[i] );
- free( state->models[i] );
- }
- }
- for ( int i = 0; i < state->meshCount; ++i ) {
- if ( state->meshes[i] != NULL ) {
- UnloadMesh( *state->meshes[i] );
- free( state->meshes[i] );
- }
- }
- for ( int i = 0; i < state->materialCount; ++i ) {
- if ( state->materials[i] != NULL ) {
- /* Prevent unloading shader that would result in double free when freeing shaders. */
- state->materials[i]->shader.id = rlGetShaderIdDefault();
-
- UnloadMaterial( *state->materials[i] );
- free( state->materials[i] );
- }
- }
- for ( int i = 0; i < state->animationCount; ++i ) {
- if ( state->animations[i] != NULL ) {
- UnloadModelAnimations( state->animations[i]->animations, state->animations[i]->animCount );
- free( state->animations[i] );
- }
- }
-
if ( IsAudioDeviceReady() ) {
CloseAudioDevice();
}
@@ -107,10 +48,6 @@ void stateFree() {
if ( state->hasWindow ) {
CloseWindow();
}
- free( state->meshes );
- free( state->materials );
- free( state->models );
- free( state->animations );
free( state->exePath );
free( state );
}