Mercurial > LightClone
diff LightClone/Source/GuiImage.cpp @ 21:b4dc5d674e22
Added GUI event system and some support data structures
author | koryspansel |
---|---|
date | Thu, 15 Sep 2011 18:42:12 -0700 |
parents | 33cb6979ac51 |
children | a785b0aaf004 |
line wrap: on
line diff
--- a/LightClone/Source/GuiImage.cpp Thu Sep 15 13:28:10 2011 -0700 +++ b/LightClone/Source/GuiImage.cpp Thu Sep 15 18:42:12 2011 -0700 @@ -79,10 +79,6 @@ kContext.ApplyCameraToEffect(kCamera, pEffect); - pEffect->SetTechnique(pEffect->GetTechnique(0)); - pEffect->Begin(&nPasses, 0); - pEffect->BeginPass(0); - D3DXMATRIX kScale; D3DXMatrixScaling(&kScale, kDimensions.x, kDimensions.y, 1.0f); @@ -95,7 +91,10 @@ pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix); pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector); pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pTexture); - pEffect->CommitChanges(); + + pEffect->SetTechnique(pEffect->GetTechnique(0)); + pEffect->Begin(&nPasses, 0); + pEffect->BeginPass(0); kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace); @@ -107,7 +106,7 @@ /* * SetTexture */ -ErrorCode GuiImage::SetTexture(const char* pName) +ErrorCode GuiImage::SetTexture(const char* pName, bool bResize) { if(pTexture) { @@ -115,7 +114,20 @@ pTexture = NULL; } - return pResourceManager->CreateTextureFromFile(pName, &pTexture); + ErrorCode eCode = pResourceManager->CreateTextureFromFile(pName, &pTexture); + if(eCode == Error_Success) + { + if(bResize) + { + D3DSURFACE_DESC kDescriptor; + pTexture->GetLevelDesc(0, &kDescriptor); + + kDimensions.x = (float)kDescriptor.Width; + kDimensions.y = (float)kDescriptor.Height; + } + } + + return eCode; } /*