Minor patch - Log system + Exécutable fonctionnel
Feat : + Log systeme
This commit is contained in:
parent
05f12d15f9
commit
d644d6966d
@ -0,0 +1,4 @@
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
82
enginecustom/Logger.h
Normal file
82
enginecustom/Logger.h
Normal file
@ -0,0 +1,82 @@
|
||||
#pragma once
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
|
||||
enum class LogLevel
|
||||
{
|
||||
Info,
|
||||
Warning,
|
||||
Error
|
||||
};
|
||||
|
||||
Logger()
|
||||
{
|
||||
char* appdata = nullptr;
|
||||
size_t len;
|
||||
_dupenv_s(&appdata, &len, "APPDATA");
|
||||
if (appdata == 0 ||appdata == nullptr)
|
||||
{
|
||||
m_appdataPath = "log.log";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_appdataPath = appdata;
|
||||
}
|
||||
free(appdata);
|
||||
std::string directoryPath = m_appdataPath + "\\Khaotic Engine";
|
||||
CreateDirectoryA(directoryPath.c_str(), NULL);
|
||||
|
||||
m_logFilePath = directoryPath + "\\" + m_logFileName;
|
||||
}
|
||||
|
||||
void Log(const std::string& message, const std::string& fileName, int lineNumber, LogLevel level = LogLevel::Info)
|
||||
{
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto in_time_t = std::chrono::system_clock::to_time_t(now);
|
||||
|
||||
std::tm buf;
|
||||
localtime_s(&buf, &in_time_t);
|
||||
|
||||
std::string levelStr;
|
||||
switch (level)
|
||||
{
|
||||
case LogLevel::Error:
|
||||
levelStr = "ERROR";
|
||||
break;
|
||||
case LogLevel::Warning:
|
||||
levelStr = "WARNING";
|
||||
break;
|
||||
case LogLevel::Info:
|
||||
levelStr = "INFO";
|
||||
break;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "[" << std::put_time(&buf, "%Y-%m-%d") << "] "
|
||||
<< "[" << std::put_time(&buf, "%X") << "] "
|
||||
<< "[" << levelStr << "] "
|
||||
<< "[" << fileName << ":" << lineNumber << "] "
|
||||
<< message;
|
||||
|
||||
std::ofstream file(m_logFilePath, std::ios::app);
|
||||
if (file.is_open())
|
||||
{
|
||||
file << ss.str() << std::endl;
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_filename;
|
||||
std::string m_appdataPath;
|
||||
std::string m_logFileName = "enginecustom.log";
|
||||
std::string m_logFilePath;
|
||||
};
|
@ -5,6 +5,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline,
|
||||
{
|
||||
SystemClass* System;
|
||||
bool result;
|
||||
Logger logger;
|
||||
|
||||
|
||||
// Create the system object.
|
||||
@ -14,6 +15,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline,
|
||||
result = System->Initialize();
|
||||
if (result)
|
||||
{
|
||||
logger.Log("System initialized", __FILE__, __LINE__);
|
||||
System->Run();
|
||||
}
|
||||
|
||||
|
@ -4,18 +4,18 @@
|
||||
#include <windows.h>
|
||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
SystemClass::SystemClass()
|
||||
SystemClass::SystemClass() : logger()
|
||||
{
|
||||
m_Input = 0;
|
||||
m_Application = 0;
|
||||
m_imguiManager = 0;
|
||||
|
||||
}
|
||||
|
||||
SystemClass::SystemClass(const SystemClass& other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SystemClass::~SystemClass()
|
||||
{
|
||||
}
|
||||
@ -25,48 +25,63 @@ bool SystemClass::Initialize()
|
||||
int screenWidth, screenHeight;
|
||||
bool result;
|
||||
|
||||
logger.Log("Initializing system class", __FILE__, __LINE__);
|
||||
|
||||
// Initialize the width and height of the screen to zero before sending the variables into the function.
|
||||
screenWidth = 0;
|
||||
screenHeight = 0;
|
||||
|
||||
m_initialWindowWidth = 0;
|
||||
m_initialWindowHeight = 0;
|
||||
m_isDirect3DInitialized = false;
|
||||
|
||||
// Initialize the windows api.
|
||||
InitializeWindows(screenWidth, screenHeight);
|
||||
|
||||
// Create and initialize the input object. This object will be used to handle reading the keyboard input from the user.
|
||||
m_Input = new InputClass;
|
||||
|
||||
result = m_Input->Initialize(m_hinstance, m_hwnd, screenWidth, screenHeight);
|
||||
if (!result)
|
||||
try
|
||||
{
|
||||
// Initialize the width and height of the screen to zero before sending the variables into the function.
|
||||
screenWidth = 0;
|
||||
screenHeight = 0;
|
||||
|
||||
m_initialWindowWidth = 0;
|
||||
m_initialWindowHeight = 0;
|
||||
m_isDirect3DInitialized = false;
|
||||
|
||||
// Initialize the windows api.
|
||||
InitializeWindows(screenWidth, screenHeight);
|
||||
|
||||
// Create and initialize the input object. This object will be used to handle reading the keyboard input from the user.
|
||||
m_Input = new InputClass;
|
||||
|
||||
result = m_Input->Initialize(m_hinstance, m_hwnd, screenWidth, screenHeight);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to initialize input class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the application class object. This object will handle rendering all the graphics for this application.
|
||||
m_Application = new ApplicationClass;
|
||||
|
||||
result = m_Application->Initialize(screenWidth, screenHeight, m_hwnd);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_isDirect3DInitialized = true;
|
||||
|
||||
// If we received a WM_SIZE message before Direct3D was initialized, resize the swap chain now
|
||||
if (m_initialWindowWidth > 0 && m_initialWindowHeight > 0)
|
||||
{
|
||||
m_Application->GetDirect3D()->ResizeSwapChain(m_initialWindowWidth, m_initialWindowHeight);
|
||||
}
|
||||
|
||||
// Initialize imgui
|
||||
m_imguiManager = new imguiManager;
|
||||
result = m_imguiManager->Initialize(m_hwnd, m_Application->GetDirect3D()->GetDevice(), m_Application->GetDirect3D()->GetDeviceContext());
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
logger.Log(std::string("Exception caught during initialization: ") + e.what(), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the application class object. This object will handle rendering all the graphics for this application.
|
||||
m_Application = new ApplicationClass;
|
||||
|
||||
result = m_Application->Initialize(screenWidth, screenHeight, m_hwnd);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_isDirect3DInitialized = true;
|
||||
|
||||
// If we received a WM_SIZE message before Direct3D was initialized, resize the swap chain now
|
||||
if (m_initialWindowWidth > 0 && m_initialWindowHeight > 0)
|
||||
{
|
||||
m_Application->GetDirect3D()->ResizeSwapChain(m_initialWindowWidth, m_initialWindowHeight);
|
||||
}
|
||||
|
||||
// Initialize imgui
|
||||
m_imguiManager = new imguiManager;
|
||||
m_imguiManager->Initialize(m_hwnd, m_Application->GetDirect3D()->GetDevice(), m_Application->GetDirect3D()->GetDeviceContext());
|
||||
|
||||
logger.Log("System class initialized", __FILE__, __LINE__);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -107,6 +122,8 @@ void SystemClass::Run()
|
||||
MSG msg;
|
||||
bool done, result;
|
||||
|
||||
logger.Log("Running the system", __FILE__, __LINE__);
|
||||
|
||||
// Initialize the message structure.
|
||||
ZeroMemory(&msg, sizeof(MSG));
|
||||
|
||||
@ -124,6 +141,7 @@ void SystemClass::Run()
|
||||
// If windows signals to end the application then exit out.
|
||||
if (msg.message == WM_QUIT)
|
||||
{
|
||||
logger.Log("WM_QUIT message received", __FILE__, __LINE__);
|
||||
done = true;
|
||||
}
|
||||
else
|
||||
@ -132,6 +150,7 @@ void SystemClass::Run()
|
||||
result = Frame();
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to process frame", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
@ -149,6 +168,7 @@ bool SystemClass::Frame()
|
||||
result = m_Input->Frame();
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to process input frame", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -156,6 +176,7 @@ bool SystemClass::Frame()
|
||||
result = m_Application->Frame(m_Input);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to process application frame", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -263,7 +284,7 @@ void SystemClass::InitializeWindows(int& screenWidth, int& screenHeight)
|
||||
DEVMODE dmScreenSettings;
|
||||
int posX, posY;
|
||||
|
||||
|
||||
logger.Log("Initializing windows", __FILE__, __LINE__);
|
||||
// Get an external pointer to this object.
|
||||
ApplicationHandle = this;
|
||||
|
||||
@ -343,6 +364,8 @@ void SystemClass::InitializeWindows(int& screenWidth, int& screenHeight)
|
||||
|
||||
void SystemClass::ShutdownWindows()
|
||||
{
|
||||
|
||||
logger.Log("Shutting down the windows", __FILE__, __LINE__);
|
||||
// Show the mouse cursor.
|
||||
ShowCursor(true);
|
||||
|
||||
|
@ -38,296 +38,292 @@ ApplicationClass::~ApplicationClass()
|
||||
|
||||
bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
|
||||
{
|
||||
char mouseString1[32], mouseString2[32], mouseString3[32];
|
||||
char modelFilename[128], textureFilename1[128], textureFilename2[128], textureFilename3[128], textureFilename4[128], textureFilename5[128], textureFilename6[128], renderString[32];
|
||||
char bitmapFilename[128];
|
||||
char spriteFilename[128];
|
||||
char fpsString[32];
|
||||
bool result;
|
||||
|
||||
m_screenWidth = screenWidth;
|
||||
m_screenHeight = screenHeight;
|
||||
logger.Log("Initializing application class", __FILE__, __LINE__);
|
||||
|
||||
// Create the Direct3D object.
|
||||
m_Direct3D = new D3DClass;
|
||||
if (!m_Direct3D)
|
||||
try
|
||||
{
|
||||
char mouseString1[32], mouseString2[32], mouseString3[32];
|
||||
char modelFilename[128], textureFilename1[128], textureFilename2[128], textureFilename3[128], textureFilename4[128], textureFilename5[128], textureFilename6[128], renderString[32];
|
||||
char bitmapFilename[128];
|
||||
char spriteFilename[128];
|
||||
char fpsString[32];
|
||||
bool result;
|
||||
|
||||
m_screenWidth = screenWidth;
|
||||
m_screenHeight = screenHeight;
|
||||
|
||||
// Create the Direct3D object.
|
||||
m_Direct3D = new D3DClass;
|
||||
if (!m_Direct3D)
|
||||
{
|
||||
logger.Log("Could not create the Direct3D object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
result = m_Direct3D->Initialize(screenWidth, screenHeight, VSYNC_ENABLED, hwnd, FULL_SCREEN, SCREEN_DEPTH, SCREEN_NEAR);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize Direct3D", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the camera object.
|
||||
m_Camera = new CameraClass;
|
||||
if (!m_Camera)
|
||||
{
|
||||
logger.Log("Could not create the camera object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the initial position of the camera.
|
||||
m_Camera->SetPosition(0.0f, 0.0f, -12.0f);
|
||||
m_Camera->SetRotation(0.0f, 0.0f, 0.0f);
|
||||
m_Camera->Render();
|
||||
m_Camera->GetViewMatrix(m_baseViewMatrix);
|
||||
|
||||
// Create and initialize the font shader object.
|
||||
m_FontShader = new FontShaderClass;
|
||||
|
||||
result = m_FontShader->Initialize(m_Direct3D->GetDevice(), hwnd);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the font shader object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the font object.
|
||||
m_Font = new FontClass;
|
||||
|
||||
result = m_Font->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), 0);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the font object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the texture shader object.
|
||||
m_TextureShader = new TextureShaderClass;
|
||||
|
||||
result = m_TextureShader->Initialize(m_Direct3D->GetDevice(), hwnd);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the texture shader object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Create and initialize the render to texture object.
|
||||
m_RenderTexture = new RenderTextureClass;
|
||||
|
||||
result = m_RenderTexture->Initialize(m_Direct3D->GetDevice(), 256, 256, SCREEN_DEPTH, SCREEN_NEAR, 1);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the render texture object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the display plane object.
|
||||
m_DisplayPlane = new DisplayPlaneClass;
|
||||
|
||||
result = m_DisplayPlane->Initialize(m_Direct3D->GetDevice(), 1.0f, 1.0f);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the display plane object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Set the sprite info file we will be using.
|
||||
strcpy_s(spriteFilename, "sprite_data_01.txt");
|
||||
|
||||
// Create and initialize the sprite object.
|
||||
m_Sprite = new SpriteClass;
|
||||
|
||||
result = m_Sprite->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), screenWidth, screenHeight, spriteFilename, 50, 50);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the sprite object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the initial mouse strings.
|
||||
strcpy_s(mouseString1, "Mouse X: 0");
|
||||
strcpy_s(mouseString2, "Mouse Y: 0");
|
||||
strcpy_s(mouseString3, "Mouse Button: No");
|
||||
|
||||
// Create and initialize the text objects for the mouse strings.
|
||||
m_MouseStrings = new TextClass[3];
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
int y = 10 + (i * 25);
|
||||
result = m_MouseStrings[i].Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), screenWidth, screenHeight, 32, m_Font, mouseString1, 10, y, 1.0f, 1.0f, 1.0f);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the mouse strings", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the file name of the bitmap file.
|
||||
strcpy_s(bitmapFilename, "stone01.tga");
|
||||
|
||||
// Create and initialize the bitmap object.
|
||||
m_Bitmap = new BitmapClass;
|
||||
|
||||
result = m_Bitmap->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), screenWidth, screenHeight, bitmapFilename, 50, 50);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the bitmap object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the file name of the model.
|
||||
strcpy_s(modelFilename, "cube.txt");
|
||||
|
||||
// Set the file name of the textures.
|
||||
strcpy_s(textureFilename1, "stone01.tga");
|
||||
strcpy_s(textureFilename2, "normal01.tga");
|
||||
strcpy_s(textureFilename3, "spec02.tga");
|
||||
strcpy_s(textureFilename4, "alpha01.tga");
|
||||
strcpy_s(textureFilename5, "light01.tga");
|
||||
strcpy_s(textureFilename6, "moss01.tga");
|
||||
|
||||
// Create and initialize the model object.
|
||||
m_Model = new ModelClass;
|
||||
|
||||
result = m_Model->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textureFilename1, textureFilename2, textureFilename3, textureFilename4,
|
||||
textureFilename5, textureFilename6);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the model object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the light shader object.
|
||||
m_LightShader = new LightShaderClass;
|
||||
|
||||
result = m_LightShader->Initialize(m_Direct3D->GetDevice(), hwnd);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the light shader object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the light object.
|
||||
m_Light = new LightClass;
|
||||
|
||||
m_Light->SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_Light->SetDirection(0.0f, 0.0f, -1.0f);
|
||||
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.resize(m_numLights);
|
||||
|
||||
m_Lights[0] = new LightClass;
|
||||
m_Lights[0]->SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f); // White
|
||||
m_Lights[0]->SetDirection(0.0f, 0.0f, -1.0f);
|
||||
m_Lights[0]->SetSpecularColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_Lights[0]->SetSpecularPower(16.0f);
|
||||
m_Lights[0]->SetPosition(10.0f, 7.0f, -5.0f);
|
||||
|
||||
// Manually set the color and position of each light.
|
||||
m_Lights[1] = new LightClass;
|
||||
m_Lights[1]->SetDiffuseColor(1.0f, 0.0f, 0.0f, 1.0f); // Red
|
||||
m_Lights[1]->SetDirection(0.0f, 0.0f, 1.0f);
|
||||
m_Lights[1]->SetSpecularColor(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
m_Lights[1]->SetSpecularPower(16.0f);
|
||||
m_Lights[1]->SetPosition(10.0f, 7.0f, -5.0f);
|
||||
|
||||
m_Lights[2] = new LightClass;
|
||||
m_Lights[2]->SetDiffuseColor(0.0f, 1.0f, 0.0f, 1.0f); // Green
|
||||
m_Lights[2]->SetDirection(0.0f, 0.0f, 1.0f);
|
||||
m_Lights[2]->SetSpecularColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
m_Lights[2]->SetSpecularPower(16.0f);
|
||||
m_Lights[2]->SetPosition(10.0f, 7.0f, -5.0f);
|
||||
|
||||
m_Lights[3] = new LightClass;
|
||||
m_Lights[3]->SetDiffuseColor(0.0f, 0.0f, 1.0f, 1.0f); // Blue
|
||||
m_Lights[3]->SetDirection(0.0f, 0.0f, 1.0f);
|
||||
m_Lights[3]->SetSpecularColor(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
m_Lights[3]->SetSpecularPower(16.0f);
|
||||
m_Lights[3]->SetPosition(10.0f, 7.0f, -5.0f);
|
||||
|
||||
|
||||
// Create and initialize the normal map shader object.
|
||||
m_ShaderManager = new ShaderManagerClass;
|
||||
|
||||
result = m_ShaderManager->Initialize(m_Direct3D->GetDevice(), hwnd);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the shader manager object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the initial render count string.
|
||||
strcpy_s(renderString, "Render Count: 0");
|
||||
|
||||
// Create and initialize the text object for the render count string.
|
||||
m_RenderCountString = new TextClass;
|
||||
|
||||
result = m_RenderCountString->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), screenWidth, screenHeight, 32, m_Font, renderString, 10, 10, 1.0f, 1.0f, 1.0f);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the render count string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the model list object.
|
||||
m_ModelList = new ModelListClass;
|
||||
m_ModelList->Initialize(25);
|
||||
|
||||
// Create and initialize the timer object.
|
||||
m_Timer = new TimerClass;
|
||||
|
||||
result = m_Timer->Initialize();
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the timer object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the position class object.
|
||||
m_Position = new PositionClass;
|
||||
|
||||
// Create the frustum class object.
|
||||
m_Frustum = new FrustumClass;
|
||||
|
||||
// Create and initialize the fps object.
|
||||
m_Fps = new FpsClass();
|
||||
|
||||
m_Fps->Initialize();
|
||||
|
||||
// Set the initial fps and fps string.
|
||||
m_previousFps = -1;
|
||||
strcpy_s(fpsString, "Fps: 0");
|
||||
|
||||
// Create and initialize the text object for the fps string.
|
||||
m_FpsString = new TextClass;
|
||||
|
||||
result = m_FpsString->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), screenWidth, screenHeight, 32, m_Font, fpsString, 10, 10, 0.0f, 1.0f, 0.0f);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not initialize the fps string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
logger.Log(std::string("Exception caught during initialization: ") + e.what(), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
result = m_Direct3D->Initialize(screenWidth, screenHeight, VSYNC_ENABLED, hwnd, FULL_SCREEN, SCREEN_DEPTH, SCREEN_NEAR);
|
||||
if (!result)
|
||||
{
|
||||
MessageBox(hwnd, L"Could not initialize Direct3D.", L"Error", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the camera object.
|
||||
m_Camera = new CameraClass;
|
||||
if (!m_Camera)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the initial position of the camera.
|
||||
m_Camera->SetPosition(0.0f, 0.0f, -12.0f);
|
||||
m_Camera->SetRotation(0.0f, 0.0f, 0.0f);
|
||||
m_Camera->Render();
|
||||
m_Camera->GetViewMatrix(m_baseViewMatrix);
|
||||
|
||||
// Create and initialize the font shader object.
|
||||
m_FontShader = new FontShaderClass;
|
||||
|
||||
result = m_FontShader->Initialize(m_Direct3D->GetDevice(), hwnd);
|
||||
if (!result)
|
||||
{
|
||||
MessageBox(hwnd, L"Could not initialize the font shader object.", L"Error", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the font object.
|
||||
m_Font = new FontClass;
|
||||
|
||||
result = m_Font->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), 0);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the texture shader object.
|
||||
m_TextureShader = new TextureShaderClass;
|
||||
|
||||
result = m_TextureShader->Initialize(m_Direct3D->GetDevice(), hwnd);
|
||||
if (!result)
|
||||
{
|
||||
MessageBox(hwnd, L"Could not initialize the texture shader object.", L"Error", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Create and initialize the render to texture object.
|
||||
m_RenderTexture = new RenderTextureClass;
|
||||
|
||||
result = m_RenderTexture->Initialize(m_Direct3D->GetDevice(), 256, 256, SCREEN_DEPTH, SCREEN_NEAR, 1);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the display plane object.
|
||||
m_DisplayPlane = new DisplayPlaneClass;
|
||||
|
||||
result = m_DisplayPlane->Initialize(m_Direct3D->GetDevice(), 1.0f, 1.0f);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Set the sprite info file we will be using.
|
||||
strcpy_s(spriteFilename, "sprite_data_01.txt");
|
||||
|
||||
// Create and initialize the sprite object.
|
||||
m_Sprite = new SpriteClass;
|
||||
|
||||
result = m_Sprite->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), screenWidth, screenHeight, spriteFilename, 50, 50);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the initial mouse strings.
|
||||
strcpy_s(mouseString1, "Mouse X: 0");
|
||||
strcpy_s(mouseString2, "Mouse Y: 0");
|
||||
strcpy_s(mouseString3, "Mouse Button: No");
|
||||
|
||||
// Create and initialize the text objects for the mouse strings.
|
||||
m_MouseStrings = new TextClass[3];
|
||||
|
||||
result = m_MouseStrings[0].Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), screenWidth, screenHeight, 32, m_Font, mouseString1, 10, 10, 1.0f, 1.0f, 1.0f);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
result = m_MouseStrings[1].Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), screenWidth, screenHeight, 32, m_Font, mouseString1, 10, 35, 1.0f, 1.0f, 1.0f);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
result = m_MouseStrings[2].Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), screenWidth, screenHeight, 32, m_Font, mouseString1, 10, 60, 1.0f, 1.0f, 1.0f);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the file name of the bitmap file.
|
||||
strcpy_s(bitmapFilename, "stone01.tga");
|
||||
|
||||
// Create and initialize the bitmap object.
|
||||
m_Bitmap = new BitmapClass;
|
||||
|
||||
result = m_Bitmap->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), screenWidth, screenHeight, bitmapFilename, 50, 50);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the file name of the model.
|
||||
strcpy_s(modelFilename, "cube.txt");
|
||||
|
||||
// Set the file name of the textures.
|
||||
strcpy_s(textureFilename1, "stone01.tga");
|
||||
strcpy_s(textureFilename2, "normal01.tga");
|
||||
strcpy_s(textureFilename3, "spec02.tga");
|
||||
strcpy_s(textureFilename4, "alpha01.tga");
|
||||
strcpy_s(textureFilename5, "light01.tga");
|
||||
strcpy_s(textureFilename6, "moss01.tga");
|
||||
|
||||
// Create and initialize the model object.
|
||||
m_Model = new ModelClass;
|
||||
|
||||
result = m_Model->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textureFilename1, textureFilename2, textureFilename3, textureFilename4,
|
||||
textureFilename5, textureFilename6);
|
||||
if (!result)
|
||||
{
|
||||
MessageBox(hwnd, L"Could not initialize the model object.", L"Error", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the light shader object.
|
||||
m_LightShader = new LightShaderClass;
|
||||
|
||||
result = m_LightShader->Initialize(m_Direct3D->GetDevice(), hwnd);
|
||||
if (!result)
|
||||
{
|
||||
MessageBox(hwnd, L"Could not initialize the light shader object.", L"Error", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the light object.
|
||||
m_Light = new LightClass;
|
||||
|
||||
m_Light->SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_Light->SetDirection(0.0f, 0.0f, -1.0f);
|
||||
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.resize(m_numLights);
|
||||
|
||||
m_Lights[0] = new LightClass;
|
||||
m_Lights[0]->SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f); // White
|
||||
m_Lights[0]->SetDirection(0.0f, 0.0f, -1.0f);
|
||||
m_Lights[0]->SetSpecularColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
m_Lights[0]->SetSpecularPower(16.0f);
|
||||
m_Lights[0]->SetPosition(10.0f, 7.0f, -5.0f);
|
||||
|
||||
// Manually set the color and position of each light.
|
||||
m_Lights[1] = new LightClass;
|
||||
m_Lights[1]->SetDiffuseColor(1.0f, 0.0f, 0.0f, 1.0f); // Red
|
||||
m_Lights[1]->SetDirection(0.0f, 0.0f, 1.0f);
|
||||
m_Lights[1]->SetSpecularColor(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
m_Lights[1]->SetSpecularPower(16.0f);
|
||||
m_Lights[1]->SetPosition(10.0f, 7.0f, -5.0f);
|
||||
|
||||
m_Lights[2] = new LightClass;
|
||||
m_Lights[2]->SetDiffuseColor(0.0f, 1.0f, 0.0f, 1.0f); // Green
|
||||
m_Lights[2]->SetDirection(0.0f, 0.0f, 1.0f);
|
||||
m_Lights[2]->SetSpecularColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
m_Lights[2]->SetSpecularPower(16.0f);
|
||||
m_Lights[2]->SetPosition(10.0f, 7.0f, -5.0f);
|
||||
|
||||
m_Lights[3] = new LightClass;
|
||||
m_Lights[3]->SetDiffuseColor(0.0f, 0.0f, 1.0f, 1.0f); // Blue
|
||||
m_Lights[3]->SetDirection(0.0f, 0.0f, 1.0f);
|
||||
m_Lights[3]->SetSpecularColor(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
m_Lights[3]->SetSpecularPower(16.0f);
|
||||
m_Lights[3]->SetPosition(10.0f, 7.0f, -5.0f);
|
||||
|
||||
|
||||
// Create and initialize the normal map shader object.
|
||||
m_ShaderManager = new ShaderManagerClass;
|
||||
|
||||
result = m_ShaderManager->Initialize(m_Direct3D->GetDevice(), hwnd);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Create and initialize the font shader object.
|
||||
m_FontShader = new FontShaderClass;
|
||||
|
||||
result = m_FontShader->Initialize(m_Direct3D->GetDevice(), hwnd);
|
||||
if (!result)
|
||||
{
|
||||
MessageBox(hwnd, L"Could not initialize the font shader object.", L"Error", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the font object.
|
||||
m_Font = new FontClass;
|
||||
|
||||
result = m_Font->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), 0);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the initial render count string.
|
||||
strcpy_s(renderString, "Render Count: 0");
|
||||
|
||||
// Create and initialize the text object for the render count string.
|
||||
m_RenderCountString = new TextClass;
|
||||
|
||||
result = m_RenderCountString->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), screenWidth, screenHeight, 32, m_Font, renderString, 10, 10, 1.0f, 1.0f, 1.0f);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the model list object.
|
||||
m_ModelList = new ModelListClass;
|
||||
m_ModelList->Initialize(25);
|
||||
|
||||
// Create and initialize the timer object.
|
||||
m_Timer = new TimerClass;
|
||||
|
||||
result = m_Timer->Initialize();
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the position class object.
|
||||
m_Position = new PositionClass;
|
||||
|
||||
// Create the frustum class object.
|
||||
m_Frustum = new FrustumClass;
|
||||
|
||||
// Create and initialize the fps object.
|
||||
m_Fps = new FpsClass();
|
||||
|
||||
m_Fps->Initialize();
|
||||
|
||||
// Set the initial fps and fps string.
|
||||
m_previousFps = -1;
|
||||
strcpy_s(fpsString, "Fps: 0");
|
||||
|
||||
// Create and initialize the text object for the fps string.
|
||||
m_FpsString = new TextClass;
|
||||
|
||||
result = m_FpsString->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), screenWidth, screenHeight, 32, m_Font, fpsString, 10, 10, 0.0f, 1.0f, 0.0f);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
logger.Log("Application class initialized", __FILE__, __LINE__);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -551,6 +547,7 @@ bool ApplicationClass::Frame(InputClass* Input)
|
||||
result = Render(rotation, x, y, z, textureTranslation);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the graphics scene", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -558,6 +555,7 @@ bool ApplicationClass::Frame(InputClass* Input)
|
||||
result = UpdateFps();
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not update the frames per second", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -580,6 +578,7 @@ bool ApplicationClass::Frame(InputClass* Input)
|
||||
result = RenderSceneToTexture(rotation);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the scene to the render texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -587,6 +586,7 @@ bool ApplicationClass::Frame(InputClass* Input)
|
||||
result = UpdateMouseStrings(mouseX, mouseY, leftMouseDown);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not update the mouse strings", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -723,6 +723,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
diffuseColor, lightPosition);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the cube model using the light shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -747,6 +748,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the object model using the light shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -764,10 +766,11 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
|
||||
chunk->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), chunk->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, chunk->GetTexture(1),
|
||||
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), chunk->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, chunk->GetTexture(5),
|
||||
diffuseColor, lightPosition);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the terrain model using the light shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -781,6 +784,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
result = m_TextureShader->Render(m_Direct3D->GetDeviceContext(), m_DisplayPlane->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_RenderTexture->GetShaderResourceView());
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the display plane using the texture shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -793,6 +797,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
result = m_TextureShader->Render(m_Direct3D->GetDeviceContext(), m_DisplayPlane->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_RenderTexture->GetShaderResourceView());
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the display plane using the texture shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -805,6 +810,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
result = m_TextureShader->Render(m_Direct3D->GetDeviceContext(), m_DisplayPlane->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_RenderTexture->GetShaderResourceView());
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the display plane using the texture shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -842,6 +848,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
m_Model->GetTexture(0), diffuseColor, lightPosition);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the model using the light shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -854,6 +861,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
result = UpdateRenderCountString(renderCount);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not update the render count string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -871,6 +879,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
m_Font->GetTexture(), m_RenderCountString->GetPixelColor());
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the render count text string using the font shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -881,6 +890,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
m_Font->GetTexture(), m_FpsString->GetPixelColor());
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the fps text string using the font shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -893,6 +903,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
m_Font->GetTexture(), m_MouseStrings[i].GetPixelColor());
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the mouse text strings using the font shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -908,6 +919,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
result = m_TextureShader->Render(m_Direct3D->GetDeviceContext(), m_Sprite->GetIndexCount(), worldMatrix, viewMatrix, orthoMatrix, m_Sprite->GetTexture());
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the sprite using the texture shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -961,6 +973,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
m_Model->GetTexture(0), m_Model->GetTexture(5), m_Model->GetTexture(3));
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the model using the alpha map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -976,6 +989,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
m_Model->GetTexture(0));
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the model using the texture shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -991,6 +1005,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
m_Model->GetTexture(0), m_Model->GetTexture(1), m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor());
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the model using the normal map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1007,6 +1022,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
m_Model->GetTexture(0), m_Model->GetTexture(5));
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the model using the multitexture shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1023,6 +1039,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
m_Model->GetTexture(0), textureTranslation);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the model using the translate shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1039,6 +1056,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
m_Camera->GetPosition(), m_Lights[0]->GetSpecularColor(), m_Lights[0]->GetSpecularPower());
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the model using the specular map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1053,6 +1071,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
result = m_ShaderManager->RenderTransparentShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), blendAmount);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not render the model using the transparent shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1104,6 +1123,9 @@ int ApplicationClass::GetScreenHeight() const
|
||||
|
||||
void ApplicationClass::GenerateTerrain()
|
||||
{
|
||||
|
||||
logger.Log("Generating terrain", __FILE__, __LINE__);
|
||||
|
||||
char modelFilename[128];
|
||||
char textureFilename1[128];
|
||||
char textureFilename2[128];
|
||||
@ -1151,6 +1173,9 @@ void ApplicationClass::GenerateTerrain()
|
||||
|
||||
void ApplicationClass::AddKobject(WCHAR* filepath)
|
||||
{
|
||||
|
||||
logger.Log("Adding object", __FILE__, __LINE__);
|
||||
|
||||
char modelFilename[128];
|
||||
char textureFilename1[128];
|
||||
char textureFilename2[128];
|
||||
@ -1185,6 +1210,9 @@ void ApplicationClass::AddKobject(WCHAR* filepath)
|
||||
|
||||
void ApplicationClass::AddCube()
|
||||
{
|
||||
|
||||
logger.Log("Adding cube", __FILE__, __LINE__);
|
||||
|
||||
char modelFilename[128];
|
||||
char textureFilename1[128];
|
||||
char textureFilename2[128];
|
||||
@ -1215,6 +1243,8 @@ void ApplicationClass::AddCube()
|
||||
|
||||
void ApplicationClass::DeleteKobject(int index)
|
||||
{
|
||||
logger.Log("Deleting object", __FILE__, __LINE__);
|
||||
|
||||
if (index < m_object.size())
|
||||
{
|
||||
m_object[index]->Shutdown();
|
||||
@ -1225,6 +1255,8 @@ void ApplicationClass::DeleteKobject(int index)
|
||||
|
||||
void ApplicationClass::DeleteTerrain()
|
||||
{
|
||||
logger.Log("Deleting terrain", __FILE__, __LINE__);
|
||||
|
||||
for (auto cube : m_terrainChunk)
|
||||
{
|
||||
cube->Shutdown();
|
||||
@ -1250,6 +1282,7 @@ bool ApplicationClass::UpdateMouseStrings(int mouseX, int mouseY, bool mouseDown
|
||||
result = m_MouseStrings[0].UpdateText(m_Direct3D->GetDeviceContext(), m_Font, finalString, 10, 50, 1.0f, 1.0f, 1.0f);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not update the mouse X string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1264,6 +1297,7 @@ bool ApplicationClass::UpdateMouseStrings(int mouseX, int mouseY, bool mouseDown
|
||||
result = m_MouseStrings[1].UpdateText(m_Direct3D->GetDeviceContext(), m_Font, finalString, 10, 75, 1.0f, 1.0f, 1.0f);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not update the mouse Y string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1282,6 +1316,7 @@ bool ApplicationClass::UpdateMouseStrings(int mouseX, int mouseY, bool mouseDown
|
||||
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not update the mouse button string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1352,6 +1387,7 @@ bool ApplicationClass::UpdateFps()
|
||||
result = m_FpsString->UpdateText(m_Direct3D->GetDeviceContext(), m_Font, finalString, 10, 10, red, green, blue);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not update the fps string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1375,6 +1411,7 @@ bool ApplicationClass::UpdateRenderCountString(int renderCount)
|
||||
result = m_RenderCountString->UpdateText(m_Direct3D->GetDeviceContext(), m_Font, finalString, 10, 30, 1.0f, 1.0f, 1.0f);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Could not update the render count string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1419,6 +1456,8 @@ void ApplicationClass::SetLightPosition(int index, XMVECTOR position)
|
||||
|
||||
void ApplicationClass::DeleteLight(int index)
|
||||
{
|
||||
logger.Log("Deleting light", __FILE__, __LINE__);
|
||||
|
||||
if (index < 0 || index >= m_Lights.size())
|
||||
{
|
||||
// Index out of bounds
|
||||
|
@ -5,6 +5,8 @@
|
||||
///////////////////////
|
||||
// MY CLASS INCLUDES //
|
||||
///////////////////////
|
||||
#include "Logger.h"
|
||||
|
||||
#include "d3dclass.h"
|
||||
#include "cameraclass.h"
|
||||
#include "object.h"
|
||||
@ -160,6 +162,12 @@ private :
|
||||
FpsClass* m_Fps;
|
||||
TextClass* m_FpsString;
|
||||
int m_previousFps;
|
||||
|
||||
// ------------------------------------------------- //
|
||||
// ------------------- LOGGER ---------------------- //
|
||||
// ------------------------------------------------- //
|
||||
|
||||
Logger logger;
|
||||
};
|
||||
|
||||
#endif
|
@ -87,6 +87,7 @@
|
||||
<ClInclude Include="lightclass.h" />
|
||||
<ClInclude Include="lightmapshaderclass.h" />
|
||||
<ClInclude Include="lightshaderclass.h" />
|
||||
<ClInclude Include="Logger.h" />
|
||||
<ClInclude Include="modelclass.h" />
|
||||
<ClInclude Include="object.h" />
|
||||
<ClInclude Include="modellistclass.h" />
|
||||
@ -108,79 +109,120 @@
|
||||
<ClInclude Include="transparentshaderclass.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="alphamap.ps" />
|
||||
<None Include="alphamap.vs" />
|
||||
<None Include="font.ps" />
|
||||
<None Include="font.vs" />
|
||||
<None Include="light.ps" />
|
||||
<None Include="light.vs" />
|
||||
<None Include="lightmap.ps" />
|
||||
<None Include="lightmap.vs" />
|
||||
<None Include="Multitexture.ps" />
|
||||
<None Include="Multitexture.vs" />
|
||||
<None Include="normalmap.ps" />
|
||||
<None Include="normalmap.vs" />
|
||||
<CopyFileToFolders Include="alphamap.ps">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="alphamap.vs">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="font.ps">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="font.vs">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="light.ps">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="light.vs">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="lightmap.ps">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="lightmap.vs">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="Multitexture.ps">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="Multitexture.vs">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="normalmap.ps">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="normalmap.vs">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<None Include="packages.config" />
|
||||
<None Include="reflection.ps" />
|
||||
<None Include="reflection.vs" />
|
||||
<None Include="specmap.ps">
|
||||
<CopyFileToFolders Include="reflection.ps">
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="specmap.vs">
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="reflection.vs">
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="texture.ps" />
|
||||
<None Include="texture.vs" />
|
||||
<None Include="transparent.ps" />
|
||||
<None Include="transparent.vs" />
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="specmap.ps">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="specmap.vs">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="texture.ps">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="texture.vs">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="transparent.ps">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="transparent.vs">
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Color.ps">
|
||||
<CopyFileToFolders Include="Color.ps">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="Color.vs">
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="Color.vs">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
</CopyFileToFolders>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\..\..\..\Downloads\grass.tga" />
|
||||
<Image Include="alpha01.tga" />
|
||||
<CopyFileToFolders Include="..\..\..\..\Downloads\grass.tga" />
|
||||
<CopyFileToFolders Include="alpha01.tga" />
|
||||
<Image Include="dirt01.tga" />
|
||||
<Image Include="font01.tga" />
|
||||
<CopyFileToFolders Include="font01.tga" />
|
||||
<Image Include="KhaoticIcon.ico" />
|
||||
<Image Include="light01.tga" />
|
||||
<Image Include="moss01.tga" />
|
||||
<Image Include="normal01.tga" />
|
||||
<CopyFileToFolders Include="light01.tga" />
|
||||
<CopyFileToFolders Include="moss01.tga" />
|
||||
<CopyFileToFolders Include="normal01.tga" />
|
||||
<Image Include="papier.tga" />
|
||||
<Image Include="spec02.tga" />
|
||||
<Image Include="stone01.tga" />
|
||||
<CopyFileToFolders Include="spec02.tga" />
|
||||
<CopyFileToFolders Include="sprite01.tga" />
|
||||
<CopyFileToFolders Include="sprite02.tga" />
|
||||
<CopyFileToFolders Include="sprite03.tga" />
|
||||
<CopyFileToFolders Include="sprite04.tga" />
|
||||
<CopyFileToFolders Include="stone01.tga" />
|
||||
<Image Include="wall.tga" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\..\..\..\Downloads\chunk.txt" />
|
||||
<Text Include="cube.txt" />
|
||||
<Text Include="font01.txt" />
|
||||
<Text Include="plane.txt" />
|
||||
<CopyFileToFolders Include="..\..\..\..\Downloads\chunk.txt" />
|
||||
<CopyFileToFolders Include="cube.txt" />
|
||||
<CopyFileToFolders Include="font01.txt" />
|
||||
<CopyFileToFolders Include="plane.txt" />
|
||||
<Text Include="sphere.txt" />
|
||||
<CopyFileToFolders Include="sprite_data_01.txt" />
|
||||
<Text Include="square.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="translate.ps">
|
||||
<CopyFileToFolders Include="translate.ps">
|
||||
<SubType>Designer</SubType>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="translate.vs">
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="translate.vs">
|
||||
<SubType>Designer</SubType>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
</CopyFileToFolders>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="resources.rc" />
|
||||
|
@ -290,11 +290,17 @@
|
||||
<ClInclude Include="resources.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="shadermanagerclass.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="transparentshaderclass.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Logger.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="font01.tga">
|
||||
<Filter>fonts</Filter>
|
||||
</Image>
|
||||
<Image Include="wall.tga">
|
||||
<Filter>assets</Filter>
|
||||
</Image>
|
||||
@ -304,9 +310,6 @@
|
||||
<Image Include="moss01.tga">
|
||||
<Filter>assets</Filter>
|
||||
</Image>
|
||||
<Image Include="stone01.tga">
|
||||
<Filter>assets</Filter>
|
||||
</Image>
|
||||
<Image Include="light01.tga">
|
||||
<Filter>assets</Filter>
|
||||
</Image>
|
||||
@ -325,24 +328,15 @@
|
||||
<Image Include="KhaoticIcon.ico">
|
||||
<Filter>Assets</Filter>
|
||||
</Image>
|
||||
<Image Include="sprite02.tga" />
|
||||
<Image Include="sprite03.tga" />
|
||||
<Image Include="sprite04.tga" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Color.ps">
|
||||
<Filter>shader</Filter>
|
||||
</None>
|
||||
<None Include="Color.vs">
|
||||
<Filter>shader</Filter>
|
||||
</None>
|
||||
<None Include="font.ps">
|
||||
<Filter>Fonts</Filter>
|
||||
</None>
|
||||
<None Include="font.vs">
|
||||
<Filter>Fonts</Filter>
|
||||
</None>
|
||||
<None Include="light.ps">
|
||||
<Filter>shader</Filter>
|
||||
</None>
|
||||
<None Include="light.vs">
|
||||
<Filter>shader</Filter>
|
||||
</None>
|
||||
@ -386,23 +380,13 @@
|
||||
<None Include="reflection.ps" />
|
||||
<None Include="specmap.ps" />
|
||||
<None Include="specmap.vs" />
|
||||
<None Include="transparent.ps" />
|
||||
<None Include="transparent.vs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="font01.txt">
|
||||
<Filter>Fonts</Filter>
|
||||
</Text>
|
||||
<Text Include="..\..\..\..\Downloads\chunk.txt">
|
||||
<Filter>Assets</Filter>
|
||||
</Text>
|
||||
<Text Include="cube.txt">
|
||||
<Filter>Assets</Filter>
|
||||
</Text>
|
||||
<Text Include="sphere.txt">
|
||||
<Filter>Assets</Filter>
|
||||
</Text>
|
||||
<Text Include="plane.txt">
|
||||
<Filter>Assets</Filter>
|
||||
</Text>
|
||||
<Text Include="square.txt">
|
||||
<Filter>assets</Filter>
|
||||
</Text>
|
||||
@ -412,4 +396,39 @@
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CopyFileToFolders Include="font.vs">
|
||||
<Filter>Fonts</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="font.ps">
|
||||
<Filter>Fonts</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="Color.vs">
|
||||
<Filter>shader</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="light.ps">
|
||||
<Filter>shader</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="font01.txt">
|
||||
<Filter>Fonts</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="font01.tga">
|
||||
<Filter>fonts</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="sprite_data_01.txt" />
|
||||
<CopyFileToFolders Include="sprite01.tga" />
|
||||
<CopyFileToFolders Include="stone01.tga">
|
||||
<Filter>assets</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="cube.txt">
|
||||
<Filter>Assets</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="spec02.tga" />
|
||||
<CopyFileToFolders Include="..\..\..\..\Downloads\chunk.txt">
|
||||
<Filter>Assets</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="plane.txt">
|
||||
<Filter>Assets</Filter>
|
||||
</CopyFileToFolders>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -3,19 +3,18 @@ Pos=60,60
|
||||
Size=400,400
|
||||
|
||||
[Window][Khaotic Engine]
|
||||
Pos=24,182
|
||||
Size=694,210
|
||||
Pos=429,57
|
||||
Size=392,218
|
||||
|
||||
[Window][Objects]
|
||||
Pos=35,13
|
||||
Size=492,353
|
||||
Collapsed=1
|
||||
Pos=39,222
|
||||
Size=379,299
|
||||
|
||||
[Window][Terrain]
|
||||
Pos=816,75
|
||||
Size=418,94
|
||||
Pos=60,60
|
||||
Size=342,82
|
||||
|
||||
[Window][Light]
|
||||
Pos=58,418
|
||||
Size=418,240
|
||||
Pos=95,296
|
||||
Size=345,230
|
||||
|
||||
|
@ -13,6 +13,8 @@ imguiManager::~imguiManager()
|
||||
|
||||
bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* deviceContext)
|
||||
{
|
||||
logger.Log("Initializing imgui", __FILE__, __LINE__);
|
||||
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
io = &ImGui::GetIO();
|
||||
@ -21,6 +23,8 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
ImGui_ImplDX11_Init(device, deviceContext);
|
||||
ImGui::StyleColorsDark();
|
||||
|
||||
logger.Log("imgui initialized", __FILE__, __LINE__);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
#ifndef _IMGUI_MANAGER_H_
|
||||
#define _IMGUI_MANAGER_H_
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_dx11.h>
|
||||
#include <imgui_impl_win32.h>
|
||||
@ -39,6 +41,8 @@ private :
|
||||
|
||||
private:
|
||||
ImGuiIO* io;
|
||||
|
||||
Logger logger;
|
||||
};
|
||||
|
||||
#endif
|
@ -22,12 +22,15 @@ ModelClass::~ModelClass()
|
||||
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, char* textureFilename1, char* textureFilename2, char* textureFilename3,
|
||||
char* textureFilename4, char* textureFilename5, char* textureFilename6)
|
||||
{
|
||||
logger.Log("Initializing model class", __FILE__, __LINE__);
|
||||
|
||||
bool result;
|
||||
|
||||
// Load in the model data.
|
||||
result = LoadModel(modelFilename);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to load model data", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -38,15 +41,19 @@ bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon
|
||||
result = InitializeBuffers(device);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to initialize buffers", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Load the textures for this model.
|
||||
result = LoadTextures(device, deviceContext, textureFilename1, textureFilename2, textureFilename3, textureFilename4, textureFilename5, textureFilename6);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to load textures", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
logger.Log("Model class initialized", __FILE__, __LINE__);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -88,6 +95,8 @@ ID3D11ShaderResourceView* ModelClass::GetTexture(int index)
|
||||
|
||||
bool ModelClass::InitializeBuffers(ID3D11Device* device)
|
||||
{
|
||||
logger.Log("Initializing buffers", __FILE__, __LINE__);
|
||||
|
||||
VertexType* vertices;
|
||||
unsigned long* indices;
|
||||
D3D11_BUFFER_DESC vertexBufferDesc, indexBufferDesc;
|
||||
@ -130,6 +139,7 @@ bool ModelClass::InitializeBuffers(ID3D11Device* device)
|
||||
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
logger.Log("Failed to create vertex buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -150,6 +160,7 @@ bool ModelClass::InitializeBuffers(ID3D11Device* device)
|
||||
result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
logger.Log("Failed to create index buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -160,6 +171,8 @@ bool ModelClass::InitializeBuffers(ID3D11Device* device)
|
||||
delete[] indices;
|
||||
indices = 0;
|
||||
|
||||
logger.Log("Buffers initialized", __FILE__, __LINE__);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -210,6 +223,8 @@ void ModelClass::RenderBuffers(ID3D11DeviceContext* deviceContext)
|
||||
bool ModelClass::LoadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* filename1, char* filename2, char* filename3, char* filename4, char* filename5,
|
||||
char* filename6)
|
||||
{
|
||||
logger.Log("Loading textures", __FILE__, __LINE__);
|
||||
|
||||
bool result;
|
||||
|
||||
|
||||
@ -219,45 +234,54 @@ bool ModelClass::LoadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceC
|
||||
result = m_Textures[0].Initialize(device, deviceContext, filename1);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to initialize texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
result = m_Textures[1].Initialize(device, deviceContext, filename2);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to initialize texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
result = m_Textures[2].Initialize(device, deviceContext, filename3);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to initialize texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
result = m_Textures[3].Initialize(device, deviceContext, filename4);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to initialize texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
result = m_Textures[4].Initialize(device, deviceContext, filename5);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to initialize texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
result = m_Textures[5].Initialize(device, deviceContext, filename6);
|
||||
if (!result)
|
||||
{
|
||||
logger.Log("Failed to initialize texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
logger.Log("Textures loaded", __FILE__, __LINE__);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ModelClass::ReleaseTextures()
|
||||
{
|
||||
logger.Log("Releasing textures", __FILE__, __LINE__);
|
||||
|
||||
// Release the texture object array.
|
||||
if (m_Textures)
|
||||
{
|
||||
@ -272,11 +296,15 @@ void ModelClass::ReleaseTextures()
|
||||
m_Textures = 0;
|
||||
}
|
||||
|
||||
logger.Log("Textures released", __FILE__, __LINE__);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool ModelClass::LoadModel(char* filename)
|
||||
{
|
||||
logger.Log("Loading model", __FILE__, __LINE__);
|
||||
|
||||
ifstream fin;
|
||||
char input;
|
||||
int i;
|
||||
@ -288,6 +316,7 @@ bool ModelClass::LoadModel(char* filename)
|
||||
// If it could not open the file then exit.
|
||||
if (fin.fail())
|
||||
{
|
||||
logger.Log("Failed to open model file", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -327,11 +356,15 @@ bool ModelClass::LoadModel(char* filename)
|
||||
// Close the model file.
|
||||
fin.close();
|
||||
|
||||
logger.Log("Model loaded", __FILE__, __LINE__);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ModelClass::CalculateModelVectors()
|
||||
{
|
||||
logger.Log("Calculating model vectors", __FILE__, __LINE__);
|
||||
|
||||
int faceCount, i, index;
|
||||
TempVertexType vertex1, vertex2, vertex3;
|
||||
VectorType tangent, binormal;
|
||||
@ -394,11 +427,15 @@ void ModelClass::CalculateModelVectors()
|
||||
m_model[index - 3].bz = binormal.z;
|
||||
}
|
||||
|
||||
logger.Log("Model vectors calculated", __FILE__, __LINE__);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void ModelClass::CalculateTangentBinormal(TempVertexType vertex1, TempVertexType vertex2, TempVertexType vertex3, VectorType& tangent, VectorType& binormal)
|
||||
{
|
||||
logger.Log("Calculating tangent and binormal", __FILE__, __LINE__);
|
||||
|
||||
float vector1[3], vector2[3];
|
||||
float tuVector[2], tvVector[2];
|
||||
float den;
|
||||
@ -449,16 +486,22 @@ void ModelClass::CalculateTangentBinormal(TempVertexType vertex1, TempVertexType
|
||||
binormal.y = binormal.y / length;
|
||||
binormal.z = binormal.z / length;
|
||||
|
||||
logger.Log("Tangent and binormal calculated", __FILE__, __LINE__);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void ModelClass::ReleaseModel()
|
||||
{
|
||||
logger.Log("Releasing model", __FILE__, __LINE__);
|
||||
|
||||
if (m_model)
|
||||
{
|
||||
delete[] m_model;
|
||||
m_model = 0;
|
||||
}
|
||||
|
||||
logger.Log("Model released", __FILE__, __LINE__);
|
||||
|
||||
return;
|
||||
}
|
@ -5,6 +5,8 @@
|
||||
//////////////
|
||||
// INCLUDES //
|
||||
//////////////
|
||||
#include "Logger.h"
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <directxmath.h>
|
||||
#include <fstream>
|
||||
@ -105,6 +107,8 @@ private:
|
||||
int m_vertexCount, m_indexCount;
|
||||
TextureClass* m_Textures;
|
||||
ModelType* m_model;
|
||||
|
||||
Logger logger;
|
||||
};
|
||||
|
||||
#endif
|
@ -49,4 +49,5 @@ private:
|
||||
XMMATRIX m_worldMatrix;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
};
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
#include "inputclass.h"
|
||||
#include "applicationclass.h"
|
||||
#include "imguiManager.h"
|
||||
@ -30,6 +32,7 @@ private:
|
||||
LPCWSTR m_applicationName;
|
||||
HINSTANCE m_hinstance;
|
||||
HWND m_hwnd;
|
||||
Logger logger;
|
||||
|
||||
InputClass* m_Input;
|
||||
ApplicationClass* m_Application;
|
||||
|
Loading…
x
Reference in New Issue
Block a user