lib/glesv2: move some services out of `VertexArray` as per the new style
authorAlexis Laferrière <alexis.laf@xymus.net>
Sat, 12 Sep 2015 14:30:25 +0000 (10:30 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 14 Sep 2015 18:00:39 +0000 (14:00 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/glesv2/examples/opengles2_hello_triangle.nit
lib/glesv2/glesv2.nit

index 48d49ab..3a1e1c5 100644 (file)
@@ -168,7 +168,7 @@ for i in [0..10000[ do
        gl.clear((new GLBuffer).color)
        program.use
        vertex_array.enable
-       vertex_array.draw_arrays_triangles
+       glDrawArrays(new GLDrawMode.triangles, 0, 3)
        egl_display.swap_buffers(surface)
 end
 
index 4e3c3ee..474b4aa 100644 (file)
@@ -314,15 +314,22 @@ class VertexArray
                glVertexAttribPointer(index, count, GL_FLOAT, GL_FALSE, 0, array);
        `}
 
-       fun enable do enable_intern(index)
-       private fun enable_intern(index: Int) `{ glEnableVertexAttribArray(index); `}
+       # Enable this vertex attribute array
+       fun enable do glEnableVertexAttribArray(index)
 
-       fun draw_arrays_triangles do draw_arrays_triangles_intern(index, count)
-       private fun draw_arrays_triangles_intern(index, count: Int) `{
-               glDrawArrays(GL_TRIANGLES, index, count);
-       `}
+       # Disable this vertex attribute array
+       fun disable do glDisableVertexAttribArray(index)
 end
 
+# Enable the generic vertex attribute array at `index`
+fun glEnableVertexAttribArray(index: Int) `{ glEnableVertexAttribArray(index); `}
+
+# Disable the generic vertex attribute array at `index`
+fun glDisableVertexAttribArray(index: Int) `{ glDisableVertexAttribArray(index); `}
+
+# Render primitives from array data
+fun glDrawArrays(mode: GLDrawMode, from, count: Int) `{ glDrawArrays(mode, from, count); `}
+
 # Low level array of `Float`
 class GLfloatArray
        super CArray[Float]