Commit b43e4672 authored by bitplane's avatar bitplane

OpenGL render targets are now the same way up as in the other drivers. When...

OpenGL render targets are now the same way up as in the other drivers. When setting the projection matrix of a render target, the Y axis is flipped and polygon winding is switched to counter-clockwise.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@787 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 838ea264
Changes in version 1.4 (... 2007) Changes in version 1.4 (... 2007)
- OpenGL render targets now the same way up as the other drivers. If you have
written opengl shaders that use render targets then you'll need to change your
texture coordinates accordingly.
- Fixed some OpenGL renderstate stuff. setBasicRenderstate returns with - Fixed some OpenGL renderstate stuff. setBasicRenderstate returns with
active texture layer 0. The material renderer must return from OnUnset active texture layer 0. The material renderer must return from OnUnset
with the same active texture layer. The alpha test is disabled and the with the same active texture layer. The alpha test is disabled and the
......
...@@ -34,7 +34,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, HWND wind ...@@ -34,7 +34,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, HWND wind
: CNullDriver(io, screenSize), COpenGLExtensionHandler(), : CNullDriver(io, screenSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(antiAlias), RenderTargetTexture(0), LastSetLight(-1), AntiAlias(antiAlias), RenderTargetTexture(0), LastSetLight(-1),
CurrentRendertargetSize(0,0), CurrentRendertargetSize(0,0), ClockwiseWinding(true),
HDc(0), Window(window), HRc(0) HDc(0), Window(window), HRc(0)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -157,7 +157,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool full ...@@ -157,7 +157,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool full
: CNullDriver(io, screenSize), COpenGLExtensionHandler(), : CNullDriver(io, screenSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(antiAlias), AntiAlias(antiAlias),
RenderTargetTexture(0), LastSetLight(-1), LastSetLight(-1), RenderTargetTexture(0), ClockwiseWinding(true),
CurrentRendertargetSize(0,0), _device(device) CurrentRendertargetSize(0,0), _device(device)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -177,7 +177,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool full ...@@ -177,7 +177,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool full
: CNullDriver(io, screenSize), COpenGLExtensionHandler(), : CNullDriver(io, screenSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(antiAlias), AntiAlias(antiAlias),
RenderTargetTexture(0), LastSetLight(-1), LastSetLight(-1), RenderTargetTexture(0), ClockwiseWinding(true),
CurrentRendertargetSize(0,0) CurrentRendertargetSize(0,0)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -213,7 +213,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool full ...@@ -213,7 +213,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool full
: CNullDriver(io, screenSize), COpenGLExtensionHandler(), : CNullDriver(io, screenSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(antiAlias), AntiAlias(antiAlias),
RenderTargetTexture(0), LastSetLight(-1), LastSetLight(-1), RenderTargetTexture(0), ClockwiseWinding(true),
CurrentRendertargetSize(0,0) CurrentRendertargetSize(0,0)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -448,6 +448,25 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri ...@@ -448,6 +448,25 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
createGLMatrix(glmat, mat); createGLMatrix(glmat, mat);
// flip z to compensate OpenGLs right-hand coordinate system // flip z to compensate OpenGLs right-hand coordinate system
glmat[12] *= -1.0f; glmat[12] *= -1.0f;
// 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
if (ClockwiseWinding)
{
glFrontFace(GL_CCW);
ClockwiseWinding = false;
}
}
else
{
if (!ClockwiseWinding)
{
glFrontFace(GL_CW);
ClockwiseWinding = true;
}
}
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadMatrixf(glmat); glLoadMatrixf(glmat);
break; break;
......
...@@ -329,6 +329,9 @@ namespace video ...@@ -329,6 +329,9 @@ namespace video
s32 LastSetLight; s32 LastSetLight;
core::dimension2d<s32> CurrentRendertargetSize; core::dimension2d<s32> CurrentRendertargetSize;
//! bool to see if we are using clockwise or counter-clockwise winding,
//! render targets use opposite winding as their projection matrix is flipped.
bool ClockwiseWinding;
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_WINDOWS_API_
HDC HDc; // Private GDI Device Context HDC HDc; // Private GDI Device Context
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment