source: opengl-game/game-gui-glfw.cpp@ 4eb4d0a

feature/imgui-sdl points-test
Last change on this file since 4eb4d0a was 4eb4d0a, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 5 years ago

Rename vulkan-game.cpp to vulkan-ref.cpp and define the GAMEGUI_INCLUDE_VULKAN preprocessor directive to control whether the gui-game classes build with Vulkan support

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#include "game-gui-glfw.hpp"
2
3bool GameGui_GLFW::Init() {
4 return glfwInit() == GLFW_TRUE ? RTWO_SUCCESS : RTWO_SUCCESS;
5}
6
7void GameGui_GLFW::Shutdown() {
8 glfwTerminate();
9}
10
11void* GameGui_GLFW::CreateWindow(const string& title, unsigned int width, unsigned int height) {
12 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
13
14 window = glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr);
15
16 return window;
17}
18
19void GameGui_GLFW::DestroyWindow() {
20 // TODO: This function can throw some errors. They should be handled
21 glfwDestroyWindow(window);
22}
23
24#ifdef GAMEGUI_INCLUDE_VULKAN
25
26bool GameGui_GLFW::CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) {
27 return glfwCreateWindowSurface(instance, window, nullptr, surface) == VK_SUCCESS ?
28 RTWO_SUCCESS : RTWO_ERROR;
29}
30
31#endif
32
33vector<const char*> GameGui_GLFW::GetRequiredExtensions() {
34 uint32_t glfwExtensionCount = 0;
35 const char** glfwExtensions;
36
37 glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
38
39 vector<const char*> extensions(glfwExtensions, glfwExtensions + glfwExtensionCount);
40
41 return extensions;
42}
43
44void GameGui_GLFW::GetWindowSize(int* width, int* height) {
45 glfwGetFramebufferSize(window, width, height);
46}
Note: See TracBrowser for help on using the repository browser.