a-game

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

commit 759b9e5046a8f2a9e6215d64510f66bcf4589034
parent df0c6303e21e671f55372b148d0d0753022f1cae
Author: amin <dev@aminmesbah.com>
Date:   Thu,  4 Jul 2019 20:37:37 +0000

Flip tex y coords and clean up view matrix

FossilOrigin-Name: e3c8026d38f2a2f0a145060fb30735b1bfe7fb63e24ab164e9681dfa5832fb9c
Diffstat:
Msrc/game.c | 7+------
Msrc/render.c | 12++++++------
2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/game.c b/src/game.c @@ -224,16 +224,11 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga viewport.max = math_v2_a(viewport.min, viewport_size); m4 view = math_m4_init_id(); - // World origin is in the lower left - //view = math_scale(view, (v3) {1.0f, -1.0f, 1.0f}); - view = math_translate(view, (v3) {0.0f, framebuffer.height, 0.0f}); - view = math_scale(view, (v3) {1.0f, -1.0f, 1.0f}); view = math_translate(view, (v3) {viewport.min.x, viewport.min.y, 0.0f}); view = math_scale(view, (v3) {ppm, ppm, 1.0f}); game_state->renderer.view = view; - // Screen origin is in the upper left - game_state->renderer.projection = math_projection_ortho(0.0f, framebuffer.width, framebuffer.height, 0.0f, -1.0f, 0.0f); + game_state->renderer.projection = math_projection_ortho(0.0f, framebuffer.width, 0.0f, framebuffer.height, -1.0f, 0.0f); } v2i current_room_i = game_state->player.pos.room; diff --git a/src/render.c b/src/render.c @@ -1,14 +1,14 @@ internal void renderer_init(struct RendererState *renderer, struct StackAllocator *allocator) { GLfloat quad_vertices[] = { - 0.5f, 0.5f, 1.0f, 1.0f, - 0.5f, -0.5f, 1.0f, 0.0f, - -0.5f, -0.5f, 0.0f, 0.0f, - -0.5f, 0.5f, 0.0f, 1.0f, + 0.5f, 0.5f, 1.0f, 0.0f, + 0.5f, -0.5f, 1.0f, 1.0f, + -0.5f, -0.5f, 0.0f, 1.0f, + -0.5f, 0.5f, 0.0f, 0.0f, }; - GLuint quad_elements[] = { 0, 1, 3, 1, 2, 3 }; - GLuint rect_elements[] = { 0, 1, 1, 2, 2, 3, 3, 0 }; + GLuint quad_elements[] = {0, 1, 3, 1, 2, 3}; + GLuint rect_elements[] = {0, 1, 1, 2, 2, 3, 3, 0}; GLuint vao; GLuint quad_vbo;