gluBuild2DMipmaps according to the datatype during runtime

how do i call gluBuild2DMipmaps according to the user datatype that can be a float, byte, int … during runtime?

When you build your textures, it’s not in run time; it’s in your GL initialisation function ?

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_FILTER,GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

Originally posted by Leyder Dylan:
[b]For using mipmapping, just add :

[quote]

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_FILTER,GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

[/b][/QUOTE]

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

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.

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.

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.