View Full Version : Texture managing problem
First Im loading two textures into ogl using 2 defined names, without using glGenTextures,
textures names: 1 and 2;
after this Im loading other textures using glGenTextures to generate free texture names for me, but glGenTextures is generating a name that was previosly loaded (1,2), if glGenTextures doesnt generate a free texture name, why use it?
12-05-2002, 02:46 AM
Maybe a driver bug?
Using glGenTextures, glBindTexture, glDeleteTextures for all your texture objects should solve the problem.
Only glGenTextures and glDeleteTexture cooperates.. It doesn't check what you have loaded.
12-05-2002, 06:28 AM
Nope, the spec says:
"A texture object is created by binding an unused name to TEXTURE 1D,
TEXTURE 2D, TEXTURE 3D, or TEXTURE CUBE MAP. The binding is effected by
void BindTexture( enum target, uint texture );
with target set to the desired texture target and texture set to the unused name".
In the next page:
void GenTextures( sizei n, uint *textures );
returns n previously unused texture object names in textures. These names are
marked as used, for the purposes of GenTextures only, but they acquire texture
state and a dimensionality only when they are first bound, just as if they were
But in the above example glBindTexture has marked 1 and 2 as used, so glGenTextures must not return those names.
I tested once again, and glGenTexture still generating names that are already in use... I think its a driver problem.
Voodoo 5 5500 (default/OEM)
PS: Theres no reason to glGenTextures exists if it generates used texture names.
glGenTextures its working, but it always start its counter in 0, so if I load a texture in position 0 without use glGenTexture it will be overwritten when glGenTexture is used.
I see where the problem is. I believe it's a matter of how those statements are interpreted. After reading your post several times real slowly, this is what is clear to me:
Naturally you would create a binding by using BindTexture() with an unused name. That we all can agree on. (Note that there is no mention of that unused name now being set to used).
The problem is interpretation of the next point. "returns n previously unused texture object names in textures. These names are marked as used, for the purposes of GenTextures only...."
This simply means that the returned names will be unused names for use in your application but GenTextures() will treat them as "used" internally to itself. Why? Technically, if GenTextures() did not treat them as used, then two successive calls to GenTextures() could technically return the same name - since the name from the first GenTextures() was not bound when the second call was made so it was never used. That would then mean combining two or more successive calls to GenTextures() into one call for N names could also technically return the same name N times (in theory). Thus it is simply stating GenTextures treats name usage slightly different in order to give you the results you expect - N unused names.
Now that I'm thinking of it, I do recall adding GenTextures() support to an application that had used hardcoded values - and I had observed the same results. This was on a voodoo3 system running opengl 1.2(?) by the way.
When you look at it that way, then the results of mixing user supplied names and GenTextures() names are undefined - at least from what I have read so far. Ever since the experience with the voodoo3 application, I always made sure I never mixed the two methods.
So, glBindTexture(when called with a unused name) doesnt mark texture-name as 'used', so glGenTexture overwrites it ...?
I still trying to understand the reason for existing glGenTexture if this doesnt works in 'mixed' mode...
PS: You all may test it on your opengl (1.1,1.2,1.3).
>> So, glBindTexture(when called with a unused name) doesnt mark texture-name as 'used', so glGenTexture overwrites it ...?
From my experience, yes.
>> I still trying to understand the reason for existing glGenTexture if this doesnt works in 'mixed' mode...
It has been my experience that you really should not mix the two methods. Either you statically assign texture IDs to your textures or use GenTextures() for dynamic texture ID assignment.
I prefer GenTextures() myself as then I don't have to worry about accidentally using the same value twice.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.