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