Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Q] Cant find any documentation on GL_S3_s3tc.

10 views
Skip to first unread message

bsod

unread,
Feb 1, 2001, 3:15:38 PM2/1/01
to
Hello folks,

I have a savage2000 which supports the GL_S3_s3tc extension, which is
nice, but i cant find any way to access it. Could i use the following
code? (taken from the S3TC on Linux thread)
-------[snip]---------
then you should get the proper include file for the function
prototypes/constant definitions for your extension. In the case of
S3TC i think it's just:

#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3

At this point you can use any of the previous four instead of
GL_RGBA/GL_RGB in the internal format in glTexImage and
gluBuildMipMaps. This will take uncompressed textures and store them
in texture memory in compressed format.
-----[end]-----

Jorrit Rouwe

unread,
Feb 5, 2001, 9:52:50 AM2/5/01
to
That would be the way to do it I think.

There is some source code on the nVidia web site demonstrating this. Go to
www.nvidia.com/developer and click on "tech demos", then look for s3tc.

Jorrit.


dant...@my-deja.com

unread,
Feb 5, 2001, 4:51:02 PM2/5/01
to

> Hello folks,
>
> I have a savage2000 which supports the GL_S3_s3tc extension, which is
> nice, but i cant find any way to access it. Could i use the following
> code? (taken from the S3TC on Linux thread)
> -------[snip]---------

Yeah, but don't use this code. I had some problems with it. Here is
some fixed code:


int compressTextureAndExport(const char *filename) {
GLint *compressedFormat;
GLint numFormat;
GLint compressed;
int internalFormat;
int compressedSize;
GLint decalMap = 0;
GLint compressedDecalMap = 1;
GLint alreadyCompressedDecalMap = 2;


glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

gluBuild2DMipmaps(GL_TEXTURE_2D,
(texture->getColorDepth() == 32) ?
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT : GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
texture->getWidth(), texture->getHeight(),
(texture->getColorDepth() == 32) ? GL_RGBA : GL_RGB,
GL_UNSIGNED_BYTE, texture->getImageData());

glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, &numFormat);
compressedFormat = (GLint *) malloc(numFormat * sizeof(GLint));
glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS_ARB, compressedFormat);

glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB,
&compressed);


if (compressed == GL_TRUE) {
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_INTERNAL_FORMAT, &internalFormat);

glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
GL_TEXTURE_IMAGE_SIZE_ARB, &compressedSize);

compressedImage = (unsigned char *) malloc(compressedSize *
sizeof(unsigned char));

glGetCompressedTexImageARB(GL_TEXTURE_2D, 0, compressedImage);

glCompressedTexImage2DARB(GL_TEXTURE_2D, 0, internalFormat,
texture->getWidth(), texture->getHeight(),
0, compressedSize, compressedImage);

// Write Compressed Image to File
FILE *fh;

fh = fopen(filename, "w");

if (!fh) {
printf("Error Creating File\n");
} else {

short w = texture->getWidth();
short h = texture->getHeight();

fwrite(&w, sizeof(short), 1, fh);
fwrite(&h, sizeof(short), 1, fh);

fwrite(&compressedSize, sizeof(GLint), 1, fh);
fwrite(&internalFormat, sizeof(GLint), 1, fh);

fwrite(compressedImage, sizeof(unsigned char), compressedSize,
fh);

fclose(fh);
printf("Compressed File Written To Disk\n");
}
} else {
printf("Compression Failed\n");
}

}

> then you should get the proper include file for the function
> prototypes/constant definitions for your extension. In the case of
> S3TC i think it's just:
>
> #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
> #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
> #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
> #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
>
> At this point you can use any of the previous four instead of
> GL_RGBA/GL_RGB in the internal format in glTexImage and
> gluBuildMipMaps. This will take uncompressed textures and store them
> in texture memory in compressed format.
> -----[end]-----
>

And don't forget to register your functions, either!

// Define at Top
typedef void (*glGetCompressedTexImageARBProc)(GLenum, GLint, void *);
typedef void (*glCompressedTexImage2DARBProc)(GLenum, GLint, GLenum,
GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);

glGetCompressedTexImageARBProc glGetCompressedTexImageARB;
glCompressedTexImage2DARBProc glCompressedTexImage2DARB;


// Register in Initialization
glGetCompressedTexImageARB = (glGetCompressedTexImageARBProc)
glXGetProcAddressARB((GLubyte *)"glGetCompressedTexImageARB");
glCompressedTexImage2DARB = (glCompressedTexImage2DARBProc)
glXGetProcAddressARB((GLubyte *)"glCompressedTexImage2DARB");

if (!glGetCompressedTexImageARB) printf("glGetCompressedTexImageARB
NOT registered\n");
if (!glCompressedTexImage2DARB) printf("glCompressedTexImage2DARB NOT
registered\n");


Good Luck!

.D.


Sent via Deja.com
http://www.deja.com/

0 new messages