v0.4.2: added support for Vertex Buffer Objects

This commit is contained in:
Evan Debenham
2016-08-21 02:37:29 -04:00
committed by Evan Debenham
parent 02166c319b
commit 9663a47958
8 changed files with 220 additions and 44 deletions

View File

@@ -30,6 +30,7 @@ import com.watabou.glscripts.Script;
import com.watabou.glwrap.Attribute;
import com.watabou.glwrap.Quad;
import com.watabou.glwrap.Uniform;
import com.watabou.glwrap.Vertexbuffer;
public class NoosaScript extends Script {
@@ -96,6 +97,20 @@ public class NoosaScript extends Script {
GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE, GLES20.GL_UNSIGNED_SHORT, 0 );
}
public void drawQuad( Vertexbuffer buffer ) {
buffer.updateGLData();
buffer.bind();
aXY.vertexBuffer( 2, 4, 0 );
aUV.vertexBuffer( 2, 4, 2 );
buffer.release();
GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE, GLES20.GL_UNSIGNED_SHORT, 0 );
}
public void drawQuadSet( FloatBuffer vertices, int size ) {
@@ -112,6 +127,24 @@ public class NoosaScript extends Script {
GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * size, GLES20.GL_UNSIGNED_SHORT, 0 );
}
public void drawQuadSet( Vertexbuffer buffer, int length, int offset ){
if (length == 0) {
return;
}
buffer.updateGLData();
buffer.bind();
aXY.vertexBuffer( 2, 4, 0 );
aUV.vertexBuffer( 2, 4, 2 );
buffer.release();
GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * length, GLES20.GL_UNSIGNED_SHORT, Quad.SIZE * offset );
}
public void lighting( float rm, float gm, float bm, float am, float ra, float ga, float ba, float aa ) {
uColorM.value4f( rm, gm, bm, am );