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. tekir90
    Replies:
    0
    Views:
    451
  2. tobotech
    Replies:
    1
    Views:
    264
  3. App Update
    Replies:
    0
    Views:
    241
  4. Pedrum Golriz
    Replies:
    1
    Views:
    326
  5. Samsung
    Replies:
    0
    Views:
    214
  6. App Update
    Replies:
    0
    Views:
    178
  7. dPRogerWilco
    Replies:
    1
    Views:
    233
  8. Bretwa
    Replies:
    0
    Views:
    850
  9. iTP
    Replies:
    0
    Views:
    343
  10. Rad Brothers
    Replies:
    1
    Views:
    862

Share This Page

Loading...