View Full Version : Generating and Loading textures

05-24-2003, 06:51 AM
The following code (Nehe: lesson 06):
--------------------------------------------glGenTextures(1, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, sizeX, sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
is used to define a texture so we could later on display it on screen using OpenGL.
How can we make sure that the graphic card has enough memory to contain a texture ?. If it doesn't have space for it, any OpenGL operations like zoom,rotate can take Host resources instead of Graphic card resources.


05-24-2003, 07:04 AM
1) We have no control for OpenGL texture storage. It is a black box by design. Generally, you should never worry about memory issues.

2) Use gluScaleImage to shrink image if it is too big and cause perfomance penalties.

3) For additional control, you can use NV_pixel_data_range extensions.

Roderic (Ingenu)
05-24-2003, 07:27 AM
There's a Texture Proxy mechanism which can tell you whether the texture will fit in memory or not at the time you ask it.

See glTexImage2D in the OpenGL Reference Manual AKA Blue Book for details.

05-24-2003, 09:52 AM
Will you people ever stop to recommend that junk GLU rouitnes???It's not so hard and it's much faster to write your own texture scaler.And now for the generation.OpenGL will kindly inform you if there was a problem with the generation of a texture id.There usually won't be any problems with that(BUT CHECK EVERY TIME!!!!!!!!).The real problem might come from the uploading of the texture image 'cause this is what takes the actuall AGP mem.I suggest to check for errors but even if you don't the programm won't crash and the texture will be simply white.If you ever consider to use 3D textures keep in mind that a simple grayscale texture with sizes 256x256 will get almost all of the AGP memory and will most likely crash the program soon or later.

05-24-2003, 02:47 PM
What's wrong with glu?


05-24-2003, 07:59 PM
GLU is slow and its texture manipulation algorithms are very basic (as in, not high quality)

05-25-2003, 01:24 AM
GLU is standard. It is more simple to use GLU at first time and switch to smth else later.