1. Are you ready for the Galaxy S20? Here is everything we know so far!

Draw circle using opengl api

Discussion in 'Android Development' started by Brunda, May 20, 2011.

  1. Brunda

    Brunda Lurker
    Thread Starter

    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);

    }
     



    1. Download the Forums for Android™ app!


      Download

       
  2. EarlyMon

    EarlyMon The PearlyMon
    VIP Member

    Welcome to the forums!

    Moved your post here.
     
Loading...
Similar Threads - Draw circle using
  1. dangerkittah_1117
    Replies:
    1
    Views:
    563
  2. App Update
    Replies:
    0
    Views:
    542
  3. App Update
    Replies:
    0
    Views:
    377
  4. Art Plays
    Replies:
    2
    Views:
    585
  5. Biffos
    Replies:
    6
    Views:
    567
  6. App Update
    Replies:
    0
    Views:
    457
  7. electricpunch
    Replies:
    1
    Views:
    428
  8. App Update
    Replies:
    1
    Views:
    556
  9. tekir90
    Replies:
    0
    Views:
    2,133
  10. tobotech
    Replies:
    1
    Views:
    1,144

Share This Page

Loading...