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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:52:52+00:00 2026-05-16T21:52:52+00:00

There is this site … … where they explain how to draw an antialiased

  • 0

There is this site…

… where they explain how to draw an antialiased line.

Exactly what I want!
but…

I don’t understand how to achieve that for a simple line. I have found the online version of the book (the article is kind of derived from the book), i have downloaded the sample code (showing a stick figure doing fancy moves), but there is so much mambojambo going on… some strange python script… circles as png-images and as header files, almost everything is written in cpp, files i copy to my project produce lots of errors that i can’t resolve properly and so on and so on. And I think I don’t need all of that fancy stuff, since I only want to draw lines in a simple cocos2d based app [Btw…. I didn’t want to use AA, but my lines are thicker than 5px which makes them have ugly holes when connected (f.e. in a circle made of several lines) so that I must use AA as it seems].

So does someone have or found a tiny little piece of runnable sample code using the principle explained in the linked article ?


Notes:

  1. In the picture you see the holes:
    http://pimml.de/circles.png

  2. Here you will find the code of the mentioned stickman (AA Lines): http://examples.oreilly.com/9780596804831/readme.html#AaLines

  3. This is how I draw my circles:

    int segments = 80;
    CGFloat width = 100;
    CGFloat height = 100;
    CGPoint center = ccp(800,200);  
    
    glDisable(GL_TEXTURE_2D);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
    //glEnable(GL_LINE_SMOOTH); // doesn't work on device
    glTranslatef(center.x, center.y, 0.0);
    glLineWidth(3.0f);
    GLfloat vertices[segments*2];
    int count=0;
    for (GLfloat i = 0; i < 360.0f; i+=(360.0f/segments))
    {
        vertices[count++] = (cos(degreesToRadian(i))*width);
        vertices[count++] = (sin(degreesToRadian(i))*height);
    }
    glVertexPointer (2, GL_FLOAT , 0, vertices); 
    glDrawArrays (GL_LINE_LOOP, 0, segments);
    
    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnable(GL_TEXTURE_2D);    
    
  • 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-16T21:52:53+00:00Added an answer on May 16, 2026 at 9:52 pm

    I ran into that issue as well. I spent a while figuring this out… I used a solution similar to this one for a while (via walterBenjamin on Apple.com):

    https://devforums.apple.com/message/264670

    This works, it is easy and it looks nice, but it still isn’t the best (for what I am doing). In the end, I wrote my own solution that combined GL Paint particle drawing with his solution of point-to-point line drawing.

    I made an array and at touchesBegin, touchesMoved, I added a point to it:

    [currentStroke addObject:[NSValue valueWithCGPoint:point]]

    Then I iterate through the strokes, such as you see in GL Paint using GL_Points.

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

Sidebar

Related Questions

There have been multiple discussions on this topic in the site but I am
I followed the instructions in this site but there's no such code inside the
I found this site http://www.shutterfly.com/documentation/api_OrderImage.sfly but there are no examples of actually walking through
There are plenty of performance questions on this site already, but it occurs to
I see there are lot of related question in this site. But Still I
This site is pretty good but I'm wondering what other resources are out there.
I know there are several similar topics like this on this site, but I
from this site there is header compress.h http://www.fredosaurus.com/notes-cpp/examples/compress/compress.html i am using visual c++ 2010
for this site: http://yoursdproperty.com/ do you see how there some extra white space all
If you visit this site , you will see that there is an image

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.