Create window.

This commit is contained in:
2021-06-08 21:07:34 +02:00
parent df7b868fd0
commit 6ad4351118
3 changed files with 51 additions and 1 deletions

3
.gitignore vendored
View File

@@ -1 +1,2 @@
.idea/ .vscode/
main

45
main.c Normal file
View 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;
}

4
run.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
gcc `pkg-config --static --libs glfw3` -o main main.c
./main