quick backup - everything is going to be changed on vulkan side.
[demo] / src / opengl / opengl.cc
index ffa1d47..9b220ab 100644 (file)
@@ -1,4 +1,5 @@
 #include <GL/glew.h>
+#include <GLFW/glfw3.h>
 #include <stdio.h>
 
 #include "gfxapi.h"
@@ -10,6 +11,8 @@ extern int win_w;
 
 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);
 
 bool init_opengl()
 {
@@ -36,7 +39,10 @@ bool init_opengl()
 
        gfx_clear = clear;
        gfx_viewport = viewport;
+       gfx_zbuffer = zbuffer;
+       gfx_cull_face = cull_face;
 
+       // glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
        return true;
 }
 
@@ -57,4 +63,29 @@ static void clear(float r, float g, float b)
 static void viewport(int x, int y, int width, int height)
 {
        glViewport(x, y, width, height);
+}
+
+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;
+       }
 }
\ No newline at end of file