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

  • Home
  • SEARCH
  • 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 8818653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:09:35+00:00 2026-06-14T05:09:35+00:00

I need a function to draw an arc in opengl. I also need a

  • 0

I need a function to draw an arc in opengl.
I also need a sample code for using it.

i can draw a circle with Lines,i want to draw arc with Line too.
This is My Function for drawing circule :

void DrawCircle(float cx, float cy, float r, int num_segments) 
{ 
    glBegin(GL_LINE_STRIP); 
    for(int ii = 0; ii < num_segments; ii++) 
    { 
        float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle 

        float x = r * cosf(theta);//calculate the x component 
        float y = r * sinf(theta);//calculate the y component 

        glVertex2f(x + cx, y + cy);//output vertex 
    } 
    glEnd(); 
}

I used LINE_STRIP for Concert the code to Drawing an arc but didn’t work.
Does anyone can help me?

  • 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-14T05:09:37+00:00Added an answer on June 14, 2026 at 5:09 am

    Not necessarily the best way, but if you just need to get something working, you can modify your circle code slightly. Add a float arc_length parameter to the function signature. Replace 2.0f * 3.1415926f with arc_length. If you need to start the arc at a given offset, you can add another parameter called float arc_start. Then add arc_start to theta in each iteration of your for loop.

    Edit based on Saman’s comments:

    What you actually want is not an arc, but a more general representation of a curve. An arc is a kind of curve, but it’s a very particular kind–i.e. one with a constant radius. It sounds like you want to draw arbitrary curves, potentially with varying radii. If so, then my recommendation is Bezier curves. Here is a pretty solid introduction:

    http://devmag.org.za/2011/04/05/bzier-curves-a-tutorial/

    Note the part later in the tutorial about drawing them, where the author says “the simplest approach is to use small increments of t to calculate successive points.” This is pretty much what you have to do in order to draw a Bezier curve in OpenGL. Pick a value of t, and increment it in a for loop, just like you did with theta in your original circle code. For each iteration, draw a point.

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

Sidebar

Related Questions

How can I draw an elliptic arc with Java without using any standard graphic
Using SVG path, we can draw 99.99% of a circle and it shows up,
I'm using controlP5 processing GUI, and I need counter inside draw() function. I know
I need to draw 3d projections and i am using opengl wrapper for JAVA.
I need a very simple function to draw a bunch of lines with anti-aliasing.
I've been learning OpenGL, and I decided to code a function to draw a
I'm trying to draw a line using ctx.lineTo in loop. I have small function
I need to draw an arc in a D2D device, is there a function
I need a function that can intersect 2 arrays for example: $Array1 = array(1,2,3);
I need a function that can print Turkish characters. public String convert(String input) {

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.