Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > OpenGL function writing help

OpenGL function writing help
Thread Tools
ZeroKoolNess1
Junior Member
Join Date: Sep 2002
Location: Evanston, Illinois
Status: Offline
Reply With Quote
Dec 3, 2003, 02:57 PM
 
I need some help. I wrote to draw a circle on screen

But I need some help to edit it to make an arc.

I want to do something like, i hope this make sense.

void drawarc (double xctr, double yctr, float radius, float startAngle, float endAngle);

With it drawing an arc of a circle origin (xctr,yctr) with a radius of (radius) that draws from startAngle to endAngle

void DrawCircle(double xctr, double yctr, double radius)
//----------------------------------------------------------------------------
// Draw an unfilled circle using the current pen color, centered at (xctr,yctr)
// with radius given by 'radius'. Default pen color is black, but you can
// change it with the 'SetPenColor()' function
// Draws a circle from a bunch of short lines
{
float vectorX;
float vectorY;
float vectorY1;
float vectorX1;
float angle;

vectorY1=yctr+radius;
vectorX1=xctr;
glBegin(GL_LINE_STRIP);
for(angle=0.0f;angle<=(2.0f*3.14159);angle+=0.01f)
{
vectorX=xctr+(radius*(float)sin((double)angle));

vectorY=yctr+(radius*(float)cos((double)angle));

glVertex2d(vectorX1,vectorY1);
vectorY1=vectorY;
vectorX1=vectorX;
}
glEnd();
glFlush();
}
That's just my opinion. What do I know, I'm just a college student.
     
calumr
Forum Regular
Join Date: Sep 2000
Location: UK
Status: Offline
Reply With Quote
Dec 4, 2003, 07:24 AM
 
Just do exactly the same thing, but this time instead of going from 0 to 2*pi, go from startAngle to endAngle.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 09:00 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,