#include <GL/glew.h>
#include <stdio.h>
+#include "gfxapi.h"
#include "opengl/opengl.h"
extern GLFWwindow *win;
extern int win_h;
extern int win_w;
+static void clear(float r, float g, float b);
+static void viewport(int x, int y, int width, int height);
+
bool init_opengl()
{
if(!glfwInit()) {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
+ glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_TRUE);
if(!(win = glfwCreateWindow(win_w, win_h, "glcow", 0, 0))) {
fprintf(stderr, "Failed to create window.\n");
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
+ glEnable(GL_FRAMEBUFFER_SRGB); // linear colorspace
+
+ gfx_clear = clear;
+ gfx_viewport = viewport;
return true;
}
glfwDestroyWindow(win);
}
glfwTerminate();
+}
+
+static void clear(float r, float g, float b)
+{
+ glClearColor(r, g, b, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+}
+
+static void viewport(int x, int y, int width, int height)
+{
+ glViewport(x, y, width, height);
}
\ No newline at end of file