- Added basic filesystem method to get the base path of the app
- Added hot reload support of the game dll - various changes and refactor
This commit is contained in:
@@ -1 +0,0 @@
|
||||
#include "EditorMain.h"
|
||||
@@ -1,5 +0,0 @@
|
||||
#pragma once
|
||||
class EditorMain
|
||||
{
|
||||
};
|
||||
|
||||
@@ -11,21 +11,70 @@
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Editor\EditorMain_win32.cpp"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Editor\EditorMain_win32.h"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Game\Game.vcxproj">
|
||||
<Project>{b7b12dcc-1a69-4371-a9fe-d6e7671497b0}</Project>
|
||||
<Name>Game</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Juliet\Juliet.vcxproj">
|
||||
<Project>{1bbc0b92-e4d8-4838-974b-439c5c501e82}</Project>
|
||||
<Name>Juliet</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="main.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SupportJustMyCode>true</SupportJustMyCode>
|
||||
<AssemblerOutput>NoListing</AssemblerOutput>
|
||||
<AssemblerListingLocation>W:\Classified\Juliet\Intermediate\JulietApp\x64\Debug\</AssemblerListingLocation>
|
||||
<UndefineAllPreprocessorDefinitions>false</UndefineAllPreprocessorDefinitions>
|
||||
<BrowseInformationFile>W:\Classified\Juliet\Intermediate\JulietApp\x64\Debug\</BrowseInformationFile>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<ConformanceMode>Default</ConformanceMode>
|
||||
<DiagnosticsFormat>Column</DiagnosticsFormat>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
<LanguageStandard_C>Default</LanguageStandard_C>
|
||||
<ModuleDependenciesFile>W:\Classified\Juliet\Intermediate\JulietApp\x64\Debug\</ModuleDependenciesFile>
|
||||
<OmitDefaultLibName>false</OmitDefaultLibName>
|
||||
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
|
||||
<ObjectFileName>W:\Classified\Juliet\Intermediate\JulietApp\x64\Debug\</ObjectFileName>
|
||||
<CallingConvention>Cdecl</CallingConvention>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>W:\Classified\Juliet\Intermediate\JulietApp\x64\Debug\JulietApp.pch</PrecompiledHeaderOutputFile>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<PreprocessKeepComments>false</PreprocessKeepComments>
|
||||
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
|
||||
<ScanSourceForModuleDependencies>false</ScanSourceForModuleDependencies>
|
||||
<ShowIncludes>false</ShowIncludes>
|
||||
<SourceDependenciesFile>W:\Classified\Juliet\Intermediate\JulietApp\x64\Debug\</SourceDependenciesFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<SmallerTypeCheck>false</SmallerTypeCheck>
|
||||
<StructMemberAlignment>Default</StructMemberAlignment>
|
||||
<TrackerLogDirectory>W:\Classified\Juliet\Intermediate\JulietApp\x64\Debug\JulietApp.tlog\</TrackerLogDirectory>
|
||||
<MinimalRebuildFromTracking>true</MinimalRebuildFromTracking>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<XMLDocumentationFileName>W:\Classified\Juliet\Intermediate\JulietApp\x64\Debug\</XMLDocumentationFileName>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<IntelJCCErratum>false</IntelJCCErratum>
|
||||
<BuildStlModules>false</BuildStlModules>
|
||||
<TreatExternalTemplatesAsInternal>true</TreatExternalTemplatesAsInternal>
|
||||
<PreprocessorDefinitions>_DEBUG;JULIET_WIN32;_UNICODE;UNICODE;</PreprocessorDefinitions>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<LinkCompiled>true</LinkCompiled>
|
||||
<ClangClMode>true</ClangClMode>
|
||||
<MSCVersion>Default</MSCVersion>
|
||||
<AdditionalOptions>--target=amd64-pc-windows-msvc </AdditionalOptions>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
|
||||
@@ -1,31 +1,52 @@
|
||||
#include <Editor/EditorMain_win32.h>
|
||||
#include <main.h>
|
||||
|
||||
#include <Core/Application/ApplicationManager.h>
|
||||
#include <Core/HAL/Display/Display.h>
|
||||
#include <Core/HAL/DynLib/DynamicLibrary.h>
|
||||
#include <Core/HAL/Event/SystemEvent.h>
|
||||
#include <Core/HAL/Filesystem/Filesystem.h>
|
||||
#include <Core/JulietInit.h>
|
||||
#include <Core/Logging/LogManager.h>
|
||||
#include <Core/Logging/LogTypes.h>
|
||||
#include <Graphics/GraphicsConfig.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
// TODO : Replace with message box from framework + call main and not winmain + subsystem
|
||||
#include <Core/DynLib/DynamicLibrary.h>
|
||||
#include <Graphics/Graphics.h>
|
||||
#include <Graphics/GraphicsConfig.h>
|
||||
#include <Graphics/RenderPass.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include <Core/Memory/Utils.h>
|
||||
#include <cstdlib>
|
||||
|
||||
// TODO : Replace with message box from framework + call main and not winmain + subsystem
|
||||
// TODO : Think how to do the draw pipeline.
|
||||
// Ex: Expose a Draw method ?
|
||||
// Store a graphics context ?
|
||||
// For now. Put everything in Update down below.
|
||||
// Should split update from draw, update should have a != timestep than graphics (60fps or more)
|
||||
|
||||
// TODO : Remove main.h. Useless
|
||||
// May be remove that Application class, useless too.
|
||||
|
||||
using namespace Juliet;
|
||||
|
||||
void Win32EditorApplication::Init()
|
||||
namespace
|
||||
{
|
||||
Log(LogLevel::Message, LogCategory::Editor, "Initializing Editor Application...");
|
||||
using GameInit_t = void (*)(void);
|
||||
using GameShutdown_t = void (*)(void);
|
||||
using GameUpdate_t = void (*)(float deltaTime);
|
||||
struct GameFunctionTable
|
||||
{
|
||||
GameInit_t Init = nullptr;
|
||||
GameShutdown_t Shutdown = nullptr;
|
||||
GameUpdate_t Update = nullptr;
|
||||
} Game;
|
||||
const char* GameFunctionTable[] = { "GameInit", "GameShutdown", "GameUpdate" };
|
||||
} // namespace
|
||||
|
||||
void JulietApplication::Init()
|
||||
{
|
||||
Log(LogLevel::Message, LogCategory::Editor, "Initializing Juliet Application...");
|
||||
|
||||
Log(LogLevel::Message, LogCategory::Editor, "%s", GetBasePath());
|
||||
|
||||
GraphicsConfig config;
|
||||
GraphicsDevice = CreateGraphicsDevice(config);
|
||||
@@ -37,18 +58,25 @@ void Win32EditorApplication::Init()
|
||||
if (Running)
|
||||
{
|
||||
AttachToWindow(GraphicsDevice, MainWindow);
|
||||
Game = LoadDynamicLibrary("Game.dll");
|
||||
//Game = LoadDynamicLibrary("Game.dll");
|
||||
|
||||
GameCode.Functions = reinterpret_cast<void**>(&Game);
|
||||
GameCode.FunctionCount = ArraySize(GameFunctionTable);
|
||||
GameCode.FunctionNames = GameFunctionTable;
|
||||
InitHotReloadCode(GameCode, StringBufferParam("Game.dll"),StringBufferParam("Game_Temp.dll"), StringBufferParam("lock.tmp"));
|
||||
if ((Running = GameCode.IsValid))
|
||||
{
|
||||
Game.Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Win32EditorApplication::Shutdown()
|
||||
void JulietApplication::Shutdown()
|
||||
{
|
||||
Log(LogLevel::Message, LogCategory::Editor, "Shutdown Editor Application...");
|
||||
Log(LogLevel::Message, LogCategory::Editor, "Shutting down Juliet Application...");
|
||||
|
||||
if (Game)
|
||||
{
|
||||
UnloadDynamicLibrary(Game);
|
||||
}
|
||||
Game.Shutdown();
|
||||
ShutdownHotReloadCode(GameCode);
|
||||
|
||||
if (MainWindow && GraphicsDevice)
|
||||
{
|
||||
@@ -64,9 +92,11 @@ void Win32EditorApplication::Shutdown()
|
||||
{
|
||||
DestroyGraphicsDevice(GraphicsDevice);
|
||||
}
|
||||
|
||||
Log(LogLevel::Message, LogCategory::Editor, "Juliet App shutdown Completed");
|
||||
}
|
||||
|
||||
void Win32EditorApplication::Update()
|
||||
void JulietApplication::Update()
|
||||
{
|
||||
SystemEvent evt;
|
||||
while (GetEvent(evt))
|
||||
@@ -80,6 +110,13 @@ void Win32EditorApplication::Update()
|
||||
}
|
||||
}
|
||||
|
||||
Game.Update(0.0f);
|
||||
|
||||
if (ShouldReloadCode(GameCode))
|
||||
{
|
||||
ReloadCode(GameCode);
|
||||
}
|
||||
|
||||
// Draw here for now
|
||||
// 1) Acquire a Command Buffer
|
||||
CommandList* cmdList = AcquireCommandList(GraphicsDevice, QueueType::Graphics);
|
||||
@@ -114,24 +151,24 @@ void Win32EditorApplication::Update()
|
||||
SubmitCommandLists(cmdList);
|
||||
}
|
||||
|
||||
bool Win32EditorApplication::IsRunning()
|
||||
bool JulietApplication::IsRunning()
|
||||
{
|
||||
return Running;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
Win32EditorApplication EditorApplication;
|
||||
JulietApplication EditorApplication;
|
||||
}
|
||||
|
||||
Win32EditorApplication& GetEditorApplication()
|
||||
JulietApplication& GetEditorApplication()
|
||||
{
|
||||
return EditorApplication;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CreateMutex(0, false, L"Local\\Juliet.Editor");
|
||||
CreateMutex(0, false, L"Local\\Juliet.App");
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
MessageBox(nullptr, L"An instance of Juliet is already running.", L"Juliet", MB_OK | MB_ICONEXCLAMATION);
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <Core/Application/IApplication.h>
|
||||
#include <Core/DynLib/DynamicLibrary.h>
|
||||
#include <Core/HAL/Display/Display.h>
|
||||
#include <Core/HAL/DynLib/DynamicLibrary.h>
|
||||
#include <Core/HotReload/HotReload.h>
|
||||
|
||||
namespace Juliet
|
||||
{
|
||||
@@ -10,7 +11,7 @@ namespace Juliet
|
||||
struct Window;
|
||||
} // namespace Juliet
|
||||
|
||||
class Win32EditorApplication : public Juliet::IApplication
|
||||
class JulietApplication : public Juliet::IApplication
|
||||
{
|
||||
protected:
|
||||
void Init() override;
|
||||
@@ -21,9 +22,9 @@ class Win32EditorApplication : public Juliet::IApplication
|
||||
private:
|
||||
Juliet::Window* MainWindow = {};
|
||||
Juliet::GraphicsDevice* GraphicsDevice = {};
|
||||
Juliet::DynamicLibrary* Game = {};
|
||||
Juliet::HotReloadCode GameCode = {};
|
||||
|
||||
bool Running = false;
|
||||
};
|
||||
|
||||
Win32EditorApplication& GetEditorApplication();
|
||||
JulietApplication& GetEditorApplication();
|
||||
Reference in New Issue
Block a user