Changeset 187b0f5 in opengl-game
- Timestamp:
- Mar 11, 2021, 2:44:43 AM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- 301c90a
- Parents:
- 20e4c2b
- git-author:
- Dmitry Portnoy <dportnoy@…> (03/11/21 02:39:25)
- git-committer:
- Dmitry Portnoy <dportnoy@…> (03/11/21 02:44:43)
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r20e4c2b r187b0f5 2 2 vulkanref 3 3 openglgame 4 sdlgame 4 5 vulkangame 5 6 -
compile.sh
r20e4c2b r187b0f5 1 # TODO: Maybe turn this into a target in the makefile 1 # TODO: Figure out why calling this from a makefile gives an error about shopt not being found 2 3 # This section is left here in case there's no easy way to get glslangValidator in the path on a Mac 2 4 3 5 OS=$(uname) … … 6 8 VULKAN_SDK_PATH=/Users/dportnoy15/Development/vulkan-sdk-macos-1.1.108.0/macOS 7 9 fi 8 if [ $OS = "Linux" ]; then9 VULKAN_SDK_PATH=/home/dportnoy/Desktop/VulkanSDK/1.1.106.0/x86_6410 fi11 12 echo $VULKAN_SDK_PATH13 10 14 11 shopt -s nullglob … … 23 20 fOut="$shaderName-$shaderType.spv" 24 21 25 $VULKAN_SDK_PATH/bin/glslangValidator -V $f -o $fOut22 glslangValidator -V $f -o $fOut 26 23 done -
makefile
r20e4c2b r187b0f5 1 # C FLAGS arecompiler flags and LIBFLAGS could be renamed LINKER_FLAGS1 # CXX_FLAGS are C++ compiler flags and LIBFLAGS could be renamed LINKER_FLAGS 2 2 OS = $(shell uname) 3 3 CC = g++ 4 CFLAGS = -std=c++17 -Wall -pedantic -rdynamic 4 #CXX_FLAGS = -std=c++17 -Wall -pedantic -g3 -rdynamic 5 CXX_FLAGS = -std=c++17 -Wall -pedantic -O3 5 6 # -rdynamic is to generate debug info for dynamic symbols on debian-based 6 7 # systems (tested on Linux Mint) … … 24 25 25 26 openglref: new-game.cpp logger.cpp utils.cpp crash-logger.cpp IMGUI/imgui_impl_glfw.cpp IMGUI/imgui_impl_opengl3.cpp $(IMGUI_FILES) 26 $(CC) $^ $(DEP) $(C FLAGS) -o $@ -DGLEW_STATIC27 $(CC) $^ $(DEP) $(CXX_FLAGS) -o $@ -DGLEW_STATIC 27 28 28 29 openglgame: main-opengl.cpp opengl-game.cpp crash-logger.cpp logger.cpp game-gui-glfw.cpp graphics-pipeline_opengl.cpp IMGUI/imgui_impl_glfw.cpp IMGUI/imgui_impl_opengl3.cpp $(IMGUI_FILES) 29 $(CC) $^ $(DEP) $(CFLAGS) -o $@ -DGLEW_STATIC 30 31 CXX_FLAGS = -std=c++17 -Wall -pedantic# -O3 -rdynamic 30 $(CC) $^ $(DEP) $(CXX_FLAGS) -o $@ -DGLEW_STATIC 32 31 33 32 ifeq ($(OS),Darwin) … … 46 45 endif 47 46 48 LIBS = `pkg-config --static --libs sdl2 sdl2_image sdl2_ttf sdl2_gfx`47 LIBS = `pkg-config --static --libs sdl2 sdl2_image sdl2_ttf` 49 48 ifeq ($(OS),Darwin) 50 49 LIBS := $(VULKAN_SDK_PATH)/lib/libvulkan.dylib $(LIBS) 51 50 endif 52 51 ifeq ($(OS),Linux) 53 LIBS = `pkg-config --static --libs sdl2` 54 LIBS := -lvulkan $(LIBS) -lSDL2_image -lSDL2_ttf -lSDL2_gfx # TODO: figure out how to statically link these, ideally using pkg-config 52 #LIBS = `pkg-config --static --libs sdl2` 53 LIBS = 54 LIBS := -lvulkan $(LIBS) -lSDL2 -lSDL2_image -lSDL2_ttf # TODO: figure out how to statically link these, ideally using pkg-config 55 55 endif 56 56 … … 63 63 GUI_HEADER_FILES = gui/screen.hpp gui/main-screen.hpp gui/game-screen.hpp gui/ui-element.hpp gui/button.hpp gui/panel.hpp gui/ui-value.hpp 64 64 65 SRC_FILES = main-vulkan.cpp vulkan-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp utils.cpp game-gui-sdl.cpp $(GUI_SRC_FILES)66 HEADER_FILES = vulkan-game.hpp crash-logger.hpp logger.hpp vulkan-utils.hpp utils.hpp game-gui-sdl.hpp game-gui.hpp graphics-pipeline_vulkan.hpp $(GUI_HEADER_FILES) 65 vulkangame: SRC_FILES = main-vulkan.cpp vulkan-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp utils.cpp game-gui-sdl.cpp IMGUI/imgui_impl_sdl.cpp IMGUI/imgui_impl_vulkan.cpp $(IMGUI_FILES) 66 vulkangame: HEADER_FILES = vulkan-game.hpp crash-logger.hpp logger.hpp vulkan-utils.hpp utils.hpp game-gui-sdl.hpp game-gui.hpp graphics-pipeline_vulkan.hpp IMGUI/imgui_impl_sdl.h IMGUI/imgui_impl_vulkan.h 67 67 68 68 vulkangame: $(SRC_FILES) $(HEADER_FILES) 69 69 $(CC) $(CXX_FLAGS) -o $@ $(SRC_FILES) $(LIB_FLAGS) -DGAMEGUI_INCLUDE_VULKAN 70 70 71 SRC_FILES = main-vulkan.cpp sdl-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp game-gui-sdl.cpp IMGUI/imgui_impl_sdl.cpp IMGUI/imgui_impl_vulkan.cpp $(IMGUI_FILES)72 HEADER_FILES = sdl-game.hpp crash-logger.hpp logger.hpp vulkan-utils.hpp game-gui.hpp game-gui-sdl.hpp IMGUI/imgui_impl_sdl.h IMGUI/imgui_impl_vulkan.h71 sdlgame: SRC_FILES = main-vulkan.cpp sdl-game.cpp crash-logger.cpp logger.cpp vulkan-utils.cpp game-gui-sdl.cpp IMGUI/imgui_impl_sdl.cpp IMGUI/imgui_impl_vulkan.cpp $(IMGUI_FILES) 72 sdlgame: HEADER_FILES = sdl-game.hpp crash-logger.hpp logger.hpp vulkan-utils.hpp game-gui.hpp game-gui-sdl.hpp IMGUI/imgui_impl_sdl.h IMGUI/imgui_impl_vulkan.h 73 73 74 74 sdlgame: $(SRC_FILES) $(HEADER_FILES) -
sdl-game.cpp
r20e4c2b r187b0f5 49 49 swapChainPresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR; 50 50 swapChainMinImageCount = 0; 51 51 currentFrame = 0; 52 imageIndex = 0; 52 53 shouldRecreateSwapChain = false; 53 54 … … 254 255 255 256 void VulkanGame::renderLoop() { 256 startTime = high_resolution_clock::now();257 curTime = duration<float, seconds::period>( high_resolution_clock::now() - startTime).count();257 startTime = steady_clock::now(); 258 curTime = duration<float, seconds::period>(steady_clock::now() - startTime).count(); 258 259 259 260 fpsStartTime = curTime; … … 265 266 while (!done) { 266 267 267 curTime = duration<float, seconds::period>( high_resolution_clock::now() - startTime).count();268 curTime = duration<float, seconds::period>(steady_clock::now() - startTime).count(); 268 269 269 270 if (curTime - fpsStartTime >= 1.0f) { … … 333 334 recreateSwapChain(); 334 335 335 imageIndex = 0;336 336 shouldRecreateSwapChain = false; 337 337 } … … 496 496 497 497 cout << "Device: " << deviceProperties.deviceName << endl; 498 499 // TODO: Eventually, maybe let the user pick out of a set of GPUs in case the user does want to use 500 // an integrated GPU. On my laptop, this function returns TRUE for the integrated GPU, but crashes 501 // when trying to use it to render. Maybe I just need to figure out which other extensions and features 502 // to check. 503 if (deviceProperties.deviceType != VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) { 504 return false; 505 } 498 506 499 507 QueueFamilyIndices indices = VulkanUtils::findQueueFamilies(physicalDevice, surface); … … 970 978 971 979 createSyncObjects(); 980 981 imageIndex = 0; 972 982 } 973 983 -
vulkan-game.cpp
r20e4c2b r187b0f5 59 59 swapChainPresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR; 60 60 swapChainMinImageCount = 0; 61 62 61 currentFrame = 0; 62 imageIndex = 0; 63 63 shouldRecreateSwapChain = false; 64 64 … … 706 706 707 707 void VulkanGame::renderLoop() { 708 startTime = high_resolution_clock::now();709 curTime = duration<float, seconds::period>( high_resolution_clock::now() - startTime).count();708 startTime = steady_clock::now(); 709 curTime = duration<float, seconds::period>(steady_clock::now() - startTime).count(); 710 710 711 711 fpsStartTime = curTime; … … 720 720 721 721 this->prevTime = curTime; 722 curTime = duration<float, seconds::period>( high_resolution_clock::now() - this->startTime).count();722 curTime = duration<float, seconds::period>(steady_clock::now() - this->startTime).count(); 723 723 this->elapsedTime = curTime - this->prevTime; 724 724 … … 901 901 recreateSwapChain(); 902 902 903 imageIndex = 0;904 903 shouldRecreateSwapChain = false; 905 904 } … … 1277 1276 1278 1277 cout << "Device: " << deviceProperties.deviceName << endl; 1278 1279 // TODO: Eventually, maybe let the user pick out of a set of GPUs in case the user does want to use 1280 // an integrated GPU. On my laptop, this function returns TRUE for the integrated GPU, but crashes 1281 // when trying to use it to render. Maybe I just need to figure out which other extensions and features 1282 // to check. 1283 if (deviceProperties.deviceType != VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) { 1284 return false; 1285 } 1279 1286 1280 1287 QueueFamilyIndices indices = VulkanUtils::findQueueFamilies(physicalDevice, surface); -
vulkan-game.hpp
r20e4c2b r187b0f5 24 24 #include "vulkan-utils.hpp" 25 25 #include "graphics-pipeline_vulkan.hpp" 26 27 26 #include "game-gui-sdl.hpp" 28 27 -
vulkan-ref.cpp
r20e4c2b r187b0f5 9 9 #include <glm/glm.hpp> 10 10 #include <glm/gtc/matrix_transform.hpp> 11 12 #include <SDL2/SDL_ttf.h> 11 13 12 14 #include <iostream>
Note:
See TracChangeset
for help on using the changeset viewer.