PDA

View Full Version : gluBuild2DMipmaps according to the datatype during runtime



dilectio
09-09-2003, 05:43 PM
how do i call gluBuild2DMipmaps according to the user datatype that can be a float, byte, int .... during runtime?

Leyder Dylan
09-10-2003, 12:07 AM
When you build your textures, it's not in run time; it's in your GL initialisation function ?

Leyder Dylan
09-10-2003, 12:12 AM
For using mipmapping, just add :




gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Texture_TGA[Compteur_02].width, Texture_TGA[Compteur_02].height, GL_RGB, GL_UNSIGNED_BYTE, Texture_TGA[Compteur_02].imageData);

after your




glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);

dilectio
09-10-2003, 12:55 AM
Originally posted by Leyder Dylan:
For using mipmapping, just add :




gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Texture_TGA[Compteur_02].width, Texture_TGA[Compteur_02].height, GL_RGB, GL_UNSIGNED_BYTE, Texture_TGA[Compteur_02].imageData);

after your




glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);


What i mean is that i have a function that accepts image data of data type that can be float, char, int etc. How do I check the data type to determine which parameter to call:




gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Texture_TGA[Compteur_02].width, Texture_TGA[Compteur_02].height, GL_RGB, GL_FLOAT, Texture_TGA[Compteur_02].imageData);

or




gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Texture_TGA[Compteur_02].width, Texture_TGA[Compteur_02].height, GL_RGB, GL_UNSIGNED_BYTE, Texture_TGA[Compteur_02].imageData);

or




gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Texture_TGA[Compteur_02].width, Texture_TGA[Compteur_02].height, GL_RGB, GL_INT, Texture_TGA[Compteur_02].imageData);

etc

Bob
09-10-2003, 01:28 AM
You determine the second last parameter by looking at the type of the pointer to the image data. If it's a GLfloat *, you pass GL_FLOAT, if it's a GLubyte *, pass GL_UNSIGNED_BYTE, and so on. You know the type by looking at the declaration of the imageData member.

dilectio
09-10-2003, 03:59 PM
Originally posted by Bob:
You determine the second last parameter by looking at the type of the pointer to the image data. If it's a GLfloat *, you pass GL_FLOAT, if it's a GLubyte *, pass GL_UNSIGNED_BYTE, and so on. You know the type by looking at the declaration of the imageData member.

Well, the problem i have requires me to determine the data type during runtime. Let me put it this way. We do not know the data type since my image file may be a float, char etc. It's more to c programming. Just like to know how it is usually done.

zeckensack
09-10-2003, 05:35 PM
You can't identify data types. You can only guess.
The image data really should be in a known format. File formats that support different data types also always contain type information. You need to track that information and pass it in.