Moved OpenGL 2D transform from the modelview matrix to the projection
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@859 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
b285054559
commit
05cf30845c
|
@ -1507,13 +1507,22 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
|
||||||
|
|
||||||
GLfloat glmat[16];
|
GLfloat glmat[16];
|
||||||
core::matrix4 m;
|
core::matrix4 m;
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
|
||||||
|
const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize();
|
||||||
|
const core::vector3df translation(-1,1,0);
|
||||||
|
|
||||||
|
m.buildProjectionMatrixOrthoLH(f32(renderTargetSize.Width), f32(-renderTargetSize.Height), -1.0, 1.0);
|
||||||
|
m.setTranslation(translation);
|
||||||
|
|
||||||
createGLMatrix(glmat, m);
|
createGLMatrix(glmat, m);
|
||||||
|
|
||||||
// in render targets, flip the screen
|
// in render targets, flip the screen
|
||||||
if ( CurrentRendertargetSize.Width != 0 )
|
if ( CurrentRendertargetSize.Width != 0 )
|
||||||
{
|
{
|
||||||
glmat[5] *= -1.0f;
|
glmat[5] *= -1.0f;
|
||||||
// because we flipped the screen, triangles are the wrong way around
|
// triangles are the wrong way around because we flipped the screen
|
||||||
if (ClockwiseWinding)
|
if (ClockwiseWinding)
|
||||||
{
|
{
|
||||||
glFrontFace(GL_CCW);
|
glFrontFace(GL_CCW);
|
||||||
|
@ -1528,15 +1537,13 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
|
||||||
ClockwiseWinding = true;
|
ClockwiseWinding = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadMatrixf(glmat);
|
glLoadMatrixf(glmat);
|
||||||
|
|
||||||
|
glTranslatef (0.375, 0.375, 0.0);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
// see http://www.opengl.org/resources/faq/technical/transformations.htm#tran0030
|
|
||||||
const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize();
|
|
||||||
gluOrtho2D(0, renderTargetSize.Width, renderTargetSize.Height, 0);
|
|
||||||
glTranslatef (0.375, 0.375, 0.);
|
|
||||||
|
|
||||||
glMatrixMode(GL_TEXTURE);
|
glMatrixMode(GL_TEXTURE);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -2420,3 +2427,4 @@ IVideoDriver* createOpenGLDriver(const core::dimension2d<s32>& screenSize,
|
||||||
|
|
||||||
#endif // _IRR_COMPILE_WITH_OPENGL_
|
#endif // _IRR_COMPILE_WITH_OPENGL_
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue