Browse Source

Reverted the OpenGL viewport reset logic.

Lasse Öörni 14 years ago
parent
commit
d892a120e7
2 changed files with 5 additions and 11 deletions
  1. 1 1
      Docs/Reference.dox
  2. 4 10
      Engine/Graphics/OpenGL/OGLGraphics.cpp

+ 1 - 1
Docs/Reference.dox

@@ -481,7 +481,7 @@ Finally note that due to OpenGL framebuffer object limitations an extra framebuf
 
 - On Direct3D9 the depth-stencil surface can be equal or larger in size than the color rendertarget. On OpenGL the sizes must always match. Furthermore, OpenGL can not use the backbuffer depth-stencil surface when rendering to a texture. To overcome these limitations, Graphics will create correctly sized depth-stencil surfaces on demand whenever a texture is set as a color rendertarget, and a null depth-stencil is specified.
 
-- On Direct3D9 setting the first color rendertarget resets the viewport dimensions. On OpenGL there is no such mechanism, but it is emulated by Graphics. However, as sometimes (for example in OpenGL shadow rendering) only a depth-stencil texture will be used for rendering, it is best to set the viewport manually, in the following sequence: first set the rendertargets, then the depth-stencil surface, and finally the viewport, if you need it to be less than the whole rendertarget.
+- On Direct3D9 setting the first color rendertarget resets the viewport dimensions. On OpenGL there is no such mechanism. However, as sometimes (for example in OpenGL shadow rendering) only a depth-stencil texture will be used for rendering, in OpenGL mode Graphics instead resets the viewport when the depth-stencil is set. The following sequence will produce reliable results on both APIs: first set the rendertargets, then the depth-stencil surface, and finally the viewport, if you need it to be less than the whole rendertarget.
 
 - On OpenGL modifying a texture will cause it to be momentarily set on the first texture unit. If another texture was set there, the assignment will be lost. Graphics performs a check to not assign textures redundantly, so it is safe and recommended to always set all needed textures before rendering.
 

+ 4 - 10
Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -1207,16 +1207,6 @@ void Graphics::SetRenderTarget(unsigned index, RenderSurface* renderTarget)
             impl_->fboBound_ = false;
         }
     }
-    
-    // Emulate Direct3D behaviour and reset the viewport when the first rendertarget is set
-    if (!index)
-    {
-        IntVector2 viewSize = GetRenderTargetDimensions();
-        SetViewport(IntRect(0, 0, viewSize.x_, viewSize.y_));
-        
-        // Disable scissor test, needs to be re-enabled by the user
-        SetScissorTest(false);
-    }
 }
 
 void Graphics::SetRenderTarget(unsigned index, Texture2D* texture)
@@ -1329,6 +1319,10 @@ void Graphics::SetDepthStencil(RenderSurface* depthStencil)
             impl_->fboBound_ = false;
         }
     }
+    
+    // Reset viewport to default when the depth-stencil changes
+    IntVector2 viewSize = GetRenderTargetDimensions();
+    SetViewport(IntRect(0, 0, viewSize.x_, viewSize.y_));
 }
 
 void Graphics::SetDepthStencil(Texture2D* texture)