69 if (tex == NULL || tex->getHandle() == 0) {
77 GLuint texHandle = tex->getHandle();
78 glGetIntegerv(GL_TEXTURE_BINDING_2D, &curTex);
79 if ((GLuint)curTex != texHandle) {
80 glBindTexture(GL_TEXTURE_2D, texHandle);
83 if ((GLuint)curTex != texHandle) {
84 glBindTexture(GL_TEXTURE_2D, (GLuint)curTex);
234bool grMakeMipMaps (GLubyte *image,
int xsize,
int ysize,
int zsize,
bool mipmap)
236 if (!((xsize & (xsize-1))==0) || !((ysize & (ysize-1))==0)) {
237 ulSetError ( UL_WARNING,
"Map is not a power-of-two in size!" ) ;
243 for (
int l = 0; l < 20; l++) {
251 for (lev = 0 ;((xsize >> (lev+1)) != 0 || (ysize >> (lev+1)) != 0); lev++) {
255 int w1 = xsize >> l1;
256 int h1 = ysize >> l1;
257 int w2 = xsize >> l2;
258 int h2 = ysize >> l2;
273 texels[l2] =
new GLubyte[w2*h2*zsize];
275 for (
int x2 = 0; x2 < w2; x2++) {
276 for (
int y2 = 0; y2 < h2; y2++) {
277 for (
int c = 0; c < zsize; c++) {
279 int x1_1 = (x1 + 1) % w1;
281 int y1_1 = (y1 + 1) % h1;
282 int t1 = texels[l1][(y1*w1 + x1)*zsize + c];
283 int t2 = texels[l1][(y1_1*w1 + x1)*zsize + c];
284 int t3 = texels[l1][(y1*w1 + x1_1)*zsize + c];
285 int t4 = texels[l1][(y1_1*w1 + x1_1)*zsize + c];
298 texels[l2][(y2*w2 + x2)*zsize + c] = a;
300 texels[l2][(y2*w2 + x2)*zsize + c] = ( t1 + t2 + t3 + t4 )/4;
307 texels[lev + 1] = NULL;
309 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
310 glHint(GL_TEXTURE_COMPRESSION_HINT_ARB, GL_NICEST);
315 GLint textureTargetFormat;
321 textureTargetFormat = GL_COMPRESSED_LUMINANCE_ARB;
325 textureTargetFormat = GL_COMPRESSED_LUMINANCE_ALPHA_ARB;
329 textureTargetFormat = GL_COMPRESSED_RGB_ARB;
333 textureTargetFormat = GL_COMPRESSED_RGBA_ARB;
338 textureTargetFormat = zsize;
345 if (xsize > tlimit || ysize > tlimit) {
349 glTexImage2D(GL_PROXY_TEXTURE_2D, map_level, textureTargetFormat, xsize, ysize, FALSE ,
350 (zsize==1)?GL_LUMINANCE:
351 (zsize==2)?GL_LUMINANCE_ALPHA:
354 GL_UNSIGNED_BYTE, NULL);
356 glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &ww);
363 for (
int l = 0; texels [l] != NULL; l++) {
364 texels [l] = texels[l+1];
367 if (xsize < 8 && ysize < 8) {
374 for (
int i = 0; texels[i] != NULL; i++) {
385 if (mipmap == TRUE || i == 0) {
386 glTexImage2D ( GL_TEXTURE_2D,
387 map_level, textureTargetFormat, w, h, FALSE ,
388 (zsize==1)?GL_LUMINANCE:
389 (zsize==2)?GL_LUMINANCE_ALPHA:
392 GL_UNSIGNED_BYTE, (GLvoid *) texels[i] ) ;
bool grMakeMipMaps(GLubyte *image, int xsize, int ysize, int zsize, bool mipmap)
bool doMipMap(const char *tfname, int mipmap)
void grApplyTextureAnisotropy(ssgTexture *tex)
bool grLoadSGI(const char *fname, ssgTextureInfo *info)
void grRegisterCustomSGILoader(void)
bool grMakeMipMaps(GLubyte *image, int xsize, int ysize, int zsize, bool mipmap)
bool doMipMap(const char *tfname, int mipmap)