Changeset a6f6833 in opengl-game
- Timestamp:
- Sep 15, 2019, 5:27:13 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 92cbc6a
- Parents:
- 09e15a4
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
game-gui-glfw.cpp
r09e15a4 ra6f6833 56 56 window = glfwCreateWindow(windowWidth, windowHeight, title.c_str(), mon, nullptr); 57 57 58 // TODO: I should check the window size after it's created to make sure it matches the requested size 59 // glfwGetFramebufferSize(window, width, height) segfaults on OSX, check other platforms 60 // I think glfwGetWindowSize(window, width, height) works fine. 61 58 62 glfwSetMouseButtonCallback(window, glfw_mouse_button_callback); 59 63 glfwSetKeyCallback(window, glfw_key_callback); … … 89 93 } 90 94 95 void GameGui_GLFW::refreshWindowSize() { 96 // glfwGetFramebufferSize(window, width, height) segfaults on OSX, check other platforms 97 // I think glfwGetWindowSize(window, width, height) works fine. 98 glfwGetWindowSize(window, &windowWidth, &windowHeight); 99 } 100 101 int GameGui_GLFW::getWindowWidth() { 102 return windowWidth; 103 } 104 105 int GameGui_GLFW::getWindowHeight() { 106 return windowHeight; 107 } 108 91 109 #ifdef GAMEGUI_INCLUDE_VULKAN 92 110 … … 95 113 RTWO_SUCCESS : RTWO_ERROR; 96 114 } 97 98 #endif99 115 100 116 vector<const char*> GameGui_GLFW::getRequiredExtensions() { … … 109 125 } 110 126 111 void GameGui_GLFW::getWindowSize(int* width, int* height) { 112 // This function segfaults on OSX, check other platforms 113 //glfwGetFramebufferSize(window, width, height); 114 115 *width = windowWidth; 116 *height = windowHeight; 117 } 127 #endif 118 128 119 129 void glfw_error_callback(int error, const char* description) { -
game-gui-glfw.hpp
r09e15a4 ra6f6833 8 8 #ifdef GAMEGUI_INCLUDE_VULKAN 9 9 #define GLFW_INCLUDE_VULKAN 10 #else 11 #include <GL/glew.h> 10 12 #endif 11 13 … … 30 32 int pollEvent(UIEvent* event); 31 33 34 void refreshWindowSize(); 35 int getWindowWidth(); 36 int getWindowHeight(); 37 32 38 #ifdef GAMEGUI_INCLUDE_VULKAN 33 39 bool createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface); 40 vector<const char*> getRequiredExtensions(); 34 41 #endif 35 36 vector<const char*> getRequiredExtensions();37 void getWindowSize(int* width, int* height);38 42 39 43 private: 40 44 GLFWwindow* window; 41 42 45 int windowWidth, windowHeight; 43 46 }; -
game-gui-sdl.cpp
r09e15a4 ra6f6833 61 61 SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 62 62 width, height, flags); 63 64 refreshWindowSize(); 63 65 64 66 return window; … … 125 127 } 126 128 129 void GameGui_SDL::refreshWindowSize() { 130 SDL_GetWindowSize(window, &windowWidth, &windowHeight); 131 } 132 133 int GameGui_SDL::getWindowWidth() { 134 return windowWidth; 135 } 136 137 int GameGui_SDL::getWindowHeight() { 138 return windowHeight; 139 } 140 127 141 #ifdef GAMEGUI_INCLUDE_VULKAN 128 142 … … 131 145 RTWO_SUCCESS : RTWO_ERROR; 132 146 } 133 134 #endif135 147 136 148 vector<const char*> GameGui_SDL::getRequiredExtensions() { … … 144 156 } 145 157 146 void GameGui_SDL::getWindowSize(int* width, int* height) { 147 SDL_GetWindowSize(window, width, height); 148 } 158 #endif -
game-gui-sdl.hpp
r09e15a4 ra6f6833 7 7 #include <SDL2/SDL_image.h> 8 8 #include <SDL2/SDL_ttf.h> 9 #include <SDL2/SDL_vulkan.h> 9 10 #ifdef GAMEGUI_INCLUDE_VULKAN 11 #include <SDL2/SDL_vulkan.h> 12 #endif 10 13 11 14 class GameGui_SDL : public GameGui { … … 22 25 int pollEvent(UIEvent* event); 23 26 27 void refreshWindowSize(); 28 int getWindowWidth(); 29 int getWindowHeight(); 30 24 31 #ifdef GAMEGUI_INCLUDE_VULKAN 25 32 bool createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface); 33 vector<const char*> getRequiredExtensions(); 26 34 #endif 27 28 vector<const char*> getRequiredExtensions();29 void getWindowSize(int* width, int* height);30 35 31 36 private: 32 37 SDL_Window* window; 38 int windowWidth, windowHeight; 33 39 34 40 static string s_errorMessage; -
game-gui.hpp
r09e15a4 ra6f6833 67 67 virtual int pollEvent(UIEvent* event) = 0; 68 68 69 /* 70 virtual void processEvents() = 0; 71 72 virtual int pollMouseEvent(MouseEvent* event) = 0; 73 74 virtual unsigned char getKeyEvent(unsigned int key) = 0; 75 virtual bool isKeyPressed(unsigned int key) = 0; 76 */ 69 virtual void refreshWindowSize() = 0; 70 virtual int getWindowWidth() = 0; 71 virtual int getWindowHeight() = 0; 77 72 78 73 #ifdef GAMEGUI_INCLUDE_VULKAN 79 74 virtual bool createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) = 0; 75 virtual vector<const char*> getRequiredExtensions() = 0; 80 76 #endif 81 82 virtual vector<const char*> getRequiredExtensions() = 0;83 virtual void getWindowSize(int* width, int* height) = 0;84 77 }; 85 78 -
opengl-game.cpp
r09e15a4 ra6f6833 66 66 } 67 67 68 int actualWidth=0, actualHeight=0;69 gui->getWindowSize(&actualWidth, &actualHeight);70 71 68 cout << "Target window size: (" << width << ", " << height << ")" << endl; 72 cout << "Actual window size: (" << actualWidth << ", " << actualHeight<< ")" << endl;69 cout << "Actual window size: (" << gui->getWindowWidth() << ", " << gui->getWindowHeight() << ")" << endl; 73 70 74 71 return RTWO_SUCCESS; -
vulkan-game.cpp
r09e15a4 ra6f6833 78 78 } 79 79 80 int actualWidth, actualHeight;81 gui->getWindowSize(&actualWidth, &actualHeight);82 83 80 cout << "Target window size: (" << width << ", " << height << ")" << endl; 84 cout << "Actual window size: (" << actualWidth << ", " << actualHeight<< ")" << endl;81 cout << "Actual window size: (" << gui->getWindowWidth() << ", " << gui->getWindowHeight() << ")" << endl; 85 82 86 83 return RTWO_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.