commit aff9783682f93a0318a151fd1052c67ca48c36a6
parent d13bfe83af471665b7b6d5533b3ae11226bd1ffc
Author: amin <dev@aminmesbah.com>
Date: Sat, 2 Jun 2018 06:37:34 +0000
Update projection matrix w/ framebuffer dimensions
This removes distortion when resizing the window.
FossilOrigin-Name: 0cf01bc21990aa20c9dc9735dfacec3037e99fdcb72ea7f8adf2f36175b1dbbf
Diffstat:
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/game.c b/src/game.c
@@ -46,6 +46,7 @@ void game_update_and_render(struct GameState *game_state, float dt, uint32_t scr
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
+ //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
m4 model = glmth_m4_init_id();
model = glmth_translate(model, glmth_v3_init(300.0f, 300.0f, 0.0f));
model = glmth_translate(model, glmth_v3_init(100.0f * cosf(dt), 100.0f * sinf(dt), 0.0f));
diff --git a/src/platform_linux.c b/src/platform_linux.c
@@ -73,6 +73,10 @@ int main(void)
lag += elapsed_ms;
//printf("%" PRIu64 ", %" PRIu64 ", %f\n", elapsed_ms, lag, PLATFORM_MS_PER_UPDATE);
+ int32_t framebuffer_width = PLATFORM_SCR_WIDTH;
+ int32_t framebuffer_height = PLATFORM_SCR_HEIGHT;
+ glfwGetFramebufferSize(window, &framebuffer_width, &framebuffer_height);
+
#ifdef PLATFORM_HOTLOAD_GAME_CODE
time_t last_write_time = file_get_modified_time(PLATFORM_GAME_LIB_PATH);
bool game_code_has_changed = last_write_time && (last_write_time != game_code.last_write_time);
@@ -85,9 +89,9 @@ int main(void)
// TODO: fall back to backup?
}
}
- game_code.game_update_and_render(&game_state, lag/PLATFORM_SECOND, PLATFORM_SCR_WIDTH, PLATFORM_SCR_HEIGHT);
+ game_code.game_update_and_render(&game_state, lag/PLATFORM_SECOND, framebuffer_width, framebuffer_height);
#else
- game_update_and_render(&game_state, lag/PLATFORM_SECOND, PLATFORM_SCR_WIDTH, PLATFORM_SCR_HEIGHT);
+ game_update_and_render(&game_state, lag/PLATFORM_SECOND, framebuffer_width, framebuffer_height);
#endif // PLATFORM_HOTLOAD_GAME_CODE
glfwSwapBuffers(window);