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 6541395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:06:01+00:00 2026-05-25T11:06:01+00:00

UPDATE: Summary: I can draw a circle using TRIANGLE_FAN and, separately, I also can

  • 0

UPDATE: Summary:
I can draw a circle using TRIANGLE_FAN and, separately, I also can draw two squares with bitmaps as textures. But the problem is when I draw the textures and then the circles. Circles aren’t drawn.

I’m drawing two texturized squares (4 vertex each). Then I draw a circle using GL_TRIANGLE_FAN but it isn’t being drawn correctly (see images).

When I draw the circles without the squares, it is drawn correctly.

Any ideas where could be the problem?

Please, ask for more information. Thanks

Adding some code that I think is important:

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    gl.glShadeModel(GL10.GL_SMOOTH);
    gl.glFrontFace(GL10.GL_CCW);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glEnable(GL10.GL_BLEND);
    gl.glCullFace(GL10.GL_BACK);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnable(GL10.GL_TEXTURE_2D);
}
public void onSurfaceChanged(GL10 gl, int w, int h) {
    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glOrthof(0, w, -0, h, -1, 1);
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();
}

public void onDrawFrame(GL10 gl) {
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    circle.draw(gl);
    needle.draw(gl);
    synchronized (tokens) {
        for (Token d : tokens) {
            d.draw(gl);
        }
    }
}

Update:
Some screenshots.
Without drawing circle and needle objects:
Without bitmaps

Drawing circle and needle:
With bitmaps
(Look at those red lines where should be a circle)

The only change in the code between those images is commenting the lines

circle.draw(gl);
needle.draw(gl);

Token:

public void draw(GL10 gl) {
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);

    gl.glPushMatrix();
    gl.glTranslatef(x, y, 0f);
    gl.glScalef(radius, radius, 0f);
    gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
    gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, nVertices+2);
    gl.glPopMatrix();
}

Circle and Needle:

    public void draw(GL10 gl) {
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);

    if (shouldLoadTexture) {
        loadGLTexture(gl);
        shouldLoadTexture = false;
    }


    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId);

    gl.glPushMatrix();
    gl.glTranslatef(x, y, 0f);
    gl.glRotatef((float) angle, 0f, 0f, 1f);
    angle += rotAngle;
    if(angle+rotAngle > 360.0)
        angle -= 360.0;
    gl.glScalef(width, height, 0f);
    gl.glDrawElements(GL10.GL_TRIANGLES, indices.length,
            GL10.GL_UNSIGNED_SHORT, indexBuffer);
    gl.glPopMatrix();

}

private void loadGLTexture(GL10 gl) {

    int[] textures = new int[1];
    gl.glGenTextures(1, textures, 0);
    textureId = textures[0];

    gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId);

    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,
            GL10.GL_LINEAR);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,
            GL10.GL_LINEAR);


    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
            GL10.GL_CLAMP_TO_EDGE);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
            GL10.GL_REPEAT);

    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
}

Update:

Following what Arne says in the first answer, I changed:

public void draw(GL10 gl) {
            //New line
            gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);

    if (shouldLoadTexture) {
        loadGLTexture(gl);
        shouldLoadTexture = false;
    }


    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId);

    gl.glPushMatrix();
    gl.glTranslatef(x, y, 0f);
    gl.glRotatef((float) angle, 0f, 0f, 1f);
    angle += rotAngle;
    if(angle+rotAngle > 360.0)
        angle -= 360.0;
    gl.glScalef(width, height, 0f);
    gl.glDrawElements(GL10.GL_TRIANGLES, indices.length,
            GL10.GL_UNSIGNED_SHORT, indexBuffer);
    gl.glPopMatrix();
            //New line
            gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
}

Now I get no circle at all. Neither red line as in the second image.

Update:

When I don’t load the texture of circle and needle (just commenting the call to loadTexture() ), I get this:

Commenting loadTexture()

So the problem should be with the textures.

  • 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-25T11:06:02+00:00Added an answer on May 25, 2026 at 11:06 am

    You enable texturing (by calling glEnable(GL_TEXTURE_2D)) at the beginning, but you don’t provide your circles (tokens) any texture coordinates. As I suppose these shouldn’t be textured, you should only enable texturing for the objects that are really textured and disable texturing again after drawing them, the same way you enable and disable the texCoord array in your updated code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When doing a cvs update , you get a nice summary of the state
Update: giving a much more thorough example. The first two solutions offered were right
UPDATE: Focus your answers on hardware solutions please. What hardware/tools/add-in are you using to
UPDATE - A comprehensive comparison, updated as of February 2015, can be found here:
I'm using the MediaWiki API to update some pages with an experimental robot. This
Summary : I have a project using GNU Autotools. I have a pot file.
Summary I'm a seasoned programmer with years of experience in Windows Forms development using
TL;DR Summary: I need a single command-line application which I can use to get
I'm using the following function to insert data into a MySQL database. Can someone
I want to save image data to my sqlite database but I can't do

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.