a-game

2D platformer written from scratch.
git clone git://git.amin.space/a-game.git
Log | Files | Refs | README | LICENSE

commit 425d408dbde1fde763da8862cc63b0b9db8b6479
parent 843edf7a9bda9c35713fbaa146fb6fe4cbe0dc7d
Author: amin <dev@aminmesbah.com>
Date:   Wed, 26 Feb 2020 05:30:25 +0000

Remove OpenGL calls from game update func

FossilOrigin-Name: 8550c743f4c3f60260c407cbb68a48e4350efe130d5183202fcc077f7d921f85
Diffstat:
Msrc/game.c | 11+----------
Msrc/render.c | 11++++++++++-
2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/game.c b/src/game.c @@ -220,15 +220,6 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga game_state->renderer.projection = math_projection_ortho(0.0f, framebuffer.width, 0.0f, framebuffer.height, -1.0f, 0.0f); } - glViewport(0, 0, framebuffer.width, framebuffer.height); - glEnable(GL_SCISSOR_TEST); - glScissor( - viewport.min.x, - viewport.min.y, - viewport.max.x - viewport.min.x, - viewport.max.y - viewport.min.y); - - v2i current_room_i = game_state->player.pos.room; struct Room *current_room = world_room_get(game_state->world, current_room_i); @@ -703,7 +694,7 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga } renderer_jobs_sort(&game_state->renderer, &game_state->world_allocator); - renderer_jobs_draw(&game_state->renderer); + renderer_jobs_draw(&game_state->renderer, framebuffer, viewport); } internal void game_cleanup(struct GameMemory *game_memory) diff --git a/src/render.c b/src/render.c @@ -130,13 +130,22 @@ internal void renderer_init(struct RendererState *renderer, struct Image *images glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } -internal void renderer_jobs_draw(struct RendererState *renderer) +internal void renderer_jobs_draw(struct RendererState *renderer, v2u framebuffer, rect viewport) { + glViewport(0, 0, framebuffer.width, framebuffer.height); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glDisable(GL_SCISSOR_TEST); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_SCISSOR_TEST); + v2 viewport_dim = math_v2_s(viewport.max, viewport.min); + glScissor( + viewport.min.x, + viewport.min.y, + viewport_dim.x, + viewport_dim.y); + #if 0 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); #else