-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathglUE.cpp
564 lines (499 loc) · 22.2 KB
/
glUE.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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
// ________ ____ ___
// | \ / | / /
// +---+ \/ |/ /
// +--+| |\ /| <
// | || | \ / | |\ \
// | | \/ | | \ \
// \_____| |__| \__\
// Copyright 2001
// Joe Michael Kniss
// << [email protected] >>
// "All Your Base are Belong to Us"
//
// glUE.cpp: implementation of the glUE class.
//
//////////////////////////////////////////////////////////////////////
#include "glUE.h"
#include "gluvv.h"
#include <iostream.h>
#include <string.h>
#ifdef WIN32
//3D texture
PFNGLTEXIMAGE3DPROC glTexImage3DEXT;
#ifdef GL_EXT_blend_minmax
PFNGLBLENDEQUATIONEXTPROC glBlendEquationEXT;
#endif
#ifdef GL_EXT_color_table
//palated texture
PFNGLCOLORTABLEEXTPROC glColorTableEXT;
#endif
#ifdef GL_EXT_pixel_texture
GLPIXELTEXGENEXTFUNCPTR glPixelTexGenEXT;
#endif
//multi-texture
#ifdef GL_ARB_multitexture
PFNGLACTIVETEXTUREARBPROC glActiveTexture;
PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTexture;
PFNGLMULTITEXCOORD1FARBPROC glMultiTexCoord1fARB;
PFNGLMULTITEXCOORD1FVARBPROC glMultiTexCoord1fvARB;
PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
PFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fvARB;
PFNGLMULTITEXCOORD3FARBPROC glMultiTexCoord3fARB;
PFNGLMULTITEXCOORD3FVARBPROC glMultiTexCoord3fvARB;
#endif
//Secondary color
#ifdef GL_EXT_secondary_color
PFNGLSECONDARYCOLOR3FEXTPROC glSecondaryColor3fEXT;
#endif
//Register Combiners
#ifdef GL_NV_register_combiners
PFNGLCOMBINERPARAMETERFVNVPROC glCombinerParameterfvNV;
PFNGLCOMBINERPARAMETERFNVPROC glCombinerParameterfNV;
PFNGLCOMBINERPARAMETERIVNVPROC glCombinerParameterivNV;
PFNGLCOMBINERPARAMETERINVPROC glCombinerParameteriNV;
PFNGLCOMBINERINPUTNVPROC glCombinerInputNV;
PFNGLCOMBINEROUTPUTNVPROC glCombinerOutputNV;
PFNGLFINALCOMBINERINPUTNVPROC glFinalCombinerInputNV;
PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC glGetCombinerInputParameterfvNV;
PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC glGetCombinerInputParameterivNV;
PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC glGetCombinerOutputParameterfvNV;
PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC glGetCombinerOutputParameterivNV;
PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC glGetFinalCombinerInputParameterfvNV;
PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC glGetFinalCombinerInputParameterivNV;
#endif
//Fragment Shaders
#ifdef GL_ATI_fragment_shader
PFNGLGENFRAGMENTSHADERSATIPROC glGenFragmentShadersATI;
PFNGLBINDFRAGMENTSHADERATIPROC glBindFragmentShaderATI;
PFNGLDELETEFRAGMENTSHADERATIPROC glDeleteFragmentShaderATI;
PFNGLBEGINFRAGMENTSHADERATIPROC glBeginFragmentShaderATI;
PFNGLENDFRAGMENTSHADERATIPROC glEndFragmentShaderATI;
PFNGLPASSTEXCOORDATIPROC glPassTexCoordATI;
PFNGLSAMPLEMAPATIPROC glSampleMapATI;
PFNGLCOLORFRAGMENTOP1ATIPROC glColorFragmentOp1ATI;
PFNGLCOLORFRAGMENTOP2ATIPROC glColorFragmentOp2ATI;
PFNGLCOLORFRAGMENTOP3ATIPROC glColorFragmentOp3ATI;
PFNGLALPHAFRAGMENTOP1ATIPROC glAlphaFragmentOp1ATI;
PFNGLALPHAFRAGMENTOP2ATIPROC glAlphaFragmentOp2ATI;
PFNGLALPHAFRAGMENTOP3ATIPROC glAlphaFragmentOp3ATI;
PFNGLSETFRAGMENTSHADERCONSTANTATIPROC glSetFragmentShaderConstantATI;
#endif
//env-bump
#ifdef GL_ATIX_envmap_bumpmap
PFNGLTEXBUMPPARAMETERIVATIXPROC glTexBumpParameterivATIX;
PFNGLTEXBUMPPARAMETERFVATIXPROC glTexBumpParameterfvATIX;
PFNGLGETTEXBUMPPARAMETERIVATIXPROC glGetTexBumpParameterivATIX;
PFNGLGETTEXBUMPPARAMETERFVATIXPROC glGetTexBumpParameterfvATIX;
#endif
//wgl extensions ...
#ifdef WGL_ARB_pbuffer
PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB;
PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB;
PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB;
PFNWGLDESTROYPBUFFERARBPROC wglDestroyPbufferARB;
PFNWGLQUERYPBUFFERARBPROC wglQueryPbufferARB;
#endif
#ifdef WGL_ARB_pixel_format
PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB;
PFNWGLGETPIXELFORMATATTRIBFVARBPROC wglGetPixelFormatAttribfvARB;
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB;
#endif
#ifdef WGL_ARB_render_texture //render to texture
PFNWGLBINDTEXIMAGEARBPROC wglBindTexImageARB;
PFNWGLRELEASETEXIMAGEARBPROC wglReleaseTexImageARB;
PFNWGLSETPBUFFERATTRIBARBPROC wglSetBufferAttribARB;
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
void LoadAllExtensions()
{
cerr << "-----------------------------------------------------" << endl;
//-------------------------------------------------------------------
//-------------------- 3d texture -----------------------------------
//-------------------- Open GL spec 1.2 -----------------------------
getOGL12();
//-------------------------------------------------------------------
//------------------- Register Combiners ----------------------------
getNV20();
//-------------------------------------------------------------------
//------------------- ATI Radeon 8000 -------------------------------
getATI8K();
//-------------------------------------------------------------------
//--------------------- wgl extensions ... ---------------------------
getWGL();
cerr << "-----------------------------------------------------" << endl << endl;
}
//=====================================================================
#endif
//=====================================================================
//-------------- standard utilities -----------------------------------
//=====================================================================
GLboolean QueryExtension(char *extName)
{
/*
** Search for extName in the extensions string. Use of strstr()
** is not sufficient because extension names can be prefixes of
** other extension names. Could use strtok() but the constant
** string returned by glGetString might be in read-only memory.
*/
char *p;
char *end;
int extNameLen;
extNameLen = strlen(extName);
p = (char *)glGetString(GL_EXTENSIONS);
if (0 == p) {
cerr << "ERROR:: could not query extensions" << endl;
return GL_FALSE;
}
end = p + strlen(p);
if(!strcmp(extName, "Print")){
for(int i=0; i< (int)strlen(p); ++i){
cerr << p[i];
} cerr << endl;
return GL_FALSE;
}
while (p < end) {
int n = strcspn(p, " ");
if ((extNameLen == n) && (strncmp(extName, p, n) == 0)) {
return GL_TRUE;
}
p += (n + 1);
}
return GL_FALSE;
}
//=====================================================================
int GlErr(char *location, char *glfuncname)
{
GLenum errCode;
const GLubyte *errString;
if((errCode = glGetError()) != GL_NO_ERROR){
errString = gluErrorString(errCode);
cerr << "OpenGL ERROR : " << location << "::" << glfuncname << " : "
<< (char *) errString << endl;
return 1;
}
return 0;
}
//=====================================================================
int CardProfile()
{
if(QueryExtension("GL_ATI_fragment_shader")){
cerr << "PLATFORM: ATI Radeon 8000 series" << endl;
return (int)GPATI8K;
}
if(QueryExtension("GL_NV_texture_shader")){
cerr << "PLATFORM: nVidia GeForce 3" << endl;
return (int)GPNV20;
}
return 0;
}
//=====================================================================
//=====================================================================
//=====================================================================
//=====================================================================
//=====================================================================
#ifdef WIN32
void getOGL12()
{
glTexImage3DEXT = 0;
if(QueryExtension("GL_EXT_texture3D")){
cerr << "3D Texture is available!" << endl;
if(!(glTexImage3DEXT =
(PFNGLTEXIMAGE3DPROC)wglGetProcAddress("glTexImage3DEXT"))){
cerr << "*********************************" << endl;
cerr << "wglGetProcAddress(\"glTexImage3DEXT\") failed!" << endl;
cerr << "GetLastError(): " << GetLastError() << endl;
cerr << "*********************************" << endl;
}
} else if((glTexImage3DEXT = (PFNGLTEXIMAGE3DPROC)wglGetProcAddress("glTexImage3D")))
cerr << "OGL1.2 3D texture is available" << endl;
else cerr << "3D texture is NOT available" << endl;
//-------------------------------------------------------------------
// blending
#ifdef GL_EXT_blend_minmax
glBlendEquationEXT = 0;
if(!(glBlendEquationEXT =
(PFNGLBLENDEQUATIONEXTPROC)wglGetProcAddress("glBlendEquationEXT"))){
cerr << "*********************************" << endl;
cerr << "wglGetProcAddress(\"glBlendEquationEXT\") failed!" << endl;
cerr << "GetLastError(): " << GetLastError() << endl;
cerr << "*********************************" << endl;
}
#endif
//-------------------------------------------------------------------
//-------------------- palated textures -----------------------------
#ifdef GL_EXT_color_table
glColorTableEXT = 0;
if(QueryExtension("GL_EXT_color_table")){
cerr << "Color Table is available" << endl;
glColorTableEXT =
(PFNGLCOLORTABLEEXTPROC)wglGetProcAddress("glColorTableEXT");
if(!glColorTableEXT){
cerr << "*********************************" << endl;
cerr << "wglGetProcAddress(\"glColorTableEXT\") failed!" << endl;
cerr << "GetLastError(): " << GetLastError() << endl;
cerr << "*********************************" << endl;
}
} else cerr << "Color Table is not available" << endl;
#endif
//HEY MOFO, THIS DOESN"T GO HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
//HEY MOFO, THIS DOESN"T GO HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
#ifdef GL_EXT_pixel_texture
glPixelTexGenEXT = 0;
if(QueryExtension("GL_EXT_pixel_texture")){
cerr << "Pixel texture is available" << endl;
}
else cerr << "Pixel Texture is NOT available" << endl;
#endif
//-------------------------------------------------------------------
//-------------------- Multi-texture --------------------------------
#ifdef GL_ARB_multitexture
glActiveTexture = 0;
glClientActiveTexture = 0;
glMultiTexCoord1fARB = 0;
glMultiTexCoord1fvARB = 0;
glMultiTexCoord2fARB = 0;
glMultiTexCoord2fvARB = 0;
glMultiTexCoord3fARB = 0;
glMultiTexCoord3fvARB = 0;
if(QueryExtension("GL_ARB_multitexture")){
cerr << "ARB multitexture is available!" << endl;
glActiveTexture =
(PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB");
glClientActiveTexture =
(PFNGLCLIENTACTIVETEXTUREARBPROC)wglGetProcAddress("glClientActiveTextureARB");
glMultiTexCoord1fARB =
(PFNGLMULTITEXCOORD1FARBPROC)wglGetProcAddress("glMultiTexCoord1fARB");
glMultiTexCoord1fvARB =
(PFNGLMULTITEXCOORD1FVARBPROC)wglGetProcAddress("glMultiTexCoord1fvARB");
glMultiTexCoord2fARB =
(PFNGLMULTITEXCOORD2FARBPROC)wglGetProcAddress("glMultiTexCoord2fARB");
glMultiTexCoord2fvARB =
(PFNGLMULTITEXCOORD2FVARBPROC)wglGetProcAddress("glMultiTexCoord2fvARB");
glMultiTexCoord3fARB =
(PFNGLMULTITEXCOORD3FARBPROC)wglGetProcAddress("glMultiTexCoord3fARB");
glMultiTexCoord3fvARB =
(PFNGLMULTITEXCOORD3FVARBPROC)wglGetProcAddress("glMultiTexCoord3fvARB");
if ((!glActiveTexture)||(!glClientActiveTexture)||(!glMultiTexCoord1fARB)||
(!glMultiTexCoord1fvARB)||(!glMultiTexCoord2fARB)||
(!glMultiTexCoord2fvARB)||(!glMultiTexCoord3fARB)||
(!glMultiTexCoord3fvARB)) {
cerr << "*********************************" << endl;
cerr << "wglGetProcAddress(\"glARBmultitexture\") failed!" << endl;
cerr << "GetLastError(): " << GetLastError() << endl;
cerr << "NOTE: You may need to get a new driver from ATI/NVIDIA" << endl;
cerr << (int) glActiveTexture << " " << (int)glClientActiveTexture << endl;
cerr << (int) glMultiTexCoord1fARB << " " << (int) glMultiTexCoord1fvARB << endl
<< (int) glMultiTexCoord2fARB << " " << (int) glMultiTexCoord2fvARB << endl
<< (int) glMultiTexCoord3fARB << " " << (int) glMultiTexCoord3fvARB << endl;
cerr << "*********************************" << endl;
}
} else cerr << "ARB multitexture texture is NOT available" << endl;
#endif
//-------------------------------------------------------------------
//------------------- GL_ARB_texture_env_combine --------------------
if(QueryExtension("GL_ARB_texture_env_combine")){
cerr << "GL_ARB_texture_env_combine is available!" << endl;
} else cerr << "GL_ARB_texture_env_combine is NOT available" << endl;
//-------------------------------------------------------------------
//----------------- Secondary color ---------------------------------
#ifdef GL_EXT_secondary_color
glSecondaryColor3fEXT = 0;
if(QueryExtension("GL_EXT_secondary_color")){
cerr << "Secondary Color is available!" << endl;
glSecondaryColor3fEXT =
(PFNGLSECONDARYCOLOR3FEXTPROC)wglGetProcAddress("glSecondaryColor3fEXT");
if(!glSecondaryColor3fEXT){
cerr << "Error aquiring Secondary Color function pointer" << endl;
}
} else {
cerr << "Secondary Color is not available" << endl;
}
#endif
}
//=====================================================================
//=====================================================================
void getNV20()
{
#ifdef GL_NV_register_combiners
if(QueryExtension("GL_NV_register_combiners")){
cerr << "GL_NV_register_combiners is available!" << endl;
glCombinerParameterfvNV =
(PFNGLCOMBINERPARAMETERFVNVPROC)wglGetProcAddress("glCombinerParameterfvNV");
glCombinerParameterfNV =
(PFNGLCOMBINERPARAMETERFNVPROC)wglGetProcAddress("glCombinerParameterfNV");
glCombinerParameterivNV =
(PFNGLCOMBINERPARAMETERIVNVPROC)wglGetProcAddress("glCombinerParameterivNV");
glCombinerParameteriNV =
(PFNGLCOMBINERPARAMETERINVPROC)wglGetProcAddress("glCombinerParameteriNV");
glCombinerInputNV =
(PFNGLCOMBINERINPUTNVPROC)wglGetProcAddress("glCombinerInputNV");
glCombinerOutputNV =
(PFNGLCOMBINEROUTPUTNVPROC)wglGetProcAddress("glCombinerOutputNV");
glFinalCombinerInputNV =
(PFNGLFINALCOMBINERINPUTNVPROC)wglGetProcAddress("glFinalCombinerInputNV");
glGetCombinerInputParameterfvNV =
(PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC)wglGetProcAddress("glGetCombinerInputParameterfvNV");
glGetCombinerInputParameterivNV =
(PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC)wglGetProcAddress("glGetCombinerInputParameterivNV");
glGetCombinerOutputParameterfvNV =
(PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)wglGetProcAddress("glGetCombinerOutputParameterfvNV");
glGetCombinerOutputParameterivNV=
(PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)wglGetProcAddress("glGetCombinerOutputParameterivNV");
glGetFinalCombinerInputParameterfvNV =
(PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)wglGetProcAddress("glGetFinalCombinerInputParameterfvNV");
glGetFinalCombinerInputParameterivNV =
(PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)wglGetProcAddress("glGetFinalCombinerInputParameterivNV");
if(!glCombinerParameterfvNV){
cerr << "*********************************" << endl;
cerr << "wglGetProcAddress(\"GL_NV_register_combiners\") failed!" << endl;
cerr << "GetLastError(): " << GetLastError() << endl;
cerr << "*********************************" << endl;
}
} else cerr << "GL_NV_register_combiners is NOT available" << endl;
#endif
//-------------------------------------------------------------------
}
//=====================================================================
//=====================================================================
void getATI8K()
{
#ifdef GL_ATIX_envmap_bumpmap
//------------------- GL_ATIX_envmap_bumpmap ------------------------
glTexBumpParameterivATIX = 0;
glTexBumpParameterfvATIX = 0;
glGetTexBumpParameterivATIX = 0;
glGetTexBumpParameterivATIX = 0;
if(QueryExtension("GL_ATIX_envmap_bumpmap")){
cerr << "GL_ATIX_envmap_bumpmap is available!" << endl;
glTexBumpParameterivATIX=
(PFNGLTEXBUMPPARAMETERIVATIXPROC)wglGetProcAddress("glTexBumpParameterivATIX");
glTexBumpParameterfvATIX=
(PFNGLTEXBUMPPARAMETERFVATIXPROC)wglGetProcAddress("glTexBumpParameterfvATIX");
glGetTexBumpParameterivATIX=
(PFNGLGETTEXBUMPPARAMETERIVATIXPROC)wglGetProcAddress("glGetTexBumpParameterivATIX");
glGetTexBumpParameterfvATIX=
(PFNGLGETTEXBUMPPARAMETERFVATIXPROC)wglGetProcAddress("glGetTexBumpParameterfvATIX");
if((!glTexBumpParameterivATIX)||(!glTexBumpParameterfvATIX)||
(!glGetTexBumpParameterivATIX)||(!glGetTexBumpParameterfvATIX)){
cerr << "*********************************" << endl;
cerr << "wglGetProcAddress(\"GL_ATIX_envmap_bumpmap\") failed!" << endl;
cerr << "GetLastError(): " << GetLastError() << endl;
cerr << "NOTE: You may need to get a new driver from ATI/NVIDIA" << endl;
cerr << (int)glTexBumpParameterivATIX << " " << (int)glTexBumpParameterfvATIX << endl;
cerr << (int)glGetTexBumpParameterivATIX << " " << (int)glGetTexBumpParameterivATIX << endl;
cerr << "*********************************" << endl;
} else { //see what the capabilites are
int matsz;
glGetTexBumpParameterivATIX(GL_BUMP_ROT_MATRIX_SIZE_ATIX, &matsz);
cerr << " -Bump rot matrix size = " << matsz << endl;
int numtex;
glGetTexBumpParameterivATIX(GL_BUMP_NUM_TEX_UNITS_ATIX, &numtex);
cerr << " -Number of available texture units = " << numtex << endl;
int texunits[32];
glGetTexBumpParameterivATIX(GL_BUMP_TEX_UNITS_ATIX, texunits);
cerr << " -Texture unit ids:" << endl;
for(int i=0; i<numtex; ++i){
if(texunits[i] == GL_TEXTURE0_ARB) cerr << " GL_TEXTURE0_ARB" << endl;
if(texunits[i] == GL_TEXTURE1_ARB) cerr << " GL_TEXTURE1_ARB" << endl;
if(texunits[i] == GL_TEXTURE2_ARB) cerr << " GL_TEXTURE2_ARB" << endl;
if(texunits[i] == GL_TEXTURE3_ARB) cerr << " GL_TEXTURE3_ARB" << endl;
if(texunits[i] == GL_TEXTURE4_ARB) cerr << " GL_TEXTURE4_ARB" << endl;
if(texunits[i] == GL_TEXTURE5_ARB) cerr << " GL_TEXTURE5_ARB" << endl;
}
}
} else cerr << "GL_ATIX_envmap_bumpmap is NOT available!" << endl;
#endif //end radeon
#ifdef GL_ATI_fragment_shader
//------------------- GL_ATI_fragment_shader ------------------------
glGenFragmentShadersATI = 0;
glBindFragmentShaderATI = 0;
glDeleteFragmentShaderATI = 0;
glBeginFragmentShaderATI = 0;
glEndFragmentShaderATI = 0;
glPassTexCoordATI = 0;
glSampleMapATI = 0;
glColorFragmentOp1ATI = 0;
glColorFragmentOp2ATI = 0;
glColorFragmentOp3ATI = 0;
glAlphaFragmentOp1ATI = 0;
glAlphaFragmentOp2ATI = 0;
glAlphaFragmentOp3ATI = 0;
glSetFragmentShaderConstantATI = 0;
if(QueryExtension("GL_ATI_fragment_shader")){
cerr << "GL_ATI_fragment_shader is available" << endl;
glGenFragmentShadersATI =
(PFNGLGENFRAGMENTSHADERSATIPROC)wglGetProcAddress("glGenFragmentShadersATI");
glBindFragmentShaderATI =
(PFNGLBINDFRAGMENTSHADERATIPROC) wglGetProcAddress("glBindFragmentShaderATI");
glDeleteFragmentShaderATI=
(PFNGLDELETEFRAGMENTSHADERATIPROC) wglGetProcAddress("glDeleteFragmentShaderATI");
glBeginFragmentShaderATI =
(PFNGLBEGINFRAGMENTSHADERATIPROC) wglGetProcAddress("glBeginFragmentShaderATI");
glEndFragmentShaderATI =
(PFNGLENDFRAGMENTSHADERATIPROC) wglGetProcAddress("glEndFragmentShaderATI");
glPassTexCoordATI =
(PFNGLPASSTEXCOORDATIPROC) wglGetProcAddress("glPassTexCoordATI");
glSampleMapATI =
(PFNGLSAMPLEMAPATIPROC) wglGetProcAddress("glSampleMapATI");
glColorFragmentOp1ATI =
(PFNGLCOLORFRAGMENTOP1ATIPROC) wglGetProcAddress("glColorFragmentOp1ATI");
glColorFragmentOp2ATI =
(PFNGLCOLORFRAGMENTOP2ATIPROC) wglGetProcAddress("glColorFragmentOp2ATI");
glColorFragmentOp3ATI =
(PFNGLCOLORFRAGMENTOP3ATIPROC) wglGetProcAddress("glColorFragmentOp3ATI");
glAlphaFragmentOp1ATI =
(PFNGLALPHAFRAGMENTOP1ATIPROC) wglGetProcAddress("glAlphaFragmentOp1ATI");
glAlphaFragmentOp2ATI =
(PFNGLALPHAFRAGMENTOP2ATIPROC) wglGetProcAddress("glAlphaFragmentOp2ATI");
glAlphaFragmentOp3ATI =
(PFNGLALPHAFRAGMENTOP3ATIPROC) wglGetProcAddress("glAlphaFragmentOp3ATI");
glSetFragmentShaderConstantATI =
(PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) wglGetProcAddress("glSetFragmentShaderConstantATI");
} else {
cerr << "GL_ATI_fragment_shader is NOT available!" << endl;
}
#endif
}
//=====================================================================
//=====================================================================
void getWGL()
{
#ifdef WGL_ARB_pbuffer
if((wglCreatePbufferARB =
(PFNWGLCREATEPBUFFERARBPROC)wglGetProcAddress("wglCreatePbufferARB"))){
cerr << "Pbuffer is available!" << endl;
}
else cerr << "Pbuffer is NOT available!" << endl;
wglGetPbufferDCARB =
(PFNWGLGETPBUFFERDCARBPROC)wglGetProcAddress("wglGetPbufferDCARB");
wglReleasePbufferDCARB =
(PFNWGLRELEASEPBUFFERDCARBPROC)wglGetProcAddress("wglReleasePbufferDCARB");
wglDestroyPbufferARB =
(PFNWGLDESTROYPBUFFERARBPROC)wglGetProcAddress("wglDestroyPbufferARB");
wglQueryPbufferARB =
(PFNWGLQUERYPBUFFERARBPROC)wglGetProcAddress("wglQueryPbufferARB");
#endif
#ifdef WGL_ARB_pixel_format
if((wglGetPixelFormatAttribivARB=
(PFNWGLGETPIXELFORMATATTRIBIVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribivARB"))){
cerr << "WGL_ARB_pixel_format is available" << endl;
} else cerr << "WGL_ARB_pixel_format is NOT available" << endl;
wglGetPixelFormatAttribfvARB=
(PFNWGLGETPIXELFORMATATTRIBFVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribfvARB");
wglChoosePixelFormatARB=
(PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
#endif
#ifdef WGL_ARB_render_texture //render to texture
if((wglBindTexImageARB=
(PFNWGLBINDTEXIMAGEARBPROC)wglGetProcAddress("wglBindTexImageARB"))){
cerr << "WGL_ARB_render_texture is available" << endl;
} else cerr << "WGL_ARB_render_texture is NOT available" << endl;
wglReleaseTexImageARB=
(PFNWGLRELEASETEXIMAGEARBPROC)wglGetProcAddress("wglReleaseTexImageARB");
wglSetBufferAttribARB=
(PFNWGLSETPBUFFERATTRIBARBPROC)wglGetProcAddress("wglSetBufferAttribARB");
#endif
}
#endif //ifdef WIN32