Add state data buffer to hold generic configs

Add some system that allows us to automatically define and allocate different
application states at runtime without having to manually make the entries into
our game state structure.

It's basically an array of pointers determined by the app states defined in the
appstate enum. This is necessary since different modes, (start menu, options,
game world) have different data and we'd like to be able to define them
uniquely.
This commit is contained in:
2016-11-28 17:47:15 +11:00
parent 15b4ff59f7
commit aeeef1a60f
4 changed files with 139 additions and 51 deletions
+8 -2
View File
@@ -206,7 +206,7 @@ i32 main(void)
glfwPollEvents();
/* Rendering commands here*/
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
asteroid_gameUpdateAndRender(gameState, &memory, windowSize,
@@ -236,10 +236,16 @@ i32 main(void)
f32 msPerFrame = secondsElapsed * 1000.0f;
f32 framesPerSecond = 1.0f / secondsElapsed;
i32 entityCount = 0;
GameWorldState *world =
ASTEROID_GET_STATE_DATA(gameState, GameWorldState);
if (world) entityCount = world->entityIndex;
char textBuffer[256];
snprintf(textBuffer, ARRAY_COUNT(textBuffer),
"Dengine | %f ms/f | %f fps | Entity Count: %d",
msPerFrame, framesPerSecond, gameState->world.entityIndex);
msPerFrame, framesPerSecond, entityCount);
glfwSetWindowTitle(window, textBuffer);
titleUpdateFrequencyInSeconds = 0.5f;