glGenTextures question
Ok, right now in my game I have 5 textures for the terrain, possibly up to 8 for my model, and then a few random question, and I was wondering if my idea of keeping them organized would waste memory/speed. Here it is
glGenTextures( 30, &texture[0] );
// load textures 1-5 here (terrain)
// load texturess 10-18 here (model)
// load textures 20-30 here (random)
I know that textures 6-9 an 19 would never be touched (as well as some of the 20's), but will just having them exist take memory? I was thinking you actually need to send the texture to the card to take memory, but I could be wrong.
glGenTextures( 30, &texture[0] );
// load textures 1-5 here (terrain)
// load texturess 10-18 here (model)
// load textures 20-30 here (random)
I know that textures 6-9 an 19 would never be touched (as well as some of the 20's), but will just having them exist take memory? I was thinking you actually need to send the texture to the card to take memory, but I could be wrong.
Having them as entries in the texture list doesn't take memory until you call glTexImage2D. OpenGL does not expose the details of video memory, it should handle everything for you.
The only wasted memory would be whatever your unsigned int texture array didn't get filled with. So in your case
unsinged int texture[30] = {0};
//you only assign textures to the first 25 elements than the last 5 are wasted or not being used.
Now if you actually assigned textures with
gluBuild2DMipmaps or glTexImage2D
to all 30 then yes you are wasting VRAM and system RAM.
BTW if you know that you're not going to use all 30 then why are you allocating 30 in your array?
unsinged int texture[30] = {0};
//you only assign textures to the first 25 elements than the last 5 are wasted or not being used.
Now if you actually assigned textures with
gluBuild2DMipmaps or glTexImage2D
to all 30 then yes you are wasting VRAM and system RAM.
BTW if you know that you're not going to use all 30 then why are you allocating 30 in your array?
Quote:Originally posted by Mars_999
BTW if you know that you're not going to use all 30 then why are you allocating 30 in your array?
Because I wrote a animated model class that uses meshworks data, so the textures are 1 through 8. I am already using texture 0-5, and at some point that will raise to 0-6 through 0-15 probably, so I want to keep the meshworks textures separate (start them on 20 or something)
Just use a seperate array for each group of textures.
i.e.
glGenTextures( 5, &terrainTexture[0] );
glGenTextures( 8, &modelTexture[0] );
glGenTextures( 10, &randomTexture[0] );
In my 2D game engine, I just have an object that takes care of smaller parts of a large texture. In other words the object takes care of the texture.
So it has one texture variable, and each instance does a glGenTexture call once. That way, when you create a bunch of these objects the textures are taken care of nicely, without any concern of one big array with many different textures owned by different objects.
This isn't the best way for all cases I suppose, but it might work for you!
i.e.
glGenTextures( 5, &terrainTexture[0] );
glGenTextures( 8, &modelTexture[0] );
glGenTextures( 10, &randomTexture[0] );
In my 2D game engine, I just have an object that takes care of smaller parts of a large texture. In other words the object takes care of the texture.
So it has one texture variable, and each instance does a glGenTexture call once. That way, when you create a bunch of these objects the textures are taken care of nicely, without any concern of one big array with many different textures owned by different objects.
This isn't the best way for all cases I suppose, but it might work for you!
"Pay no attention to that man behind the curtain." - Wizard of Oz
Quote:Originally posted by aaronsullivan
Just use a seperate array for each group of textures.
i.e.
glGenTextures( 5, &terrainTexture[0] );
glGenTextures( 8, &modelTexture[0] );
glGenTextures( 10, &randomTexture[0] );
Thats perfect, Thanks
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Pointer Warning in glGenTextures | Pixelated | 1 | 2,242 |
Apr 6, 2008 01:28 PM Last Post: OneSadCookie |
|
| glGenTextures() dies from EXC_BAD_ACCES? O.o | wyrmmage | 8 | 4,168 |
Apr 7, 2007 07:23 PM Last Post: wyrmmage |
|
| glGenTextures and EXC_BAD_ACCESS | BobbyWatson | 1 | 3,952 |
Aug 31, 2002 01:48 PM Last Post: BobbyWatson |
|
| death by glGenTextures(), with TGA | sealfin | 7 | 4,069 |
Jul 18, 2002 07:02 AM Last Post: sealfin |
|

