BROKEN trying to set up surface current issues is GLFW window pointer is null
This commit is contained in:
parent
e5f420a238
commit
4792f3ffde
6 changed files with 56 additions and 3 deletions
|
|
@ -1,10 +1,12 @@
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
#include "yave_vulkan_instance.hpp"
|
#include "yave_vulkan_instance.hpp"
|
||||||
|
#include "yave_vulkan_surface.hpp"
|
||||||
|
|
||||||
namespace yave {
|
namespace yave {
|
||||||
|
|
||||||
void Application::run() {
|
void Application::run() {
|
||||||
YaveVulkanInstance VI = YaveVulkanInstance();
|
YaveVulkanInstance VI = YaveVulkanInstance();
|
||||||
|
YaveVulkanSurface VS = YaveVulkanSurface(VI, yaveWindow);
|
||||||
|
|
||||||
while (!yaveWindow.shouldClose()) {
|
while (!yaveWindow.shouldClose()) {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ public:
|
||||||
YaveVulkanInstance(const YaveVulkanInstance &) = delete;
|
YaveVulkanInstance(const YaveVulkanInstance &) = delete;
|
||||||
YaveVulkanInstance &operator=(const YaveVulkanInstance &) = delete;
|
YaveVulkanInstance &operator=(const YaveVulkanInstance &) = delete;
|
||||||
|
|
||||||
|
VkInstance *getVkInstance(){return &instance;}
|
||||||
YaveVulkanInstance();
|
YaveVulkanInstance();
|
||||||
~YaveVulkanInstance();
|
~YaveVulkanInstance();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
17
src/yave_vulkan_surface.cpp
Normal file
17
src/yave_vulkan_surface.cpp
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include "yave_vulkan_surface.hpp"
|
||||||
|
#include "yave_vulkan_instance.hpp"
|
||||||
|
|
||||||
|
namespace yave {
|
||||||
|
YaveVulkanSurface::YaveVulkanSurface(YaveVulkanInstance &yaveVulkanInstance,
|
||||||
|
YaveWindow &window) {
|
||||||
|
VkWaylandSurfaceCreateInfoKHR createInfo{};
|
||||||
|
createInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
|
||||||
|
createInfo.display = glfwGetWaylandDisplay();
|
||||||
|
createInfo.surface = glfwGetWaylandWindow(window.getGLFWWindow());
|
||||||
|
//VkInstance *vkInstance = yaveVulkanInstance.getVkInstance();
|
||||||
|
if (vkCreateWaylandSurfaceKHR((*yaveVulkanInstance.getVkInstance()), &createInfo, nullptr, &surface)) {
|
||||||
|
throw std::runtime_error("failed to create window surface!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
YaveVulkanSurface::~YaveVulkanSurface() {}
|
||||||
|
} // namespace yave
|
||||||
31
src/yave_vulkan_surface.hpp
Normal file
31
src/yave_vulkan_surface.hpp
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "yave_vulkan_instance.hpp"
|
||||||
|
#include "yave_window.hpp"
|
||||||
|
#include <vulkan/vulkan_core.h>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
// This engine is for now Wayland only!!!
|
||||||
|
#define VK_USE_PLATFORM_WAYLAND_KHR
|
||||||
|
#include <vulkan/vulkan_wayland.h>
|
||||||
|
#define GLFW_INCLUDE_VULKAN
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#define GLFW_EXPOSE_NATIVE_WAYLAND
|
||||||
|
#include <GLFW/glfw3native.h>
|
||||||
|
|
||||||
|
namespace yave {
|
||||||
|
|
||||||
|
class YaveVulkanSurface {
|
||||||
|
|
||||||
|
private:
|
||||||
|
VkSurfaceKHR surface;
|
||||||
|
|
||||||
|
public:
|
||||||
|
YaveVulkanSurface(YaveVulkanInstance &yaveVulkanInstance, YaveWindow &window);
|
||||||
|
~YaveVulkanSurface();
|
||||||
|
// Delete Copy constructors
|
||||||
|
// This class should match one to one with vulkan instances
|
||||||
|
YaveVulkanSurface(const YaveVulkanSurface &) = delete;
|
||||||
|
YaveVulkanSurface &operator=(const YaveVulkanSurface &) = delete;
|
||||||
|
};
|
||||||
|
} // namespace yave
|
||||||
|
|
@ -27,6 +27,8 @@ public:
|
||||||
YaveWindow(int w, int h, std::string name);
|
YaveWindow(int w, int h, std::string name);
|
||||||
~YaveWindow();
|
~YaveWindow();
|
||||||
|
|
||||||
|
GLFWwindow *getGLFWWindow() { return window; }
|
||||||
|
|
||||||
// Tell apllicaton that the user has attempted to close the window
|
// Tell apllicaton that the user has attempted to close the window
|
||||||
bool shouldClose() { return glfwWindowShouldClose(window); }
|
bool shouldClose() { return glfwWindowShouldClose(window); }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
# CMake toolchain file
|
# CMake toolchain file
|
||||||
|
|
||||||
# linker flags
|
# linker flags
|
||||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--strip-debug")
|
#set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--strip-debug")
|
||||||
|
|
||||||
# cflags
|
# cflags
|
||||||
set(CMAKE_CXX_FLAGS_INIT "-ansi -Wall")
|
set(CMAKE_CXX_FLAGS_INIT "-ansi -Wall")
|
||||||
|
|
||||||
# cflags for debug build
|
# cflags for debug build
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g3 -ggdb3")
|
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g -ggdb")
|
||||||
|
|
||||||
# cflags for release build
|
# cflags for release build
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG -s")
|
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG -s")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue