#include <GL/glew.h>
+#include <GLFW/glfw3.h>
#include <stdio.h>
#include "gfxapi.h"
static void clear(float r, float g, float b);
static void viewport(int x, int y, int width, int height);
+static void zbuffer(bool enable);
+static void cull_face(Gfx_cull_face cf);
+static void reshape(int width, int height) {}
+static void wireframe(bool enable);
+static void swapbuffers();
+static void begin_drawing();
+static void end_drawing();
bool init_opengl()
{
gfx_clear = clear;
gfx_viewport = viewport;
+ gfx_zbuffer = zbuffer;
+ gfx_cull_face = cull_face;
+ gfx_reshape = reshape;
+ gfx_wireframe = wireframe;
+ gfx_swapbuffers = swapbuffers;
+ gfx_begin_drawing = begin_drawing;
+ gfx_end_drawing = end_drawing;
+ // glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
return true;
}
static void viewport(int x, int y, int width, int height)
{
glViewport(x, y, width, height);
-}
\ No newline at end of file
+}
+
+static void zbuffer(bool enable)
+{
+ if(enable)
+ glEnable(GL_DEPTH_TEST);
+ else
+ glDisable(GL_DEPTH_TEST);
+}
+
+static void cull_face(Gfx_cull_face cf)
+{
+ switch(cf) {
+ case GFX_CULL_NONE:
+ glDisable(GL_CULL_FACE);
+ break;
+ case GFX_CULL_FRONT:
+ glEnable(GL_CULL_FACE);
+ glCullFace(GL_FRONT);
+ break;
+ case GFX_CULL_BACK:
+ glEnable(GL_CULL_FACE);
+ glCullFace(GL_BACK);
+ break;
+ }
+}
+
+static void wireframe(bool enabled)
+{
+ if(enabled)
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ else
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+}
+
+static void swapbuffers()
+{
+ glfwSwapBuffers(win);
+}
+
+static void begin_drawing()
+{
+}
+
+static void end_drawing()
+{
+}