Changeset 301c90a in opengl-game
- Timestamp:
- Mar 13, 2021, 10:37:06 PM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- d255d52
- Parents:
- 187b0f5
- Files:
-
- 4 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
IMGUI/imconfig.h
r187b0f5 r301c90a 108 108 } 109 109 */ 110 111 #include <glm/glm.hpp> 112 113 #define IM_VEC2_CLASS_EXTRA \ 114 ImVec2(const glm::vec2& f) { x = f.x; y = f.y; } \ 115 operator glm::vec2() const { return glm::vec2(x,y); } -
VulkanGame.vcxproj
r187b0f5 r301c90a 142 142 <ClCompile Include="FileStackWalker.cpp" /> 143 143 <ClCompile Include="game-gui-sdl.cpp" /> 144 <ClCompile Include="gui\imgui\button-imgui.cpp" /> 145 <ClCompile Include="gui\imgui\ui-wdget.cpp" /> 144 146 <ClCompile Include="IMGUI\imgui.cpp" /> 145 147 <ClCompile Include="IMGUI\imgui_demo.cpp" /> … … 165 167 <ClInclude Include="graphics-pipeline.hpp" /> 166 168 <ClInclude Include="graphics-pipeline_vulkan.hpp" /> 169 <ClInclude Include="gui\imgui\button-imgui.hpp" /> 170 <ClInclude Include="gui\imgui\ui-widget.hpp" /> 167 171 <ClInclude Include="IMGUI\imconfig.h" /> 168 172 <ClInclude Include="IMGUI\imgui.h" /> -
VulkanGame.vcxproj.filters
r187b0f5 r301c90a 31 31 <ClCompile Include="sdl-game.cpp"> 32 32 <Filter>IMGUI SDL Reference</Filter> 33 </ClCompile> 34 <ClCompile Include="gui\imgui\ui-wdget.cpp"> 35 <Filter>gui\imgui</Filter> 36 </ClCompile> 37 <ClCompile Include="gui\imgui\button-imgui.cpp"> 38 <Filter>gui\imgui</Filter> 33 39 </ClCompile> 34 40 </ItemGroup> … … 74 80 <Filter>IMGUI SDL Reference</Filter> 75 81 </ClInclude> 82 <ClInclude Include="gui\imgui\ui-widget.hpp"> 83 <Filter>gui\imgui</Filter> 84 </ClInclude> 85 <ClInclude Include="gui\imgui\button-imgui.hpp"> 86 <Filter>gui\imgui</Filter> 87 </ClInclude> 76 88 </ItemGroup> 77 89 <ItemGroup> … … 102 114 <UniqueIdentifier>{e540b46d-7c98-427d-a28d-4fc20d495826}</UniqueIdentifier> 103 115 </Filter> 116 <Filter Include="gui"> 117 <UniqueIdentifier>{79c30e01-25f8-48e6-894f-da73dea26f89}</UniqueIdentifier> 118 </Filter> 119 <Filter Include="gui\imgui"> 120 <UniqueIdentifier>{2954212f-ed3d-45c5-b46a-bbb81a16ca78}</UniqueIdentifier> 121 </Filter> 104 122 </ItemGroup> 105 123 </Project> -
compiler.hpp
r187b0f5 r301c90a 1 #ifndef COMPILER_H2 #define COMPILER_H1 #ifndef _COMPILER_H 2 #define _COMPILER_H 3 3 4 4 #if defined _WIN64 … … 16 16 #endif 17 17 18 #endif 18 #endif // _COMPILER_H -
consts.hpp
r187b0f5 r301c90a 1 #ifndef _RTWO_CONSTS_H 2 #define _RTWO_CONSTS_H 1 #ifndef _CONSTS_H 2 #define _CONSTS_H 3 4 // TODO: Move ScreenType somewhere else that's more UI-related 3 5 4 6 #define GAME_VERSION "0.01.000" … … 18 20 }; 19 21 20 #endif // _ RTWO_CONSTS_H22 #endif // _CONSTS_H -
crash-logger.hpp
r187b0f5 r301c90a 1 #ifndef CRASH_LOGGER_H2 #define CRASH_LOGGER_H1 #ifndef _CRASH_LOGGER_H 2 #define _CRASH_LOGGER_H 3 3 4 4 class CrashLogger { … … 8 8 }; 9 9 10 #endif 10 #endif // _CRASH_LOGGER_H -
game-gui-sdl.cpp
r187b0f5 r301c90a 154 154 } 155 155 156 // TODO: Check that this is only used where the drawable size is needed 157 // Maybe create a separate refreshWindowSize funcion as well. 156 158 void GameGui_SDL::refreshWindowSize() { 157 // TODO: Make sure this works on a mac (the analogous glfw function had issues on Mac retina displays) 158 SDL_GetWindowSize(window, &windowWidth, &windowHeight); 159 // TODO: Make sure this works on a Mac (the analogous glfw function had issues on Mac retina displays) 160 161 #ifdef GAMEGUI_INCLUDE_VULKAN 162 SDL_Vulkan_GetDrawableSize(window, &windowWidth, &windowHeight); 163 #else 164 SDL_GL_GetDrawableSize(window, &windowWidth, &windowHeight); 165 #endif 159 166 160 167 if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) { -
main-vulkan.cpp
r187b0f5 r301c90a 24 24 25 25 try { 26 game.run(800, 600, 0); 27 //game.run(800, 600, GUI_FLAGS_WINDOW_FULLSCREEN); 26 game.run(800, 600, GUI_FLAGS_WINDOW_FULLSCREEN); 28 27 } catch (const exception& e) { 29 28 cerr << e.what() << endl; -
vulkan-game.cpp
r187b0f5 r301c90a 8 8 9 9 #include "IMGUI/imgui_impl_sdl.h" 10 #include "IMGUI/imgui_internal.h" // For CalcItemSize 10 11 11 12 #include "logger.hpp" 12 13 13 14 #include "utils.hpp" 15 16 #include "gui/imgui/button-imgui.hpp" 14 17 15 18 using namespace std; … … 854 857 } 855 858 859 // This was left ovedr from the previous SDL UI implementation. 860 // Might need something like this again when I start processing screen-specific UI events not related 861 // to the IMGUI ui, such as arrow keys for movement and other buttons for shotting or something 856 862 // currentScreen->handleEvent(e); 857 863 } … … 911 917 ImGui::NewFrame(); 912 918 913 (this->*currentRenderScreenFn)( );919 (this->*currentRenderScreenFn)(gui->getWindowWidth(), gui->getWindowHeight()); 914 920 915 921 ImGui::Render(); … … 2187 2193 } 2188 2194 2189 void VulkanGame::renderMainScreen() { 2190 unsigned int windowWidth = 640; 2191 unsigned int windowHeight = 480; 2192 2195 void VulkanGame::renderMainScreen(int width, int height) { 2193 2196 { 2194 2197 int padding = 4; 2195 ImGui::SetNextWindowPos( ImVec2(-padding, -padding), ImGuiCond_Once);2196 ImGui::SetNextWindowSize( ImVec2(windowWidth + 2 * padding, windowHeight + 2 * padding), ImGuiCond_Always);2198 ImGui::SetNextWindowPos(vec2(-padding, -padding), ImGuiCond_Once); 2199 ImGui::SetNextWindowSize(vec2(width + 2 * padding, height + 2 * padding), ImGuiCond_Always); 2197 2200 ImGui::Begin("WndMain", nullptr, 2198 2201 ImGuiWindowFlags_NoTitleBar | … … 2200 2203 ImGuiWindowFlags_NoMove); 2201 2204 2202 ImGui::InvisibleButton("", ImVec2(10, 80));2203 ImGui::InvisibleButton("", ImVec2(285, 18)); 2204 ImGui:: SameLine();2205 if ( ImGui::Button("New Game")) {2205 ButtonImGui btn("New Game"); 2206 2207 ImGui::InvisibleButton("", vec2(10, height / 6)); 2208 if (btn.draw((width - btn.getWidth()) / 2)) { 2206 2209 goToScreen(&VulkanGame::renderGameScreen); 2207 2210 } 2208 2211 2209 ImGui::InvisibleButton("", ImVec2(10, 15));2210 ImGui::InvisibleButton("", ImVec2(300, 18)); 2211 ImGui:: SameLine();2212 if ( ImGui::Button("Quit")) {2212 ButtonImGui btn2("Quit"); 2213 2214 ImGui::InvisibleButton("", vec2(10, 15)); 2215 if (btn2.draw((width - btn2.getWidth()) / 2)) { 2213 2216 quitGame(); 2214 2217 } … … 2218 2221 } 2219 2222 2220 void VulkanGame::renderGameScreen( ) {2223 void VulkanGame::renderGameScreen(int width, int height) { 2221 2224 { 2222 ImGui::SetNextWindowSize( ImVec2(130, 65), ImGuiCond_Once);2223 ImGui::SetNextWindowPos( ImVec2(10, 50), ImGuiCond_Once);2225 ImGui::SetNextWindowSize(vec2(130, 65), ImGuiCond_Once); 2226 ImGui::SetNextWindowPos(vec2(10, 50), ImGuiCond_Once); 2224 2227 ImGui::Begin("WndStats", nullptr, 2225 2228 ImGuiWindowFlags_NoTitleBar | … … 2234 2237 2235 2238 { 2236 ImGui::SetNextWindowSize( ImVec2(250, 35), ImGuiCond_Once);2237 ImGui::SetNextWindowPos( ImVec2(380, 10), ImGuiCond_Once);2239 ImGui::SetNextWindowSize(vec2(250, 35), ImGuiCond_Once); 2240 ImGui::SetNextWindowPos(vec2(width - 260, 10), ImGuiCond_Always); 2238 2241 ImGui::Begin("WndMenubar", nullptr, 2239 2242 ImGuiWindowFlags_NoTitleBar | 2240 2243 ImGuiWindowFlags_NoResize | 2241 2244 ImGuiWindowFlags_NoMove); 2242 ImGui::InvisibleButton("", ImVec2(155, 18));2245 ImGui::InvisibleButton("", vec2(155, 18)); 2243 2246 ImGui::SameLine(); 2244 2247 if (ImGui::Button("Main Menu")) { … … 2249 2252 2250 2253 { 2251 ImGui::SetNextWindowSize( ImVec2(200, 200), ImGuiCond_Once);2252 ImGui::SetNextWindowPos( ImVec2(430, 60), ImGuiCond_Once);2254 ImGui::SetNextWindowSize(vec2(200, 200), ImGuiCond_Once); 2255 ImGui::SetNextWindowPos(vec2(width - 210, 60), ImGuiCond_Always); 2253 2256 ImGui::Begin("WndDebug", nullptr, 2254 2257 ImGuiWindowFlags_NoTitleBar | … … 2267 2270 } 2268 2271 2272 // TODO: Probably turn this into a UI widget class 2269 2273 void VulkanGame::renderGuiValueList(vector<UIValue>& values) { 2270 2274 float maxWidth = 0.0f; … … 2304 2308 } 2305 2309 2306 void VulkanGame::goToScreen(void (VulkanGame::* renderScreenFn)( )) {2310 void VulkanGame::goToScreen(void (VulkanGame::* renderScreenFn)(int width, int height)) { 2307 2311 currentRenderScreenFn = renderScreenFn; 2308 2312 -
vulkan-game.hpp
r187b0f5 r301c90a 243 243 SDL_Window* window = nullptr; 244 244 245 int drawableWidth, drawableHeight; 246 245 247 VkInstance instance; 246 248 VkDebugUtilsMessengerEXT debugMessenger; … … 360 362 /*** High-level vars ***/ 361 363 362 void (VulkanGame::* currentRenderScreenFn)(); 364 // TODO: Just typedef the type of this function to RenderScreenFn or something since it's used in a few places 365 void (VulkanGame::* currentRenderScreenFn)(int width, int height); 363 366 364 367 map<string, vector<UIValue>> valueLists; … … 456 459 /*** High-level functions ***/ 457 460 458 void renderMainScreen( );459 void renderGameScreen( );461 void renderMainScreen(int width, int height); 462 void renderGameScreen(int width, int height); 460 463 461 464 void initGuiValueLists(map<string, vector<UIValue>>& valueLists); 462 465 void renderGuiValueList(vector<UIValue>& values); 463 466 464 void goToScreen(void (VulkanGame::* renderScreenFn)( ));467 void goToScreen(void (VulkanGame::* renderScreenFn)(int width, int height)); 465 468 void quitGame(); 466 469 };
Note:
See TracChangeset
for help on using the changeset viewer.