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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:43:13+00:00 2026-06-07T22:43:13+00:00

I have problem rendering many circles on the screen using these code. float degree

  • 0

I have problem rendering many circles on the screen using these code.

float degree = 0;
unsigned int ctr = 0;
for(int xi = -3200; xi < 3200; xi+= 2*r)
{
    for(int yi = 4800; yi > -4800; yi-= 2*r)
    {
        for(int i = 0; i < 360; ++i)
        {
            vertices.push_back(xi + r * cos(float(degree)));
            vertices.push_back(yi + r * sin(float(degree)));
            vertices.push_back(-8);

            indices.push_back(i+ctr);               
            ++degree;
        }
        ctr += 360;
        degree = 0;
    }
}

unsigned int i = 0;
for(i = 0; i < indices.size()/360; ++i) 
{
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3, GL_FLOAT, 0, &vertices[i*360]);
    glLineWidth(1);
    glDrawElements(GL_LINE_LOOP, 360, GL_UNSIGNED_INT, &indices[i*360]);
    glDisableClientState(GL_VERTEX_ARRAY);
}

Here is the result
circles

In addition, the program crashes when I change xi value to [-6400, 6400]

  • 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-07T22:43:15+00:00Added an answer on June 7, 2026 at 10:43 pm

    Leaving aside the questionable nature of this technique, you look to be accessing the indices incorrectly.

    glVertexPointer(3, GL_FLOAT, 0, &vertices[i*360]);
    glDrawElements(GL_LINE_LOOP, 360, GL_UNSIGNED_INT, &indices[i*360]);
    

    The indices of glDrawElements specify an offset from the vertices at glVertexPointer. You’ve defined the indices as relative to the start of the vertex buffer:

    indices.push_back(i+ctr);   
    

    But you’re moving the buffer offset for each circle you draw. So in your indices buffer, the second circle starts at index 360. But when you draw the second circle, you also move the vertex pointer such that index 360 is the 0th element of the pointer.

    Then when you try to access index 360, you’re actually accessing element 720 (360 + start of buffer @360).

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

Sidebar

Related Questions

I have a problem with rendering my html page by the same browsers in
Ok so I have a problem with rails and rendering partials. I have a
Ok, here's a problem I'm having. I have Lua bindings to a rendering engine
I have problem with my query on C, I’m using the oci8 driver. This
i have a problem with rendering image on RDL file in reporting services (SQL
I'm sure this is a common problem for many web applications these days. What
I have a portlet which has many rendering and action methods: @Controller @RequestMapping(VIEW) public
I have some problems with performance in my code… I need to render many-colored
I have problem with http://abfoodpolicy.com/ . In IE 8 and 9 the right sidebar
I have problem with repopulating form_upload after validation. Other input fields or selectboxes are

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.