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