Changeset 85b5fec in opengl-game
- Timestamp:
- Mar 14, 2021, 2:10:20 AM (3 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- 7865c5b
- Parents:
- d255d52
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
VulkanGame.vcxproj
rd255d52 r85b5fec 143 143 <ClCompile Include="game-gui-sdl.cpp" /> 144 144 <ClCompile Include="gui\imgui\button-imgui.cpp" /> 145 <ClCompile Include="gui\imgui\ui-w dget.cpp" />145 <ClCompile Include="gui\imgui\ui-widget.cpp" /> 146 146 <ClCompile Include="IMGUI\imgui.cpp" /> 147 147 <ClCompile Include="IMGUI\imgui_demo.cpp" /> -
VulkanGame.vcxproj.filters
rd255d52 r85b5fec 32 32 <Filter>IMGUI SDL Reference</Filter> 33 33 </ClCompile> 34 <ClCompile Include="gui\imgui\ui-w dget.cpp">34 <ClCompile Include="gui\imgui\ui-widget.cpp"> 35 35 <Filter>gui\imgui</Filter> 36 36 </ClCompile> -
sdl-game.cpp
rd255d52 r85b5fec 8 8 9 9 #include "logger.hpp" 10 11 #include "gui/imgui/button-imgui.hpp" 10 12 11 13 using namespace std; … … 343 345 ImGui::NewFrame(); 344 346 345 (this->*currentRenderScreenFn)( );347 (this->*currentRenderScreenFn)(gui->getWindowWidth(), gui->getWindowHeight()); 346 348 347 349 ImGui::Render(); … … 1009 1011 } 1010 1012 1011 void VulkanGame::renderMainScreen() { 1012 unsigned int windowWidth = 640; 1013 unsigned int windowHeight = 480; 1014 1013 void VulkanGame::renderMainScreen(int width, int height) { 1015 1014 { 1016 1015 int padding = 4; 1017 ImGui::SetNextWindowPos( ImVec2(-padding, -padding), ImGuiCond_Once);1018 ImGui::SetNextWindowSize( ImVec2(windowWidth + 2 * padding, windowHeight + 2 * padding), ImGuiCond_Always);1016 ImGui::SetNextWindowPos(vec2(-padding, -padding), ImGuiCond_Once); 1017 ImGui::SetNextWindowSize(vec2(width + 2 * padding, height + 2 * padding), ImGuiCond_Always); 1019 1018 ImGui::Begin("WndMain", nullptr, 1020 1019 ImGuiWindowFlags_NoTitleBar | … … 1022 1021 ImGuiWindowFlags_NoMove); 1023 1022 1024 ImGui::InvisibleButton("", ImVec2(10, 80));1025 ImGui::InvisibleButton("", ImVec2(285, 18)); 1026 ImGui:: SameLine();1027 if ( ImGui::Button("New Game")) {1023 ButtonImGui btn("New Game"); 1024 1025 ImGui::InvisibleButton("", vec2(10, height / 6)); 1026 if (btn.draw((width - btn.getWidth()) / 2)) { 1028 1027 goToScreen(&VulkanGame::renderGameScreen); 1029 1028 } 1030 1029 1031 ImGui::InvisibleButton("", ImVec2(10, 15));1032 ImGui::InvisibleButton("", ImVec2(300, 18)); 1033 ImGui:: SameLine();1034 if ( ImGui::Button("Quit")) {1030 ButtonImGui btn2("Quit"); 1031 1032 ImGui::InvisibleButton("", vec2(10, 15)); 1033 if (btn2.draw((width - btn2.getWidth()) / 2)) { 1035 1034 quitGame(); 1036 1035 } … … 1040 1039 } 1041 1040 1042 void VulkanGame::renderGameScreen( ) {1041 void VulkanGame::renderGameScreen(int width, int height) { 1043 1042 { 1044 ImGui::SetNextWindowSize( ImVec2(130, 65), ImGuiCond_Once);1045 ImGui::SetNextWindowPos( ImVec2(10, 50), ImGuiCond_Once);1043 ImGui::SetNextWindowSize(vec2(130, 65), ImGuiCond_Once); 1044 ImGui::SetNextWindowPos(vec2(10, 50), ImGuiCond_Once); 1046 1045 ImGui::Begin("WndStats", nullptr, 1047 1046 ImGuiWindowFlags_NoTitleBar | … … 1056 1055 1057 1056 { 1058 ImGui::SetNextWindowSize( ImVec2(250, 35), ImGuiCond_Once);1059 ImGui::SetNextWindowPos( ImVec2(380, 10), ImGuiCond_Once);1057 ImGui::SetNextWindowSize(vec2(250, 35), ImGuiCond_Once); 1058 ImGui::SetNextWindowPos(vec2(width - 260, 10), ImGuiCond_Always); 1060 1059 ImGui::Begin("WndMenubar", nullptr, 1061 1060 ImGuiWindowFlags_NoTitleBar | 1062 1061 ImGuiWindowFlags_NoResize | 1063 1062 ImGuiWindowFlags_NoMove); 1064 ImGui::InvisibleButton("", ImVec2(155, 18));1063 ImGui::InvisibleButton("", vec2(155, 18)); 1065 1064 ImGui::SameLine(); 1066 1065 if (ImGui::Button("Main Menu")) { … … 1071 1070 1072 1071 { 1073 ImGui::SetNextWindowSize( ImVec2(200, 200), ImGuiCond_Once);1074 ImGui::SetNextWindowPos( ImVec2(430, 60), ImGuiCond_Once);1072 ImGui::SetNextWindowSize(vec2(200, 200), ImGuiCond_Once); 1073 ImGui::SetNextWindowPos(vec2(width - 210, 60), ImGuiCond_Always); 1075 1074 ImGui::Begin("WndDebug", nullptr, 1076 1075 ImGuiWindowFlags_NoTitleBar | … … 1089 1088 } 1090 1089 1090 // TODO: Probably turn this into a UI widget class 1091 1091 void VulkanGame::renderGuiValueList(vector<UIValue>& values) { 1092 1092 float maxWidth = 0.0f; … … 1126 1126 } 1127 1127 1128 void VulkanGame::goToScreen(void (VulkanGame::* renderScreenFn)( )) {1128 void VulkanGame::goToScreen(void (VulkanGame::* renderScreenFn)(int width, int height)) { 1129 1129 currentRenderScreenFn = renderScreenFn; 1130 1131 // TODO: Maybe just set shouldRecreateSwapChain to true instead. Check this render loop logic 1132 // to make sure there'd be no issues 1133 //recreateSwapChain(); 1130 1134 } 1131 1135 -
sdl-game.hpp
rd255d52 r85b5fec 109 109 /*** High-level vars ***/ 110 110 111 void (VulkanGame::* currentRenderScreenFn)(); 111 // TODO: Just typedef the type of this function to RenderScreenFn or something since it's used in a few places 112 void (VulkanGame::* currentRenderScreenFn)(int width, int height); 112 113 113 114 map<string, vector<UIValue>> valueLists; … … 158 159 /*** High-level functions ***/ 159 160 160 void renderMainScreen( );161 void renderGameScreen( );161 void renderMainScreen(int width, int height); 162 void renderGameScreen(int width, int height); 162 163 163 164 void initGuiValueLists(map<string, vector<UIValue>>& valueLists); 164 165 void renderGuiValueList(vector<UIValue>& values); 165 166 166 void goToScreen(void (VulkanGame::* renderScreenFn)( ));167 void goToScreen(void (VulkanGame::* renderScreenFn)(int width, int height)); 167 168 void quitGame(); 168 169 -
vulkan-game.cpp
rd255d52 r85b5fec 11 11 12 12 #include "logger.hpp" 13 14 13 #include "utils.hpp" 15 14
Note:
See TracChangeset
for help on using the changeset viewer.