check screen state

This commit is contained in:
Jupeyy 2018-03-21 15:41:45 +01:00
parent 91b1699994
commit 9b8da90151

View file

@ -616,19 +616,25 @@ void CCommandProcessorFragment_OpenGL3_3::SetState(const CCommandBuffer::SState
}
}
// screen mapping
//orthographic projection matrix
//if we use the same z coordinate for every vertex, we can just ignore the z coordinate and set it in the shaders
float m[2*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
};
//transpose bcs of column-major order of opengl
glUniformMatrix4x2fv(pProgram->m_LocPos, 1, true, (float*)&m);
if(pProgram->m_LastScreen[0] != State.m_ScreenTL.x || pProgram->m_LastScreen[1] != State.m_ScreenTL.y || pProgram->m_LastScreen[2] != State.m_ScreenBR.x || pProgram->m_LastScreen[3] != State.m_ScreenBR.y)
{
pProgram->m_LastScreen[0] = State.m_ScreenTL.x;
pProgram->m_LastScreen[1] = State.m_ScreenTL.y;
pProgram->m_LastScreen[2] = State.m_ScreenBR.x;
pProgram->m_LastScreen[3] = State.m_ScreenBR.y;
// screen mapping
// orthographic projection matrix
// the z coordinate is the same for every vertex, so just ignore the z coordinate and set it in the shaders
float m[2 * 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
};
// transpose bcs of column-major order of opengl
glUniformMatrix4x2fv(pProgram->m_LocPos, 1, true, (float*)&m);
}
}
void CCommandProcessorFragment_OpenGL3_3::UseProgram(CGLSLTWProgram *pProgram)