Browse Source

Fixed UI not being rendered correctly if multiple 3D viewports active.

Lasse Öörni 14 years ago
parent
commit
e4ab3b3b1f
2 changed files with 11 additions and 8 deletions
  1. 0 1
      Engine/Graphics/View.cpp
  2. 11 7
      Engine/UI/UI.cpp

+ 0 - 1
Engine/Graphics/View.cpp

@@ -1156,7 +1156,6 @@ void View::RenderBatchesLightPrepass()
     #ifdef USE_OPENGL
     graphics_->SetAlphaTest(false);
     graphics_->SetBlendMode(BLEND_REPLACE);
-    graphics_->SetColorWrite(true);
     graphics_->SetDepthTest(CMP_ALWAYS);
     graphics_->SetDepthWrite(true);
     graphics_->SetScissorTest(false);

+ 11 - 7
Engine/UI/UI.cpp

@@ -235,26 +235,26 @@ void UI::Render()
     
     if (!graphics_ || graphics_->IsDeviceLost() || !quads_.Size())
         return;
-    
+
     // Update quad geometry into the vertex buffer
     unsigned numVertices = quads_.Size() * 6;
     // Resize the vertex buffer if too small or much too large
     if (vertexBuffer_->GetVertexCount() < numVertices || vertexBuffer_->GetVertexCount() > numVertices * 2)
         vertexBuffer_->SetSize(numVertices, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1, true);
-    
+
     unsigned vertexSize = vertexBuffer_->GetVertexSize();
     void* lockedData = vertexBuffer_->Lock(0, numVertices, LOCK_DISCARD);
     if (!lockedData)
         return;
-    
+
     for (unsigned i = 0; i < batches_.Size(); ++i)
         batches_[i].UpdateGeometry(graphics_, ((unsigned char*)lockedData) + batches_[i].quadStart_ * vertexSize * 6);
-    
+
     vertexBuffer_->Unlock();
-    
+
     Vector2 scale(2.0f, -2.0f);
     Vector2 offset(-1.0f, 1.0f);
-    
+
     Matrix4 projection(Matrix4::IDENTITY);
     projection.m00_ = scale.x_;
     projection.m03_ = offset.x_;
@@ -263,7 +263,11 @@ void UI::Render()
     projection.m22_ = 1.0f;
     projection.m23_ = 0.0f;
     projection.m33_ = 1.0f;
-    
+
+    graphics_->ResetRenderTargets();
+    graphics_->ResetDepthStencil();
+    graphics_->SetViewport(IntRect(0, 0, graphics_->GetWidth(), graphics_->GetHeight()));
+       
     graphics_->ClearParameterSources();
     graphics_->ResetRenderTargets();
     graphics_->SetAlphaTest(false);