dx12 dynamic lib loading + creation of device first pass.

This commit is contained in:
2025-01-12 22:11:47 -05:00
parent 6c80168e8c
commit 4c43cce133
9 changed files with 361 additions and 81 deletions

View File

@@ -14,62 +14,76 @@
#include <Graphics/Graphics.h>
#include <Windows.h>
namespace Juliet
// 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)
using namespace Juliet;
void Win32EditorApplication::Init()
{
void Win32EditorApplication::Init()
Log(LogLevel::Message, LogCategory::Editor, "Initializing Editor Application...");
GraphicsConfig config;
GraphicsDevice = CreateGraphicsDevice(config);
MainWindow = CreatePlatformWindow("Juliet Editor", 1280, 720);
// TODO : Assign the graphics device to the main window (and detach)
Running = MainWindow != nullptr && GraphicsDevice != nullptr;
}
void Win32EditorApplication::Shutdown()
{
Log(LogLevel::Message, LogCategory::Editor, "Shutdown Editor Application...");
if (MainWindow)
{
Log(LogLevel::Message, LogCategory::Editor, "Initializing Editor Application...");
MainWindow = CreatePlatformWindow("Juliet Editor", 1280, 720);
GraphicsConfig config;
GraphicsDevice* device = CreateGraphicsDevice(config);
Assert(!device && "Currently not implemented so device should be null");
Running = MainWindow != nullptr;
DestroyPlatformWindow(MainWindow);
}
void Win32EditorApplication::Shutdown()
if (GraphicsDevice)
{
Log(LogLevel::Message, LogCategory::Editor, "Shutdown Editor Application...");
if (MainWindow)
{
DestroyPlatformWindow(MainWindow);
}
DestroyGraphicsDevice(GraphicsDevice);
}
}
void Win32EditorApplication::Update()
void Win32EditorApplication::Update()
{
SystemEvent evt;
while (GetEvent(evt))
{
SystemEvent evt;
while (GetEvent(evt))
if (evt.Type == EventType::Window_Close_Request)
{
if (evt.Type == EventType::Window_Close_Request)
if (evt.Data.Window.AssociatedWindowID == GetWindowID(MainWindow))
{
if (evt.Data.Window.AssociatedWindowID == GetWindowID(MainWindow))
{
Running = false;
}
Running = false;
}
}
}
bool Win32EditorApplication::IsRunning()
{
return Running;
}
// Draw here for now
// 1) Acquire a Command Buffer
namespace
{
Win32EditorApplication EditorApplication;
}
Win32EditorApplication& GetEditorApplication()
{
return EditorApplication;
}
}
} // namespace Juliet
bool Win32EditorApplication::IsRunning()
{
return Running;
}
namespace
{
Win32EditorApplication EditorApplication;
}
Win32EditorApplication& GetEditorApplication()
{
return EditorApplication;
}
int main(int argc, char** argv)
{
@@ -80,7 +94,7 @@ int main(int argc, char** argv)
return EXIT_FAILURE;
}
StartApplication(Juliet::EditorApplication, Juliet::JulietInit_Flags::Display);
StartApplication(EditorApplication, JulietInit_Flags::Display);
// Pause here to not close the console window immediatly on stop
system("PAUSE");

View File

@@ -5,20 +5,23 @@
namespace Juliet
{
struct GraphicsDevice;
struct Window;
}
class Win32EditorApplication : public IApplication
{
protected:
void Init() override;
void Shutdown() override;
void Update() override;
bool IsRunning() override;
class Win32EditorApplication : public Juliet::IApplication
{
protected:
void Init() override;
void Shutdown() override;
void Update() override;
bool IsRunning() override;
private:
Window* MainWindow = {};
bool Running = false;
};
private:
Juliet::Window* MainWindow = {};
Juliet::GraphicsDevice* GraphicsDevice = {};
Win32EditorApplication& GetEditorApplication();
} // namespace Juliet
bool Running = false;
};
Win32EditorApplication& GetEditorApplication();