-
Notifications
You must be signed in to change notification settings - Fork 17
/
grguMisc.cpp
315 lines (277 loc) · 8.58 KB
/
grguMisc.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
302
303
304
305
306
307
308
309
310
311
312
313
314
//**************************************************************
//* OpenGLide - Glide to OpenGL Wrapper
//* http://openglide.sourceforge.net
//*
//* Other 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"
//*************************************************
//* Sets the External Error Function to call if
//* Glides Generates and Error
//*************************************************
FX_ENTRY void FX_CALL
grErrorSetCallback( void (*function)(const char *string, FxBool fatal) )
{
#ifdef OGL_DONE
GlideMsg( "grErrorSetCallback( --- )\n" );
#endif
ExternErrorFunction = function;
}
//*************************************************
//* Sets the Cull Mode
//*************************************************
FX_ENTRY void FX_CALL
grCullMode( GrCullMode_t mode )
{
#ifdef OGL_DONE
GlideMsg( "grCullMode( %d )\n", mode );
#endif
RenderDrawTriangles( );
Glide.State.CullMode = mode;
switch ( Glide.State.CullMode )
{
case GR_CULL_DISABLE:
glDisable( GL_CULL_FACE );
glCullFace( GL_BACK ); // This will be called in initialization
break;
case GR_CULL_NEGATIVE:
glEnable( GL_CULL_FACE );
if ( Glide.State.OriginInformation == GR_ORIGIN_LOWER_LEFT )
{
glFrontFace( GL_CCW );
}
else
{
glFrontFace( GL_CW );
}
break;
case GR_CULL_POSITIVE:
glEnable( GL_CULL_FACE );
if ( Glide.State.OriginInformation == GR_ORIGIN_LOWER_LEFT )
{
glFrontFace( GL_CW );
}
else
{
glFrontFace( GL_CCW );
}
break;
}
#ifdef OPENGL_DEBUG
GLErro( "grCullMode" );
#endif
}
//*************************************************
//* Set the size and location of the hardware clipping window
//*************************************************
FX_ENTRY void FX_CALL
grClipWindow( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy )
{
#ifdef OGL_PARTDONE
GlideMsg( "grClipWindow( %d, %d, %d, %d )\n", minx, miny, maxx, maxy );
#endif
RenderDrawTriangles( );
Glide.State.ClipMinX = minx;
Glide.State.ClipMaxX = maxx;
Glide.State.ClipMinY = miny;
Glide.State.ClipMaxY = maxy;
// calculate the corresponding OpenGL coords
// (the multiplication has to come first because the values are integers)
OpenGL.ClipMinX = OpenGL.WindowWidth * minx / Glide.WindowWidth;
OpenGL.ClipMaxX = OpenGL.WindowWidth * maxx / Glide.WindowWidth;
OpenGL.ClipMinY = OpenGL.WindowHeight * miny / Glide.WindowHeight;
OpenGL.ClipMaxY = OpenGL.WindowHeight * maxy / Glide.WindowHeight;
if ( ( Glide.State.ClipMinX != 0 ) ||
( Glide.State.ClipMinY != 0 ) ||
( Glide.State.ClipMaxX != (FxU32) Glide.WindowWidth ) ||
( Glide.State.ClipMaxY != (FxU32) Glide.WindowHeight ) )
{
OpenGL.Clipping = true;
}
else
{
OpenGL.Clipping = false;
}
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
if ( Glide.State.OriginInformation == GR_ORIGIN_LOWER_LEFT )
{
glOrtho( Glide.State.ClipMinX, Glide.State.ClipMaxX,
Glide.State.ClipMinY, Glide.State.ClipMaxY,
OpenGL.ZNear, OpenGL.ZFar );
glViewport( OpenGL.ClipMinX, OpenGL.ClipMinY,
OpenGL.ClipMaxX - OpenGL.ClipMinX,
OpenGL.ClipMaxY - OpenGL.ClipMinY );
// Used for the buffer clearing
glScissor( OpenGL.ClipMinX, OpenGL.ClipMinY,
OpenGL.ClipMaxX - OpenGL.ClipMinX,
OpenGL.ClipMaxY - OpenGL.ClipMinY );
}
else
{
glOrtho( Glide.State.ClipMinX, Glide.State.ClipMaxX,
Glide.State.ClipMaxY, Glide.State.ClipMinY,
OpenGL.ZNear, OpenGL.ZFar );
glViewport( OpenGL.ClipMinX, OpenGL.WindowHeight - OpenGL.ClipMaxY,
OpenGL.ClipMaxX - OpenGL.ClipMinX,
OpenGL.ClipMaxY - OpenGL.ClipMinY );
// Used for the buffer clearing
glScissor( OpenGL.ClipMinX, OpenGL.WindowHeight - OpenGL.ClipMaxY,
OpenGL.ClipMaxX - OpenGL.ClipMinX,
OpenGL.ClipMaxY - OpenGL.ClipMinY );
}
glMatrixMode( GL_MODELVIEW );
}
//*************************************************
FX_ENTRY void FX_CALL
grDisableAllEffects( void )
{
#ifdef OGL_PARTDONE
GlideMsg( "grDisableAllEffects( )\n" );
#endif
grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO );
grAlphaTestFunction( GR_CMP_ALWAYS );
grChromakeyMode( GR_CHROMAKEY_DISABLE );
grDepthBufferMode( GR_DEPTHBUFFER_DISABLE );
grFogMode( GR_FOG_DISABLE );
}
//*************************************************
FX_ENTRY void FX_CALL
grResetTriStats( void )
{
#ifdef OGL_NOTDONE
GlideMsg( "grResetTriStats( )\n" );
#endif
}
//*************************************************
FX_ENTRY void FX_CALL
grTriStats( FxU32 *trisProcessed, FxU32 *trisDrawn )
{
#ifdef OGL_NOTDONE
GlideMsg( "grTriStats( )\n" );
#endif
}
//*************************************************
FX_ENTRY void FX_CALL
grHints( GrHint_t hintType, FxU32 hintMask )
{
#ifdef OGL_PARTDONE
GlideMsg( "grHints( %d, %d )\n", hintType, hintMask );
#endif
switch( hintType )
{
case GR_HINT_STWHINT:
Glide.State.STWHint = hintMask;
break;
}
}
//*************************************************
/*
FX_ENTRY void FX_CALL
grSplash( float x, float y, float width, float height, FxU32 frame )
{
#ifdef OGL_NOTDONE
GlideMsg( "grSplash( %-4.2f, %-4.2f, %-4.2f, %-4.2f, %lu )\n",
x, y, width, height, frame );
#endif
}
*/
//*************************************************
FX_ENTRY void FX_CALL
ConvertAndDownloadRle( GrChipID_t tmu,
FxU32 startAddress,
GrLOD_t thisLod,
GrLOD_t largeLod,
GrAspectRatio_t aspectRatio,
GrTextureFormat_t format,
FxU32 evenOdd,
FxU8 *bm_data,
long bm_h,
FxU32 u0,
FxU32 v0,
FxU32 width,
FxU32 height,
FxU32 dest_width,
FxU32 dest_height,
FxU16 *tlut )
{
#ifdef OGL_NOTDONE
GlideMsg( "ConvertAndDownloadRle( %d, %lu, %d, %d, %d, %d, %d, ---, %l, %lu, %lu, %lu, %lu, %lu, %lu, --- )\n",
tmu, startAddress, thisLod, largeLod, aspectRatio, format, evenOdd, bm_h, u0, v0, width, height,
dest_width, dest_height );
#endif
}
//*************************************************
FX_ENTRY void FX_CALL
grCheckForRoom( FxI32 n )
{
#ifdef OGL_NOTDONE
GlideMsg( "grCheckForRoom( %l )\n", n );
#endif
}
//*************************************************
FX_ENTRY void FX_CALL
grParameterData( FxU32 param, FxU32 components, FxU32 type, FxI32 offset )
{
#ifdef OGL_NOTDONE
GlideMsg( "grParameterData( %lu, %lu, %lu, %l )\n",
param, components, type, offset );
#endif
}
//*************************************************
FX_ENTRY int FX_CALL
guEncodeRLE16( void *dst,
void *src,
FxU32 width,
FxU32 height )
{
#ifdef OGL_NOTDONE
GlideMsg( "guEncodeRLE16( ---, ---, %lu, %lu ) = 1\n", width, height );
#endif
return 1;
}
//*************************************************
FX_ENTRY FxU32 FX_CALL
guEndianSwapWords( FxU32 value )
{
#ifdef OGL_DONE
GlideMsg( "guEndianSwapWords( %lu )\n", value );
#endif
return ( value << 16 ) | ( value >> 16 );
}
//*************************************************
FX_ENTRY FxU16 FX_CALL
guEndianSwapBytes( FxU16 value )
{
#ifdef OGL_DONE
GlideMsg( "guEndianSwapBytes( %u )\n", value );
#endif
return ( value << 8 ) | ( value >> 8 );
}
FX_ENTRY void FX_CALL
guMovieStart( void )
{
#ifdef OGL_NOTDONE
GlideMsg( "guMovieStart( ) - Not Supported\n" );
#endif
}
FX_ENTRY void FX_CALL
guMovieStop( void )
{
#ifdef OGL_NOTDONE
GlideMsg( "guMovieStop( ) - Not Supported\n" );
#endif
}
FX_ENTRY void FX_CALL
guMovieSetName( const char *name )
{
#ifdef OGL_NOTDONE
GlideMsg( "guMovieSetName( ) - Not Supported\n" );
#endif
}