1 | #include "game-gui-glfw.hpp"
|
---|
2 |
|
---|
3 | bool GameGui_GLFW::Init() {
|
---|
4 | return glfwInit() == GLFW_TRUE ? RTWO_SUCCESS : RTWO_SUCCESS;
|
---|
5 | }
|
---|
6 |
|
---|
7 | void GameGui_GLFW::Shutdown() {
|
---|
8 | glfwTerminate();
|
---|
9 | }
|
---|
10 |
|
---|
11 | void* 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 |
|
---|
19 | void GameGui_GLFW::DestroyWindow() {
|
---|
20 | // TODO: This function can throw some errors. They should be handled
|
---|
21 | glfwDestroyWindow(window);
|
---|
22 | }
|
---|
23 |
|
---|
24 | bool GameGui_GLFW::CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) {
|
---|
25 | return glfwCreateWindowSurface(instance, window, nullptr, surface) == VK_SUCCESS ?
|
---|
26 | RTWO_SUCCESS : RTWO_ERROR;
|
---|
27 | }
|
---|
28 |
|
---|
29 | vector<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 |
|
---|
40 | void GameGui_GLFW::GetWindowSize(int* width, int* height) {
|
---|
41 | glfwGetFramebufferSize(window, width, height);
|
---|
42 | }
|
---|