1 /* $Id: quadric.c,v 1.2 1999/11/11 03:21:43 kendallb Exp $ */
4 * Mesa 3-D graphics library
6 * Copyright (C) 1995-1999 Brian Paul
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * Revision 1.2 1999/11/11 03:21:43 kendallb
28 * . Updated GL/gl.h with GLCALLACKP and GLAPIENTRYP macros for compatibility
29 * with the IBM VisualAge C++ compiler. Eventually some more code will be
30 * needed in the headers to enable the reversal of (__stdcall*) to (*__stdcall)
31 * for the IBM compilers, however we currently build using our own header files
32 * that already handle this.
34 * . Changed instances of (GLCALLBACK*) to GLCALLBACKP for compatibility
35 * with the IBM VisualAge C++ compiler in src-glu.
37 * . Misc cleanups for warnings generated with Watcom C++ in src-glu. Compiles
38 * with 0 warnings now.
40 * . tess_hash.c: line 244 - Why is this function stubbed out? I removed the
41 * code with a #if 0 to avoid a compiler warning, but it looks dangerous.
43 * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
46 * Revision 1.19 1999/02/27 13:55:31 brianp
47 * fixed BeOS-related GLU typedef problems
49 * Revision 1.18 1999/01/03 03:23:15 brianp
50 * now using GLAPIENTRY and GLCALLBACK keywords (Ted Jump)
52 * Revision 1.17 1999/01/03 03:19:15 brianp
53 * rewrote some of gluCylinder
55 * Revision 1.16 1998/06/01 01:08:36 brianp
56 * small update for Next/OpenStep from Alexander Mai
58 * Revision 1.15 1998/03/15 18:28:54 brianp
59 * reimplemented gluDisk() point and line mode
61 * Revision 1.14 1998/03/15 18:14:17 brianp
62 * fixed a compiler cast warning
64 * Revision 1.13 1998/02/07 14:28:34 brianp
65 * another change to gluQuadricCallback(), this time for StormC compiler
67 * Revision 1.12 1998/02/05 00:43:19 brianp
68 * Yes, still another change to gluQuadricCallback()!
70 * Revision 1.11 1998/02/04 00:27:43 brianp
71 * yet another change to gluQuadricCallback()!
73 * Revision 1.10 1998/02/04 00:23:23 brianp
74 * fixed CALLBACK problem in gluQuadricCallback() (Stephane Rehel)
76 * Revision 1.9 1998/02/04 00:20:09 brianp
77 * added missing (int) in ErrorFunc cast
79 * Revision 1.8 1998/01/16 03:37:51 brianp
80 * fixed another assignment warning in gluQuadricCallback()
82 * Revision 1.7 1998/01/16 03:35:26 brianp
83 * fixed Windows compilation warnings (Theodore Jump)
85 * Revision 1.6 1997/10/29 02:02:20 brianp
86 * various MS Windows compiler changes (David Bucciarelli, v20 3dfx driver)
88 * Revision 1.5 1997/09/17 01:51:48 brianp
89 * changed glu*Callback() functions to match prototype in glu.h
91 * Revision 1.4 1997/07/24 01:28:44 brianp
92 * changed precompiled header symbol from PCH to PC_HEADER
94 * Revision 1.3 1997/05/28 02:29:38 brianp
95 * added support for precompiled headers (PCH), inserted APIENTRY keyword
97 * Revision 1.2 1997/03/12 02:15:38 brianp
98 * fixed problem in gluPartialDisk() reported by Kenneth H. Carpenter
100 * Revision 1.1 1996/09/27 01:19:39 brianp
107 * texture coordinate support
108 * flip normals according to orientation
109 * there's still some inside/outside orientation bugs in possibly all
110 * but the sphere function
126 * Sin and Cos for degree angles:
128 #define SIND( A ) sin( (A)*(M_PI/180.0) )
129 #define COSD( A) cos( (A)*(M_PI/180.0) )
133 * Texture coordinates if texture flag is set
135 #define TXTR_COORD(x,y) if (qobj->TextureFlag) glTexCoord2f(x,y);
140 GLenum DrawStyle
; /* GLU_FILL, LINE, SILHOUETTE, or POINT */
141 GLenum Orientation
; /* GLU_INSIDE or GLU_OUTSIDE */
142 GLboolean TextureFlag
; /* Generate texture coords? */
143 GLenum Normals
; /* GLU_NONE, GLU_FLAT, or GLU_SMOOTH */
144 void (GLCALLBACKP ErrorFunc
)(GLenum err
); /* Error handler callback function */
150 * Process a GLU error.
152 static void quadric_error( GLUquadricObj
*qobj
, GLenum error
, const char *msg
)
154 /* Call the error call back function if any */
155 if (qobj
->ErrorFunc
) {
156 (*qobj
->ErrorFunc
)( error
);
158 /* Print a message to stdout if MESA_DEBUG variable is defined */
159 if (getenv("MESA_DEBUG")) {
160 fprintf(stderr
,"GLUError: %s: %s\n", (char*) gluErrorString(error
), msg
);
167 GLUquadricObj
* GLAPIENTRY
gluNewQuadric( void )
171 q
= (GLUquadricObj
*) malloc( sizeof(struct GLUquadric
) );
173 q
->DrawStyle
= GLU_FILL
;
174 q
->Orientation
= GLU_OUTSIDE
;
175 q
->TextureFlag
= GL_FALSE
;
176 q
->Normals
= GLU_SMOOTH
;
184 void GLAPIENTRY
gluDeleteQuadric( GLUquadricObj
*state
)
187 free( (void *) state
);
194 * Set the drawing style to be GLU_FILL, GLU_LINE, GLU_SILHOUETTE,
197 void GLAPIENTRY
gluQuadricDrawStyle( GLUquadricObj
*quadObject
, GLenum drawStyle
)
199 if (quadObject
&& (drawStyle
==GLU_FILL
|| drawStyle
==GLU_LINE
200 || drawStyle
==GLU_SILHOUETTE
|| drawStyle
==GLU_POINT
)) {
201 quadObject
->DrawStyle
= drawStyle
;
204 quadric_error( quadObject
, GLU_INVALID_ENUM
, "qluQuadricDrawStyle" );
211 * Set the orientation to GLU_INSIDE or GLU_OUTSIDE.
213 void GLAPIENTRY
gluQuadricOrientation( GLUquadricObj
*quadObject
,
216 if (quadObject
&& (orientation
==GLU_INSIDE
|| orientation
==GLU_OUTSIDE
)) {
217 quadObject
->Orientation
= orientation
;
220 quadric_error( quadObject
, GLU_INVALID_ENUM
, "qluQuadricOrientation" );
227 * Set the error handler callback function.
229 void GLAPIENTRY
gluQuadricCallback( GLUquadricObj
*qobj
,
230 GLenum which
, void (GLCALLBACKP fn
)() )
233 * UGH, this is a mess! I thought ANSI was a standard.
235 if (qobj
&& which
==GLU_ERROR
) {
237 qobj
->ErrorFunc
= (void(*)(int))fn
;
238 #elif defined(OPENSTEP)
239 qobj
->ErrorFunc
= (void(*)(GLenum
))fn
;
240 #elif defined(_WIN32)
241 qobj
->ErrorFunc
= (void(GLCALLBACKP
)(int))fn
;
242 #elif defined(__STORM__)
243 qobj
->ErrorFunc
= (void(GLCALLBACKP
)(GLenum
))fn
;
244 #elif defined(__BEOS__)
245 qobj
->ErrorFunc
= (void(*)(GLenum
))fn
;
247 qobj
->ErrorFunc
= (void(GLCALLBACKP
)())fn
;
253 void GLAPIENTRY
gluQuadricNormals( GLUquadricObj
*quadObject
, GLenum normals
)
256 && (normals
==GLU_NONE
|| normals
==GLU_FLAT
|| normals
==GLU_SMOOTH
)) {
257 quadObject
->Normals
= normals
;
262 void GLAPIENTRY
gluQuadricTexture( GLUquadricObj
*quadObject
,
263 GLboolean textureCoords
)
266 quadObject
->TextureFlag
= textureCoords
;
274 * Call glNormal3f after scaling normal to unit length.
276 static void normal3f( GLfloat x
, GLfloat y
, GLfloat z
)
280 mag
= sqrt( x
*x
+ y
*y
+ z
*z
);
286 glNormal3f( x
, y
, z
);
291 void GLAPIENTRY
gluCylinder( GLUquadricObj
*qobj
,
292 GLdouble baseRadius
, GLdouble topRadius
,
293 GLdouble height
, GLint slices
, GLint stacks
)
295 GLdouble da
, r
, dr
, dz
;
296 GLfloat x
, y
, z
, nz
, nsign
;
299 if (qobj
->Orientation
==GLU_INSIDE
) {
306 da
= 2.0*M_PI
/ slices
;
307 dr
= (topRadius
-baseRadius
) / stacks
;
308 dz
= height
/ stacks
;
309 nz
= (baseRadius
-topRadius
) / height
; /* Z component of normal vectors */
311 if (qobj
->DrawStyle
==GLU_POINT
) {
312 glBegin( GL_POINTS
);
313 for (i
=0;i
<slices
;i
++) {
316 normal3f( x
*nsign
, y
*nsign
, nz
*nsign
);
320 for (j
=0;j
<=stacks
;j
++) {
321 glVertex3f( x
*r
, y
*r
, z
);
328 else if (qobj
->DrawStyle
==GLU_LINE
|| qobj
->DrawStyle
==GLU_SILHOUETTE
) {
330 if (qobj
->DrawStyle
==GLU_LINE
) {
333 for (j
=0;j
<=stacks
;j
++) {
334 glBegin( GL_LINE_LOOP
);
335 for (i
=0;i
<slices
;i
++) {
338 normal3f( x
*nsign
, y
*nsign
, nz
*nsign
);
339 glVertex3f( x
*r
, y
*r
, z
);
347 /* draw one ring at each end */
348 if (baseRadius
!=0.0) {
349 glBegin( GL_LINE_LOOP
);
350 for (i
=0;i
<slices
;i
++) {
353 normal3f( x
*nsign
, y
*nsign
, nz
*nsign
);
354 glVertex3f( x
*baseRadius
, y
*baseRadius
, 0.0 );
357 glBegin( GL_LINE_LOOP
);
358 for (i
=0;i
<slices
;i
++) {
361 normal3f( x
*nsign
, y
*nsign
, nz
*nsign
);
362 glVertex3f( x
*topRadius
, y
*topRadius
, height
);
367 /* draw length lines */
369 for (i
=0;i
<slices
;i
++) {
372 normal3f( x
*nsign
, y
*nsign
, nz
*nsign
);
373 glVertex3f( x
*baseRadius
, y
*baseRadius
, 0.0 );
374 glVertex3f( x
*topRadius
, y
*topRadius
, height
);
378 else if (qobj
->DrawStyle
==GLU_FILL
) {
379 GLfloat ds
= 1.0 / slices
;
380 GLfloat dt
= 1.0 / stacks
;
384 for (j
=0;j
<stacks
;j
++) {
386 glBegin( GL_QUAD_STRIP
);
387 for (i
=0;i
<=slices
;i
++) {
398 normal3f( x
*nsign
, y
*nsign
, nz
*nsign
);
400 glVertex3f( x
* r
, y
* r
, z
);
401 normal3f( x
*nsign
, y
*nsign
, nz
*nsign
);
402 TXTR_COORD(s
, t
+ dt
);
403 glVertex3f( x
* (r
+ dr
), y
* (r
+ dr
), z
+ dz
);
406 normal3f( x
*nsign
, y
*nsign
, nz
*nsign
);
408 glVertex3f( x
* r
, y
* r
, z
);
409 normal3f( x
*nsign
, y
*nsign
, nz
*nsign
);
410 TXTR_COORD(s
, t
+ dt
);
411 glVertex3f( x
* (r
+ dr
), y
* (r
+ dr
), z
+ dz
);
427 void GLAPIENTRY
gluSphere( GLUquadricObj
*qobj
,
428 GLdouble radius
, GLint slices
, GLint stacks
)
430 GLfloat rho
, drho
, theta
, dtheta
;
432 GLfloat s
, t
, ds
, dt
;
433 GLint i
, j
, imin
, imax
;
437 if (qobj
->Normals
==GLU_NONE
) {
443 if (qobj
->Orientation
==GLU_INSIDE
) {
450 drho
= M_PI
/ (GLfloat
) stacks
;
451 dtheta
= 2.0 * M_PI
/ (GLfloat
) slices
;
453 /* texturing: s goes from 0.0/0.25/0.5/0.75/1.0 at +y/+x/-y/-x/+y axis */
454 /* t goes from -1.0/+1.0 at z = -radius/+radius (linear along longitudes) */
455 /* cannot use triangle fan on texturing (s coord. at top/bottom tip varies) */
457 if (qobj
->DrawStyle
==GLU_FILL
) {
458 if (!qobj
->TextureFlag
) {
459 /* draw +Z end as a triangle fan */
460 glBegin( GL_TRIANGLE_FAN
);
461 glNormal3f( 0.0, 0.0, 1.0 );
463 glVertex3f( 0.0, 0.0, nsign
* radius
);
464 for (j
=0;j
<=slices
;j
++) {
465 theta
= (j
==slices
) ? 0.0 : j
* dtheta
;
466 x
= -sin(theta
) * sin(drho
);
467 y
= cos(theta
) * sin(drho
);
468 z
= nsign
* cos(drho
);
469 if (normals
) glNormal3f( x
*nsign
, y
*nsign
, z
*nsign
);
470 glVertex3f( x
*radius
, y
*radius
, z
*radius
);
477 t
= 1.0; /* because loop now runs from 0 */
478 if (qobj
->TextureFlag
) {
487 /* draw intermediate stacks as quad strips */
488 for (i
=imin
;i
<imax
;i
++) {
490 glBegin( GL_QUAD_STRIP
);
492 for (j
=0;j
<=slices
;j
++) {
493 theta
= (j
==slices
) ? 0.0 : j
* dtheta
;
494 x
= -sin(theta
) * sin(rho
);
495 y
= cos(theta
) * sin(rho
);
496 z
= nsign
* cos(rho
);
497 if (normals
) glNormal3f( x
*nsign
, y
*nsign
, z
*nsign
);
499 glVertex3f( x
*radius
, y
*radius
, z
*radius
);
500 x
= -sin(theta
) * sin(rho
+drho
);
501 y
= cos(theta
) * sin(rho
+drho
);
502 z
= nsign
* cos(rho
+drho
);
503 if (normals
) glNormal3f( x
*nsign
, y
*nsign
, z
*nsign
);
506 glVertex3f( x
*radius
, y
*radius
, z
*radius
);
512 if (!qobj
->TextureFlag
) {
513 /* draw -Z end as a triangle fan */
514 glBegin( GL_TRIANGLE_FAN
);
515 glNormal3f( 0.0, 0.0, -1.0 );
517 glVertex3f( 0.0, 0.0, -radius
*nsign
);
521 for (j
=slices
;j
>=0;j
--) {
522 theta
= (j
==slices
) ? 0.0 : j
* dtheta
;
523 x
= -sin(theta
) * sin(rho
);
524 y
= cos(theta
) * sin(rho
);
525 z
= nsign
* cos(rho
);
526 if (normals
) glNormal3f( x
*nsign
, y
*nsign
, z
*nsign
);
529 glVertex3f( x
*radius
, y
*radius
, z
*radius
);
534 else if (qobj
->DrawStyle
==GLU_LINE
|| qobj
->DrawStyle
==GLU_SILHOUETTE
) {
535 /* draw stack lines */
536 for (i
=1;i
<stacks
;i
++) { /* stack line at i==stacks-1 was missing here */
538 glBegin( GL_LINE_LOOP
);
539 for (j
=0;j
<slices
;j
++) {
541 x
= cos(theta
) * sin(rho
);
542 y
= sin(theta
) * sin(rho
);
544 if (normals
) glNormal3f( x
*nsign
, y
*nsign
, z
*nsign
);
545 glVertex3f( x
*radius
, y
*radius
, z
*radius
);
549 /* draw slice lines */
550 for (j
=0;j
<slices
;j
++) {
552 glBegin( GL_LINE_STRIP
);
553 for (i
=0;i
<=stacks
;i
++) {
555 x
= cos(theta
) * sin(rho
);
556 y
= sin(theta
) * sin(rho
);
558 if (normals
) glNormal3f( x
*nsign
, y
*nsign
, z
*nsign
);
559 glVertex3f( x
*radius
, y
*radius
, z
*radius
);
564 else if (qobj
->DrawStyle
==GLU_POINT
) {
565 /* top and bottom-most points */
566 glBegin( GL_POINTS
);
567 if (normals
) glNormal3f( 0.0, 0.0, nsign
);
568 glVertex3d( 0.0, 0.0, radius
);
569 if (normals
) glNormal3f( 0.0, 0.0, -nsign
);
570 glVertex3d( 0.0, 0.0, -radius
);
572 /* loop over stacks */
573 for (i
=1;i
<stacks
-1;i
++) {
575 for (j
=0;j
<slices
;j
++) {
577 x
= cos(theta
) * sin(rho
);
578 y
= sin(theta
) * sin(rho
);
580 if (normals
) glNormal3f( x
*nsign
, y
*nsign
, z
*nsign
);
581 glVertex3f( x
*radius
, y
*radius
, z
*radius
);
591 void GLAPIENTRY
gluDisk( GLUquadricObj
*qobj
,
592 GLdouble innerRadius
, GLdouble outerRadius
,
593 GLint slices
, GLint loops
)
605 if (qobj
->Normals
!=GLU_NONE
) {
606 if (qobj
->Orientation
==GLU_OUTSIDE
) {
607 glNormal3f( 0.0, 0.0, +1.0 );
610 glNormal3f( 0.0, 0.0, -1.0 );
614 da
= 2.0*M_PI
/ slices
;
615 dr
= (outerRadius
-innerRadius
) / (GLfloat
) loops
;
617 switch (qobj
->DrawStyle
) {
620 /* texture of a gluDisk is a cut out of the texture unit square
621 * x, y in [-outerRadius, +outerRadius]; s, t in [0, 1]
624 GLfloat dtc
= 2.0f
* outerRadius
;
626 GLfloat r1
= innerRadius
;
628 for (l
=0; l
<loops
; l
++) {
629 GLfloat r2
= r1
+ dr
;
630 if (qobj
->Orientation
==GLU_OUTSIDE
) {
632 glBegin( GL_QUAD_STRIP
);
633 for (s
=0;s
<=slices
;s
++) {
635 if (s
==slices
) a
= 0.0;
637 sa
= sin(a
); ca
= cos(a
);
638 TXTR_COORD(0.5+sa
*r2
/dtc
,0.5+ca
*r2
/dtc
);
639 glVertex2f( r2
*sa
, r2
*ca
);
640 TXTR_COORD(0.5+sa
*r1
/dtc
,0.5+ca
*r1
/dtc
);
641 glVertex2f( r1
*sa
, r1
*ca
);
647 glBegin( GL_QUAD_STRIP
);
648 for (s
=slices
;s
>=0;s
--) {
650 if (s
==slices
) a
= 0.0;
652 sa
= sin(a
); ca
= cos(a
);
653 TXTR_COORD(0.5-sa
*r2
/dtc
,0.5+ca
*r2
/dtc
);
654 glVertex2f( r2
*sa
, r2
*ca
);
655 TXTR_COORD(0.5-sa
*r1
/dtc
,0.5+ca
*r1
/dtc
);
656 glVertex2f( r1
*sa
, r1
*ca
);
668 for (l
=0; l
<=loops
; l
++) {
669 GLfloat r
= innerRadius
+ l
* dr
;
670 glBegin( GL_LINE_LOOP
);
671 for (s
=0; s
<slices
; s
++) {
673 glVertex2f( r
*sin(a
), r
*cos(a
) );
678 for (s
=0; s
<slices
; s
++) {
682 glBegin( GL_LINE_STRIP
);
683 for (l
=0; l
<=loops
; l
++) {
684 GLfloat r
= innerRadius
+ l
* dr
;
685 glVertex2f( r
*x
, r
*y
);
694 glBegin( GL_POINTS
);
695 for (s
=0; s
<slices
; s
++) {
700 for (l
=0; l
<=loops
; l
++) {
701 GLfloat r
= innerRadius
* l
* dr
;
702 glVertex2f( r
*x
, r
*y
);
710 if (innerRadius
!=0.0) {
712 glBegin( GL_LINE_LOOP
);
713 for (a
=0.0; a
<2.0*M_PI
; a
+=da
) {
714 GLfloat x
= innerRadius
* sin(a
);
715 GLfloat y
= innerRadius
* cos(a
);
722 glBegin( GL_LINE_LOOP
);
723 for (a
=0; a
<2.0*M_PI
; a
+=da
) {
724 GLfloat x
= outerRadius
* sin(a
);
725 GLfloat y
= outerRadius
* cos(a
);
739 void GLAPIENTRY
gluPartialDisk( GLUquadricObj
*qobj
, GLdouble innerRadius
,
740 GLdouble outerRadius
, GLint slices
, GLint loops
,
741 GLdouble startAngle
, GLdouble sweepAngle
)
743 if (qobj
->Normals
!=GLU_NONE
) {
744 if (qobj
->Orientation
==GLU_OUTSIDE
) {
745 glNormal3f( 0.0, 0.0, +1.0 );
748 glNormal3f( 0.0, 0.0, -1.0 );
752 if (qobj
->DrawStyle
==GLU_POINT
) {
754 GLdouble radius
, delta_radius
;
755 GLdouble angle
, delta_angle
;
756 delta_radius
= (outerRadius
- innerRadius
) / (loops
-1);
757 delta_angle
= DEG_TO_RAD((sweepAngle
) / (slices
-1));
758 glBegin( GL_POINTS
);
759 radius
= innerRadius
;
760 for (loop
=0; loop
<loops
; loop
++) {
761 angle
= DEG_TO_RAD(startAngle
);
762 for (slice
=0; slice
<slices
; slice
++) {
763 glVertex2d( radius
* sin(angle
), radius
* cos(angle
) );
764 angle
+= delta_angle
;
766 radius
+= delta_radius
;
770 else if (qobj
->DrawStyle
==GLU_LINE
) {
772 GLdouble radius
, delta_radius
;
773 GLdouble angle
, delta_angle
;
774 delta_radius
= (outerRadius
- innerRadius
) / loops
;
775 delta_angle
= DEG_TO_RAD(sweepAngle
/ slices
);
777 radius
= innerRadius
;
778 for (loop
=0; loop
<loops
; loop
++) {
779 angle
= DEG_TO_RAD(startAngle
);
780 glBegin( GL_LINE_STRIP
);
781 for (slice
=0; slice
<slices
; slice
++) {
782 glVertex2d( radius
* sin(angle
), radius
* cos(angle
) );
783 angle
+= delta_angle
;
786 radius
+= delta_radius
;
789 angle
= DEG_TO_RAD(startAngle
);
790 for (slice
=0; slice
<slices
; slice
++) {
791 radius
= innerRadius
;
792 glBegin( GL_LINE_STRIP
);
793 for (loop
=0; loop
<loops
; loop
++) {
794 glVertex2d( radius
* sin(angle
), radius
* cos(angle
) );
795 radius
+= delta_radius
;
798 angle
+= delta_angle
;
801 else if (qobj
->DrawStyle
==GLU_SILHOUETTE
) {
803 GLdouble angle
, delta_angle
;
804 delta_angle
= DEG_TO_RAD(sweepAngle
/ slices
);
805 /* draw outer ring */
806 glBegin( GL_LINE_STRIP
);
807 angle
= DEG_TO_RAD(startAngle
);
808 for (slice
=0; slice
<=slices
; slice
++) {
809 glVertex2d( outerRadius
* sin(angle
), outerRadius
* cos(angle
) );
810 angle
+= delta_angle
;
813 /* draw inner ring */
814 if (innerRadius
>0.0) {
815 glBegin( GL_LINE_STRIP
);
816 angle
= DEG_TO_RAD(startAngle
);
817 for (slice
=0; slice
<slices
; slice
++) {
818 glVertex2d( innerRadius
* sin(angle
), innerRadius
* cos(angle
) );
819 angle
+= delta_angle
;
824 if (sweepAngle
<360.0) {
825 GLdouble stopAngle
= startAngle
+ sweepAngle
;
827 glVertex2d( innerRadius
*SIND(startAngle
), innerRadius
*COSD(startAngle
) );
828 glVertex2d( outerRadius
*SIND(startAngle
), outerRadius
*COSD(startAngle
) );
829 glVertex2d( innerRadius
*SIND(stopAngle
), innerRadius
*COSD(stopAngle
) );
830 glVertex2d( outerRadius
*SIND(stopAngle
), outerRadius
*COSD(stopAngle
) );
834 else if (qobj
->DrawStyle
==GLU_FILL
) {
836 GLdouble radius
, delta_radius
;
837 GLdouble angle
, delta_angle
;
838 delta_radius
= (outerRadius
- innerRadius
) / loops
;
839 delta_angle
= DEG_TO_RAD(sweepAngle
/ slices
);
840 radius
= innerRadius
;
841 for (loop
=0; loop
<loops
; loop
++) {
842 glBegin( GL_QUAD_STRIP
);
843 angle
= DEG_TO_RAD(startAngle
);
844 for (slice
=0; slice
<slices
; slice
++) {
845 if (qobj
->Orientation
==GLU_OUTSIDE
) {
846 glVertex2d( (radius
+delta_radius
)*sin(angle
),
847 (radius
+delta_radius
)*cos(angle
) );
848 glVertex2d( radius
* sin(angle
), radius
* cos(angle
) );
851 glVertex2d( radius
* sin(angle
), radius
* cos(angle
) );
852 glVertex2d( (radius
+delta_radius
)*sin(angle
),
853 (radius
+delta_radius
)*cos(angle
) );
855 angle
+= delta_angle
;
858 radius
+= delta_radius
;