mirror of
https://github.com/Kugelschieber/vk-experiments.git
synced 2026-01-18 06:40:27 +00:00
Create surface for GLFW window and fixed logging for window functions.
This commit is contained in:
25
src/main.c
25
src/main.c
@@ -121,7 +121,7 @@ int vkeCreateLogicalDeviceAndQueues(VKEContext* ctx, VKEConfig* config, VKEQueue
|
||||
};
|
||||
float queuePriority = 1.0f;
|
||||
queueCreateInfo.pQueuePriorities = &queuePriority;
|
||||
//VkPhysicalDeviceFeatures deviceFeatures;
|
||||
//VkPhysicalDeviceFeatures deviceFeatures; TODO
|
||||
VkDeviceCreateInfo createInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||
.pQueueCreateInfos = &queueCreateInfo,
|
||||
@@ -146,21 +146,7 @@ int vkeCreateLogicalDeviceAndQueues(VKEContext* ctx, VKEConfig* config, VKEQueue
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vkeCreateSurface(VKEContext* ctx) {
|
||||
VkDisplaySurfaceCreateInfoKHR surfaceCreateInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR
|
||||
// TODO
|
||||
};
|
||||
|
||||
if(vkCreateDisplayPlaneSurfaceKHR(ctx->instance, &surfaceCreateInfo, NULL, &ctx->surface) != VK_SUCCESS) {
|
||||
vkeLogError("error creating surface");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vkeInit(VKEContext* ctx, VKEConfig* config) {
|
||||
int vkeInit(VKEContext* ctx, VKEConfig* config, GLFWwindow* window) {
|
||||
if(!vkeCheckValidationLayerSupport(config->validationLayers, config->validationLayerCount)) {
|
||||
vkeLogError("validation layer not supported");
|
||||
return -1;
|
||||
@@ -209,10 +195,9 @@ int vkeInit(VKEContext* ctx, VKEConfig* config) {
|
||||
return -5;
|
||||
}
|
||||
|
||||
// TODO
|
||||
/*if(vkeCreateSurface(ctx) != 0) {
|
||||
if(vkeCreateWindowSurface(ctx->instance, window, &ctx->surface) != 0) {
|
||||
return -6;
|
||||
}*/
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -249,7 +234,7 @@ int main(int argc, const char *argv[]) {
|
||||
.validationLayers = validationLayers
|
||||
};
|
||||
|
||||
if(vkeInit(&ctx, &config) != 0) {
|
||||
if(vkeInit(&ctx, &config, window) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
18
src/window.c
18
src/window.c
@@ -1,17 +1,20 @@
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
|
||||
#include "window.h"
|
||||
#include <stdio.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "log.h"
|
||||
|
||||
GLFWwindow* vkeCreateWindow(const char* title, int width, int height) {
|
||||
int err = glfwInit();
|
||||
|
||||
if(err != GLFW_TRUE) {
|
||||
perror("error initializing glfw");
|
||||
vkeLogError("error initializing glfw");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(glfwVulkanSupported() != GLFW_TRUE) {
|
||||
perror("vulkan not supported");
|
||||
vkeLogError("vulkan not supported");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -25,3 +28,12 @@ void vkeDestroyWindow(GLFWwindow* window) {
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
int vkeCreateWindowSurface(VkInstance instance, GLFWwindow* window, VkSurfaceKHR* surface) {
|
||||
if(glfwCreateWindowSurface(instance, window, NULL, surface) != VK_SUCCESS) {
|
||||
vkeLogError("error creating surface");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef VKE_WINDOW_H
|
||||
#define VKE_WINDOW_H
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
// Creates a new window for given title and dimensions.
|
||||
@@ -10,4 +11,7 @@ GLFWwindow* vkeCreateWindow(const char* title, int width, int height);
|
||||
// Destroys given window.
|
||||
void vkeDestroyWindow(GLFWwindow* window);
|
||||
|
||||
// Create a Vulkan surface for given window.
|
||||
int vkeCreateWindowSurface(VkInstance instance, GLFWwindow* window, VkSurfaceKHR* surface);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user