Compare commits
No commits in common. "08c8b689adac66db0af35f678bbd3301887858b9" and "a95e3a79b143df7a79d6055d960486e5b7115f08" have entirely different histories.
08c8b689ad
...
a95e3a79b1
2 changed files with 0 additions and 85 deletions
|
|
@ -14,7 +14,6 @@ find_package(Vulkan REQUIRED)
|
|||
find_package(glfw3 REQUIRED)
|
||||
set(GLFW_LIBRARIES glfw)
|
||||
find_package(glm REQUIRED)
|
||||
#find_package(m REQUIRED)
|
||||
|
||||
# Include dirs
|
||||
include_directories(
|
||||
|
|
@ -35,9 +34,6 @@ target_link_libraries(${PROJECT_NAME}
|
|||
${GLFW_LIBRARIES}
|
||||
${Vulkan_LIBRARIES}
|
||||
${GLM_LIBRARY_DIRS}
|
||||
${CMAKE_DL_LIBS}
|
||||
#${M_LIBRARIES}
|
||||
m
|
||||
)
|
||||
|
||||
# Compile Shaders
|
||||
|
|
|
|||
81
src/main.c
81
src/main.c
|
|
@ -1,6 +1,4 @@
|
|||
#include "dyn_arr.h"
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -47,7 +45,6 @@ typedef struct Application {
|
|||
VkDevice device;
|
||||
VkQueue graphicsQueue;
|
||||
VkQueue presentQueue;
|
||||
VkSwapchainKHR swapChain;
|
||||
} Application;
|
||||
|
||||
typedef struct SwapChainSupportDetails {
|
||||
|
|
@ -358,29 +355,6 @@ VkPresentModeKHR chooseSwapPresentMode(VkPresentModeKHR *availablePresentModes,
|
|||
return VK_PRESENT_MODE_FIFO_KHR;
|
||||
}
|
||||
|
||||
VkExtent2D chooseSwapExtent(GLFWwindow *window,
|
||||
const VkSurfaceCapabilitiesKHR *capabilities) {
|
||||
if (capabilities->currentExtent.width != UINT_MAX) {
|
||||
return capabilities->currentExtent;
|
||||
}
|
||||
|
||||
int width, height;
|
||||
glfwGetFramebufferSize(window, &width, &height);
|
||||
VkExtent2D actualExtent = {(uint32_t)width, (uint32_t)height};
|
||||
|
||||
// check width and height are within bounds
|
||||
actualExtent.width =
|
||||
fmin(capabilities->maxImageExtent.width, actualExtent.width);
|
||||
actualExtent.width =
|
||||
fmax(capabilities->minImageExtent.width, actualExtent.width);
|
||||
actualExtent.height =
|
||||
fmin(capabilities->maxImageExtent.height, actualExtent.height);
|
||||
actualExtent.height =
|
||||
fmax(capabilities->minImageExtent.height, actualExtent.height);
|
||||
|
||||
return actualExtent;
|
||||
}
|
||||
|
||||
bool isDeviceSuitable(VkPhysicalDevice device, VkSurfaceKHR *surface) {
|
||||
QueueFamilyIndices indices = findQueueFamilies(device, surface);
|
||||
bool completeIndeces =
|
||||
|
|
@ -510,59 +484,6 @@ void createSurface(Application *app) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
void createSwapChain(Application *app) {
|
||||
SwapChainSupportDetails swapChainSupport =
|
||||
querySwapchainSupport(app->physicalDevice, &app->surface);
|
||||
VkSurfaceFormatKHR surfaceFormat = chooseSwapSurfaceFormat(
|
||||
swapChainSupport.formats, swapChainSupport.numFormats);
|
||||
VkPresentModeKHR presentMode = chooseSwapPresentMode(
|
||||
swapChainSupport.presentModes, swapChainSupport.numPresentModes);
|
||||
VkExtent2D extent =
|
||||
chooseSwapExtent(app->window, &swapChainSupport.capabilities);
|
||||
|
||||
uint32_t imageCount = swapChainSupport.capabilities.minImageCount + 1;
|
||||
if (swapChainSupport.capabilities.maxImageCount > 0 &&
|
||||
imageCount > swapChainSupport.capabilities.maxImageCount) {
|
||||
imageCount = swapChainSupport.capabilities.maxImageCount;
|
||||
}
|
||||
|
||||
VkSwapchainCreateInfoKHR createInfo = {0};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
|
||||
createInfo.surface = app->surface;
|
||||
createInfo.minImageCount = imageCount;
|
||||
createInfo.imageFormat = surfaceFormat.format;
|
||||
createInfo.imageColorSpace = surfaceFormat.colorSpace;
|
||||
createInfo.imageExtent = extent;
|
||||
createInfo.imageArrayLayers = 1;
|
||||
createInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
|
||||
QueueFamilyIndices indices =
|
||||
findQueueFamilies(app->physicalDevice, &app->surface);
|
||||
uint32_t queueFamilyIndices[] = {indices.graphicsFamily,
|
||||
indices.presentFamily};
|
||||
|
||||
if (indices.graphicsFamily != indices.presentFamily) {
|
||||
createInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
|
||||
createInfo.queueFamilyIndexCount = 2;
|
||||
createInfo.pQueueFamilyIndices = queueFamilyIndices;
|
||||
} else {
|
||||
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||
createInfo.queueFamilyIndexCount = 0;
|
||||
createInfo.pQueueFamilyIndices = NULL;
|
||||
}
|
||||
|
||||
createInfo.preTransform = swapChainSupport.capabilities.currentTransform;
|
||||
createInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||
createInfo.presentMode = presentMode;
|
||||
createInfo.clipped = VK_TRUE;
|
||||
createInfo.oldSwapchain = VK_NULL_HANDLE;
|
||||
|
||||
if (vkCreateSwapchainKHR(app->device, &createInfo, NULL, &app->swapChain) !=
|
||||
VK_SUCCESS) {
|
||||
fprintf(stderr, "Failed to create swapchain!");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void initVulkan(Application *app) {
|
||||
createInstance(app);
|
||||
|
|
@ -570,7 +491,6 @@ void initVulkan(Application *app) {
|
|||
createSurface(app);
|
||||
pickPhysicalDevice(app);
|
||||
createLogicalDevice(app);
|
||||
createSwapChain(app);
|
||||
}
|
||||
|
||||
void mainLoop(Application *app) {
|
||||
|
|
@ -580,7 +500,6 @@ void mainLoop(Application *app) {
|
|||
}
|
||||
|
||||
void cleanup(Application *app) {
|
||||
vkDestroySwapchainKHR(app->device, app->swapChain, NULL);
|
||||
vkDestroyDevice(app->device, NULL);
|
||||
if (enableValidationLayers) {
|
||||
DestroyDebugUtilsMessengerEXT(app->instance, app->debugMessenger, NULL);
|
||||
|
|
|
|||
Loading…
Reference in a new issue