diff LightClone/Source/GuiImage.cpp @ 23:a785b0aaf004

More work on the Gui system
author koryspansel
date Thu, 15 Sep 2011 21:45:00 -0700
parents b4dc5d674e22
children 3a63df04f3c0
line wrap: on
line diff
--- a/LightClone/Source/GuiImage.cpp	Thu Sep 15 20:31:15 2011 -0700
+++ b/LightClone/Source/GuiImage.cpp	Thu Sep 15 21:45:00 2011 -0700
@@ -68,38 +68,45 @@
  */
 void GuiImage::Render(RenderContext& kContext, Camera& kCamera)
 {
-	if(pTexture)
+	if(bVisible)
 	{
-		uint32 nPasses = 0;
+		if(pTexture)
+		{
+			uint32 nPasses = 0;
 
-		const float fOffsetX = -0.5f * ScreenSizeX;
-		const float fOffsetY = +0.5f * ScreenSizeY;
+			const float fOffsetX = -0.5f * ScreenSizeX;
+			const float fOffsetY = +0.5f * ScreenSizeY;
 
-		const D3DXVECTOR4 kColorVector(1.0f, 1.0f, 1.0f, 1.0f);
+			const D3DXVECTOR4 kColorVector(1.0f, 1.0f, 1.0f, 1.0f);
+
+			kContext.ApplyCameraToEffect(kCamera, pEffect);
 
-		kContext.ApplyCameraToEffect(kCamera, pEffect);
+			D3DXMATRIX kScale;
+			D3DXMatrixScaling(&kScale, kDimensions.x, kDimensions.y, 1.0f);
 
-		D3DXMATRIX kScale;
-		D3DXMatrixScaling(&kScale, kDimensions.x, kDimensions.y, 1.0f);
+			const D3DXVECTOR2& kLocation = GetPosition();
 
-		D3DXMATRIX kTranslate;
-		D3DXMatrixTranslation(&kTranslate, fOffsetX + kPosition.x + 0.5f, fOffsetY - kPosition.y + 0.5f, 0.0f);
+			D3DXMATRIX kTranslate;
+			D3DXMatrixTranslation(&kTranslate, fOffsetX + kLocation.x + 0.5f, fOffsetY - kLocation.y + 0.5f, 0.0f);
 
-		D3DXMATRIX kWorldMatrix;
-		D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate);
+			D3DXMATRIX kWorldMatrix;
+			D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate);
+
+			pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix);
+			pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector);
+			pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pTexture);
 
-		pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix);
-		pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector);
-		pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pTexture);
+			pEffect->SetTechnique(pEffect->GetTechnique(0));
+			pEffect->Begin(&nPasses, 0);
+			pEffect->BeginPass(0);
+
+			kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace);
 
-		pEffect->SetTechnique(pEffect->GetTechnique(0));
-		pEffect->Begin(&nPasses, 0);
-		pEffect->BeginPass(0);
+			pEffect->EndPass();
+			pEffect->End();
+		}
 
-		kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace);
-
-		pEffect->EndPass();
-		pEffect->End();
+		GuiElement::Render(kContext, kCamera);
 	}
 }