summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/main.c b/main.c
index 911e5d7..0d479b8 100644
--- a/main.c
+++ b/main.c
@@ -86,15 +86,11 @@ struct RenderVulkan {
VkDevice device;
};
-struct RenderVulkan *vk;
-
#define ERRMSG_LEN 4096
void setErrMsg(struct RenderVulkan *vk, const char *fmt, ...)
{
- if (!vk->errMsg) {
- vk->errMsg = calloc(1, ERRMSG_LEN);
- }
+ vk->errMsg = realloc(vk->errMsg, ERRMSG_LEN);
va_list args;
va_start(args, fmt);
stbsp_vsnprintf(vk->errMsg, ERRMSG_LEN, fmt, args);
@@ -531,24 +527,26 @@ done:
free(devices);
}
-int main()
+void rvkCheckFatal(struct RenderVulkan *vk)
{
const char *errMsg = NULL;
- struct RenderVulkan *vk = renderVulkanCreate();
if ((errMsg = getErrMsg(vk))) {
fprintf(stderr, "%s\n", errMsg);
renderVulkanDestroy(vk);
- return 1;
+ exit(1);
}
+}
+
+int main()
+{
+ const char *errMsg = NULL;
+ struct RenderVulkan *vk = renderVulkanCreate();
+ rvkCheckFatal(vk);
printf("Created Vulkan Instance Successfully\n");
selectPhysicalDevice(vk);
- if ((errMsg = getErrMsg(vk))) {
- fprintf(stderr, "%s\n", errMsg);
- renderVulkanDestroy(vk);
- return 1;
- }
+ rvkCheckFatal(vk);
renderVulkanDestroy(vk);
return 0;