commit 819d9623f0256e9b3c8d7aa83829d3339599341e
Author: mjkloeckner <martin.cachari@gmail.com>
Date: Tue, 27 Dec 2022 23:59:54 -0300
first insertion
Diffstat:
A | Makefile | | | 21 | +++++++++++++++++++++ |
A | main.c | | | 44 | ++++++++++++++++++++++++++++++++++++++++++++ |
A | opengl | | | 0 | |
3 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@@ -0,0 +1,21 @@
+CC := gcc
+CLIBS := `sdl2-config --libs` $(shell pkg-config --libs glfw3 glew)
+CFLAGS := `sdl2-config --cflags` -Wall -Wshadow -pedantic -ansi -std=c99 -O3
+SRCS := $(wildcard *.c)
+OBJS := $(SRCS:.c=.o)
+
+TARGET := opengl
+
+.PHONY: all clean
+
+all: $(TARGET)
+
+$(TARGET): $(OBJS)
+ $(CC) $(CLIBS) $(CFLAGS) -o $@ $^
+ rm -f $(OBJS)
+
+%.o: %.c
+ $(CC) $(CLIBS) $(CFLAGS) -c $< -o $@
+
+clean:
+ rm -f $(OBJS)
diff --git a/main.c b/main.c
@@ -0,0 +1,44 @@
+#include <GL/glew.h>
+#include <GL/glut.h>
+#include <GLFW/glfw3.h>
+
+#include <stdio.h>
+
+#define WINDOW_TITLE "OpenGL Test Window"
+#define WINDOW_WIDTH 800
+#define WINDOW_HEIGHT 600
+
+void glfwPrintError(int e, const char *s) {
+ fprintf(stderr, "%s\n", s);
+}
+
+int main (void) {
+ GLenum err;
+
+ if(!glfwInit()) {
+ fprintf(stderr, "GLFW: failed to initialize\n");
+ return 1;
+ }
+
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
+
+ GLFWwindow *win = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT,
+ WINDOW_TITLE, NULL, NULL);
+
+ if(!win) {
+ fprintf(stderr, "GLFW: failed to create window\n");
+ glfwTerminate();
+ }
+
+ glfwSetErrorCallback(&glfwPrintError);
+
+ glfwMakeContextCurrent(win);
+
+ if((err = glewInit()) != 0) {
+ fprintf(stderr, "GLEW: %s\n", glewGetErrorString(err));
+ return 2;
+ }
+
+ return 0;
+}
diff --git a/opengl b/opengl
Binary files differ.