commit ee24c6a716587d7ae4eb9083ff6f0cf9eca8b62f
parent 217f7d5282cac448e9e932bc5ea83e347ce29ecc
Author: Amin Mesbah <dev@aminmesbah.com>
Date: Thu, 4 Jul 2019 13:35:26 -0700
Flip tex y coords and clean up view matrix
Diffstat:
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;