-
Notifications
You must be signed in to change notification settings - Fork 17
/
grguDraw.cpp
302 lines (259 loc) · 7.54 KB
/
grguDraw.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
//**************************************************************
//* OpenGLide - Glide to OpenGL Wrapper
//* http://openglide.sourceforge.net
//*
//* Drawing Functions
//*
//* OpenGLide is OpenSource under LGPL license
//* Originally made by Fabio Barros
//* Modified by Paul for Glidos (http://www.glidos.net)
//* Linux version by Simon White
//**************************************************************
#include "GlOgl.h"
#include "GLRender.h"
//*************************************************
//* Draws a Triangle on the screen
//*************************************************
FX_ENTRY void FX_CALL
grDrawTriangle( const GrVertex *a, const GrVertex *b, const GrVertex *c )
{
#ifdef OGL_CRITICAL
GlideMsg( "grDrawTriangle( ---, ---, --- )\n" );
#endif
RenderAddTriangle( a, b, c, true );
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
{
RenderDrawTriangles( );
glFlush( );
}
}
//*************************************************
//* Draws a Triangle on the screen
//*************************************************
FX_ENTRY void FX_CALL
grDrawPlanarPolygonVertexList( int nVertices, const GrVertex vlist[] )
{
#ifdef OGL_CRITICAL
GlideMsg("grDrawPlanarPolygonVertexList( %d, --- )\n", nVertices );
#endif
for ( int i = 2; i < nVertices; i++ )
{
RenderAddTriangle( &vlist[ 0 ], &vlist[ i - 1 ], &vlist[ i ], true );
}
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
{
RenderDrawTriangles( );
glFlush( );
}
}
//*************************************************
//* Draws a Line on the screen
//*************************************************
FX_ENTRY void FX_CALL
grDrawLine( const GrVertex *a, const GrVertex *b )
{
#ifdef OGL_CRITICAL
GlideMsg("grDrawLine( ---, --- )\n");
#endif
/*
* RenderAddLine actually renders the line, so
* we must render the queued triangles first to
* avoid out-of-order rendering.
*/
RenderDrawTriangles( );
RenderAddLine( a, b, true );
}
//*************************************************
//* Draws a Point on the screen
//*************************************************
FX_ENTRY void FX_CALL
grDrawPoint( const GrVertex *a )
{
#ifdef OGL_CRITICAL
GlideMsg( "grDrawPoint( --- )\n" );
#endif
RenderAddPoint( a, true );
}
//*************************************************
//* Draw a convex non-planar polygon
//*************************************************
FX_ENTRY void FX_CALL
grDrawPolygon( int nverts, const int ilist[], const GrVertex vlist[] )
{
#ifdef OGL_CRITICAL
GlideMsg( "grDrawPolygon( %d, ---, --- )\n" );
#endif
for ( int i = 2; i < nverts; i++ )
{
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
&vlist[ ilist[ i - 1 ] ],
&vlist[ ilist[ i ] ],
true );
}
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
{
RenderDrawTriangles( );
glFlush( );
}
}
//*************************************************
//* Draw a convex planar polygon
//*************************************************
FX_ENTRY void FX_CALL
grDrawPlanarPolygon( int nverts, const int ilist[], const GrVertex vlist[] )
{
#ifdef OGL_CRITICAL
GlideMsg( "grDrawPlanarPolygon( %d, ---, --- )\n", nverts );
#endif
for ( int i = 2; i < nverts; i++ )
{
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
&vlist[ ilist[ i - 1 ] ],
&vlist[ ilist[ i ] ],
true );
}
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
{
RenderDrawTriangles( );
glFlush( );
}
}
//*************************************************
//* Draw a convex non-planar polygon
//*************************************************
FX_ENTRY void FX_CALL
grDrawPolygonVertexList( int nVertices, const GrVertex vlist[] )
{
#ifdef OGL_CRITICAL
GlideMsg( "grDrawPolygonVertexList( %d, --- )\n", nVertices );
#endif
for ( int i = 2; i < nVertices; i++ )
{
RenderAddTriangle( &vlist[ 0 ],
&vlist[ i - 1 ],
&vlist[ i ],
true );
}
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
{
RenderDrawTriangles( );
glFlush( );
}
}
FX_ENTRY void FX_CALL
guAADrawTriangleWithClip( const GrVertex *a, const GrVertex *b,
const GrVertex *c )
{
#ifdef OGL_CRITICAL
GlideMsg("guAADrawTriangleWithClip( ---, ---, --- )\n");
#endif
RenderAddTriangle( a, b, c, false );
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
{
RenderDrawTriangles( );
glFlush( );
}
}
FX_ENTRY void FX_CALL
guDrawTriangleWithClip( const GrVertex *a,
const GrVertex *b,
const GrVertex *c )
{
#ifdef OGL_CRITICAL
GlideMsg("guDrawTriangleWithClip( ---, ---, --- )\n");
#endif
RenderAddTriangle( a, b, c, false );
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
{
RenderDrawTriangles( );
glFlush( );
}
}
FX_ENTRY void FX_CALL
guDrawPolygonVertexListWithClip( int nverts, const GrVertex vlist[] )
{
#ifdef OGL_CRITICAL
GlideMsg( "guDrawPolygonVertexListWithClip( %d, --- )\n", nverts );
#endif
for ( int i = 2; i < nverts; i++ )
{
RenderAddTriangle( &vlist[ 0 ],
&vlist[ i - 1 ],
&vlist[ i ],
false );
}
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
{
RenderDrawTriangles( );
glFlush( );
}
}
FX_ENTRY void FX_CALL
grAADrawLine( const GrVertex *a, const GrVertex *b )
{
#ifdef OGL_CRITICAL
GlideMsg( "grAADrawLine( ---, --- )\n" );
#endif
RenderAddLine( a, b, true );
}
FX_ENTRY void FX_CALL
grAADrawPoint(const GrVertex *a )
{
#ifdef OGL_CRITICAL
GlideMsg("grAADrawPoint( --- )\n");
#endif
RenderAddPoint( a, true );
}
FX_ENTRY void FX_CALL
grAADrawPolygon( const int nverts, const int ilist[], const GrVertex vlist[] )
{
#ifdef OGL_CRITICAL
GlideMsg( "grAADrawPolygon( %d, ---, --- )\n", nverts );
#endif
for ( int i = 2; i < nverts; i++ )
{
RenderAddTriangle( &vlist[ ilist[ 0 ] ],
&vlist[ ilist[ i - 1 ] ],
&vlist[ ilist[ i ] ],
true );
}
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
{
RenderDrawTriangles( );
glFlush( );
}
}
FX_ENTRY void FX_CALL
grAADrawPolygonVertexList( const int nverts, const GrVertex vlist[] )
{
#ifdef OGL_CRITICAL
GlideMsg( "grAADrawPolygonVertexList( %d, --- )\n", nverts );
#endif
for ( int i = 2; i < nverts; i++ )
{
RenderAddTriangle( &vlist[ 0 ],
&vlist[ i - 1 ],
&vlist[ i ],
true );
}
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
{
RenderDrawTriangles( );
glFlush( );
}
}
FX_ENTRY void FX_CALL
grAADrawTriangle( const GrVertex *a, const GrVertex *b, const GrVertex *c,
FxBool ab_antialias, FxBool bc_antialias, FxBool ca_antialias )
{
#ifdef OGL_CRITICAL
GlideMsg("grAADrawTriangle( ---, ---, ---, %d, %d, %d )\n",
ab_antialias, bc_antialias, ca_antialias );
#endif
RenderAddTriangle( a, b, c, true );
if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER )
{
RenderDrawTriangles( );
glFlush( );
}
}