Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid OpenGLES drawing buffer, blank screen
    text
    copied!<p>Im trying to draw primitives using a FloatBuffer for my vertices and a ShortBuffer for the indexes. Everything works fine with no crashes or warnings but the screen is blank. I can draw with glDrawTexfOES without trouble. If anyone could take a look at the code I would appreciate it alot. </p> <pre><code>public abstract class PrimitiveBase extends DrawableEntity { protected float[] _vertices; protected short[] _indices; private FloatBuffer _verticesBuffer; private ShortBuffer _indicesBuffer; public PrimitiveBase(Sprite sprite, float x, float y) { super(sprite, x, y); } protected abstract void setVertices(); @Override public void draw(float x, float y, float scaleX, float scaleY) { GL10 gl = GlSystem.getGl(); gl.glPushMatrix(); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glScalef(scaleX, scaleY, 1.0F); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glVertexPointer(2, GL10.GL_FLOAT, 0, _verticesBuffer); gl.glColor4f(1.0F, 0, 0, 0); gl.glDrawElements(GL10.GL_TRIANGLES, _indices.length, GL10.GL_UNSIGNED_SHORT, _indicesBuffer); gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glPushMatrix(); } @Override public void load(EntityManager parent) { setVertices(); ByteBuffer vbb = ByteBuffer.allocateDirect(_vertices.length * 4); vbb.order(ByteOrder.nativeOrder()); _verticesBuffer = vbb.asFloatBuffer(); _verticesBuffer.put(_vertices); _verticesBuffer.position(0); ByteBuffer ibb = ByteBuffer.allocateDirect(_indices.length * 2); ibb.order(ByteOrder.nativeOrder()); _indicesBuffer = ibb.asShortBuffer(); _indicesBuffer.put(_indices); _indicesBuffer.position(0); } } public class Rectangle extends PrimitiveBase { private float _width; private float _heigth; public Rectangle(Sprite sprite, float x, float y, float width, float height) { super(sprite, x, y); _heigth = height; _width = width; } @Override protected void setVertices() { _vertices = new float[8]; _indices = new short[] { 0, 1, 2, 0, 2, 3 }; _vertices[0] = getX() - (_width / 2); _vertices[1] = getY() + (_heigth / 2); _vertices[2] = getX() + (_width / 2); _vertices[3] = getY() + (_heigth / 2); _vertices[4] = getX() + (_width / 2); _vertices[5] = getY() - (_heigth / 2); _vertices[6] = getX() - (_width / 2); _vertices[7] = getY() - (_heigth / 2); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload