Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6883695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:24:53+00:00 2026-05-27T05:24:53+00:00

Im drawing a circle and even if i draw a basic shape (eg.square, diamond)

  • 0

Im drawing a circle and even if i draw a basic shape (eg.square, diamond) using java opengl ES in android.

If I run the application in honeycomb the shape is coming fine but if I run it in gingerbread with the shape few more unnecessary points where getting drawn(it getting scattered) and if I keep on executing it rarely it comes without those points.

My Renderer class,

public void onDrawFrame(GL10 gl) {
     gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
     gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslatef(0, 0, -5.0f);
gl.glRotatef(-100, 1.0f, 0.0f, 0.0f);
gl.glRotatef(40, 1.0f, 0.0f, 0.0f);

mCircle= new Circle();
     Circle.setCirclePoints(1.5f,4, 1, 360);
Circle.draw(gl);

}

public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);         
     float ratio = (float) width / height;
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrthof(-6.5f, +6.5f, -6.5f, 6.5f, 6.5f, -6.5f);

  }
          public void onSurfaceCreated(GL10 gl, EGLConfig config) {
       gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
gl.glClearColor(0,0,0,0);
gl.glEnable(GL10.GL_CULL_FACE);
gl.glShadeModel(GL10.GL_SMOOTH);
gl.glEnable(GL10.GL_DEPTH_TEST);
    }   

In my Circle Class

public void setCirclePoints(float radius, int slices, int stacks,
        float angle)
    ByteBuffer vbb = ByteBuffer.allocateDirect(((slices+2)* 3 * 4));
    vbb.order(ByteOrder.nativeOrder());
    mSliceVertexBuffer = vbb.asFloatBuffer();

    mSliceVertexBuffer.put(0.0f);
    mSliceVertexBuffer.put(0.0f);
    mSliceVertexBuffer.put(nsign * radius);

    for (int j = 0; j <= slices; j++) {
        theta = j * dtheta;
        x = (float) 1.25f * (float) (Math.cos(theta + dupTheta));
        y = (float) Math.sin(theta + dupTheta);
        z = nsign;
        mSliceVertexBuffer.put(x * radius);
        mSliceVertexBuffer.put(y * radius);
        mSliceVertexBuffer.put(z * radius);
        } 

              }
public void draw(GL10 gl){
     gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
     gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mSliceVertexBuffer);
     gl.glColor4f(212,21,54,34);
    gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0,sliceCount);
     gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}

Im really clue less.. I dont know why its not drawing properly in android version <3.0.

edit: I tried to solve it, I found that when I’m trying to plot the points, few vertex are going out of the viewport(may be infinity, I dont know) in android 2.3.3, but for the same points in android 3.0 it drawing the proper shape.

Help me out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:24:54+00:00Added an answer on May 27, 2026 at 5:24 am

    I made a blunder mistake
    The issue was in

        gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0,sliceCount);
    

    where the sliceCount is total number of points x,y,z. I divided that one by 3.

           gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0,sliceCount/3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am drawing a circle using wxpython for a project.Please look through the
I am developing a small application in Java. I am using Java2D Library for
i want to crop image via drawing circle using touchMoved event. so how can
I am drawing a concave shape in canvas using the following code: var ctx
I am using Bresenham's circle algorithm for fast circle drawing. However, I also want
UPDATE: Summary: I can draw a circle using TRIANGLE_FAN and, separately, I also can
I am drawing a circle using cocos2d, I set alpha to 0 using glColor4ub,
For an iPhone application I want to draw a circle, that is only for
I'm drawing a circle in C# and i have divided it into some parts,i
I'm creating an application where I will be drawing two circles onto the screen,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.