Got the program to run and almost run without leaks
This commit is contained in:
parent
e59126b873
commit
fc9768f859
2 changed files with 19 additions and 15 deletions
|
|
@ -30,16 +30,16 @@ file(GLOB_RECURSE HEADER_FILES
|
|||
${CMAKE_SOURCE_DIR}/src/*.h)
|
||||
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
|
||||
|
||||
## Error on memory address issues in debug mode
|
||||
#if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
# set(
|
||||
# CMAKE_C_FLAGS
|
||||
# "${CMAKE_C_FLAGS} -Werror -fsanitize=undefined -fsanitize=address"
|
||||
# )
|
||||
# target_link_options(${PROJECT_NAME}
|
||||
# BEFORE PUBLIC -fsanitize=undefined PUBLIC -fsanitize=address
|
||||
# )
|
||||
#endif()
|
||||
# Error on memory address issues in debug mode
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
set(
|
||||
CMAKE_C_FLAGS
|
||||
"${CMAKE_C_FLAGS} -Werror -fsanitize=undefined -fsanitize=address"
|
||||
)
|
||||
target_link_options(${PROJECT_NAME}
|
||||
BEFORE PUBLIC -fsanitize=undefined PUBLIC -fsanitize=address
|
||||
)
|
||||
endif()
|
||||
|
||||
# Link Libraries
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
|
|
|
|||
14
src/main.c
14
src/main.c
|
|
@ -183,16 +183,17 @@ void createInstance(Application *app) {
|
|||
}
|
||||
}
|
||||
|
||||
// This currently leaks memory :(
|
||||
VkResult result = vkCreateInstance(&createInfo, NULL, &app->instance);
|
||||
if (result != VK_SUCCESS) {
|
||||
fprintf(stderr, "Failed to create vulkan instance\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Instance Extentions Available:\n");
|
||||
for (uint i = 0; i < extensionCount; i++) {
|
||||
printf("\t%s\n", extensions[i].extensionName);
|
||||
}
|
||||
//printf("Instance Extentions Available:\n");
|
||||
//for (uint i = 0; i < extensionCount; i++) {
|
||||
// printf("\t%s\n", extensions[i].extensionName);
|
||||
//}
|
||||
}
|
||||
|
||||
void initWindow(Application *app) {
|
||||
|
|
@ -334,7 +335,7 @@ SwapChainSupportDetails querySwapchainSupport(VkPhysicalDevice device,
|
|||
&details.numPresentModes, NULL);
|
||||
if (details.numPresentModes > 0) {
|
||||
details.presentModes =
|
||||
malloc(details.numFormats * sizeof(VkPresentModeKHR));
|
||||
malloc(details.numPresentModes * sizeof(VkPresentModeKHR));
|
||||
vkGetPhysicalDeviceSurfacePresentModesKHR(
|
||||
device, *surface, &details.numPresentModes, details.presentModes);
|
||||
}
|
||||
|
|
@ -578,6 +579,9 @@ void createSwapChain(Application *app) {
|
|||
|
||||
app->swapChainImageFormat = surfaceFormat.format;
|
||||
app->swapChainExtent = extent;
|
||||
|
||||
free(swapChainSupport.presentModes);
|
||||
free(swapChainSupport.formats);
|
||||
}
|
||||
|
||||
void createImageViews(Application *app) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue