Skip to content

Commit cb642f4

Browse files
jonjondevRaelr
authored andcommitted
Removed Vulkan dependency on window module
1 parent 7bdc597 commit cb642f4

File tree

10 files changed

+14
-22
lines changed

10 files changed

+14
-22
lines changed

engine/render/renderer/Renderer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "render/renderer/platform/vulkan/CommandBuffer.h"
1818
#include "render/renderer/platform/vulkan/Context.h"
1919
#include "render/renderer/platform/vulkan/DescriptorPool.h"
20-
#include "renderer/Common.h"
20+
#include "renderer/CameraData.h"
2121
#include "renderer/Renderer2D.h"
2222
#include "renderer/Renderer3D.h"
2323

engine/render/renderer/platform/vulkan/Context.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@
77
//
88

99
#define VOLK_IMPLEMENTATION
10+
#define GLFW_INCLUDE_VULKAN
1011

1112
#include "Context.h"
1213

13-
#include <GLFW/glfw3.h>
1414
#include <utils/Logging.h>
1515

1616
#include "render/renderer/Renderer.h"
1717
#include "utils/TypeAdaptor.h"
1818

19+
// clang-format off
20+
#include <GLFW/glfw3.h> // Must be final include
21+
// clang-format on
22+
1923
namespace Siege::Vulkan
2024
{
2125
Context::~Context()
@@ -32,7 +36,10 @@ void Context::Init(Window& window)
3236

3337
vulkanInstance = Instance(window.GetRequiredExtensions());
3438

35-
surface = (VkSurfaceKHR) Siege::Window::GetWindowSurface(window, vulkanInstance.GetInstance());
39+
glfwCreateWindowSurface(vulkanInstance.GetInstance(),
40+
reinterpret_cast<GLFWwindow*>(window.GetRawWindow()),
41+
nullptr,
42+
&surface);
3643

3744
CC_ASSERT(surface != VK_NULL_HANDLE, "Unable to create surface!")
3845

File renamed without changes.

engine/render/renderer/renderer/Renderer3D.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void Renderer3D::DrawQuad(const Vec3 position,
100100

101101
void Renderer3D::Render(uint32_t currentFrame,
102102
Vulkan::CommandBuffer& commandBuffer,
103-
CameraData cameraData)
103+
const CameraData& cameraData)
104104
{
105105
global3DData.cameraData = cameraData;
106106
uint64_t globalDataSize = sizeof(global3DData);

engine/render/renderer/renderer/Renderer3D.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "../lights/PointLight.h"
1313
#include "../model/Model.h"
1414
#include "BillboardRenderer.h"
15-
#include "Common.h"
15+
#include "CameraData.h"
1616
#include "DebugRenderer3D.h"
1717
#include "LightRenderer.h"
1818
#include "ModelRenderer.h"
@@ -71,7 +71,7 @@ class Renderer3D
7171

7272
static void Render(uint32_t currentFrame,
7373
Vulkan::CommandBuffer& commandBuffer,
74-
CameraData cameraData);
74+
const CameraData& cameraData);
7575
static void Flush();
7676

7777
static void DestroyRenderer3D();

engine/window/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ windowDepends := $(patsubst %.o, %.d, $(call rwildcard,$(windowBinDir)/,*.o))
1616
windowLibs := $(vendorDir)/glfw/build/src/libglfw3.a
1717

1818
linkFlags += -l utils
19-
compileFlags += -I $(vendorDir)/glfw/include -I $(vendorDir)/vulkan/include
19+
compileFlags += -I $(vendorDir)/glfw/include
2020

2121
# Build the static library
2222
$(windowLib): $(windowObjects)

engine/window/Window.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@ MHArray<const char*> Window::GetRequiredExtensions()
115115
return Glfw::GetRequiredExtensions();
116116
}
117117

118-
void* Window::GetWindowSurface(Window& window, void* instance)
119-
{
120-
return Glfw::GetWindowSurface((Glfw::Window) window.GetRawWindow(), instance);
121-
}
122-
123118
void Window::ToggleCursor(bool state)
124119
{
125120
state ? DisableCursor() : EnableCursor();

engine/window/Window.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class Window
5757
void DisableCursor();
5858

5959
static MHArray<const char*> GetRequiredExtensions();
60-
static void* GetWindowSurface(Window& window, void* instance);
6160

6261
void ToggleCursor(bool state);
6362

engine/window/platform/glfw/Window.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "Window.h"
1010

11-
#define GLFW_INCLUDE_VULKAN
1211
#include <GLFW/glfw3.h>
1312

1413
#include "window/Window.h"
@@ -99,13 +98,6 @@ MHArray<const char*> GetRequiredExtensions()
9998
return MHArray<const char*>(glfwExtensions, glfwExtensionCount);
10099
}
101100

102-
void* GetWindowSurface(Window window, void* instance)
103-
{
104-
VkSurfaceKHR surface = nullptr;
105-
glfwCreateWindowSurface((VkInstance) instance, window, nullptr, &surface);
106-
return surface;
107-
}
108-
109101
void FreeWindow(Window window)
110102
{
111103
glfwDestroyWindow(window);

engine/window/platform/glfw/Window.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ void SetIsMouseMotionRaw(Window window, bool state);
4545
bool WindowShouldClose(Window window);
4646

4747
MHArray<const char*> GetRequiredExtensions();
48-
void* GetWindowSurface(Window window, void* instance);
4948

5049
void FreeWindow(Window window);
5150
void FreeGlfw();

0 commit comments

Comments
 (0)