Changeset 5b3462b in opengl-game for new-game.cpp
- Timestamp:
- May 8, 2018, 2:54:09 AM (7 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- f0cc877
- Parents:
- 1c81bf0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
new-game.cpp
r1c81bf0 r5b3462b 69 69 float NEAR_CLIP = 0.1f; 70 70 float FAR_CLIP = 100.0f; 71 72 // Should really have some array or struct of UI-related variables 73 bool isRunning = true; 71 74 72 75 ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); … … 518 521 //glfwSwapInterval(0); 519 522 520 while (!glfwWindowShouldClose(window) ) {523 while (!glfwWindowShouldClose(window) && isRunning) { 521 524 double current_seconds = glfwGetTime(); 522 525 double elapsed_seconds = current_seconds - previous_seconds; … … 813 816 814 817 void renderGui() { 815 bool show_demo_window = true;816 bool show_another_window = true;817 818 818 ImGui_ImplGlfwGL3_NewFrame(); 819 819 820 820 // 1. Show a simple window. 821 821 // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug". 822 /* 822 823 { 823 824 static float f = 0.0f; … … 837 838 ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); 838 839 } 839 840 // 2. Show another simple window. In most cases you will use an explicit Begin/End pair to name your windows. 841 if (show_another_window) { 842 ImGui::Begin("Another Window", &show_another_window); 843 ImGui::Text("Hello from another window!"); 844 if (ImGui::Button("Close Me")) 845 show_another_window = false; 840 */ 841 842 { 843 ImGui::SetNextWindowSize(ImVec2(85, 22), ImGuiCond_Once); 844 ImGui::SetNextWindowPos(ImVec2(10, 50), ImGuiCond_Once); 845 ImGui::Begin("WndStats", NULL, ImGuiWindowFlags_NoTitleBar | 846 ImGuiWindowFlags_NoResize | 847 ImGuiWindowFlags_NoMove); 848 ImGui::Text("Score: ???"); 846 849 ImGui::End(); 847 850 } 848 851 849 // 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui! 850 if (show_demo_window) { 851 ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver); // Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly! 852 ImGui::ShowDemoWindow(&show_demo_window); 852 { 853 ImGui::SetNextWindowPos(ImVec2(380, 10), ImGuiCond_Once); 854 ImGui::SetNextWindowSize(ImVec2(250, 35), ImGuiCond_Once); 855 ImGui::Begin("WndMenubar", NULL, ImGuiWindowFlags_NoTitleBar | 856 ImGuiWindowFlags_NoResize | 857 ImGuiWindowFlags_NoMove); 858 ImGui::InvisibleButton("", ImVec2(190, 18)); 859 ImGui::SameLine(); 860 if (ImGui::Button("Quit")) { 861 isRunning = false; 862 } 863 ImGui::End(); 853 864 } 854 865
Note:
See TracChangeset
for help on using the changeset viewer.