Changeset cabdd5c in opengl-game
- Timestamp:
- Sep 14, 2019, 12:13:54 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 2e77b3f
- Parents:
- cb01aff
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
new-game.cpp
rcb01aff rcabdd5c 287 287 */ 288 288 289 /*** START OF REFACTORED CODE ***/ 289 290 // Helps to test logging during crashes 290 291 void badFunc() { … … 368 369 cout << "OpenGL debug message callback is not supported" << endl; 369 370 } 371 /*** END OF REFACTORED CODE ***/ 370 372 371 373 srand(time(0)); … … 955 957 bindUniformData(modelGroups[TYPE_EXPLOSION].attribs["cur_time"]); 956 958 959 /*** START OF REFACTORED CODE ***/ 957 960 // Render scene 958 961 959 962 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 960 961 // Anton's book suggests placing this here, after glClear(). Check it's impact on framerate 962 //glViewport(0, 0, windowWidth, windowHeight); 963 /*** END OF REFACTORED CODE ***/ 963 964 964 965 switch (curState) { -
vulkan-ref.cpp
rcb01aff rcabdd5c 108 108 }; 109 109 110 /*** START OF REFACTORED CODE ***/ 110 111 VkResult CreateDebugUtilsMessengerEXT(VkInstance instance, 111 112 const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, … … 144 145 private: 145 146 GameGui* gui = new GameGui_SDL(); 147 146 148 SDL_version sdlVersion; 147 149 SDL_Window* window = nullptr; 148 149 // TODO: Come up with more descriptive names for these150 150 SDL_Renderer* gRenderer = nullptr; 151 /*** END OF REFACTORED CODE ***/ 151 152 SDL_Texture* uiOverlay = nullptr; 152 153 … … 155 156 SDL_Texture* uiImage = nullptr; 156 157 158 /*** START OF REFACTORED CODE ***/ 157 159 VkInstance instance; 158 160 VkDebugUtilsMessengerEXT debugMessenger; 161 /*** END OF REFACTORED CODE ***/ 159 162 VkSurfaceKHR surface; 160 163 … … 222 225 bool framebufferResized = false; 223 226 224 // TODO: Make make some more initi functions, or call this initUI if the 225 // amount of things initialized here keeps growing 227 /*** START OF REFACTORED CODE ***/ 226 228 bool initWindow() { 227 // TODO: Put all fonts, textures, and images in the assets folder228 229 229 if (gui->init() == RTWO_ERROR) { 230 230 cout << "UI library could not be initialized!" << endl; … … 245 245 return RTWO_ERROR; 246 246 } 247 /*** END OF REFACTORED CODE ***/ 247 248 248 249 SDL_VERSION(&sdlVersion); … … 307 308 } 308 309 310 /*** START OF REFACTORED CODE ***/ 309 311 void initVulkan() { 310 312 createInstance(); 311 313 setupDebugMessenger(); 314 /*** END OF REFACTORED CODE ***/ 312 315 createSurface(); 313 316 pickPhysicalDevice(); … … 459 462 } 460 463 464 /*** START OF REFACTORED CODE ***/ 461 465 vector<const char*> getRequiredExtensions() { 462 466 vector<const char*> extensions = gui->getRequiredExtensions(); … … 487 491 createInfo.pfnUserCallback = debugCallback; 488 492 } 493 /*** END OF REFACTORED CODE ***/ 489 494 490 495 void createSurface() { … … 708 713 if (capabilities.currentExtent.width != numeric_limits<uint32_t>::max()) { 709 714 return capabilities.currentExtent; 710 } 711 else { 712 int width, height; 713 gui->getWindowSize(&width, &height); 714 715 } else { 715 716 VkExtent2D actualExtent = { 716 static_cast<uint32_t>( width),717 static_cast<uint32_t>( height)717 static_cast<uint32_t>(gui->getWindowWidth()), 718 static_cast<uint32_t>(gui->getWindowHeight()) 718 719 }; 719 720 … … 1811 1812 1812 1813 void recreateSwapChain() { 1813 int width = 0, height = 0; 1814 1815 gui->getWindowSize(&width, &height); 1816 1817 while (width == 0 || height == 0 || 1814 gui->refreshWindowSize(); 1815 1816 while (gui->getWindowWidth() == 0 || gui->getWindowHeight() == 0 || 1818 1817 (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) != 0) { 1819 1818 SDL_WaitEvent(nullptr); 1820 gui-> getWindowSize(&width, &height);1819 gui->refreshWindowSize(); 1821 1820 } 1822 1821 … … 1875 1874 1876 1875 vkDestroyCommandPool(device, commandPool, nullptr); 1877 1878 1876 vkDestroyDevice(device, nullptr); 1879 1877 vkDestroySurfaceKHR(instance, surface, nullptr); 1878 1879 /*** START OF REFACTORED CODE ***/ 1880 1880 if (enableValidationLayers) { 1881 1881 DestroyDebugUtilsMessengerEXT(instance, debugMessenger, nullptr); 1882 1882 } 1883 1883 1884 vkDestroySurfaceKHR(instance, surface, nullptr);1885 1884 vkDestroyInstance(instance, nullptr); 1885 /*** END OF REFACTORED CODE ***/ 1886 1886 1887 1887 // TODO: Check if any of these functions accept null parameters … … 1906 1906 } 1907 1907 1908 /*** START OF REFACTORED CODE ***/ 1908 1909 SDL_DestroyRenderer(gRenderer); 1909 1910 gRenderer = nullptr; … … 1912 1913 gui->shutdown(); 1913 1914 delete gui; 1915 /*** END OF REFACTORED CODE ***/ 1914 1916 } 1915 1917 … … 1986 1988 }; 1987 1989 1990 /*** START OF REFACTORED CODE ***/ 1988 1991 int main(int argc, char* argv[]) { 1989 1992 … … 2009 2012 return EXIT_SUCCESS; 2010 2013 } 2014 /*** END OF REFACTORED CODE ***/
Note:
See TracChangeset
for help on using the changeset viewer.