lib/glesv2: intro culling related features
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 2 Jan 2015 20:41:29 +0000 (15:41 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 2 Jan 2015 21:30:56 +0000 (16:30 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/glesv2/glesv2.nit

index 670c903..3a49a8f 100644 (file)
@@ -375,6 +375,27 @@ class GLES
        # Set the viewport
        fun viewport(x, y, width, height: Int) `{ glViewport(x, y, width, height); `}
 
+       # Define front- and back-facing polygons
+       #
+       # Front-facing polygons are clockwise if `value`, counter-clockwise otherwise.
+       fun front_face=(value: Bool) `{ glFrontFace(value? GL_CW: GL_CCW); `}
+
+       # Specify whether front- or back-facing polygons can be culled, default is `back` only
+       #
+       # One or both of `front` or `back` must be `true`. If you want to deactivate culling
+       # use `(new GLCap.cull_face).disable`.
+       #
+       # Require: `front or back`
+       fun cull_face(front, back: Bool)
+       do
+               assert not (front or back)
+               cull_face_native(front, back)
+       end
+
+       private fun cull_face_native(front, back: Bool) `{
+               glCullFace(front? back? GL_FRONT_AND_BACK: GL_BACK: GL_FRONT);
+       `}
+
        # Clear the `buffer`
        fun clear(buffer: GLBuffer) `{ glClear(buffer); `}