hello there!!!
i’m having some problems with textures. Can some good soul help with this code ???
i’m waiting for your important reply

What i’m doing is something like this:
(Where FPrimitiveTexture[] is a vector 0…2 of TGLuint and my own Primitive Object Field )

TextureImage : PTAUX_RGBImageRec;

glGenTextures( 2, FPrimitiveTexture[0] );

// Create Nearest Filtered Texture
glGenTextures(3, FPrimitiveTexture[0]);
glBindTexture(GL_TEXTURE_2D, FPrimitiveTexture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage^.sizeX, TextureImage^.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage^.data);

// Create Linear Filtered Texture
glBindTexture(GL_TEXTURE_2D, FPrimitiveTexture[1]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage^.sizeX, TextureImage^.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage^.data);

// Create MipMapped Texture
glBindTexture(GL_TEXTURE_2D, FPrimitiveTexture[2]);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage^.sizeX, TextureImage^.sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage^.data);

at the end of whole process above the vector FPrimitiveTexture still are ( 0, 0, 0 );
what’s happend ?

_ _
0 0

You are wrong with your call to glGenTexture.

The call declaration is :

void glGenTextures(
GLsizei n,
GLuint * textures

When you do : glGenTextures(2,FPrim[0]), FPrim[0] is an int and not a pointer to an int.

The correct call is :




This will give you the correct texture names.

Best regards.


Another thing to be said here is about the third parameter in glTexImage2D (same with second in gluBuild2DMipMaps): This does not specifies the number of components (as said in MSVC), but rather the format of the generated texture. This is in most cases the same as the seventh argument. However, if you send three as an argument, OpenGL assumes it is three components (and not the format defined as number three, because there is no), and uses a predefined format of three components as resulting textureformat, and this is different between drivers.

This means that if you load a 24-bit RGB texture, and pass 3 as argument, the resulting texture might (depending on the driver) end up in a 16-bit texture.

Just a tip then, always pass the same value as third and seventh (or sixth for mipmaps) argument.

Thanks you guys for the help.

But doesn’t work…
when i pass something like this: glGenTextures(2,FPrim) or
glGenTextures(2,@FPrim[0]) i got a error like: 2nd parameter isn’t the same as function declaration!!

i meam, the glGenTexture isn’t asking for array or a pointer.
So let me explain what i’m doing:
i created a class(object) that has a field array[0…2] of TGLuint and others fields.
So one of these fields are a type of object, example: 1 => tri
2 => quad

But the textures are fixed and individual to each object derived of TPrimitive.
So when i called TPrimitive.PrimitiveDraw
just check what kind of primitive are and draw it with glbindtexture applying the texture in protected field…
i think is very simple, but i can’t make it happens.

It’s possible, my idea ???

still waiting for your important reply

thanks !!!