Light à reparer

This commit is contained in:
GolfOcean334 2024-04-05 15:39:00 +02:00
parent 15087d22c5
commit 38242fc60b
2 changed files with 67 additions and 1 deletions

View File

@ -85,7 +85,25 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
m_Camera->Render();
m_Camera->GetViewMatrix(m_baseViewMatrix);
// Create and initialize the specular map shader object.
m_SpecMapShader = new SpecMapShaderClass;
result = m_SpecMapShader->Initialize(m_Direct3D->GetDevice(), hwnd);
if (!result)
{
MessageBox(hwnd, L"Could not initialize the specular map shader object.", L"Error", MB_OK);
return false;
}
// Create and initialize the normal map shader object.
m_NormalMapShader = new NormalMapShaderClass;
result = m_NormalMapShader->Initialize(m_Direct3D->GetDevice(), hwnd);
if (!result)
{
MessageBox(hwnd, L"Could not initialize the normal map shader object.", L"Error", MB_OK);
return false;
}
// Create and initialize the font shader object.
m_FontShader = new FontShaderClass;
@ -275,6 +293,25 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
m_Light->SetSpecularColor(1.0f, 1.0f, 1.0f, 1.0f);
m_Light->SetSpecularPower(16.0f);
// Set the number of lights we will use.
m_numLights = 4;
// Create and initialize the light objects array.
m_Lights = new LightClass[m_numLights];
// Manually set the color and position of each light.
m_Lights[0].SetDiffuseColor(1.0f, 0.0f, 0.0f, 1.0f); // Red
m_Lights[0].SetPosition(-3.0f, 1.0f, 3.0f);
m_Lights[1].SetDiffuseColor(0.0f, 1.0f, 0.0f, 1.0f); // Green
m_Lights[1].SetPosition(3.0f, 1.0f, 3.0f);
m_Lights[2].SetDiffuseColor(0.0f, 0.0f, 1.0f, 1.0f); // Blue
m_Lights[2].SetPosition(-3.0f, 1.0f, -3.0f);
m_Lights[3].SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f); // White
m_Lights[3].SetPosition(3.0f, 1.0f, -3.0f);
// Create and initialize the normal map shader object.
m_ShaderManager = new ShaderManagerClass;
@ -509,6 +546,13 @@ void ApplicationClass::Shutdown()
m_Sprite = 0;
}
// Release the light objects.
if (m_Lights)
{
delete[] m_Lights;
m_Lights = 0;
}
// Release the light object.
if (m_Light)
{
@ -524,6 +568,22 @@ void ApplicationClass::Shutdown()
m_LightShader = 0;
}
// Release the normal map shader object.
if (m_NormalMapShader)
{
m_NormalMapShader->Shutdown();
delete m_NormalMapShader;
m_NormalMapShader = 0;
}
// Release the specular map shader object.
if (m_SpecMapShader)
{
m_SpecMapShader->Shutdown();
delete m_SpecMapShader;
m_SpecMapShader = 0;
}
// Release the model object.
if (m_Model)
{

View File

@ -15,12 +15,15 @@
#include "alphamapshaderclass.h"
#include "bitmapclass.h"
#include "spriteclass.h"
#include "textureshaderclass.h"
#include "timerclass.h"
#include "fontshaderclass.h"
#include "fontclass.h"
#include "textclass.h"
#include "fpsclass.h"
#include "inputclass.h"
#include "normalmapshaderclass.h"
#include "specmapshaderclass.h"
#include "shadermanagerclass.h"
#include "modellistclass.h"
#include "positionclass.h"
@ -65,6 +68,7 @@ private:
CameraClass* m_Camera;
LightShaderClass* m_LightShader;
LightClass* m_Light;
LightClass* m_Lights;
LightMapShaderClass* m_LightMapShader;
MultiTextureShaderClass* m_MultiTextureShader;
AlphaMapShaderClass* m_AlphaMapShader;
@ -82,6 +86,8 @@ private:
FpsClass* m_Fps;
TextClass* m_FpsString;
int m_previousFps;
NormalMapShaderClass* m_NormalMapShader;
SpecMapShaderClass* m_SpecMapShader;
ShaderManagerClass* m_ShaderManager;
ModelListClass* m_ModelList;
PositionClass* m_Position;