true architecture
This commit is contained in:
parent
5714bbf085
commit
e849aebc4e
30
Resource.h
30
Resource.h
@ -1,30 +0,0 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Fichier Include généré par Microsoft Visual C++.
|
||||
// Utilisé par khaotic-engine.rc
|
||||
|
||||
#define IDS_APP_TITLE 103
|
||||
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDD_KHAOTICENGINE_DIALOG 102
|
||||
#define IDD_ABOUTBOX 103
|
||||
#define IDM_ABOUT 104
|
||||
#define IDM_EXIT 105
|
||||
#define IDI_KHAOTICENGINE 107
|
||||
#define IDI_SMALL 108
|
||||
#define IDC_KHAOTICENGINE 109
|
||||
#define IDC_MYICON 2
|
||||
#ifndef IDC_STATIC
|
||||
#define IDC_STATIC -1
|
||||
#endif
|
||||
// Valeurs par défaut suivantes des nouveaux objets
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#define _APS_NO_MFC 130
|
||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
31
enginecustom.sln
Normal file
31
enginecustom.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34607.119
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "enginecustom", "enginecustom\enginecustom.vcxproj", "{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}.Debug|x64.Build.0 = Debug|x64
|
||||
{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}.Debug|x86.Build.0 = Debug|Win32
|
||||
{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}.Release|x64.ActiveCfg = Release|x64
|
||||
{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}.Release|x64.Build.0 = Release|x64
|
||||
{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}.Release|x86.ActiveCfg = Release|Win32
|
||||
{92CF56C4-76BB-40D4-8FE5-36C15F5F127A}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {1EF23231-6B54-4B81-9818-BF931C50AA46}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
26
enginecustom/Main.cpp
Normal file
26
enginecustom/Main.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "systemclass.h"
|
||||
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow)
|
||||
{
|
||||
SystemClass* System;
|
||||
bool result;
|
||||
|
||||
|
||||
// Create the system object.
|
||||
System = new SystemClass;
|
||||
|
||||
// Initialize and run the system object.
|
||||
result = System->Initialize();
|
||||
if (result)
|
||||
{
|
||||
System->Run();
|
||||
}
|
||||
|
||||
// Shutdown and release the system object.
|
||||
System->Shutdown();
|
||||
delete System;
|
||||
System = 0;
|
||||
|
||||
return 0;
|
||||
}
|
290
enginecustom/Systemclass.cpp
Normal file
290
enginecustom/Systemclass.cpp
Normal file
@ -0,0 +1,290 @@
|
||||
#include "systemclass.h"
|
||||
|
||||
SystemClass::SystemClass()
|
||||
{
|
||||
m_Input = 0;
|
||||
m_Application = 0;
|
||||
}
|
||||
|
||||
SystemClass::SystemClass(const SystemClass& other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SystemClass::~SystemClass()
|
||||
{
|
||||
}
|
||||
|
||||
bool SystemClass::Initialize()
|
||||
{
|
||||
int screenWidth, screenHeight;
|
||||
bool result;
|
||||
|
||||
|
||||
// Initialize the width and height of the screen to zero before sending the variables into the function.
|
||||
screenWidth = 0;
|
||||
screenHeight = 0;
|
||||
|
||||
// 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;
|
||||
|
||||
m_Input->Initialize();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SystemClass::Shutdown()
|
||||
{
|
||||
// Release the application class object.
|
||||
if (m_Application)
|
||||
{
|
||||
m_Application->Shutdown();
|
||||
delete m_Application;
|
||||
m_Application = 0;
|
||||
}
|
||||
|
||||
// Release the input object.
|
||||
if (m_Input)
|
||||
{
|
||||
delete m_Input;
|
||||
m_Input = 0;
|
||||
}
|
||||
|
||||
// Shutdown the window.
|
||||
ShutdownWindows();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SystemClass::Run()
|
||||
{
|
||||
MSG msg;
|
||||
bool done, result;
|
||||
|
||||
|
||||
// Initialize the message structure.
|
||||
ZeroMemory(&msg, sizeof(MSG));
|
||||
|
||||
// Loop until there is a quit message from the window or the user.
|
||||
done = false;
|
||||
while (!done)
|
||||
{
|
||||
// Handle the windows messages.
|
||||
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
// If windows signals to end the application then exit out.
|
||||
if (msg.message == WM_QUIT)
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise do the frame processing.
|
||||
result = Frame();
|
||||
if (!result)
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool SystemClass::Frame()
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
// Check if the user pressed escape and wants to exit the application.
|
||||
if (m_Input->IsKeyDown(VK_ESCAPE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Do the frame processing for the application class object.
|
||||
result = m_Application->Frame();
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK SystemClass::MessageHandler(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (umsg)
|
||||
{
|
||||
// Check if a key has been pressed on the keyboard.
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
// If a key is pressed send it to the input object so it can record that state.
|
||||
m_Input->KeyDown((unsigned int)wparam);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check if a key has been released on the keyboard.
|
||||
case WM_KEYUP:
|
||||
{
|
||||
// If a key is released then send it to the input object so it can unset the state for that key.
|
||||
m_Input->KeyUp((unsigned int)wparam);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Any other messages send to the default message handler as our application won't make use of them.
|
||||
default:
|
||||
{
|
||||
return DefWindowProc(hwnd, umsg, wparam, lparam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SystemClass::InitializeWindows(int& screenWidth, int& screenHeight)
|
||||
{
|
||||
WNDCLASSEX wc;
|
||||
DEVMODE dmScreenSettings;
|
||||
int posX, posY;
|
||||
|
||||
|
||||
// Get an external pointer to this object.
|
||||
ApplicationHandle = this;
|
||||
|
||||
// Get the instance of this application.
|
||||
m_hinstance = GetModuleHandle(NULL);
|
||||
|
||||
// Give the application a name.
|
||||
m_applicationName = L"Engine";
|
||||
|
||||
// Setup the windows class with default settings.
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = m_hinstance;
|
||||
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
|
||||
wc.hIconSm = wc.hIcon;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = m_applicationName;
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
|
||||
// Register the window class.
|
||||
RegisterClassEx(&wc);
|
||||
|
||||
// Determine the resolution of the clients desktop screen.
|
||||
screenWidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
screenHeight = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
// Setup the screen settings depending on whether it is running in full screen or in windowed mode.
|
||||
if (FULL_SCREEN)
|
||||
{
|
||||
// If full screen set the screen to maximum size of the users desktop and 32bit.
|
||||
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
|
||||
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
||||
dmScreenSettings.dmPelsWidth = (unsigned long)screenWidth;
|
||||
dmScreenSettings.dmPelsHeight = (unsigned long)screenHeight;
|
||||
dmScreenSettings.dmBitsPerPel = 32;
|
||||
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||
|
||||
// Change the display settings to full screen.
|
||||
ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
|
||||
|
||||
// Set the position of the window to the top left corner.
|
||||
posX = posY = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If windowed then set it to 800x600 resolution.
|
||||
screenWidth = 800;
|
||||
screenHeight = 600;
|
||||
|
||||
// Place the window in the middle of the screen.
|
||||
posX = (GetSystemMetrics(SM_CXSCREEN) - screenWidth) / 2;
|
||||
posY = (GetSystemMetrics(SM_CYSCREEN) - screenHeight) / 2;
|
||||
}
|
||||
|
||||
// Create the window with the screen settings and get the handle to it.
|
||||
m_hwnd = CreateWindowEx(WS_EX_APPWINDOW, m_applicationName, m_applicationName,
|
||||
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP,
|
||||
posX, posY, screenWidth, screenHeight, NULL, NULL, m_hinstance, NULL);
|
||||
|
||||
// Bring the window up on the screen and set it as main focus.
|
||||
ShowWindow(m_hwnd, SW_SHOW);
|
||||
SetForegroundWindow(m_hwnd);
|
||||
SetFocus(m_hwnd);
|
||||
|
||||
// Hide the mouse cursor.
|
||||
ShowCursor(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void SystemClass::ShutdownWindows()
|
||||
{
|
||||
// Show the mouse cursor.
|
||||
ShowCursor(true);
|
||||
|
||||
// Fix the display settings if leaving full screen mode.
|
||||
if (FULL_SCREEN)
|
||||
{
|
||||
ChangeDisplaySettings(NULL, 0);
|
||||
}
|
||||
|
||||
// Remove the window.
|
||||
DestroyWindow(m_hwnd);
|
||||
m_hwnd = NULL;
|
||||
|
||||
// Remove the application instance.
|
||||
UnregisterClass(m_applicationName, m_hinstance);
|
||||
m_hinstance = NULL;
|
||||
|
||||
// Release the pointer to this class.
|
||||
ApplicationHandle = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT umessage, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (umessage)
|
||||
{
|
||||
// Check if the window is being destroyed.
|
||||
case WM_DESTROY:
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check if the window is being closed.
|
||||
case WM_CLOSE:
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// All other messages pass to the message handler in the system class.
|
||||
default:
|
||||
{
|
||||
return ApplicationHandle->MessageHandler(hwnd, umessage, wparam, lparam);
|
||||
}
|
||||
}
|
||||
}
|
44
enginecustom/applicationclass.cpp
Normal file
44
enginecustom/applicationclass.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "applicationclass.h"
|
||||
|
||||
|
||||
ApplicationClass::ApplicationClass()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ApplicationClass::ApplicationClass(const ApplicationClass& other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ApplicationClass::~ApplicationClass()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ApplicationClass::Shutdown()
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool ApplicationClass::Frame()
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ApplicationClass::Render()
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
37
enginecustom/applicationclass.h
Normal file
37
enginecustom/applicationclass.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef _APPLICATIONCLASS_H_
|
||||
#define _APPLICATIONCLASS_H_
|
||||
|
||||
|
||||
//////////////
|
||||
// INCLUDES //
|
||||
//////////////
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
/////////////
|
||||
// GLOBALS //
|
||||
/////////////
|
||||
const bool FULL_SCREEN = false;
|
||||
const bool VSYNC_ENABLED = true;
|
||||
const float SCREEN_DEPTH = 1000.0f;
|
||||
const float SCREEN_NEAR = 0.3f;
|
||||
|
||||
class ApplicationClass
|
||||
{
|
||||
public:
|
||||
ApplicationClass();
|
||||
ApplicationClass(const ApplicationClass&);
|
||||
~ApplicationClass();
|
||||
|
||||
bool Initialize(int, int, HWND);
|
||||
void Shutdown();
|
||||
bool Frame();
|
||||
|
||||
private:
|
||||
bool Render();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -18,11 +18,22 @@
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="applicationclass.cpp" />
|
||||
<ClCompile Include="inputclass.cpp" />
|
||||
<ClCompile Include="Main.cpp" />
|
||||
<ClCompile Include="Systemclass.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="applicationclass.h" />
|
||||
<ClInclude Include="inputclass.h" />
|
||||
<ClInclude Include="systemclass.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{2c5096eb-e3ec-4bec-b945-27ca67723d1f}</ProjectGuid>
|
||||
<RootNamespace>khaoticengine</RootNamespace>
|
||||
<ProjectGuid>{92cf56c4-76bb-40d4-8fe5-36c15f5f127a}</ProjectGuid>
|
||||
<RootNamespace>enginecustom</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
@ -126,22 +137,6 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="khaotic-engine.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="khaotic-engine.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="khaotic-engine.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="khaotic-engine.ico" />
|
||||
<Image Include="small.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
@ -15,35 +15,28 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resource.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="khaotic-engine.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="khaotic-engine.cpp">
|
||||
<ClCompile Include="Main.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Systemclass.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="inputclass.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="applicationclass.cpp">
|
||||
<Filter>Fichiers sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="khaotic-engine.rc">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="small.ico">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Image>
|
||||
<Image Include="khaotic-engine.ico">
|
||||
<Filter>Fichiers de ressources</Filter>
|
||||
</Image>
|
||||
<ClInclude Include="systemclass.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="inputclass.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="applicationclass.h">
|
||||
<Filter>Fichiers d%27en-tête</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
54
enginecustom/inputclass.cpp
Normal file
54
enginecustom/inputclass.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include "inputclass.h"
|
||||
|
||||
|
||||
InputClass::InputClass()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
InputClass::InputClass(const InputClass& other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
InputClass::~InputClass()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void InputClass::Initialize()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
// Initialize all the keys to being released and not pressed.
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
m_keys[i] = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void InputClass::KeyDown(unsigned int input)
|
||||
{
|
||||
// If a key is pressed then save that state in the key array.
|
||||
m_keys[input] = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void InputClass::KeyUp(unsigned int input)
|
||||
{
|
||||
// If a key is released then clear that state in the key array.
|
||||
m_keys[input] = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool InputClass::IsKeyDown(unsigned int key)
|
||||
{
|
||||
// Return what state the key is in (pressed/not pressed).
|
||||
return m_keys[key];
|
||||
}
|
26
enginecustom/inputclass.h
Normal file
26
enginecustom/inputclass.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef _INPUTCLASS_H_
|
||||
#define _INPUTCLASS_H_
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Class name: InputClass
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class InputClass
|
||||
{
|
||||
public:
|
||||
InputClass();
|
||||
InputClass(const InputClass&);
|
||||
~InputClass();
|
||||
|
||||
void Initialize();
|
||||
|
||||
void KeyDown(unsigned int);
|
||||
void KeyUp(unsigned int);
|
||||
|
||||
bool IsKeyDown(unsigned int);
|
||||
|
||||
private:
|
||||
bool m_keys[256];
|
||||
};
|
||||
|
||||
#endif
|
49
enginecustom/systemclass.h
Normal file
49
enginecustom/systemclass.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef _SYSTEMCLASS_H_
|
||||
#define _SYSTEMCLASS_H_
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <windows.h>
|
||||
#include "inputclass.h"
|
||||
#include "applicationclass.h"
|
||||
|
||||
class SystemClass
|
||||
{
|
||||
public:
|
||||
SystemClass();
|
||||
SystemClass(const SystemClass&);
|
||||
~SystemClass();
|
||||
|
||||
bool Initialize();
|
||||
void Shutdown();
|
||||
void Run();
|
||||
|
||||
LRESULT CALLBACK MessageHandler(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
private:
|
||||
bool Frame();
|
||||
void InitializeWindows(int&, int&);
|
||||
void ShutdownWindows();
|
||||
|
||||
private:
|
||||
LPCWSTR m_applicationName;
|
||||
HINSTANCE m_hinstance;
|
||||
HWND m_hwnd;
|
||||
|
||||
InputClass* m_Input;
|
||||
ApplicationClass* m_Application;
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// FUNCTION PROTOTYPES //
|
||||
/////////////////////////
|
||||
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
|
||||
/////////////
|
||||
// GLOBALS //
|
||||
/////////////
|
||||
static SystemClass* ApplicationHandle = 0;
|
||||
|
||||
|
||||
#endif
|
15
framework.h
15
framework.h
@ -1,15 +0,0 @@
|
||||
// header.h : fichier Include pour les fichiers Include système standard,
|
||||
// ou les fichiers Include spécifiques aux projets
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
#define WIN32_LEAN_AND_MEAN // Exclure les en-têtes Windows rarement utilisés
|
||||
// Fichiers d'en-tête Windows
|
||||
#include <windows.h>
|
||||
// Fichiers d'en-tête C RunTime
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
@ -1,309 +0,0 @@
|
||||
|
||||
///////////////**************new**************////////////////////
|
||||
|
||||
//Include and link appropriate libraries and headers//
|
||||
#pragma comment(lib, "d3d11.lib")
|
||||
#pragma comment(lib, "d3d10.lib")
|
||||
|
||||
#include <windows.h>
|
||||
#include <d3d11.h>
|
||||
#include <d3d10.h>
|
||||
#include <DirectXMath.h>
|
||||
#include <DirectXCollision.h>
|
||||
#include <DirectXPackedVector.h>
|
||||
|
||||
//Global Declarations//
|
||||
IDXGISwapChain* SwapChain;
|
||||
ID3D11Device* d3d11Device;
|
||||
ID3D11DeviceContext* d3d11DevCon;
|
||||
ID3D11RenderTargetView* renderTargetView;
|
||||
|
||||
float red = 0.0f;
|
||||
float green = 0.0f;
|
||||
float blue = 0.0f;
|
||||
int colormodr = 1;
|
||||
int colormodg = 1;
|
||||
int colormodb = 1;
|
||||
|
||||
///////////////**************new**************////////////////////
|
||||
|
||||
LPCTSTR WndClassName = L"firstwindow";
|
||||
HWND hwnd = NULL;
|
||||
|
||||
const int Width = 300;
|
||||
const int Height = 300;
|
||||
|
||||
///////////////**************new**************////////////////////
|
||||
|
||||
//Function Prototypes//
|
||||
bool InitializeDirect3d11App(HINSTANCE hInstance);
|
||||
void ReleaseObjects();
|
||||
bool InitScene();
|
||||
void UpdateScene();
|
||||
void DrawScene();
|
||||
|
||||
///////////////**************new**************////////////////////
|
||||
|
||||
bool InitializeWindow(HINSTANCE hInstance,
|
||||
int ShowWnd,
|
||||
int width, int height,
|
||||
bool windowed);
|
||||
int messageloop();
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd,
|
||||
UINT msg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
|
||||
int WINAPI WinMain(_In_ HINSTANCE hInstance, //Main windows function
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPSTR lpCmdLine,
|
||||
_In_ int nShowCmd)
|
||||
{
|
||||
|
||||
if (!InitializeWindow(hInstance, nShowCmd, Width, Height, true))
|
||||
{
|
||||
MessageBox(0, L"Window Initialization - Failed",
|
||||
L"Error", MB_OK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////**************new**************////////////////////
|
||||
|
||||
if (!InitializeDirect3d11App(hInstance)) //Initialize Direct3D
|
||||
{
|
||||
MessageBox(0, L"Direct3D Initialization - Failed",
|
||||
L"Error", MB_OK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!InitScene()) //Initialize our scene
|
||||
{
|
||||
MessageBox(0, L"Scene Initialization - Failed",
|
||||
L"Error", MB_OK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
messageloop();
|
||||
|
||||
ReleaseObjects();
|
||||
|
||||
///////////////**************new**************////////////////////
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool InitializeWindow(HINSTANCE hInstance,
|
||||
int ShowWnd,
|
||||
int width, int height,
|
||||
bool windowed)
|
||||
{
|
||||
typedef struct _WNDCLASS {
|
||||
UINT cbSize;
|
||||
UINT style;
|
||||
WNDPROC lpfnWndProc;
|
||||
int cbClsExtra;
|
||||
int cbWndExtra;
|
||||
HANDLE hInstance;
|
||||
HICON hIcon;
|
||||
HCURSOR hCursor;
|
||||
HBRUSH hbrBackground;
|
||||
LPCTSTR lpszMenuName;
|
||||
LPCTSTR lpszClassName;
|
||||
} WNDCLASS;
|
||||
|
||||
WNDCLASSEX wc;
|
||||
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.cbClsExtra = NULL;
|
||||
wc.cbWndExtra = NULL;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 2);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = WndClassName;
|
||||
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||
|
||||
if (!RegisterClassEx(&wc))
|
||||
{
|
||||
MessageBox(NULL, L"Error registering class",
|
||||
L"Error", MB_OK | MB_ICONERROR);
|
||||
return 1;
|
||||
}
|
||||
|
||||
hwnd = CreateWindowEx(
|
||||
NULL,
|
||||
WndClassName,
|
||||
L"Khaotic Engine",
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
width, height,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (!hwnd)
|
||||
{
|
||||
MessageBox(NULL, L"Error creating window",
|
||||
L"Error", MB_OK | MB_ICONERROR);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ShowWindow(hwnd, ShowWnd);
|
||||
UpdateWindow(hwnd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////**************new**************////////////////////
|
||||
|
||||
bool InitializeDirect3d11App(HINSTANCE hInstance)
|
||||
{
|
||||
//Describe our Buffer
|
||||
DXGI_MODE_DESC bufferDesc;
|
||||
|
||||
ZeroMemory(&bufferDesc, sizeof(DXGI_MODE_DESC));
|
||||
|
||||
bufferDesc.Width = Width;
|
||||
bufferDesc.Height = Height;
|
||||
bufferDesc.RefreshRate.Numerator = 60;
|
||||
bufferDesc.RefreshRate.Denominator = 1;
|
||||
bufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
bufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
||||
bufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
|
||||
|
||||
//Describe our SwapChain
|
||||
DXGI_SWAP_CHAIN_DESC swapChainDesc;
|
||||
|
||||
ZeroMemory(&swapChainDesc, sizeof(DXGI_SWAP_CHAIN_DESC));
|
||||
|
||||
swapChainDesc.BufferDesc = bufferDesc;
|
||||
swapChainDesc.SampleDesc.Count = 4; //multisampling standard
|
||||
swapChainDesc.SampleDesc.Quality = D3D11_STANDARD_MULTISAMPLE_PATTERN;
|
||||
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
swapChainDesc.BufferCount = 2; // triple buffering
|
||||
swapChainDesc.OutputWindow = hwnd;
|
||||
swapChainDesc.Windowed = TRUE;
|
||||
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||
|
||||
|
||||
//Create our SwapChain
|
||||
D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, NULL, NULL,
|
||||
D3D11_SDK_VERSION, &swapChainDesc, &SwapChain, &d3d11Device, NULL, &d3d11DevCon);
|
||||
|
||||
//Create our BackBuffer
|
||||
ID3D11Texture2D* BackBuffer;
|
||||
SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&BackBuffer);
|
||||
|
||||
//Create our Render Target
|
||||
d3d11Device->CreateRenderTargetView(BackBuffer, NULL, &renderTargetView);
|
||||
BackBuffer->Release();
|
||||
|
||||
//Set our Render Target
|
||||
d3d11DevCon->OMSetRenderTargets(1, &renderTargetView, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ReleaseObjects()
|
||||
{
|
||||
//Release the COM Objects we created
|
||||
SwapChain->Release();
|
||||
d3d11Device->Release();
|
||||
d3d11DevCon->Release();
|
||||
}
|
||||
bool InitScene()
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void UpdateScene()
|
||||
{
|
||||
//Update the colors of our scene
|
||||
red += colormodr * 0.00005f;
|
||||
green += colormodg * 0.00002f;
|
||||
blue += colormodb * 0.00001f;
|
||||
|
||||
if (red >= 1.0f || red <= 0.0f)
|
||||
colormodr *= -1;
|
||||
if (green >= 1.0f || green <= 0.0f)
|
||||
colormodg *= -1;
|
||||
if (blue >= 1.0f || blue <= 0.0f)
|
||||
colormodb *= -1;
|
||||
}
|
||||
|
||||
void DrawScene()
|
||||
{
|
||||
//Clear our backbuffer to the updated color
|
||||
DirectX::XMFLOAT4 bgColor(red, green, blue, 1.0f);
|
||||
float color[4] = { bgColor.x, bgColor.y, bgColor.z, bgColor.w };
|
||||
d3d11DevCon->ClearRenderTargetView(renderTargetView, color);
|
||||
|
||||
//Present the backbuffer to the screen
|
||||
SwapChain->Present(0, 0);
|
||||
}
|
||||
|
||||
///////////////**************new**************////////////////////
|
||||
|
||||
int messageloop() {
|
||||
MSG msg;
|
||||
ZeroMemory(&msg, sizeof(MSG));
|
||||
while (true)
|
||||
{
|
||||
BOOL PeekMessageL(
|
||||
LPMSG lpMsg,
|
||||
HWND hWnd,
|
||||
UINT wMsgFilterMin,
|
||||
UINT wMsgFilterMax,
|
||||
UINT wRemoveMsg
|
||||
);
|
||||
|
||||
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
if (msg.message == WM_QUIT)
|
||||
break;
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
else {
|
||||
///////////////**************new**************////////////////////
|
||||
// run game code
|
||||
|
||||
UpdateScene();
|
||||
DrawScene();
|
||||
|
||||
///////////////**************new**************////////////////////
|
||||
}
|
||||
}
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hwnd,
|
||||
UINT msg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case WM_KEYDOWN:
|
||||
if (wParam == VK_ESCAPE) {
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProc(hwnd,
|
||||
msg,
|
||||
wParam,
|
||||
lParam);
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource.h"
|
Binary file not shown.
Before Width: | Height: | Size: 45 KiB |
Binary file not shown.
@ -1,31 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34607.119
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "khaotic-engine", "khaotic-engine.vcxproj", "{2C5096EB-E3EC-4BEC-B945-27CA67723D1F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2C5096EB-E3EC-4BEC-B945-27CA67723D1F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2C5096EB-E3EC-4BEC-B945-27CA67723D1F}.Debug|x64.Build.0 = Debug|x64
|
||||
{2C5096EB-E3EC-4BEC-B945-27CA67723D1F}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{2C5096EB-E3EC-4BEC-B945-27CA67723D1F}.Debug|x86.Build.0 = Debug|Win32
|
||||
{2C5096EB-E3EC-4BEC-B945-27CA67723D1F}.Release|x64.ActiveCfg = Release|x64
|
||||
{2C5096EB-E3EC-4BEC-B945-27CA67723D1F}.Release|x64.Build.0 = Release|x64
|
||||
{2C5096EB-E3EC-4BEC-B945-27CA67723D1F}.Release|x86.ActiveCfg = Release|Win32
|
||||
{2C5096EB-E3EC-4BEC-B945-27CA67723D1F}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {AE9097A3-6D17-4474-B6FB-ACA76C7C3C8B}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// // L'inclusion de SDKDDKVer.h définit la version de plateforme Windows la plus haute disponible.
|
||||
// Si vous voulez générer votre application pour une plateforme Windows précédente, incluez WinSDKVer.h et
|
||||
// définissez la macro _WIN32_WINNT sur la plateforme à prendre en charge avant d'inclure SDKDDKVer.h.
|
||||
#include <SDKDDKVer.h>
|
Loading…
x
Reference in New Issue
Block a user