From f2820ea39251faaa5d9c6f0f2553fd1084f2c6eb Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Thu, 14 Sep 2017 19:47:04 +0200 Subject: [PATCH] use 4*4 array instead of declearing a full matrix class --- src/engine/client/backend_sdl.cpp | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index b3b1cb7df..481d8d6df 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -552,29 +552,15 @@ void CCommandProcessorFragment_OpenGL3_3::SetState(const CCommandBuffer::SState } // screen mapping - //ortho matrix... we only need this projection... just made all structs here.. - struct vec4{ - vec4() {} - vec4(float a, float b, float c, float d) : x(a), y(b), z(c), w(d) {} - vec4(vec4& v) : x(v.x), y(v.y), z(v.z), w(v.w) {} - float x; - float y; - float z; - float w; + //orthographic projection matrix + + float m[4*4] = { + 2.f/(State.m_ScreenBR.x - State.m_ScreenTL.x), 0, 0, -((State.m_ScreenBR.x + State.m_ScreenTL.x)/(State.m_ScreenBR.x - State.m_ScreenTL.x)), + 0, (2.f/(State.m_ScreenTL.y - State.m_ScreenBR.y)), 0, -((State.m_ScreenTL.y + State.m_ScreenBR.y)/(State.m_ScreenTL.y - State.m_ScreenBR.y)), + 0, 0, -(2.f/(9.f)), -((11.f)/(9.f)), + 0, 0, 0, 1.0f }; - struct mat4{ - mat4(vec4& r1, vec4& r2, vec4& r3, vec4& r4) { r[0] = r1; r[1] = r2; r[2] = r3; r[3] = r4; } - vec4 r[4]; - }; - - vec4 r1( (2.f/(State.m_ScreenBR.x - State.m_ScreenTL.x)), 0, 0, -((State.m_ScreenBR.x + State.m_ScreenTL.x)/(State.m_ScreenBR.x - State.m_ScreenTL.x))); - vec4 r2( 0, (2.f/(State.m_ScreenTL.y - State.m_ScreenBR.y)), 0, -((State.m_ScreenTL.y + State.m_ScreenBR.y)/(State.m_ScreenTL.y - State.m_ScreenBR.y))); - vec4 r3( 0, 0, -(2.f/(9.f)), -((11.f)/(9.f))); - vec4 r4( 0, 0, 0, 1.0f); - - mat4 m(r1,r2,r3,r4); - //transpose bcs of column-major order of opengl glUniformMatrix4fv(pProgram->m_LocPos, 1, true, (float*)&m); }