Create Vulkan surface
This commit is contained in:
parent
ece828d045
commit
0205f70ba6
@ -7,7 +7,7 @@ namespace nf::cli {
|
||||
Client::Client(ClientConfig config)
|
||||
: m_config(config)
|
||||
, m_window(m_config.appName, m_config.display)
|
||||
, m_renderEngine()
|
||||
, m_renderEngine(m_window.getHandle())
|
||||
{
|
||||
// Setup window and renderer
|
||||
}
|
||||
|
@ -23,6 +23,10 @@ namespace nf::cli {
|
||||
setDisplay(config);
|
||||
}
|
||||
|
||||
HWND Window::getHandle() const {
|
||||
return m_handle;
|
||||
}
|
||||
|
||||
void Window::setDisplay(DisplayConfig config) {
|
||||
NFLog("Setting window display");
|
||||
m_config = config;
|
||||
|
@ -10,6 +10,7 @@ namespace nf::cli {
|
||||
public:
|
||||
Window(const char* windowTitle, DisplayConfig config);
|
||||
|
||||
HWND getHandle() const;
|
||||
void setDisplay(DisplayConfig config);
|
||||
void runLoop();
|
||||
void show(bool show = true);
|
||||
|
@ -5,11 +5,13 @@
|
||||
#include "util.h"
|
||||
|
||||
namespace nf::cli::render {
|
||||
RenderEngine::RenderEngine()
|
||||
RenderEngine::RenderEngine(HWND window)
|
||||
: m_instance()
|
||||
, m_surface()
|
||||
{
|
||||
NFLog("Initializing render engine");
|
||||
createInstance();
|
||||
createSurface(window);
|
||||
}
|
||||
|
||||
void RenderEngine::createInstance() {
|
||||
@ -27,10 +29,18 @@ namespace nf::cli::render {
|
||||
instanceCI.ppEnabledExtensionNames = instanceExtNames.data();
|
||||
instanceCI.enabledExtensionCount = instanceExtNames.size();
|
||||
if (vkCreateInstance(&instanceCI, nullptr, &m_instance) != VK_SUCCESS)
|
||||
NFError("Could not create Vulkan instance.");
|
||||
NFError("Could not create Vulkan instance");
|
||||
}
|
||||
|
||||
void RenderEngine::createSurface(HWND window) {
|
||||
VkWin32SurfaceCreateInfoKHR surfaceCI = { VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR };
|
||||
surfaceCI.hwnd = window;
|
||||
if (vkCreateWin32SurfaceKHR(m_instance, &surfaceCI, nullptr, &m_surface) != VK_SUCCESS)
|
||||
NFError("Could not create Vulkan surface");
|
||||
}
|
||||
|
||||
RenderEngine::~RenderEngine() {
|
||||
vkDestroySurfaceKHR(m_instance, m_surface, nullptr);
|
||||
vkDestroyInstance(m_instance, nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,14 @@
|
||||
namespace nf::cli::render {
|
||||
class RenderEngine {
|
||||
public:
|
||||
RenderEngine();
|
||||
RenderEngine(HWND window);
|
||||
|
||||
~RenderEngine();
|
||||
private:
|
||||
void createInstance();
|
||||
void createSurface(HWND window);
|
||||
|
||||
VkInstance m_instance;
|
||||
VkSurfaceKHR m_surface;
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user