Changeset a8f0577 in opengl-game
- Timestamp:
- Jul 8, 2019, 5:01:29 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 80de39d
- Parents:
- 7dcd925
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
makefile
r7dcd925 ra8f0577 34 34 $(CC) $^ $(DEP) $(CFLAGS) -o $@ 35 35 36 CXX_FLAGS = -std=c++17 -Wall -pedantic 36 CXX_FLAGS = -std=c++17 -Wall -pedantic# -O3 -rdynamic 37 37 38 38 ifeq ($(OS),Darwin) … … 51 51 endif 52 52 53 LIBS = -lSDL253 LIBS = `pkg-config --static --libs sdl2` 54 54 ifeq ($(OS),Darwin) 55 55 LIBS := $(VULKAN_SDK_PATH)/lib/libvulkan.dylib $(LIBS) … … 61 61 LIB_FLAGS = $(LIB_PATHS) $(LIBS) 62 62 63 vulkangame: vulkan-game -ref.cpp #vulkan-game.cpp game-gui-sdl.cpp63 vulkangame: vulkan-game.cpp game-gui-sdl.cpp 64 64 $(CC) $(CXX_FLAGS) -o $@ $^ $(LIB_FLAGS) 65 65 -
vulkan-game.cpp
r7dcd925 ra8f0577 20 20 using namespace std; 21 21 using namespace glm; 22 23 bool checkValidationLayerSupport();24 vector<const char*> getRequiredExtensions(SDL_Window* window);25 22 26 23 const int SCREEN_WIDTH = 800; … … 68 65 } 69 66 initVulkan(); 70 createInstance();71 67 mainLoop(); 72 68 cleanup(); … … 125 121 createInfo.pApplicationInfo = &appInfo; 126 122 127 auto extensions = getRequiredExtensions(window);123 vector<const char*> extensions = getRequiredExtensions(); 128 124 createInfo.enabledExtensionCount = static_cast<uint32_t>(extensions.size()); 129 125 createInfo.ppEnabledExtensionNames = extensions.data(); … … 156 152 } 157 153 154 bool checkValidationLayerSupport() { 155 uint32_t layerCount; 156 vkEnumerateInstanceLayerProperties(&layerCount, nullptr); 157 158 vector<VkLayerProperties> availableLayers(layerCount); 159 vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data()); 160 161 for (const char* layerName : validationLayers) { 162 bool layerFound = false; 163 164 for (const auto& layerProperties : availableLayers) { 165 if (strcmp(layerName, layerProperties.layerName) == 0) { 166 layerFound = true; 167 break; 168 } 169 } 170 171 if (!layerFound) { 172 return false; 173 } 174 } 175 176 return true; 177 } 178 179 vector<const char*> getRequiredExtensions() { 180 uint32_t extensionCount = 0; 181 SDL_Vulkan_GetInstanceExtensions(window, &extensionCount, nullptr); 182 183 vector<const char*> extensions(extensionCount); 184 SDL_Vulkan_GetInstanceExtensions(window, &extensionCount, extensions.data()); 185 186 if (enableValidationLayers) { 187 extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); 188 } 189 190 return extensions; 191 } 192 158 193 void mainLoop() { 159 194 // TODO: Create some generic event-handling functions in game-gui-* … … 204 239 } 205 240 }; 206 207 vector<const char*> getRequiredExtensions(SDL_Window* window) {208 uint32_t extensionCount;209 SDL_Vulkan_GetInstanceExtensions(window, &extensionCount, nullptr);210 211 vector<const char*> extensions(extensionCount);212 SDL_Vulkan_GetInstanceExtensions(window, &extensionCount, extensions.data());213 214 if (enableValidationLayers) {215 extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);216 }217 218 return extensions;219 }220 221 bool checkValidationLayerSupport() {222 uint32_t layerCount;223 vkEnumerateInstanceLayerProperties(&layerCount, nullptr);224 225 vector<VkLayerProperties> availableLayers(layerCount);226 vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());227 228 for (const char* layerName : validationLayers) {229 bool layerFound = false;230 231 for (const auto& layerProperties : availableLayers) {232 if (strcmp(layerName, layerProperties.layerName) == 0) {233 layerFound = true;234 break;235 }236 }237 238 if (!layerFound) {239 return false;240 }241 }242 243 return true;244 }245 241 246 242 int main() { … … 251 247 cout << "DEBUGGING IS ON" << endl; 252 248 #endif 249 253 250 /* 254 251 mat4 matrix;
Note:
See TracChangeset
for help on using the changeset viewer.