Changeset 85b5fec in opengl-game for sdl-game.cpp
- Timestamp:
- Mar 14, 2021, 2:10:20 AM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- 7865c5b
- Parents:
- d255d52
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.