forked from HaloMods/SparkEdit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShaderManager.cpp
616 lines (504 loc) · 19.5 KB
/
ShaderManager.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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
// ShaderManager.cpp: implementation of the CShaderManager class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ShaderManager.h"
#include "ProfileSettings.h"
#include "HaloTagManager.h"
#include "glext.h"
extern COutputPane *g_pOutput;
extern CProfileSettings gProfile;
extern CHaloTagManager gTagManager;
//typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum target);
#define GL_GLEXT_PROTOTYPES
PFNGLACTIVETEXTUREARBPROC pglActiveTextureARB;
PFNGLMULTITEXCOORD2FVARBPROC pglMultiTexCoord2fvARB;
PFNGLMULTITEXCOORD2FARBPROC pglMultiTexCoord2fARB;
PFNGLCLIENTACTIVETEXTUREARBPROC pglClientActiveTextureARB;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CShaderManager::CShaderManager()
{
m_pMapFile = 0;
m_Magic = 0;
m_BitmapCount = 0;
m_MapVersion = 0;
m_pGlTextureNames = NULL;
m_LightmapSetCount = 0;
ZeroMemory(&m_LightmapCount, sizeof(m_LightmapCount));
ZeroMemory(m_pGlLightmapNames, sizeof(m_pGlLightmapNames));
int i = sizeof(m_pGlLightmapNames);
ZeroMemory(&m_BitmapList, sizeof(m_BitmapList));
}
CShaderManager::~CShaderManager()
{
Cleanup();
}
/*-------------------------------------------------------------------
* Name: UpdateBitmapList()
* Description:
* Builds a list of the current map's bitmaps. This list contains
* the header information necessary for loading the bitmaps
* and constructing the shaders.
*-----------------------------------------------------------------*/
void CShaderManager::UpdateBitmapList(CString Name, UINT str_offset, UINT data_location, UINT bitmap_tag_id,int BitmapType)
{
CEBITMAP_FILE_HDR ce_BitmapFileHeader;
CEBITMAP_LOCATOR_ELEMENT ce_BitmapElement;
switch (BitmapType)
{
case 0:
if(m_BitmapCount < MAX_BITM_COUNT)
{
/* Read bmp header from metadata */
m_pMapFile->Seek(data_location, 0);
m_pMapFile->Read(&m_BitmapList[m_BitmapCount].hdr0, sizeof(bitm_header_t));
//if(m_BitmapList[m_BitmapCount].hdr0.image_count > 12)
// TRACE("largecount\n");
m_BitmapList[m_BitmapCount].hdr0.offset_to_first -= m_Magic;
m_BitmapList[m_BitmapCount].hdr0.image_offset -= m_Magic;
// Read 1st section
m_pMapFile->Seek(m_BitmapList[m_BitmapCount].hdr0.offset_to_first,0);
m_pMapFile->Read(&m_BitmapList[m_BitmapCount].hdr1, sizeof(bitm_first_t));
/* Read 2nd section */
//allocate sub-bitmap headers
m_BitmapList[m_BitmapCount].pHeader2 = new bitm_image_t[m_BitmapList[m_BitmapCount].hdr0.image_count];
m_pMapFile->Seek(m_BitmapList[m_BitmapCount].hdr0.image_offset,0);
m_pMapFile->Read(m_BitmapList[m_BitmapCount].pHeader2,
sizeof(bitm_image_t)*m_BitmapList[m_BitmapCount].hdr0.image_count);
/* this reference will be used in the shader-bitmap search later */
m_BitmapList[m_BitmapCount].BitmapNamePtr = str_offset;
m_BitmapList[m_BitmapCount].BitmapTagId = bitmap_tag_id;
strncpy(m_BitmapList[m_BitmapCount].bitmap_name, Name.GetBuffer(128), 128);
Name.ReleaseBuffer();
//TRACE("%s\n", Name);
//
//for(int i=0; i<m_BitmapList[m_BitmapCount].hdr0.image_count; i++)
//{
// TRACE("%d\n", m_BitmapList[m_BitmapCount].pHeader2[i].size);
//}
//
m_BitmapCount++;
}
if(m_BitmapCount >= MAX_BITM_COUNT)
{
g_pOutput->PostText("Bitmap list overrun...\n", LOG_RED);
}
break;
case 1:
if(m_BitmapCount < MAX_BITM_COUNT)
{
UINT BitmapIndex = data_location;
m_BitmapList[m_BitmapCount].BitmapType = 1;
m_BitmapFile.Seek(0,0);
m_BitmapFile.Read(&ce_BitmapFileHeader,sizeof(ce_BitmapFileHeader));
m_BitmapFile.Seek(ce_BitmapFileHeader.LocatorBlockOffset + sizeof(ce_BitmapElement) * BitmapIndex ,0);
m_BitmapFile.Read(&ce_BitmapElement,sizeof(ce_BitmapElement));
m_BitmapList[m_BitmapCount].BitmapNamePtr = ce_BitmapElement.name_offset + ce_BitmapFileHeader.NameBlockOffset;
m_BitmapList[m_BitmapCount].BitmapTagId = bitmap_tag_id;
m_BitmapFile.Seek(ce_BitmapElement.offset, 0);
m_BitmapFile.Read(&m_BitmapList[m_BitmapCount].hdr0, sizeof(bitm_header_t));
m_BitmapList[m_BitmapCount].hdr0.offset_to_first += ce_BitmapElement.offset;
m_BitmapList[m_BitmapCount].hdr0.image_offset += ce_BitmapElement.offset;
m_BitmapFile.Seek(m_BitmapList[m_BitmapCount].hdr0.offset_to_first,0);
m_BitmapFile.Read(&m_BitmapList[m_BitmapCount].hdr1, sizeof(bitm_first_t));
m_BitmapList[m_BitmapCount].pHeader2 = new bitm_image_t[m_BitmapList[m_BitmapCount].hdr0.image_count];
m_BitmapFile.Seek(m_BitmapList[m_BitmapCount].hdr0.image_offset,0);
m_BitmapFile.Read(m_BitmapList[m_BitmapCount].pHeader2,
sizeof(bitm_image_t)*m_BitmapList[m_BitmapCount].hdr0.image_count);
strncpy(m_BitmapList[m_BitmapCount].bitmap_name, Name.GetBuffer(128), 128);
Name.ReleaseBuffer();
m_BitmapCount++;
}
if(m_BitmapCount >= MAX_BITM_COUNT)
{
g_pOutput->PostText("Bitmap list overrun...\n", LOG_RED);
}
break;
}
}
void CShaderManager::Initialize(CFile *pMapFile, UINT magic, UINT version)
{
CString bitmap_path;
m_pMapFile = pMapFile;
m_Magic = magic;
m_MapVersion = version;
m_ImageUtils.m_Version = version;
switch (m_ImageUtils.m_Version)
{
case 0x7:
bitmap_path = gProfile.GetBitmapPath();
if(OpenBitmapFile(bitmap_path) == FALSE)
{
AfxMessageBox("Unable to open HaloPC 'bitmaps.map' file.\r\nPlease check Tools->Options... and make sure the path is set correctly.");
}
break;
case 0x261:
bitmap_path = gProfile.GetCEBitmapPath();
if(OpenBitmapFile(bitmap_path) == FALSE)
{
AfxMessageBox("Unable to open HaloCE 'bitmaps.map' file.\r\nPlease check Tools->Options... and make sure the path is set correctly.");
}
break;
}
}
/*-------------------------------------------------------------------
* Name: BuildShaders()
* Description:
* Fills in the missing information for each one of the shaders.
* For now, it just fills in the main bitmap header. We will
* perform simple texturing, saving multitexturing effects such as
*
*-----------------------------------------------------------------*/
void CShaderManager::BuildShaders()
{
int i;
// allocate the texture names
m_pGlTextureNames = new UINT[m_BitmapCount];
glGenTextures(m_BitmapCount, m_pGlTextureNames);
for(i=0; i<m_BitmapCount; i++)
{
m_BitmapList[i].GlTextureName = m_pGlTextureNames[i];
}
}
void CShaderManager::Cleanup()
{
int i;
for(i=0; i<m_BitmapCount; i++)
{
if(m_BitmapList[i].pHeader2)
delete m_BitmapList[i].pHeader2;
if(m_BitmapList[i].pTextureData)
delete [] m_BitmapList[i].pTextureData;
}
glDeleteTextures(m_BitmapCount, m_pGlTextureNames);
for(i=0; i<m_LightmapSetCount; i++)
{
glDeleteTextures(m_LightmapCount[i], m_pGlLightmapNames[i]);
m_LightmapCount[i] = 0;
if(m_pGlLightmapNames[i])
delete [] m_pGlLightmapNames[i];
m_pGlLightmapNames[i] = NULL;
}
if(m_pGlTextureNames)
delete [] m_pGlTextureNames;
m_pGlTextureNames = NULL;
m_MapVersion = 0;
m_pMapFile = 0;
m_Magic = 0;
m_BitmapCount = 0;
m_LightmapSetCount = 0;
ZeroMemory(&m_BitmapList, sizeof(m_BitmapList));
}
BOOL CShaderManager::OpenBitmapFile(CString path)
{
BOOL bStatus;
bStatus = m_BitmapFile.Open(path, CFile::modeRead);
return(bStatus);
}
void CShaderManager::CloseBitmapFile()
{
if(m_BitmapFile.m_hFile != (HANDLE)0xffffffff)
m_BitmapFile.Close();
}
void CShaderManager::LoadTextures()
{
int i, j;
CString str;
BITMAP_STATUS texture_status;
if(!((m_MapVersion == 7)&&(m_BitmapFile.m_hFile == (HANDLE)0xFFFFFFFF)))
{
for(i=0; i<m_BitmapCount; i++)
{
str.Format("Loading bitmap (tagid=%08X) %s\n", m_BitmapList[i].BitmapTagId, m_BitmapList[i].bitmap_name);
g_pOutput->PostText(str, LOG_GREY);
texture_status = gTagManager.GetTextureStatus(m_BitmapList[i].BitmapTagId);
if(texture_status == LIGHTMAP)
{
m_LightmapCount[m_LightmapSetCount] = m_BitmapList[i].hdr0.image_count;
m_pGlLightmapNames[m_LightmapSetCount] = new UINT[m_LightmapCount[m_LightmapSetCount]];
glGenTextures(m_LightmapCount[m_LightmapSetCount], m_pGlLightmapNames[m_LightmapSetCount]);
for(j=0; j<m_LightmapCount[m_LightmapSetCount]; j++)
{
glBindTexture(GL_TEXTURE_2D, m_pGlLightmapNames[m_LightmapSetCount][j]);
LoadBitmap(i, j);
}
m_LightmapSetCount++;
}
else if(texture_status == BITMAP_ENABLED)
{
glBindTexture(GL_TEXTURE_2D, m_pGlTextureNames[i]);
LoadBitmap(i, 0);
}
}
}
}
void CShaderManager::ActivateShader(int texture_index)
{
if(texture_index < m_BitmapCount)
glBindTexture(GL_TEXTURE_2D, m_BitmapList[texture_index].GlTextureName);
}
void CShaderManager::LoadBitmap(UINT bitmap_index, UINT sub_bitmap)
{
BYTE *texdata = NULL;
//allocate buffers for read file and DXT decompression
if(m_BitmapList[bitmap_index].pHeader2[sub_bitmap].size)
{
texdata = new BYTE[m_BitmapList[bitmap_index].pHeader2[sub_bitmap].size];
m_BitmapList[bitmap_index].pTextureData = new UINT[m_BitmapList[bitmap_index].pHeader2[sub_bitmap].width *
m_BitmapList[bitmap_index].pHeader2[sub_bitmap].height];
//if(m_MapVersion == 7)
//{
/* Read in raw texture data from halo map file */
// m_BitmapFile.Seek(m_BitmapList[bitmap_index].pHeader2[sub_bitmap].offset, 0);
// m_BitmapFile.Read(texdata, m_BitmapList[bitmap_index].pHeader2[sub_bitmap].size);
//}
//else if(m_MapVersion == 5)
//{
// m_pMapFile->Seek(m_BitmapList[bitmap_index].pHeader2[sub_bitmap].offset, 0);
// m_pMapFile->Read(texdata, m_BitmapList[bitmap_index].pHeader2[sub_bitmap].size);
//}
//else if(m_MapVersion == 0x261)
//{
// m_pMapFile->Seek(m_BitmapList[bitmap_index].pHeader2[sub_bitmap].offset,0);
// m_pMapFile->Read(texdata, m_BitmapList[bitmap_index].pHeader2[sub_bitmap].size);
//}
switch (m_MapVersion)
{
case 0x7:
m_BitmapFile.Seek(m_BitmapList[bitmap_index].pHeader2[sub_bitmap].offset, 0);
m_BitmapFile.Read(texdata, m_BitmapList[bitmap_index].pHeader2[sub_bitmap].size);
break;
case 0x5:
m_pMapFile->Seek(m_BitmapList[bitmap_index].pHeader2[sub_bitmap].offset, 0);
m_pMapFile->Read(texdata, m_BitmapList[bitmap_index].pHeader2[sub_bitmap].size);
break;
case 0x261:
switch (m_BitmapList[bitmap_index].BitmapType)
{
case 0:
m_pMapFile->Seek(m_BitmapList[bitmap_index].pHeader2[sub_bitmap].offset, 0);
m_pMapFile->Read(texdata, m_BitmapList[bitmap_index].pHeader2[sub_bitmap].size);
break;
case 1:
m_BitmapFile.Seek(m_BitmapList[bitmap_index].pHeader2[sub_bitmap].offset, 0);
m_BitmapFile.Read(texdata, m_BitmapList[bitmap_index].pHeader2[sub_bitmap].size);
break;
}
break;
};
//decompress
m_ImageUtils.DecompressDXT(&(m_BitmapList[bitmap_index].pHeader2[sub_bitmap]),
m_BitmapList[bitmap_index].pHeader2[sub_bitmap].size,
texdata,
m_BitmapList[bitmap_index].pTextureData);
/*
//channel detection code
UINT swap;
BYTE mask_data;
int junk = m_BitmapList[bitmap_index].pHeader2[sub_bitmap].width*
m_BitmapList[bitmap_index].pHeader2[sub_bitmap].height;
for(int k=0; k<junk; k++)
{
swap = *((UINT*)&m_BitmapList[bitmap_index].pTextureData[k]);
mask_data = (swap & 0xFF000000) >> 24;
swap = mask_data;
swap |= mask_data << 8;
swap |= mask_data << 16;
swap |= mask_data << 24;
m_BitmapList[bitmap_index].pTextureData[k] = swap;
}
*/
// Build mipmaps for that fine blurry look.
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA8,
m_BitmapList[bitmap_index].pHeader2[sub_bitmap].width,
m_BitmapList[bitmap_index].pHeader2[sub_bitmap].height,
0,
GL_BGRA_EXT,
GL_UNSIGNED_BYTE,
m_BitmapList[bitmap_index].pTextureData);
delete [] m_BitmapList[bitmap_index].pTextureData;
m_BitmapList[bitmap_index].pTextureData = NULL;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
delete texdata;
texdata = 0;
}
}
void CShaderManager::ActivateLightmap(int bsp_index, int lightmap_index)
{
if(lightmap_index < 0)
{
//TRACE("lightmap not used\n");
}
else if(lightmap_index < m_LightmapCount[bsp_index])
{
pglActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE);
glBindTexture(GL_TEXTURE_2D, m_pGlLightmapNames[bsp_index][lightmap_index]);
}
}
void CShaderManager::ActivateLightmapBlend(int texture_index, int bsp_index, int lightmap_index)
{
int count;
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &count);
if(1)//TODO: check for number of texturing units during initialization
{
//enable advanced texture blending extensions
//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
//set up material texture stage
if(texture_index < m_BitmapCount)
{
pglActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, m_BitmapList[texture_index].GlTextureName);
}
//set up lightmap texture stage
if((lightmap_index < m_LightmapCount[bsp_index])&&(lightmap_index >= 0))
{
pglActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, m_pGlLightmapNames[bsp_index][lightmap_index]);
}
}
}
void CShaderManager::DeactivateLightmapBlend()
{
pglActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);
pglActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);
}
void CShaderManager::InitializeOpenGLExtensions()
{
char* extensionsList = (char*) glGetString(GL_EXTENSIONS);
pglActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB");
pglMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC)wglGetProcAddress("glMultiTexCoord2fvARB");
pglMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)wglGetProcAddress("glMultiTexCoord2fARB");
pglClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)wglGetProcAddress("glClientActiveTextureARB");
}
void CShaderManager::ActivateSingleTexture(UINT texture_index)
{
pglActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE);
glBindTexture(GL_TEXTURE_2D, m_BitmapList[texture_index].GlTextureName);
}
void CShaderManager::DeactivateSingleTexture()
{
pglActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);
}
void CShaderManager::LoadBitmapFile()
{
CFile bitmaps;
BITMAP_FILE_HDR header;
BITMAP_LOCATOR_ELEMENT *pLocator = NULL;
char *pNameBlock = NULL;
UINT name_size;
bitmaps.Open("C:\\Program Files\\Microsoft Games\\HaloCE\\maps\\bitmaps.map", CFile::modeRead);
bitmaps.Read(&header, 16);
name_size = header.LocatorBlockOffset - header.NameBlockOffset;
pLocator = new BITMAP_LOCATOR_ELEMENT[header.LocatorBlockCount];
pNameBlock = new char[name_size];
bitmaps.Seek(header.NameBlockOffset, 0);
bitmaps.Read(pNameBlock, name_size);
bitmaps.Read(pLocator, sizeof(BITMAP_LOCATOR_ELEMENT)*header.LocatorBlockCount);
bitmaps.Close();
for(int i=0; i<header.LocatorBlockCount; i++)
{
printf("%8X %8X %s\n", pLocator[i].offset, pLocator[i].size, &pNameBlock[pLocator[i].name_offset]);
}
if(pLocator)
delete pLocator;
if(pNameBlock)
delete pNameBlock;
}
void CShaderManager::ActivateDetailBlend(int base_texture, int detail_tex1, int detail_tex2, int bsp_index)
{
int count;
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &count);
if(1)//TODO: check for number of texturing units during initialization
{
//enable advanced texture blending extensions
// REPLACE Arg0
// MODULATE Arg0 * Arg1
// ADD Arg0 + Arg1
// ADD_SIGNED_EXT Arg0 + Arg1 - 0.5
// INTERPOLATE_EXT Arg0 * (Arg2) + Arg1 * (1-Arg2)
//
// PRIMARY_COLOR_EXT primary color of incoming fragment
// TEXTURE texture color of corresponding texture unit
// CONSTANT_EXT texture environment constant color
// PREVIOUS_EXT result of previous texture environment; on
// texture unit 0, this maps to PRIMARY_COLOR_EXT
//set up material texture stage
if(base_texture < m_BitmapCount)
{
pglActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_BitmapList[base_texture].GlTextureName);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE);
}
//set up detail 1
if(0)//detail_tex1 < m_BitmapCount)
{
pglActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_BitmapList[detail_tex1].GlTextureName);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_INTERPOLATE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT,GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_TEXTURE2_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ONE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_TEXTURE2_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_TEXTURE);
// Reset the current matrix and apply our chosen scale value
glLoadIdentity();
glScalef(100.0f, 100.0f, 1);
glMatrixMode(GL_MODELVIEW);
}
//set up detail 2
if(0)//detail_tex2 < m_BitmapCount)
{
pglActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_BitmapList[detail_tex2].GlTextureName);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_RGB_SCALE_EXT);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_PREVIOUS_EXT);
glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND0_RGB_EXT,GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_EXT,GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND1_RGB_EXT,GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_TEXTURE2_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ONE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_TEXTURE2_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_TEXTURE);
// Reset the current matrix and apply our chosen scale value
glLoadIdentity();
glScalef(100.0f, 100.0f, 1);
glMatrixMode(GL_MODELVIEW);
}
//set up blending function
// glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_INTERPOLATE_EXT);
// glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_TEXTURE0_ARB);
// glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE1_ARB);
// glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE2_ARB);
// glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);
// glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
// glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
}
}