21 #define GL_EXT_texture_env_combine 1
29 #ifndef GL_TEXTURE_CUBE_MAP_EXT
30 #define GL_TEXTURE_CUBE_MAP_EXT 0x8513
31 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515
32 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516
33 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517
34 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518
35 #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519
36 #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A
46 switch (textureformat)
92 -1, -1, -1, -1, -1, -1, -1, -1,
93 -1, -1, -1, -1, -1, -1, -1, -1,
94 -1, -1, -1, -1, -1, -1, -1, -1,
95 -1, -1, -1, -1, -1, -1, -1, -1
100 for (
int a = 0;
a < 256;
a++, dest += 4, src += 4) {
108 return num < 0 ? -num : num;
115 if ( (num/2)*2 != num )
125 static GLint round2( GLint n )
128 for (m = 1; m < n; m *= 2)
137 static GLint bytes_per_pixel( GLenum format, GLenum type )
143 case GL_STENCIL_INDEX:
144 case GL_DEPTH_COMPONENT:
152 case GL_LUMINANCE_ALPHA:
171 case GL_UNSIGNED_BYTE:
172 m =
sizeof (GLubyte);
180 case GL_UNSIGNED_SHORT:
181 m =
sizeof (GLushort);
184 m =
sizeof (GLshort);
186 case GL_UNSIGNED_INT:
193 m =
sizeof (GLfloat);
201 static GLint appleBuild2DMipmaps( GLenum target,
210 void *image, *newimage;
211 GLint neww, newh,
level, bpp;
215 GLint unpackrowlength, unpackalignment, unpackskiprows, unpackskippixels;
216 GLint packrowlength, packalignment, packskiprows, packskippixels;
217 if (width < 1 || height < 1)
218 return GLU_INVALID_VALUE;
219 glGetIntegerv( GL_MAX_TEXTURE_SIZE, &maxsize );
224 h = round2( height );
227 bpp = bytes_per_pixel( format, type );
230 return GLU_INVALID_ENUM;
232 glGetIntegerv( GL_UNPACK_ROW_LENGTH, &unpackrowlength );
233 glGetIntegerv( GL_UNPACK_ALIGNMENT, &unpackalignment );
234 glGetIntegerv( GL_UNPACK_SKIP_ROWS, &unpackskiprows );
235 glGetIntegerv( GL_UNPACK_SKIP_PIXELS, &unpackskippixels );
236 glGetIntegerv( GL_PACK_ROW_LENGTH, &packrowlength );
237 glGetIntegerv( GL_PACK_ALIGNMENT, &packalignment );
238 glGetIntegerv( GL_PACK_SKIP_ROWS, &packskiprows );
239 glGetIntegerv( GL_PACK_SKIP_PIXELS, &packskippixels );
242 glPixelStorei( GL_PACK_ROW_LENGTH, 0 );
243 glPixelStorei( GL_PACK_ALIGNMENT, 1 );
244 glPixelStorei( GL_PACK_SKIP_ROWS, 0 );
245 glPixelStorei( GL_PACK_SKIP_PIXELS, 0 );
248 if (w != width || h != height) {
250 image = malloc( (w+4)*h*bpp );
252 return GLU_OUT_OF_MEMORY;
253 error = gluScaleImage( format, width, height, type, data,
260 image = (
void*) data;
266 glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
267 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
268 glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
269 glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
271 glTexImage2D( target, level, components, w, h, 0, format, type, image );
272 if (w == 1 && h == 1)
274 neww = (w < 2) ? 1 : w/2;
275 newh = (h < 2) ? 1 : h/2;
276 newimage = malloc( (neww+4)*newh*bpp );
278 return GLU_OUT_OF_MEMORY;
279 error = gluScaleImage( format, w, h, type, image,
280 neww, newh, type, newimage );
296 glPixelStorei( GL_UNPACK_ROW_LENGTH, unpackrowlength );
297 glPixelStorei( GL_UNPACK_ALIGNMENT, unpackalignment );
298 glPixelStorei( GL_UNPACK_SKIP_ROWS, unpackskiprows );
299 glPixelStorei( GL_UNPACK_SKIP_PIXELS, unpackskippixels );
300 glPixelStorei( GL_PACK_ROW_LENGTH, packrowlength );
301 glPixelStorei( GL_PACK_ALIGNMENT, packalignment );
302 glPixelStorei( GL_PACK_SKIP_ROWS, packskiprows );
303 glPixelStorei( GL_PACK_SKIP_PIXELS, packskippixels );
308 #define gluBuild2DMipmaps appleBuild2DMipmaps
329 while ( *handle < static_cast<int>(
textures.size()) ) {
335 if ( (*handle) ==
static_cast<int>(
textures.size()) ) {
342 switch (texture_target)
345 textures[*handle].targets = GL_TEXTURE_1D;
348 textures[*handle].targets = GL_TEXTURE_2D;
350 #ifdef GL_EXT_texture3D
352 textures[*handle].targets = GL_TEXTURE_3D;
365 textures[*handle].texturestage = texturestage;
366 textures[*handle].mipmapped = mipmap;
367 glGenTextures( 1, &
textures[*handle].name );
372 glTexParameteri(
textures[*handle].targets, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
374 glTexParameteri(
textures[*handle].targets, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
376 glTexParameteri(
textures[*handle].targets, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
379 glTexParameteri(
textures[*handle].targets, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
380 glTexParameteri(
textures[*handle].targets, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
382 glTexParameteri(
textures[*handle].targets, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
383 glTexParameteri(
textures[*handle].targets, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
386 glTexParameterf(
textures[*handle].targets, GL_TEXTURE_PRIORITY, .5 );
392 if (palette && textureformat ==
PALETTE8) {
394 textures[*handle].palette = (GLubyte*) malloc(
sizeof (GLubyte)*1024 );
403 glPrioritizeTextures( 1,
404 #
if defined (__APPLE__)
407 &handle, &priority );
417 const unsigned char *oldbuf,
426 assert( pixsize <= 4 );
428 int i,
j,
k, l, m, n, o;
433 int newwidth = width > maxwidth ? maxwidth :
width;
434 int scalewidth = width/newwidth;
435 int newheight = height > maxheight ? maxheight :
height;
436 int scaleheight = height/newheight;
437 int inewfade = (
int) (newfade*0x100);
439 if ( (scalewidth != 2) || (scaleheight != 2) || (inewfade != 0x100) ) {
445 int wmask = scalewidth-1;
446 int hmask = scaleheight-1;
448 int ostride = newwidth*pixsize;
449 int istride = width*pixsize;
450 int rowstride = scaleheight*istride;
451 int chunkstride = 32*pixsize;
452 int ichunkstride = scalewidth*chunkstride;
457 amask >>= 1, tshift++, wshift++;
460 amask >>= 1, tshift++, hshift++;
461 int tmask = (1<<tshift)-1;
462 *newbuf = (
unsigned char*) malloc( newheight*newwidth*pixsize*
sizeof (
unsigned char) );
463 unsigned int temp[32*4];
464 unsigned char *orow = (*newbuf);
465 const unsigned char *irow = oldbuf;
466 for (i = 0; i < newheight; i++, orow += ostride, irow += rowstride) {
467 const unsigned char *crow = irow;
468 unsigned char *orow2 = orow;
469 for (j = 0; j < newwidth; j += 32, crow += ichunkstride, orow2 += chunkstride) {
470 const unsigned char *crow2 = crow;
471 for (k = 0; k < chunkstride; k++)
473 for (m = 0; m < scaleheight; m++, crow2 += istride)
474 for (k = n = l = 0; (k < chunkstride) && (j+l < newwidth); k += pixsize, l++)
475 for (o = 0; o < scalewidth; o++)
476 (temp[k+0] += crow2[n++]),
477 (pixsize > 1) && (temp[k+1] += crow2[n++]),
478 (pixsize > 2) && (temp[k+2] += crow2[n++]),
480 (pixsize > 3) && (temp[k+3] += crow2[n++]);
481 for (k = l = 0; (k < chunkstride) && (j+l < newwidth); k += pixsize, l++)
482 ( orow2[k+0] = (
unsigned char) ( ( ( (temp[k+0]+tmask)>>tshift )*inewfade+0x80*(0x100-inewfade) )>>8 ) ),
484 && ( orow2[k+1] = (
unsigned char) ( ( ( (temp[k+1]+tmask)>>tshift )*inewfade+0x80*(0x100-inewfade) )>>8 ) ),
486 && ( orow2[k+2] = (
unsigned char) ( ( ( (temp[k+2]+tmask)>>tshift )*inewfade+0x80*(0x100-inewfade) )>>8 ) ),
489 && ( orow2[k+3] = (
unsigned char) ( ( ( (temp[k+3]+tmask)>>tshift )*inewfade+0x80*(0x100-inewfade) )>>8 ) );
496 *newbuf = (
unsigned char*) malloc( newheight*newwidth*pixsize*
sizeof (
unsigned char) );
497 unsigned char *orow = (*newbuf);
498 int ostride = newwidth*pixsize;
499 int istride = width*pixsize;
500 const unsigned char *irow[2] = {oldbuf, oldbuf+istride};
501 unsigned int temp[4] = { 0,0,0,0 };
502 for (i = 0; i < newheight; i++, irow[0] += 2*istride, irow[1] += 2*istride, orow += ostride)
503 for (j = k = 0; j < newwidth; j++, k += pixsize) {
504 (temp[0] = irow[0][(k<<1)+0]),
505 (pixsize > 1) && (temp[1] = irow[0][(k<<1)+1]),
506 (pixsize > 2) && (temp[2] = irow[0][(k<<1)+2]),
508 (pixsize > 3) && (temp[3] = irow[0][(k<<1)+3]);
510 (temp[0] += irow[0][(k<<1)+pixsize+0]),
511 (pixsize > 1) && (temp[1] += irow[0][(k<<1)+pixsize+1]),
512 (pixsize > 2) && (temp[2] += irow[0][(k<<1)+pixsize+2]),
514 (pixsize > 3) && (temp[3] += irow[0][(k<<1)+pixsize+3]);
516 (temp[0] += irow[1][(k<<1)+0]),
517 (pixsize > 1) && (temp[1] += irow[1][(k<<1)+1]),
518 (pixsize > 2) && (temp[2] += irow[1][(k<<1)+2]),
520 (pixsize > 3) && (temp[3] += irow[1][(k<<1)+3]);
522 (temp[0] += irow[1][(k<<1)+pixsize+0]),
523 (pixsize > 1) && (temp[1] += irow[1][(k<<1)+pixsize+1]),
524 (pixsize > 2) && (temp[2] += irow[1][(k<<1)+pixsize+2]),
526 (pixsize > 3) && (temp[3] += irow[1][(k<<1)+pixsize+3]);
528 ( orow[k+0] = (
unsigned char) ( (temp[0]+3)>>2 ) ),
529 (pixsize > 1) && ( orow[k+1] = (
unsigned char) ( (temp[1]+3)>>2 ) ),
530 (pixsize > 2) && ( orow[k+2] = (
unsigned char) ( (temp[2]+3)>>2 ) ),
532 (pixsize > 3) && ( orow[k+3] = (
unsigned char) ( (temp[3]+3)>>2 ) );
542 internalformat = GL_COMPRESSED_RGB_ARB;
546 return internalformat;
552 internalformat = GL_COMPRESSED_RGBA_ARB;
568 return internalformat;
573 switch (textureformat)
610 GLenum image2D = GL_TEXTURE_2D;
614 image2D = GL_TEXTURE_2D;
638 assert(0 ||!
"Bad case in file gl_texture.cpp, line 668 as of this writing.");
658 return "CUBEMAP_POSITIVE_X";
661 return "CUBEMAP_NEGATIVE_X";
664 return "CUBEMAP_POSITIVE_Y";
667 return "CUBEMAP_NEGATIVE_Y";
670 return "CUBEMAP_POSITIVE_Z";
673 return "CUBEMAP_NEGATIVE_Z";
676 return "TEXTURE_RECTANGLE";
696 glTexSubImage2D( image2D, 0, x, y, width, height,
textures[handle].textureformat, GL_UNSIGNED_BYTE, buffer );
708 unsigned int pageIndex )
716 unsigned char *data = NULL;
717 unsigned char *tempbuf = NULL;
718 GLenum internalformat;
728 if (internformat >=
DXT1 && internformat <=
DXT5) {
730 if (buffer[0]) mips = mips*10+(buffer[0]-
'0');
731 if (buffer[1]) mips = mips*10+(buffer[1]-
'0');
740 static unsigned char NONPOWEROFTWO[1024] = {
746 buffer = NONPOWEROFTWO;
751 logsize = logsize > logwid ? logsize : logwid;
755 if (maxdimension == 65536)
758 "Transferring %dx%d texture, page %d (eff: %dx%d - limited at %d - %d mips), onto name %d (%s)\n",
769 if (maxdimension == 44) {
774 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
775 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
776 if (internformat >=
DXT1 && internformat <=
DXT5) {
777 if (
textures[handle].width > 8 &&
textures[handle].height > 8 && mips > 0) {
778 offset1 += ( (
textures[handle].width+3)/4 )*( (
textures[handle].height+3)/4 )*blocksize;
790 if (internformat >=
DXT1 && internformat <=
DXT5) {
791 while ( (
textures[handle].width > maxdimension ||
textures[handle].height > maxdimension) && mips > 0 ) {
792 offset1 += ( (
textures[handle].width+3)/4 )*( (
textures[handle].height+3)/4 )*blocksize;
802 for (
int i = 0;
i < mips; ++
i) {
803 offset2 += ( (w+3)/4 )*( (h+3)/4 )*blocksize;
811 #if !defined (GL_COLOR_INDEX8_EXT)
822 ( internformat ==
PALETTE8 ? 1 : (internformat ==
RGBA32 ? 4 : 3) )*
sizeof (
unsigned char),
841 switch (internformat)
859 offset2 += ( ( (w+3)/4 )*( (h+3)/4 ) )*8;
863 offset2 += ( ( (w+3)/4 )*( (h+3)/4 ) )*16;
880 offset1 += pageIndex*(offset2-2);
882 int height =
textures[handle].height;
886 unsigned char *tmpbuffer = buffer+offset1;
890 textures[handle].textureformat = GL_RGBA;
895 if (detail_texture) {
900 glTexParameteri(
textures[handle].targets, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
902 glTexParameteri(
textures[handle].targets, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
904 glTexParameteri(
textures[handle].targets, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
908 if (internformat >=
DXT1 && internformat <=
DXT5) {
911 unsigned int offset = 0;
916 size = ( (width+3)/4 )*( (height+3)/4 )*blocksize;
917 for (i = 0; i < mips; ++i) {
926 size = ( (width+3)/4 )*( (height+3)/4 )*blocksize;
932 size = ( (width+3)/4 )*( (height+3)/4 )*blocksize;
935 glTexParameteri(
textures[handle].targets, GL_TEXTURE_BASE_LEVEL, 0 );
936 glTexParameteri(
textures[handle].targets, GL_TEXTURE_MAX_LEVEL, 0 );
942 gluBuild2DMipmaps( image2D,
955 if (internformat >=
DXT1 && internformat <=
DXT5) {
957 size = ( (width+3)/4 )*( (height+3)/4 )*blocksize;
959 glTexParameteri(
textures[handle].targets, GL_TEXTURE_BASE_LEVEL, 0 );
960 glTexParameteri(
textures[handle].targets, GL_TEXTURE_MAX_LEVEL, 0 );
963 glTexImage2D( image2D,
978 #if defined (GL_COLOR_INDEX8_EXT)
980 error = glGetError();
982 error = glGetError();
992 gluBuild2DMipmaps( image2D,
1000 glTexImage2D( image2D,
1002 GL_COLOR_INDEX8_EXT,
1013 unsigned char *tbuf = (
unsigned char*) malloc(
sizeof (
unsigned char)*nsize );
1016 for (
int i = 0;
i < nsize;
i += 4) {
1017 tbuf[
i] =
textures[handle].palette[4*buffer[j]];
1018 tbuf[
i+1] =
textures[handle].palette[4*buffer[j]+1];
1019 tbuf[
i+2] =
textures[handle].palette[4*buffer[j]+2];
1021 tbuf[
i+3] =
textures[handle].palette[4*buffer[j]+3];
1027 RGBA32, imagetarget, maxdimension, detail_texture );
1042 glDeleteTextures( 1, &
textures[handle].name );
1056 for (
size_t handle = 0; handle <
textures.size(); ++handle) {
1071 for (
size_t handle = 0; handle <
textures.size(); handle++)
1082 glDisable( GL_TEXTURE_GEN_S );
1083 glDisable( GL_TEXTURE_GEN_T );
1084 glDisable( GL_TEXTURE_GEN_R );
1087 glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
1088 glTexGenfv( GL_S, GL_EYE_PLANE, params );
1089 glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
1090 glTexGenfv( GL_T, GL_EYE_PLANE, paramt );
1091 glEnable( GL_TEXTURE_GEN_S );
1092 glEnable( GL_TEXTURE_GEN_T );
1093 glDisable( GL_TEXTURE_GEN_R );
1096 glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
1097 glTexGenfv( GL_S, GL_OBJECT_PLANE, params );
1098 glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
1099 glTexGenfv( GL_T, GL_OBJECT_PLANE, paramt );
1100 glEnable( GL_TEXTURE_GEN_S );
1101 glEnable( GL_TEXTURE_GEN_T );
1102 glDisable( GL_TEXTURE_GEN_R );
1105 glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP );
1106 glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP );
1107 glEnable( GL_TEXTURE_GEN_S );
1108 glEnable( GL_TEXTURE_GEN_T );
1109 glDisable( GL_TEXTURE_GEN_R );
1113 glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV );
1114 glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV );
1115 glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV );
1116 glEnable( GL_TEXTURE_GEN_S );
1117 glEnable( GL_TEXTURE_GEN_T );
1118 glEnable( GL_TEXTURE_GEN_R );
1153 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, type );
1156 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
1157 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
1158 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );
1159 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB );
1160 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA );
1161 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
1162 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );
1163 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_TEXTURE );
1164 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, GL_SRC_ALPHA );
1165 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_CONSTANT );
1166 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA );
1167 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB, GL_CONSTANT );
1168 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB, GL_SRC_ALPHA );
1170 GLfloat arg2v[4] = {
1173 glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, arg2v );
1175 glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB );
1176 glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_INTERPOLATE_ARB );
1177 glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1 );
1178 glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1 );
1181 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
1182 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
1183 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );
1184 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_CONSTANT );
1185 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA );
1186 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
1187 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );
1188 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_TEXTURE );
1189 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_ONE_MINUS_SRC_ALPHA );
1191 GLfloat arg2v[4] = {
1194 glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, arg2v );
1196 glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB );
1197 glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE );
1198 glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1 );
1199 glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1 );
1202 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
1203 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
1204 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );
1205 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB );
1206 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
1207 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );
1208 glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB );
1209 glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE );
1210 glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1 );
1211 glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1 );
1214 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
1215 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
1216 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB );
1217 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );
1218 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA );
1219 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
1220 glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_TEXTURE );
1221 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );
1222 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, GL_SRC_ALPHA );
1223 glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE );
1224 glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE );
1225 glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2 );
1226 glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, 2 );
1231 #ifndef GL_CLAMP_TO_EDGE_EXT
1232 #define GL_CLAMP_TO_EDGE_EXT 0x812F
1234 #ifndef GL_CLAMP_TO_BORDER_ARB
1235 #define GL_CLAMP_TO_BORDER_ARB 0x812D
1243 GLenum e1 = GL_REPEAT;
1260 glTexParameteri( tt, GL_TEXTURE_WRAP_S, e1 );
1261 if (target !=
TEXTURE1D) glTexParameteri( tt, GL_TEXTURE_WRAP_T, e1 );
1262 if (target ==
TEXTURE3D) glTexParameteri( tt, GL_TEXTURE_WRAP_R, e1 );
1264 glTexParameteri( tt, GL_TEXTURE_WRAP_S, e2 );
1265 if (target !=
TEXTURE1D) glTexParameteri( tt, GL_TEXTURE_WRAP_T, e2 );
1266 if (target ==
TEXTURE3D) glTexParameteri( tt, GL_TEXTURE_WRAP_R, e2 );