|
|
|
@ -111,21 +111,35 @@ initAssets(memory_arena* arena, |
|
|
|
RenderState* |
|
|
|
RenderState* |
|
|
|
initRenderState(memory_arena* arena) |
|
|
|
initRenderState(memory_arena* arena) |
|
|
|
{ |
|
|
|
{ |
|
|
|
RenderState* rs = ARENA_ALLOC(arena, RenderState, 1); |
|
|
|
RenderState* rs = UTIL_ALLOC(1, RenderState); |
|
|
|
|
|
|
|
|
|
|
|
if (rs) { |
|
|
|
if (rs) { |
|
|
|
rs->arena = arena; |
|
|
|
rs->arena = arena; |
|
|
|
rs->assets = initAssets(arena); |
|
|
|
rs->assets = initAssets(arena); |
|
|
|
rs->gl_ctx = initGLContext(arena); |
|
|
|
rs->gl_ctx = initGLContext(arena); |
|
|
|
rs->xforms = ARENA_ALLOC(arena, transforms, 1); |
|
|
|
rs->xforms = ARENA_ALLOC(arena, transforms, 1); |
|
|
|
rs->handles = ARENA_ALLOC(arena, SDLHandles, 1); |
|
|
|
//rs->handles = ARENA_ALLOC(arena, SDLHandles, 1);
|
|
|
|
|
|
|
|
rs->handles = UTIL_ALLOC(1, SDLHandles); |
|
|
|
rs->max_gl_meshes = 256; |
|
|
|
rs->max_gl_meshes = 256; |
|
|
|
|
|
|
|
// TODO: should have a different arena for gl_meshes, because these will
|
|
|
|
|
|
|
|
// be the most volatile objects
|
|
|
|
rs->gl_meshes = ARENA_ALLOC(arena, GLmesh, rs->max_gl_meshes); |
|
|
|
rs->gl_meshes = ARENA_ALLOC(arena, GLmesh, rs->max_gl_meshes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return rs; |
|
|
|
return rs; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
freeRenderState(RenderState*& rs) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (rs) { |
|
|
|
|
|
|
|
arenaFree(rs->arena); |
|
|
|
|
|
|
|
utilSafeFree(rs->handles); |
|
|
|
|
|
|
|
utilSafeFree(rs); |
|
|
|
|
|
|
|
rs = nullptr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool |
|
|
|
bool |
|
|
|
initGraphics(SDLHandles* handles) |
|
|
|
initGraphics(SDLHandles* handles) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -318,12 +332,12 @@ loop(RenderState* rs) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
quit(RenderState* rs) |
|
|
|
quit(RenderState*& rs) |
|
|
|
{ |
|
|
|
{ |
|
|
|
SDL_GL_DeleteContext(rs->handles->sdl_gl_ctx); |
|
|
|
SDL_GL_DeleteContext(rs->handles->sdl_gl_ctx); |
|
|
|
SDL_DestroyWindow(rs->handles->window); |
|
|
|
SDL_DestroyWindow(rs->handles->window); |
|
|
|
SDL_Quit(); |
|
|
|
SDL_Quit(); |
|
|
|
std::free(rs->arena); |
|
|
|
freeRenderState(rs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int |
|
|
|
int |
|
|
|
|