pbm with cube mapping

my problem is that when I use 2 differents cube maps for 2 objects, both of them use the last 6-cube maps that have been loaded.
I have checked everything, and my program bind the right textures with the right object, so I don’t understand why I can’t use 2 different cube maps.
Thanks a lot

check carefully if all your bind texture functions
are out side any glbegin() glend() pair.
that was my problem. i got all the binding calls out side those calls

No, my binding calls seem to be at the right place. Here is a small sample of my code :

/* enable cube texture mapping /
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_CUBE_MAP_EXT);
/
set the environnement mode /
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
/
bind the textures /
MyTexture[0]->Bind();
MyTexture[1]->Bind();
MyTexture[2]->Bind();
MyTexture[3]->Bind();
MyTexture[4]->Bind();
MyTexture[5]->Bind();
glBegin(GL_TRIANGLES);
/
draw the geometry */
glEnd();

Help !!!

Hi, with you’r code, the texture used for the geometry is the “mytexture[5]” isn’t it ?

If you use different objects with different textures, i think u should do:

Mytexture[i]->Bind();
glBegin(GL_TRIANGLES)
/* Draw the geometry relative to the texture number i /
glEnd();
MyTexture[j]->Bind();
glBegin(GL_TRIANGLES);
/
Draw the geometry realtive to the texture number j */
glEnd();

I think u can just bind textures one by one.

no, no, since I use cube mapping for my objects, my geometry uses the 6 textures !!
[each numer has a special number which tells called CubeMapNum]. Here is my binding method :

void OR_Texture::Bind()
{
glBindTexture(GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT+CubeMapNum, NumTex);
glMaterialfv(GL_FRONT, GL_SPECULAR, Specular);
glMaterialf(GL_FRONT, GL_SHININESS, Shine);
glMaterialfv(GL_FRONT, GL_AMBIENT, Ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, Diffuse);
glMaterialfv(GL_FRONT, GL_EMISSION, Emission);
}

I realy don’t understand why it does not work, because if I only use one cube mapping [i.e. 6 textures !], it works well, but if I use 2 cube map [i.e. 12 textures !], only the second cube map is taken into account !
Help !

[This message has been edited by nikopol0 (edited 11-24-2000).]

A cubemap is not 6 textures – it is 6 images all in one texture.

The target that cubemap textures are bound to is GL_TEXTURE_CUBE_MAP_ARB. (or in your case, _EXT)

However, when you specify a cubemap texture image, you need to say what face it is for.

Likewise, when you enable/disable cubemapping, you use GL_TEXTURE_CUBE_MAP_ARB.

  • Matt

ok, so I only call :
glBindTexture(GL_TEXTURE_CUBE_MAP_EXT, NumTex);
for all my 6 map, am I wrong ?
but I still have the same pbm …
perhaps I am wrong when I load my 6 image into memory … here is my code :
glTexImage2D
(
GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT+CubeMapNum,
0,
Components,
Width,
Height,
0,
Format,
Type,
Data
);

where CubMapNum is the number of the map
[1->6]
thx a lot

You only bind ONE texture for all SIX sides
of the cube. As far as I can tell, there’s
just ONE texture which contains all the six
faces of the cube (tiled within it).

Not only is it one texture and not six, but also the offset from the POSITIVE_X face should be from 0 to 5, not 1 to 6.

  • Matt

ok, that’s exactly what I do [I only bind once the texture, and my ofset starts at 0], but I still have the problem when I load 2 differents cube maps …
I really don’t know what to do …
but thx a lot for your reply !
and if someone has a piece of code that works well, it would be very nice to send it to me.