• 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
Apr 14, 2011
1
0
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);

}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones