From b2e1e2412b175dfa224d18e66f87eaa282f3a4f6 Mon Sep 17 00:00:00 2001 From: c Date: Wed, 21 Feb 2024 08:57:01 -0500 Subject: migt --- .gitignore | 3 +++ Makefile | 6 ++++++ src/main.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..651be83 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +migt +*.out diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2699da9 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +CC := gcc +SRC := src/main.c +LIBS := -lglfw -lGLEW + +all: + $(CC) $(SRC) $(LIBS) -o migt diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..f5941bb --- /dev/null +++ b/src/main.c @@ -0,0 +1,54 @@ +#include +#include + +#include +#include + +int main(int argc, char** argv) { + glewExperimental = 1; + + if (!glfwInit()) { + fprintf(stderr, "bad\n"); + return 1; + } + + // Window hints. + glfwWindowHint(GLFW_SAMPLES, 4); // 4x antialiasing. + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // Version 3.3. + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + + // Create the window. + GLFWwindow* window; + window = glfwCreateWindow( 1024, 768, "Hi", NULL, NULL); + + if (!window) { + fprintf(stderr, "no window\n"); + glfwTerminate(); + return 1; + } + + // Glue. + glfwMakeContextCurrent(window); + glewExperimental = 1; + + // Is the glue OK? + if (glewInit() != GLEW_OK) { + fprintf(stderr, "glewless\n"); + return 1; + } + + glfwSetInputMode(window, GLFW_STICKY_KEYS, 1); + + do { + glfwSwapBuffers(window); + glfwPollEvents(); + } while ( + glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS + && !glfwWindowShouldClose(window) + ); + + + return 0; +} -- cgit v1.2.3