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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:10:36+00:00 2026-05-14T05:10:36+00:00

While making a little Pong game in C++ OpenGL, I decided it’d be fun

  • 0

While making a little Pong game in C++ OpenGL, I decided it’d be fun to create arcs (semi-circles) when stuff bounces. I decided to skip Bezier curves for the moment and just go with straight algebra, but I didn’t get far. My algebra follows a simple quadratic function (y = +- sqrt(mx+c)).

This little excerpt is just an example I’ve yet to fully parameterize, I just wanted to see how it would look. When I draw this, however, it gives me a straight vertical line where the line’s tangent line approaches -1.0 / 1.0.

Is this a limitation of the GL_LINE_STRIP style or is there an easier way to draw semi-circles / arcs? Or did I just completely miss something obvious?

void Ball::drawBounce()
{   float piecesToDraw = 100.0f;
    float arcWidth = 10.0f;
    float arcAngle = 4.0f;

    glBegin(GL_LINE_STRIP);
        for (float i = 0.0f; i < piecesToDraw; i += 1.0f)  // Positive Half
        {   float currentX = (i / piecesToDraw) * arcWidth;
            glVertex2f(currentX, sqrtf((-currentX * arcAngle)+ arcWidth));
        }
        for (float j = piecesToDraw; j > 0.0f; j -= 1.0f) // Negative half (go backwards in X direction now)
        {   float currentX = (j / piecesToDraw) * arcWidth;
            glVertex2f(currentX, -sqrtf((-currentX * arcAngle) + arcWidth));
        }
    glEnd();
}

Thanks in advance.

  • 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-14T05:10:36+00:00Added an answer on May 14, 2026 at 5:10 am

    What is the purpose of sqrtf((-currentX * arcAngle)+ arcWidth)? When i>25, that expression becomes imaginary. The proper way of doing this would be using sin()/cos() to generate the X and Y coordinates for a semi-circle as stated in your question. If you want to use a parabola instead, the cleaner way would be to calculate y=H-H(x/W)^2

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

Sidebar

Related Questions

I'm a newbie so bear with me. I'm making a little forum for fun.
I'm making a simple little utility while learning Python. It dynamically generates a list
I'm making a little game in C. I try to program in an object-oriented
I am programatically making some LinkButtons, and they worked fine for a while, but
It's been a little while since I did C++ development professionally and I'd like
Apple has a nice little tutorial for making a simple master-detail interface. Interface Builder
I've noticed some of my actions (on a development environment) take a little while
I'm working on a quick page intended for mobile browsers. While there is little
While the C# spec does include a pre-processor and basic directives (#define, #if, etc),
While going through university and from following the development of SO, I've heard a

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.