Changeset 7fc5e27 in opengl-game for game-gui-glfw.cpp
- Timestamp:
- Sep 3, 2019, 7:07:39 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- b6e60b4
- Parents:
- 1ce9afe
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
game-gui-glfw.cpp
r1ce9afe r7fc5e27 11 11 bool GameGui_GLFW::s_keyDown[NUM_KEYS]; 12 12 13 string& GameGui_GLFW:: GetError() {13 string& GameGui_GLFW::getError() { 14 14 return GameGui_GLFW::s_errorMessage; 15 15 } 16 16 17 bool GameGui_GLFW:: Init() {17 bool GameGui_GLFW::init() { 18 18 GameGui_GLFW::s_errorMessage = "No error"; 19 19 glfwSetErrorCallback(glfw_error_callback); 20 21 windowWidth = -1; 22 windowHeight = -1; 20 23 21 24 return glfwInit() == GLFW_TRUE ? RTWO_SUCCESS : RTWO_ERROR; 22 25 } 23 26 24 void GameGui_GLFW:: Shutdown() {27 void GameGui_GLFW::shutdown() { 25 28 glfwTerminate(); 26 29 } 27 30 28 void* GameGui_GLFW:: CreateWindow(const string& title, unsigned int width, unsignedint height, bool fullscreen) {31 void* GameGui_GLFW::createWindow(const string& title, int width, int height, bool fullscreen) { 29 32 GLFWwindow* window = nullptr; 30 33 GLFWmonitor* mon = nullptr; … … 49 52 const GLFWvidmode* vmode = glfwGetVideoMode(mon); 50 53 51 width = vmode->width; 52 height = vmode->height; 53 54 // TODO: Should probably enable some way to retrieve this from outside this class 55 // and print it out there 56 cout << "Fullscreen resolution " << vmode->width << "x" << vmode->height << endl; 54 windowWidth = vmode->width; 55 windowHeight = vmode->height; 56 } else { 57 windowWidth = width; 58 windowHeight = height; 57 59 } 58 60 59 window = glfwCreateWindow(wi dth, height, title.c_str(), mon, nullptr);61 window = glfwCreateWindow(windowWidth, windowHeight, title.c_str(), mon, nullptr); 60 62 //glfwMakeContextCurrent(window); 61 63 … … 68 70 } 69 71 70 void GameGui_GLFW:: DestroyWindow() {72 void GameGui_GLFW::destroyWindow() { 71 73 // TODO: This function can throw some errors. They should be handled 72 74 glfwDestroyWindow(window); … … 75 77 #ifdef GAMEGUI_INCLUDE_VULKAN 76 78 77 bool GameGui_GLFW:: CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) {79 bool GameGui_GLFW::createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) { 78 80 return glfwCreateWindowSurface(instance, window, nullptr, surface) == VK_SUCCESS ? 79 81 RTWO_SUCCESS : RTWO_ERROR; … … 82 84 #endif 83 85 84 vector<const char*> GameGui_GLFW:: GetRequiredExtensions() {86 vector<const char*> GameGui_GLFW::getRequiredExtensions() { 85 87 uint32_t glfwExtensionCount = 0; 86 88 const char** glfwExtensions; … … 93 95 } 94 96 95 void GameGui_GLFW::GetWindowSize(int* width, int* height) { 96 glfwGetFramebufferSize(window, width, height); 97 void GameGui_GLFW::getWindowSize(int* width, int* height) { 98 // This function segfaults on OSX, check other platforms 99 //glfwGetFramebufferSize(window, width, height); 100 101 *width = windowWidth; 102 *height = windowHeight; 97 103 } 98 104
Note:
See TracChangeset
for help on using the changeset viewer.