Textures

ops…
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]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
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]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
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]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
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 ?

thanks!!!
_ _
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 :

glGenTextures(2,FPrim);

or

glGenTextures(2,&FPrim[0]);

This will give you the correct texture names.

Best regards.

Eric

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 !!!