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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:10:20+00:00 2026-06-05T21:10:20+00:00

Using Cocos2d to draw a thicker circle: glLineWidth(20); ccDrawCircle(self.ripplePosition, _radius, 0, 50, NO); But

  • 0

Using Cocos2d to draw a thicker circle:

glLineWidth(20);
ccDrawCircle(self.ripplePosition, _radius, 0, 50, NO);

But this is what shows up(notice how it looks like it’s created from 4 different segments):

https://i.stack.imgur.com/jYW4s.png

I tried increasing the number of segments to larger values but the result is the same.

Is this a bug in Cocos2D? Any ideas on how to achieve a “perfect” circle?

Here is the implementation of ccDrawCircle from cocos2d 2.0rc2:

void ccDrawCircle( CGPoint center, float r, float a, NSUInteger segs, BOOL drawLineToCenter)
{
lazy_init();

int additionalSegment = 1;
if (drawLineToCenter)
    additionalSegment++;

const float coef = 2.0f * (float)M_PI/segs;

GLfloat *vertices = calloc( sizeof(GLfloat)*2*(segs+2), 1);
if( ! vertices )
    return;

for(NSUInteger i = 0;i <= segs; i++) {
    float rads = i*coef;
    GLfloat j = r * cosf(rads + a) + center.x;
    GLfloat k = r * sinf(rads + a) + center.y;

    vertices[i*2] = j;
    vertices[i*2+1] = k;
}
vertices[(segs+1)*2] = center.x;
vertices[(segs+1)*2+1] = center.y;

[shader_ use];
[shader_ setUniformForModelViewProjectionMatrix];    
[shader_ setUniformLocation:colorLocation_ with4fv:(GLfloat*) &color_.r count:1];

ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );

glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segs+additionalSegment);

free( vertices );

CC_INCREMENT_GL_DRAWS(1);
}
  • 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-06-05T21:10:22+00:00Added an answer on June 5, 2026 at 9:10 pm

    I went with a slightly modified version of ccDrawCircle and it works pretty well (performs a lot better than using and resizing a sprite):

    void ccDrawDonut( CGPoint center, float r1, float r2, NSUInteger segs)
    {
        lazy_init();
    
        const float coef = 2.0f * (float)M_PI/segs;
    
        GLfloat *vertices = calloc( sizeof(GLfloat)*4*segs+4, 1);
        if( ! vertices )
            return;
    
        for(NSUInteger i = 0;i <= segs; i++) {
            float rads = i*coef;
            GLfloat j1 = r1 * cosf(rads) + center.x;
            GLfloat k1 = r1 * sinf(rads) + center.y;
            vertices[i*4] = j1;
            vertices[i*4+1] = k1;
    
            rads+= coef/2;
            GLfloat j2 = r2 * cosf(rads) + center.x;
            GLfloat k2 = r2 * sinf(rads) + center.y;
    
            vertices[i*4+2] = j2;
            vertices[i*4+3] = k2;
        }
    
        [shader_ use];
        [shader_ setUniformForModelViewProjectionMatrix];
        [shader_ setUniformLocation:colorLocation_ with4fv:(GLfloat*) &color_.r count:1];
    
        ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
    
        glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei) 2*segs+2);
    
        free( vertices );
    
        CC_INCREMENT_GL_DRAWS(1);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to draw semi-transparent primitives (lines, circles) in OpenGL ES using Cocos2d but
I am using cocos2d to build an iPhone game. It's mostly done, but along
i'm using cocos2d game engine for python. And i read api document but i
I'm using Cocos2D and the system particles and I hope I wrote this correctly
I am using cocos2d but there is a chance its not that which is
I'm using Cocos2d for all the animated sprite/transition stuff, but I'm not sure how
I would like to know how to draw text/label at specific angle using cocos2d.
How can I draw a line using a texture in Cocos2D? Specifically I'm looking
I'm using an ParticleSystem with PointSprites (inspired by the Cocos2D Source). But I wonder
I am drawing a circle using cocos2d, I set alpha to 0 using glColor4ub,

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.