Changeset f133da0 in opengl-game
- Timestamp:
- Sep 16, 2019, 2:09:05 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- c6fec84
- Parents:
- df2cc24
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
game-gui-glfw.cpp
rdf2cc24 rf133da0 60 60 // I think glfwGetWindowSize(window, width, height) works fine. 61 61 62 return window; 63 } 64 65 void GameGui_GLFW::bindEventHandlers() { 62 66 glfwSetMouseButtonCallback(window, glfw_mouse_button_callback); 63 67 glfwSetKeyCallback(window, glfw_key_callback); 64 65 return window;66 68 } 67 69 -
game-gui-glfw.hpp
rdf2cc24 rf133da0 29 29 void destroyWindow(); 30 30 31 void bindEventHandlers(); 31 32 void processEvents(); 32 33 int pollEvent(UIEvent* event); -
new-game.cpp
rdf2cc24 rf133da0 397 397 cout << "MAX_UNIFORMS: " << MAX_UNIFORMS << endl; 398 398 399 /*** START OF REFACTORED CODE ***/ 399 400 // Setup Dear ImGui binding 400 401 IMGUI_CHECKVERSION(); … … 411 412 glfwSetMouseButtonCallback(window, mouse_button_callback); 412 413 glfwSetKeyCallback(window, key_callback); 414 /*** END OF REFACTORED CODE ***/ 413 415 414 416 glfwSetWindowSizeCallback(window, window_size_callback); … … 2446 2448 } 2447 2449 2450 /*** START OF REFACTORED CODE ***/ 2448 2451 void renderMainMenuGui() { 2449 2452 ImGui_ImplGlfwGL3_NewFrame(); … … 2478 2481 ImGui_ImplGlfwGL3_RenderDrawData(ImGui::GetDrawData()); 2479 2482 } 2483 /*** END OF REFACTORED CODE ***/ 2480 2484 2481 2485 void initGuiValueLists(map<string, vector<UIValue>> valueLists) { -
opengl-game.cpp
rdf2cc24 rf133da0 87 87 cout << "OpenGL debug message callback is not supported" << endl; 88 88 } 89 90 // Setup Dear ImGui binding 91 IMGUI_CHECKVERSION(); 92 ImGui::CreateContext(); 93 ImGuiIO& io = ImGui::GetIO(); (void)io; 94 //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls 95 //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls 96 ImGui_ImplGlfwGL3_Init(window, true); 97 98 // Setup style 99 ImGui::StyleColorsDark(); 100 //ImGui::StyleColorsClassic(); 101 102 // The glfw event handlers have to be bound after ImGui is initialized. 103 // Otherwise, it seems they get overridden by ImGui 104 ((GameGui_GLFW*)gui)->bindEventHandlers(); 89 105 } 90 106 … … 103 119 break; 104 120 case UI_EVENT_KEY: 121 cout << "Got a key event" << endl; 105 122 if (e.key.keycode == GLFW_KEY_ESCAPE) { 106 123 quit = true; … … 121 138 //glViewport(0, 0, gui->getWindowWidth(), gui->getWindowHeight()); 122 139 140 renderScene(); 141 renderUI(); 142 123 143 glfwSwapBuffers(window); 124 144 } 125 145 } 126 146 147 void OpenGLGame::renderScene() { 148 149 } 150 151 void OpenGLGame::renderUI() { 152 ImGui_ImplGlfwGL3_NewFrame(); 153 154 { 155 int padding = 4; 156 ImGui::SetNextWindowPos(ImVec2(-padding, -padding), ImGuiCond_Once); 157 ImGui::SetNextWindowSize(ImVec2(gui->getWindowWidth() + 2 * padding, gui->getWindowHeight() + 2 * padding), ImGuiCond_Always); 158 ImGui::Begin("WndMain", NULL, 159 ImGuiWindowFlags_NoTitleBar | 160 ImGuiWindowFlags_NoResize | 161 ImGuiWindowFlags_NoMove); 162 163 ImGui::InvisibleButton("", ImVec2(10, 80)); 164 ImGui::InvisibleButton("", ImVec2(285, 18)); 165 ImGui::SameLine(); 166 ImGui::Button("New Game"); 167 168 ImGui::InvisibleButton("", ImVec2(10, 15)); 169 ImGui::InvisibleButton("", ImVec2(300, 18)); 170 ImGui::SameLine(); 171 ImGui::Button("Quit"); 172 173 ImGui::End(); 174 } 175 176 ImGui::Render(); 177 ImGui_ImplGlfwGL3_RenderDrawData(ImGui::GetDrawData()); 178 } 179 127 180 void OpenGLGame::cleanup() { 181 ImGui_ImplGlfwGL3_Shutdown(); 182 ImGui::DestroyContext(); 183 128 184 gui->destroyWindow(); 129 185 gui->shutdown(); -
opengl-game.hpp
rdf2cc24 rf133da0 1 1 #ifndef _OPENGL_GAME_H 2 2 #define _OPENGL_GAME_H 3 4 #include "IMGUI/imgui.h" 5 #include "imgui_impl_glfw_gl3.h" 3 6 4 7 #include "game-gui-glfw.hpp" … … 18 21 void initOpenGL(); 19 22 void mainLoop(); 23 void renderScene(); 24 void renderUI(); 20 25 void cleanup(); 21 26 };
Note:
See TracChangeset
for help on using the changeset viewer.