PDA

View Full Version : damn texture selection...



gunslinger
12-17-2003, 12:56 AM
ok guys,
i have to face my old forgotten texture problem. I am not a newbie anymore, yet i am not yet a pro, so I have a lot of stupid questions left to answer.
I am experiencing new and fancy features of OGL, such ad cube maps. Ok cool, i have managed to understand the basic of the cubemap, but now i am stuck on a trivial trouble:
I have different sets of textures, working toghether:
just say 6 for the skybox stuff and one for the cubemap (which is divided in 6 subtextures).
Now these 2 stes of textures, must have different attribs. When i generata the whole stuff i have something like:

for(the 6 sides of the skybox)
{
if (!LoadTGA(&skyboxtex[i],"data/tron_zpos.tga"))
{
printf("non trovo texture2\n");
exit(0);
}

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
}
glGenTextures(1, &global.texID);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

for (i = 0; i < 6; i++) {
glTexImage2D(
cubefaces[i],
0, // level
GL_RGB, // internal format
128, // width
128, // height
0, // border
GL_RGB, // format
GL_UNSIGNED_BYTE, // type
CubeMap[CUBE_POS_X + i]); // pixel data
}
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

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);

now, when i'll be swiching between the varoius textures in my OGL app, i'll be forced to re-enter all the settings at every frame or OGL remembers which param has every single texture i have defined in the init stuff?

in othe words may i just tell opengl something like:

glBindexture (GL_TEXTURE_2D,skybox)
draw the skybox;
glBindTexture (GL_TEXTURE_CUBE_MAP_EXT,cubemap)
draw the cubemapped objects;

with no more stupid gltexparam?

thanks 4 the help, the gunslinger

Mazy
12-17-2003, 01:30 AM
the TexParameter stuff is bound to the texture, so that you dont need to resubmit, the texGen, and TexEnv are bound to the textureUnit, so they should be set each time you need to change them.