Merge branch 'main' of https://github.com/GamingCampus-AdrienBourgois/khaotic-engine
This commit is contained in:
commit
40bba01c1a
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
|
143
enginecustom/enginecustom.vcxproj
Normal file
143
enginecustom/enginecustom.vcxproj
Normal file
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<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>{92cf56c4-76bb-40d4-8fe5-36c15f5f127a}</ProjectGuid>
|
||||
<RootNamespace>enginecustom</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
42
enginecustom/enginecustom.vcxproj.filters
Normal file
42
enginecustom/enginecustom.vcxproj.filters
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Fichiers sources">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Fichiers d%27en-tête">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Fichiers de ressources">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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>
|
||||
<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
|
Loading…
x
Reference in New Issue
Block a user