Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
MirrorView.h
Go to the documentation of this file.
1#pragma once
2#include <GLFW/glfw3.h>
3#include <vector>
4
5namespace EngineCore {
6 class Renderer;
7 class Headset;
9}
10
11namespace EngineCore {
12
21 class MirrorView {
22 public:
25
35 void connect(const Headset* headset, const Renderer* renderer);
36
43 void cleanup();
44
48 struct RenderResult {
49 enum class Status { Visible, Invisible, Error };
51 VkSemaphore imageAvailableSemaphore = VK_NULL_HANDLE; // This will hold the semaphore
52 };
53
64 MirrorView::RenderResult render(uint32_t swapchainImageIndex);
65
66 void present();
67 private:
68
79 static void framebufferResizeCallback(GLFWwindow* window, int width, int height);
80
93 static void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
94
104 static void iconifyCallback(GLFWwindow* window, int iconified);
105
106 // the surface to display the rendered images on
107 VkSurfaceKHR mirrorSurface = nullptr;
108
112 VkSwapchainKHR swapchain = nullptr;
113
114 // true when the window has been resized.
116
117 // true when the window has been restored from minimized state
118 static bool hasBeenRestored;
119
120 // The pointer to the window. nullptr if it does not exist yet
121 GLFWwindow* window = nullptr;
122
123 const Headset* headset = nullptr;
124 const Renderer* renderer = nullptr;
125
129 VkExtent2D swapchainResolution = { 0u, 0u };
130
135
138 uint32_t xrSwapchainImageIndex = 0u; // XR swapchain index for semaphore lookup
139
140 public:
141
150 VkSurfaceKHR getSurface() const;
151
160 GLFWwindow* getGlfwWindow() const;
161 private:
162
166 std::vector<VkImage> mirrorSwapchainImages;
167
174 void recreateSwapchain();
175 };
176}
The application context is the core class which stores the basic openxr and vulkan objects.
void connect(const Headset *headset, const Renderer *renderer)
Connects the mirror view to the headset pointer and the renderer pointer.
const Renderer * renderer
Definition MirrorView.h:124
void recreateSwapchain()
Recreates the swapchain. Can be called when no swapchain exists yet to create one.
VkSurfaceKHR mirrorSurface
Definition MirrorView.h:107
MirrorView::RenderResult render(uint32_t swapchainImageIndex)
Renders the given swapchainImageIndex.
static bool hasBeenRestored
Definition MirrorView.h:118
uint32_t mirrorDestinationImageIndex
Definition MirrorView.h:137
uint32_t xrSwapchainImageIndex
Definition MirrorView.h:138
VkSwapchainKHR swapchain
The swapchain on which the images to display are swapped.
Definition MirrorView.h:112
void cleanup()
Cleanup resources allocated by MirrorView.
static bool hasWindowBeenResized
Definition MirrorView.h:115
ApplicationContext * context
A pointer to the engines application context.
Definition MirrorView.h:134
GLFWwindow * getGlfwWindow() const
Gets glfw window.
VkSurfaceKHR getSurface() const
Gets the surface.
static void iconifyCallback(GLFWwindow *window, int iconified)
Callback, called when the window gets minimized or gets unfocused.
static void framebufferResizeCallback(GLFWwindow *window, int width, int height)
Callback, called when the framebuffer gets resized. Aka the window gets resized.
const Headset * headset
Definition MirrorView.h:123
MirrorView(ApplicationContext *context=nullptr)
VkExtent2D swapchainResolution
The swapchain resolution.
Definition MirrorView.h:129
static void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
Callback, called when glfw detects a key press.
std::vector< VkImage > mirrorSwapchainImages
The mirror swapchain images.
Definition MirrorView.h:166
The renderer is the main class for rendering. It owns all data which is used any time in any frame....
Definition Renderer.h:72
Log category system implementation.
Values that represent mirror view render results.
Definition MirrorView.h:48