From 4c27922ab711b403d0a6b8bfae415f75268a5616 Mon Sep 17 00:00:00 2001 From: Themaister Date: Mon, 24 Dec 2012 00:21:42 +0100 Subject: [PATCH] Don't rotate overlay if game is rotated. --- gfx/gl.c | 10 +++++----- gfx/gl_common.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gfx/gl.c b/gfx/gl.c index 3233e46fad..49b05d5d6c 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -617,18 +617,18 @@ void gl_set_projection(gl_t *gl, struct gl_ortho *ortho, bool allow_rotate) #endif // Calculate projection. - math_matrix proj; - matrix_ortho(&proj, ortho->left, ortho->right, + matrix_ortho(&gl->mvp_no_rot, ortho->left, ortho->right, ortho->bottom, ortho->top, ortho->znear, ortho->zfar); if (allow_rotate) { math_matrix rot; matrix_rotate_z(&rot, M_PI * gl->rotation / 180.0f); - matrix_multiply(&proj, &rot, &proj); + matrix_multiply(&gl->mvp, &rot, &gl->mvp_no_rot); } + else + gl->mvp = gl->mvp_no_rot; - gl->mvp = proj; gl_shader_set_coords_func(gl, &gl->coords, &gl->mvp); } @@ -1865,7 +1865,7 @@ static void gl_render_overlay(gl_t *gl) glEnable(GL_BLEND); gl->coords.vertex = gl->overlay_vertex_coord; gl->coords.tex_coord = gl->overlay_tex_coord; - gl_shader_set_coords_func(gl, &gl->coords, &gl->mvp); + gl_shader_set_coords_func(gl, &gl->coords, &gl->mvp_no_rot); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisable(GL_BLEND); diff --git a/gfx/gl_common.h b/gfx/gl_common.h index ca672c01d7..8d93f1b1e7 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -255,7 +255,7 @@ typedef struct gl unsigned last_height[TEXTURES]; unsigned tex_w, tex_h; GLfloat tex_coords[8]; - math_matrix mvp; + math_matrix mvp, mvp_no_rot; struct gl_coords coords;