Changeset f133da0 in opengl-game for opengl-game.cpp
- Timestamp:
- Sep 16, 2019, 2:09:05 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- c6fec84
- Parents:
- df2cc24
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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();
Note:
See TracChangeset
for help on using the changeset viewer.