source: opengl-game/game-gui-glfw.cpp@ 8667f76

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

Move getWindowSize and getRequiredExtensions to the game gui

  • 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
24bool GameGui_GLFW::CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) {
25 return glfwCreateWindowSurface(instance, window, nullptr, surface) == VK_SUCCESS ?
26 RTWO_SUCCESS : RTWO_ERROR;
27}
28
29vector<const char*> GameGui_GLFW::GetRequiredExtensions() {
30 uint32_t glfwExtensionCount = 0;
31 const char** glfwExtensions;
32
33 glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
34
35 vector<const char*> extensions(glfwExtensions, glfwExtensions + glfwExtensionCount);
36
37 return extensions;
38}
39
40void GameGui_GLFW::GetWindowSize(int* width, int* height) {
41 glfwGetFramebufferSize(window, width, height);
42}
Note: See TracBrowser for help on using the repository browser.