This commit is contained in:
2024-04-11 11:04:37 +02:00
7 changed files with 174 additions and 149 deletions

View File

@@ -9,6 +9,8 @@ ShaderManagerClass::ShaderManagerClass()
m_AlphaMapShader = 0;
m_SpecMapShader = 0;
m_TransparentShader = 0;
m_LightShader = 0;
m_LightMapShader = 0;
}
@@ -88,7 +90,7 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
return false;
}
// Create and initialize the specular map shader object.
// Create and initialize the transparent shader object.
m_TransparentShader = new TransparentShaderClass;
result = m_TransparentShader->Initialize(device, hwnd);
@@ -99,6 +101,23 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
}
logger.Log("ShaderManagerClass initialized", __FILE__, __LINE__);
// Create and initialize the light shader object.
m_LightShader = new LightShaderClass;
result = m_LightShader->Initialize(device, hwnd);
if (!result)
{
return false;
}
// Create and initialize the light map shader object.
m_LightMapShader = new LightMapShaderClass;
result = m_LightMapShader->Initialize(device, hwnd);
if (!result)
{
return false;
}
return true;
}
@@ -164,6 +183,21 @@ void ShaderManagerClass::Shutdown()
}
logger.Log("ShaderManagerClass shut down", __FILE__, __LINE__);
// Release the light shader object.
if (m_LightShader)
{
m_LightShader->Shutdown();
delete m_LightShader;
m_LightShader = 0;
}
// Release the light map shader object.
if (m_LightMapShader)
{
m_LightMapShader->Shutdown();
delete m_LightMapShader;
m_LightMapShader = 0;
}
return;
@@ -280,5 +314,35 @@ bool ShaderManagerClass::RenderTransparentShader(ID3D11DeviceContext* deviceCont
return false;
}
return true;
}
bool ShaderManagerClass::RenderlightShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor[], XMFLOAT4 lightPosition[])
{
bool result;
result = m_LightShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, lightPosition);
if (!result)
{
return false;
}
return true;
}
bool ShaderManagerClass::RenderlightMapShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix,
XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture1, ID3D11ShaderResourceView* texture2)
{
bool result;
result = m_LightMapShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
return false;
}
return true;
}