From 1f94bc79219c1479b4737c927a6e862c4a3acf6a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Sat, 12 Sep 2015 10:30:25 -0400 Subject: [PATCH] lib/glesv2: move some services out of `VertexArray` as per the new style MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/glesv2/examples/opengles2_hello_triangle.nit | 2 +- lib/glesv2/glesv2.nit | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/glesv2/examples/opengles2_hello_triangle.nit b/lib/glesv2/examples/opengles2_hello_triangle.nit index 48d49ab..3a1e1c5 100644 --- a/lib/glesv2/examples/opengles2_hello_triangle.nit +++ b/lib/glesv2/examples/opengles2_hello_triangle.nit @@ -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 diff --git a/lib/glesv2/glesv2.nit b/lib/glesv2/glesv2.nit index 4e3c3ee..474b4aa 100644 --- a/lib/glesv2/glesv2.nit +++ b/lib/glesv2/glesv2.nit @@ -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] -- 1.7.9.5