diff --git a/.gitignore b/.gitignore index f2f3841..93cfaee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .vscode/ +build/ main diff --git a/run.sh b/run.sh index 4a5b979..e8a700e 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,6 @@ #!/bin/bash -gcc `pkg-config --static --libs glfw3` -o main main.c +mkdir -p build +gcc `pkg-config --static --libs glfw3` -c src/window.c -o build/window.o +gcc `pkg-config --static --libs glfw3` build/window.o -o main src/main.c ./main diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..a2c850d --- /dev/null +++ b/src/main.c @@ -0,0 +1,22 @@ +#include +#include +#include "window.h" + +void loop(GLFWwindow* window) { + while(!glfwWindowShouldClose(window)) { + // ... + glfwPollEvents(); + } +} + +int main(int argc, const char *argv[]) { + GLFWwindow* window = vkeCreateWindow("Test", 800, 600); + + if(window == NULL) { + return -1; + } + + loop(window); + vkeDestroyWindow(window); + return 0; +} diff --git a/main.c b/src/window.c similarity index 55% rename from main.c rename to src/window.c index b6c9eeb..fab7b53 100644 --- a/main.c +++ b/src/window.c @@ -1,7 +1,8 @@ +#include "window.h" #include #include -GLFWwindow* createWindow(const char* title, int width, int height) { +GLFWwindow* vkeCreateWindow(const char* title, int width, int height) { int err = glfwInit(); if(err != GLFW_TRUE) { @@ -20,26 +21,7 @@ GLFWwindow* createWindow(const char* title, int width, int height) { return window; } -void destroyWindow(GLFWwindow* window) { +void vkeDestroyWindow(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; -} diff --git a/src/window.h b/src/window.h new file mode 100644 index 0000000..f609b0a --- /dev/null +++ b/src/window.h @@ -0,0 +1,13 @@ +#ifndef VKE_WINDOW_H +#define VKE_WINDOW_H + +#include + +// Creates a new window for given title and dimensions. +// Returns NULL in case of an error. +GLFWwindow* vkeCreateWindow(const char* title, int width, int height); + +// Destroys given window. +void vkeDestroyWindow(GLFWwindow* window); + +#endif