PDA

View Full Version : glGenTextures



Omaha
05-22-2005, 04:47 PM
You know, it's often occured to me that maybe I should do some kind of batching with my texture generation, but then I wonder, is there really anything gained by glGenTextures(10, TextureNames); over ten calls to glGenTextures(1, &TextureName); ten times?

Just makes life easier in loading images and uploading textures.

Ehsan Kamrani
05-22-2005, 05:28 PM
I believe that you don't like to waste your time and write many glGenTextures while you can use from one call to this function. and you don't like to add the lines of your source code.Isn't it?
-Ehsan-

Omaha
05-22-2005, 06:33 PM
Well, my usual code structure is:

load an image
upload the image as a texture

load an image
upload the image as a texture

load an image
upload the image as a texture

The functions behind both processes share a parameter, and that is a structure containing, among other things, the texture name as retrieved from glGenTextures. Normally in the UploadTexture() function there's just a call:

[CODE]glGenTextures(1, &UImage.TextureName);[CODE]

Now I suppose instead of uploading them immediately I could load all images, add them to a queue of sorts, and then upload them all at once, and call glGenTextures((length of queue), (some temporary array)) and then assign the values manually, but ultimately, is there a point? One at a time is working just fine for now.

Ehsan Kamrani
05-22-2005, 07:14 PM
You have another option:
unsigned int textureNames[n];
glGenTextures( n, textureNames );

//Load the images

glBindTexture( GL_TEXTURE_2D, textureNames[0] );
//Specify the properties

glBindTexture( GL_TEXTURE_2D, textureNames[1] );
//Specify the properties
...
But your code works and you can use from your code.It's on to you.
-Ehsan-