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

@@ -27,6 +27,7 @@ import com.watabou.gltextures.SmartTexture;
import com.watabou.gltextures.TextureCache;
import com.watabou.glwrap.Matrix;
import com.watabou.glwrap.Quad;
import com.watabou.glwrap.Vertexbuffer;
import android.graphics.Bitmap;
import android.graphics.RectF;
@@ -38,6 +39,7 @@ public class BitmapText extends Visual {
protected float[] vertices = new float[16];
protected FloatBuffer quads;
protected Vertexbuffer buffer;
public int realLength;
@@ -58,15 +60,6 @@ public class BitmapText extends Visual {
this.font = font;
}
@Override
public void destroy() {
text = null;
font = null;
vertices = null;
quads = null;
super.destroy();
}
@Override
protected void updateMatrix() {
// "origin" field is ignored
@@ -80,25 +73,37 @@ public class BitmapText extends Visual {
public void draw() {
super.draw();
if (dirty) {
updateVertices();
quads.limit(quads.position());
if (buffer == null)
buffer = new Vertexbuffer(quads);
else
buffer.updateVertices(quads);
}
NoosaScript script = NoosaScript.get();
font.texture.bind();
if (dirty) {
updateVertices();
}
script.camera( camera() );
script.uModel.valueM4( matrix );
script.lighting(
rm, gm, bm, am,
ra, ga, ba, aa );
script.drawQuadSet( quads, realLength );
script.drawQuadSet( buffer, realLength, 0 );
}
@Override
public void destroy() {
super.destroy();
if (buffer != null)
buffer.delete();
}
protected void updateVertices() {
width = 0;