From 05cf30845c73b4ec9069d7f766b4616572d6f6de Mon Sep 17 00:00:00 2001 From: bitplane Date: Thu, 23 Aug 2007 11:56:54 +0000 Subject: [PATCH] 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-e03cc46cb475 --- source/Irrlicht/COpenGLDriver.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index ecd88319..9d699d96 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -1507,13 +1507,22 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh GLfloat glmat[16]; core::matrix4 m; + + glMatrixMode(GL_PROJECTION); + + const core::dimension2d& 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); // in render targets, flip the screen if ( CurrentRendertargetSize.Width != 0 ) { 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) { glFrontFace(GL_CCW); @@ -1528,15 +1537,13 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh ClockwiseWinding = true; } } - glMatrixMode(GL_PROJECTION); + glLoadMatrixf(glmat); + glTranslatef (0.375, 0.375, 0.0); + glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - // see http://www.opengl.org/resources/faq/technical/transformations.htm#tran0030 - const core::dimension2d& renderTargetSize = getCurrentRenderTargetSize(); - gluOrtho2D(0, renderTargetSize.Width, renderTargetSize.Height, 0); - glTranslatef (0.375, 0.375, 0.); glMatrixMode(GL_TEXTURE); glLoadIdentity(); @@ -2420,3 +2427,4 @@ IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, #endif // _IRR_COMPILE_WITH_OPENGL_ +