mirror of
https://github.com/Kugelschieber/vk-experiments.git
synced 2026-01-18 06:40:27 +00:00
Create window.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
.idea/
|
.vscode/
|
||||||
|
main
|
||||||
|
|||||||
45
main.c
Normal file
45
main.c
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
GLFWwindow* createWindow(const char* title, int width, int height) {
|
||||||
|
int err = glfwInit();
|
||||||
|
|
||||||
|
if(err != GLFW_TRUE) {
|
||||||
|
perror("error initializing glfw");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(glfwVulkanSupported() != GLFW_TRUE) {
|
||||||
|
perror("vulkan not supported");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
|
GLFWwindow* window = glfwCreateWindow(width, height, title, NULL, NULL);
|
||||||
|
glfwSetWindowSizeLimits(window, width, height, width, height);
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroyWindow(GLFWwindow* window) {
|
||||||
|
glfwDestroyWindow(window);
|
||||||
|
glfwTerminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(GLFWwindow* window) {
|
||||||
|
while(!glfwWindowShouldClose(window)) {
|
||||||
|
// ...
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, const char *argv[]) {
|
||||||
|
GLFWwindow* window = createWindow("Test", 800, 600);
|
||||||
|
|
||||||
|
if(window == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
loop(window);
|
||||||
|
destroyWindow(window);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user