• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Draw circle using opengl api

Brunda

Lurker
Hi all!!

i'm getting BufferOverflowException... to me buffer seems to be of have more memory allocated, below is the code...

ByteBuffer vbb = ByteBuffer.allocateDirect(VERTICIES * 3 * 5);
vbb.order(ByteOrder.nativeOrder());
vertexBuffer = vbb.asFloatBuffer();

ByteBuffer ibb = ByteBuffer.allocateDirect(VERTICIES * 3 * 2);
ibb.order(ByteOrder.nativeOrder());
indexBuffer = ibb.asShortBuffer();

public void onDrawFrame(GL10 gl) {
gl.glClearColor(mRed, mGreen, mBlue, 1.0f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

for (int i = 0; i < VERTICIES * 3; i += 3) {
coords[i + 0] = (float) Math.cos(theta);
coords[i + 1] = (float) Math.sin(theta);
coords[i + 2] = 0;
vertexBuffer.put(coords[i + 0]);
vertexBuffer.put(coords[i + 1]);
vertexBuffer.put(coords[i + 2]);
theta += Math.PI / 90;
}
gl.glColor4f(0, 0, 1, 0.5f);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glDrawElements(GL10.GL_TRIANGLE_FAN, VERTICIES,
GL10.GL_UNSIGNED_SHORT, indexBuffer);

}
 
Back
Top Bottom