X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fopengl%2Fopengl.cc;h=66dd002e5a4c2c04c3bb4730ccf654b1d40dfeb7;hb=72995482b98ff2a014ddd737131a0935ead89977;hp=ffa1d47290cd5f677868aac51a44261751665fbd;hpb=3bf3536271e4afa8a8a93c75e2ab1256c0bf718a;p=demo diff --git a/src/opengl/opengl.cc b/src/opengl/opengl.cc index ffa1d47..66dd002 100644 --- a/src/opengl/opengl.cc +++ b/src/opengl/opengl.cc @@ -1,4 +1,5 @@ #include +#include #include #include "gfxapi.h" @@ -10,6 +11,10 @@ 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); +static void reshape(int width, int height) {} +static void wireframe(bool enable); bool init_opengl() { @@ -36,7 +41,12 @@ bool init_opengl() gfx_clear = clear; gfx_viewport = viewport; + gfx_zbuffer = zbuffer; + gfx_cull_face = cull_face; + gfx_reshape = reshape; + gfx_wireframe = wireframe; + // glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); return true; } @@ -57,4 +67,37 @@ 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); -} \ 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); +}