mirror of
https://github.com/Kugelschieber/vk-experiments.git
synced 2026-01-18 06:40:27 +00:00
Refactorings.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.vscode/
|
||||
build/
|
||||
main
|
||||
|
||||
4
run.sh
4
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
|
||||
|
||||
22
src/main.c
Normal file
22
src/main.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#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;
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "window.h"
|
||||
#include <stdio.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
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;
|
||||
}
|
||||
13
src/window.h
Normal file
13
src/window.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef VKE_WINDOW_H
|
||||
#define VKE_WINDOW_H
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
// 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
|
||||
Reference in New Issue
Block a user