]> icculus.org git repositories - taylor/freespace2.git/blob - src/graphics/circle.cpp
Initial revision
[taylor/freespace2.git] / src / graphics / circle.cpp
1 /*
2  * $Logfile: /Freespace2/code/Graphics/Circle.cpp $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Code to draw circles.
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:09  root
11  * Initial revision
12  *
13  * 
14  * 2     10/07/98 10:52a Dave
15  * Initial checkin.
16  * 
17  * 1     10/07/98 10:48a Dave
18  * 
19  * 9     3/10/98 4:18p John
20  * Cleaned up graphics lib.  Took out most unused gr functions.   Made D3D
21  * & Glide have popups and print screen.  Took out all >8bpp software
22  * support.  Made Fred zbuffer.  Made zbuffer allocate dynamically to
23  * support Fred.  Made zbuffering key off of functions rather than one
24  * global variable.
25  * 
26  * 8     11/06/97 11:18a John
27  * fixed bug with some scanlines being drawn twice
28  * 
29  * 7     11/26/96 6:50p John
30  * Added some more hicolor primitives.  Made windowed mode run as current
31  * bpp, if bpp is 8,16,or 32.
32  * 
33  * 6     11/26/96 4:30p John
34  * Put in some better quality circle_empty code.
35  * 
36  * 5     11/07/96 6:19p John
37  * Added a bunch of 16bpp primitives so the game sort of runs in 16bpp
38  * mode.
39  * 
40  * 4     10/26/96 1:40p John
41  * Added some now primitives to the 2d library and
42  * cleaned up some old ones.
43  *
44  * $NoKeywords: $
45  */
46
47 #include "2d.h"
48 #include "pixel.h"
49 #include "circle.h"
50
51 // THIS COULD BE OPTIMIZED BY MOVING THE GR_RECT CODE INTO HERE!!!!!!!!
52
53 #define circle_fill(x,y,w) gr_rect((x),(y),(w),1)
54
55 void gr8_circle( int xc, int yc, int d )
56 {
57         int p,x, y, r;
58
59         r = d/2;
60         p=3-d;
61         x=0;
62         y=r;
63
64         // Big clip
65         if ( (xc+r) < gr_screen.clip_left ) return;
66         if ( (xc-r) > gr_screen.clip_right ) return;
67         if ( (yc+r) < gr_screen.clip_top ) return;
68         if ( (yc-r) > gr_screen.clip_bottom ) return;
69
70         while(x<y)      {
71                 // Draw the first octant
72                 circle_fill( xc-y, yc-x, y*2+1 );
73                 if ( x != 0 )   
74                         circle_fill( xc-y, yc+x, y*2+1 );
75
76                 if (p<0) 
77                         p=p+(x<<2)+6;
78                 else    {
79                         // Draw the second octant
80                         circle_fill( xc-x, yc-y, x*2+1 );
81                         if ( y != 0 )   
82                                 circle_fill( xc-x, yc+y, x*2+1 );
83                         p=p+((x-y)<<2)+10;
84                         y--;
85                 }
86                 x++;
87         }
88
89         if(x==y)        {
90                 circle_fill( xc-x, yc-y, x*2+1 );
91                 if ( y != 0 )   
92                         circle_fill( xc-x, yc+y, x*2+1 );
93         }
94
95 }
96