27 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
28 glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
29 glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE);
30 glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
33 window = glfwCreateWindow(WIDTH, HEIGHT,
"Vulkan",
nullptr,
nullptr);
36 glfwSetWindowUserPointer(window,
this);
40 auto func = [](GLFWwindow* w, int, int)
45 glfwSetFramebufferSizeCallback(window, func);
47 auto funKey = [](GLFWwindow* w,
int key,
int scancode,
int action,
int mods) {
50 glfwSetKeyCallback(window, funKey);
64 vk::SemaphoreCreateInfo semaphoreInfo;
65 for (
auto& sem : renderingFinnishedSemaphore) {
72 glfwDestroyWindow(window);
78 for (
auto& sem : renderingFinnishedSemaphore) {
85 vkDestroySurfaceKHR(instance, surface,
nullptr);
91 while (!glfwWindowShouldClose(window)) {
106 std::optional<vk::Semaphore> imageAvailableSemaphore;
108 std::tie(index, imageAvailableSemaphore) =
swapchains[i]->acquireImage();
109 std::tuple <int, uint32_t> idImage(i, index);
110 std::vector<vk::Semaphore> semaphores;
111 std::vector<vk::Semaphore> signalSemaphore = { renderingFinnishedSemaphore[index] };
112 if (imageAvailableSemaphore.has_value()) {
113 semaphores.push_back(imageAvailableSemaphore.value());
115 vulkanDrawing->
submitDrawCall(idImage, semaphores , signalSemaphore);
116 swapchains[i]->presentImage(index, renderingFinnishedSemaphore[index]);
118 catch (vk::OutOfDateKHRError) {
119 std::cout <<
"test " <<
"ahhh" << std::endl;
129 throw std::runtime_error(
"failed to create window surface!");
135 uint32_t glfwExtensionCount = 0;
136 const char** glfwExtensions;
137 glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
139 std::vector<const char*> extensions(glfwExtensions, glfwExtensions + glfwExtensionCount);
142 extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
149 VkBool32 presentSupport =
false;
150 vkGetPhysicalDeviceSurfaceSupportKHR(device, i, surface, &presentSupport);
151 return presentSupport;
156 return deviceExtensions;
162 details.
capabilities = device.getSurfaceCapabilitiesKHR(surface);
164 details.
formats = device.getSurfaceFormatsKHR(surface);
166 details.
presentModes = device.getSurfacePresentModesKHR(surface);
172 int width = 0, height = 0;
173 glfwGetFramebufferSize(window, &width, &height);
174 while (width == 0 || height == 0) {
175 glfwGetFramebufferSize(window, &width, &height);
182 glfwGetFramebufferSize(window, w, h);
194 PRINT(
"\n \n----------------------------------------------");
195 std::cout <<
"To navigate in the scene use:" << std::endl;
196 std::cout <<
"----Translation----" << std::endl;
197 std::cout <<
"Up: " <<
"Up arrow" <<
"\t" <<
"Down: " <<
"Down arrow" << std::endl;
198 std::cout <<
"Left: " <<
"Left arrow" <<
"\t" <<
"Right: " <<
"Right arrow" << std::endl;
199 std::cout <<
"Forward: " <<
"Page Up" <<
"\t" <<
"Backward:" <<
"Page Down" << std::endl;
200 std::cout <<
"----Rotation-------" << std::endl;
201 const char* upRotKey = glfwGetKeyName(GLFW_KEY_W, 0);
202 const char* downRotKey = glfwGetKeyName(GLFW_KEY_S, 0);
203 std::cout <<
"Pitch Up: " << upRotKey <<
"\t" <<
"Pitch Down: " << downRotKey << std::endl;
204 const char* leftRotKey = glfwGetKeyName(GLFW_KEY_A, 0);
205 const char* rightRotKey = glfwGetKeyName(GLFW_KEY_D, 0);
206 std::cout <<
"Yaw Left: " << leftRotKey <<
"\t" <<
"Yaw Right: " << rightRotKey << std::endl;
207 const char* rollKey = glfwGetKeyName(GLFW_KEY_Q, 0);
208 const char* rollClockKey = glfwGetKeyName(GLFW_KEY_E, 0);
209 std::cout <<
"Roll conterclockwise: " << rollKey <<
"\t" <<
"roll clockwise: " << rollClockKey << std::endl;
210 const char* reset = glfwGetKeyName(GLFW_KEY_0, 0);
211 PRINT(
"Reset the view: %s (0)", reset);
212 std::cout <<
"-------------\n" << std::endl;
213 std::cout <<
"To exit press: ESC" << std::endl;
214 std::cout <<
"-------------\n" << std::endl;
215 std::cout <<
"To enter/exit manual calibration mode: F1" << std::endl;
216 std::cout <<
"Save correction calibration to disk: F2" << std::endl;
217 std::cout <<
"Load correction calibration to disk: F3" << std::endl;
218 const char* oneCam = glfwGetKeyName(GLFW_KEY_1, 0);
219 const char* twoCam = glfwGetKeyName(GLFW_KEY_2, 0);
220 const char* threeCam = glfwGetKeyName(GLFW_KEY_3, 0);
221 PRINT(
"---Select a camera---\n camera 1, 2, 3 : %s (1), %s (2), %s (3) ", oneCam, twoCam, threeCam);
222 const char* refCam = glfwGetKeyName(GLFW_KEY_GRAVE_ACCENT, 0);
223 PRINT(
"Reference camera (camera 0): %s",refCam);
224 PRINT(
"--Adjust rotation--\n %s %s (roll), %s %s (yaw), %s %s (pitch)",
225 rollKey,rollClockKey,leftRotKey,rightRotKey,upRotKey,downRotKey);
227 const char* t1 = glfwGetKeyName(GLFW_KEY_I, 0);
228 const char* t1b = glfwGetKeyName(GLFW_KEY_K, 0);
229 const char* t2 = glfwGetKeyName(GLFW_KEY_J, 0);
230 const char* t2b = glfwGetKeyName(GLFW_KEY_L, 0);
231 const char* t3 = glfwGetKeyName(GLFW_KEY_U, 0);
232 const char* t3b = glfwGetKeyName(GLFW_KEY_O, 0);
233 PRINT(
"--Adjust translation--\n %s %s (left/right), %s %s (up/down), %s %s (forward/backward)", t2,t2b,t1,t1b,t3,t3b);
235 const char* p1 = glfwGetKeyName(GLFW_KEY_T, 0);
236 const char* p1b = glfwGetKeyName(GLFW_KEY_G, 0);
237 const char* p2 = glfwGetKeyName(GLFW_KEY_Y, 0);
238 const char* p2b = glfwGetKeyName(GLFW_KEY_H, 0);
239 PRINT(
"--Adjust principal pt--\n %s %s (x axis), %s %s (y axis)", p1, p1b, p2, p2b);
241 const char* f1 = glfwGetKeyName(GLFW_KEY_Z, 0);
242 const char* f1b = glfwGetKeyName(GLFW_KEY_X, 0);
243 const char* f2 = glfwGetKeyName(GLFW_KEY_C, 0);
244 const char* f2b = glfwGetKeyName(GLFW_KEY_V, 0);
245 PRINT(
"--Adjust focal--\n %s %s (x axis), %s %s (y axis)", f1, f1b, f2, f2b);
248 const char* plusStep = glfwGetKeyName(GLFW_KEY_EQUAL, 0);
249 const char* minusStep = glfwGetKeyName(GLFW_KEY_MINUS, 0);
250 PRINT(
"---To adjust the step---\n multiply by 2: %s \t divide by 2: %s ",plusStep,minusStep);
251 PRINT(
"Print current correction: space bar");
252 PRINT(
"Enable/Disable selected camera: F4");
253 PRINT(
"----------------------------------------------\n\n");
258 const float delta = 0.004;
259 const float deltaRot = 0.2;
260 const int inputAction = GLFW_REPEAT;
262 if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
263 glfwSetWindowShouldClose(window, GL_TRUE);
266 if (key == GLFW_KEY_F1 && action == GLFW_PRESS) {
269 std::cout <<
"Qualibration Mode is turn ON" << std::endl;
272 std::cout <<
"Qualibration Mode is turn OFF" << std::endl;
276 if (key == GLFW_KEY_F2 && action == GLFW_PRESS) {
279 if (key == GLFW_KEY_F3 && action == GLFW_PRESS) {
284 if (key == GLFW_KEY_LEFT && action == inputAction) {
288 else if (key == GLFW_KEY_RIGHT && action == inputAction) {
292 else if (key == GLFW_KEY_UP && action == inputAction) {
296 else if (key == GLFW_KEY_DOWN && action == inputAction) {
300 else if (key == GLFW_KEY_PAGE_UP && action == inputAction) {
304 else if (key == GLFW_KEY_PAGE_DOWN && action == inputAction) {
308 else if (key == GLFW_KEY_Q && action == inputAction) {
312 else if (key == GLFW_KEY_E && action == inputAction) {
316 else if (key == GLFW_KEY_W && action == inputAction) {
320 else if (key == GLFW_KEY_S && action == inputAction) {
324 else if (key == GLFW_KEY_A && action == inputAction) {
328 else if (key == GLFW_KEY_D && action == inputAction) {
332 else if (key == GLFW_KEY_SPACE && action == GLFW_PRESS)
334 std::cout <<
"current rotation (Openxr Space): " << glm::to_string(
currentRotation) << std::endl;
335 std::cout <<
"current translation (Openxr Space): " << glm::to_string(
currentTranslation) << std::endl << std::endl;
337 else if ((key == GLFW_KEY_0 || key == GLFW_KEY_KP_0) && action == GLFW_PRESS) {
343 glm::vec3 deltaQualR = {0,0,0};
344 glm::vec3 deltaQualT = { 0,0,0 };
345 glm::vec2 deltaQualF = { 0,0 };
346 glm::vec2 deltaQualP = { 0,0 };
348 if (key == GLFW_KEY_F4 && action == GLFW_PRESS) {
350 std::cout <<
"No camera selected" << std::endl;
357 else if (key == GLFW_KEY_GRAVE_ACCENT && action == GLFW_PRESS) {
358 std::cout <<
"select Camera 0" << std::endl;
361 else if (key == GLFW_KEY_1 && action == GLFW_PRESS) {
362 std::cout <<
"select Camera 1" << std::endl;
365 else if (key == GLFW_KEY_2 && action == GLFW_PRESS) {
366 std::cout <<
"select Camera 2" << std::endl;
369 else if (key == GLFW_KEY_3 && action == GLFW_PRESS) {
370 std::cout <<
"select Camera 3" << std::endl;
373 else if (key == GLFW_KEY_EQUAL && action == GLFW_PRESS) {
374 deltaValueCalibration *= 2;
376 else if (key == GLFW_KEY_MINUS && action == GLFW_PRESS) {
377 deltaValueCalibration /= 2;
379 else if (key == GLFW_KEY_SPACE && action == GLFW_PRESS){
380 PRINT(
"Current step %f", deltaValueCalibration);
382 for (
int i = 0; i < corrections.size(); i++) {
383 std::cout <<
"Correction for camera " << i <<
" (OMAF space) : " << glm::to_string(corrections[i]) << std::endl;
385 std::cout << std::endl;
387 else if (action == GLFW_PRESS) {
391 deltaQualR[2] -= deltaValueCalibration;
395 deltaQualR[2] += deltaValueCalibration;
399 deltaQualR[1] -= deltaValueCalibration;
403 deltaQualR[1] += deltaValueCalibration;
407 deltaQualR[0] += deltaValueCalibration;
411 deltaQualR[0] -= deltaValueCalibration;
416 deltaQualT[2] -= 0.1 * deltaValueCalibration;
420 deltaQualT[2] += 0.1 * deltaValueCalibration;
424 deltaQualT[1] += 0.1 * deltaValueCalibration;
428 deltaQualT[1] -= 0.1 * deltaValueCalibration;
432 deltaQualT[0] += 0.1 * deltaValueCalibration;
436 deltaQualT[0] -= 0.1 *deltaValueCalibration;
442 deltaQualP[0] += 10 * deltaValueCalibration;
446 deltaQualP[0] -= 10 * deltaValueCalibration;
450 deltaQualP[1] += 10 * deltaValueCalibration;
454 deltaQualP[1] -= 10 * deltaValueCalibration;
461 deltaQualF[0] += 20 * deltaValueCalibration;
465 deltaQualF[0] -= 20 * deltaValueCalibration;
469 deltaQualF[1] += 20 * deltaValueCalibration;
473 deltaQualF[1] -= 20 * deltaValueCalibration;
479 if (deltaQualR.x != 0 || deltaQualR.y != 0 || deltaQualR.z != 0) {
482 else if (deltaQualT.x != 0 || deltaQualT.y != 0 || deltaQualT.z != 0) {
485 else if (deltaQualP.x != 0 || deltaQualP.y != 0 ) {
488 else if (deltaQualF.x != 0 || deltaQualF.y != 0) {
505#ifdef HVT_UDP_CONTROL
510#ifdef HVT_UDP_CONTROL
Encapsulate the vkSwapchainKHR object and the operations linked to it. Inherit from SwapchainAbstract...
File that contain the VulkanContext class to manage Vulkan Instance, Physical device,...
file that contains the VulkanWrapper class that manages the classes related to Vulkan code and ease t...
Contains the class that represents a window created with the GLFW library.
Class that encapsulate a vkSwapchainHHR object and the methods linked to it.
The class that manages the drawing operation (manage and record command buffers).
vk::Fence submitDrawCall(std::tuple< int, uint32_t > idImage, const std::vector< vk::Semaphore > &imageAvailableSemaphores, std::vector< vk::Semaphore > &signalSemaphore, uint32_t depthIndex=UINT_MAX)
void loadConfigurationsFromDisk()
void setCorrectionTranslation(int camId, glm::vec3 translationCorrection)
void saveConfigurationsToDisk()
void setCorrectionFocal(int camId, glm::vec2 focals)
void setCorrectionPrincipalPt(int camId, glm::vec2 principalPt)
const std::vector< glm::vec3 > getCorrectionVectorRotation()
void updateSpaceTransform(glm::vec3 translation, glm::vec3 rotation)
std::vector< bool > getCameraActivation()
void setCorrectionRotation(int camId, glm::vec3 rotationCorrection)
glm::vec3 currentTranslation
glm::vec3 currentRotation
bool separateFromWindowDim
std::vector< std::unique_ptr< SwapchainAbstract > > swapchains
const bool enableValidationLayers
The class that represents a window created with the GLFW library.
void framebufferResizeCallback()
void checkForCorrectSize() override
void getFrameBufferSize(int *w, int *h, vk::PhysicalDevice &pDevice) override
VkBool32 isDeviceSupportingSufaceKHR(VkPhysicalDevice device, int i) override
void createSurface() override
std::vector< const char * > getRequiredExtensions() override
void mainLoop(VulkanDrawing *vulkanDrawing) override
void inputKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mode)
void continueInit() override
void cleanUpSurface() override
bool isSynchroWithSemaphore() override
std::vector< const char * > getRequiredDeviceExtensions() override
void printInputCommands()
SwapChainSupportDetails querySwapChainSupport(vk::PhysicalDevice device) override
void initWindow() override
void resetOrigin() override
Struct that contains the capability for the sapchain, the formats and the present mode supported.
vk::SurfaceCapabilitiesKHR capabilities
std::vector< vk::SurfaceFormatKHR > formats
std::vector< vk::PresentModeKHR > presentModes