Hi all,
I have a problem with texturing.
I draw a wall with a random hole at baseline. To do that, I use 3 cubes:
- Before the hole (from [minX, minY] to [xHole, maxY]
- Up to the hole (from [xHole, maxYHole] to [xHole+maxXHole, maxY]
- After the hole
Then I have a wall texture and I want it is placed good over the 3 cubes: insted I get three distinct textures with not-continuity effect…
This is the code.
if (useEnvmap)
{
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_2D);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
// when texture area is small, bilinear filter the closest mipmap
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST );
// when texture area is large, bilinear filter the first mipmap
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
//glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);//combina texture cno luci
glBindTexture(GL_TEXTURE_2D, 3);
glDisable(GL_LIGHTING);
}
else
glColor3f(0,0,1);
glPushMatrix();
glTranslated((-myFloor->floorMaxX + xBuco)/2, maxY/2, pz+maxZ/2);
glScaled(abs(-myFloor->floorMaxX-xBuco)/2 , maxY/2 , maxZ);
drawCubeFill();
glPopMatrix();
glPushMatrix();
glTranslated(xBuco+bucoMaxX/2, (maxY-bucoMaxY)/2+bucoMaxY, pz+maxZ/2);
glScaled(bucoMaxX/2 , (maxY-bucoMaxY)/2 , maxZ);
drawCubeFill();
glPopMatrix();
glPushMatrix();
glTranslated((myFloor->floorMaxX + xBuco + bucoMaxX)/2, maxY/2, pz+maxZ/2);
glScaled(abs(myFloor->floorMaxX-(xBuco+bucoMaxX))/2 , maxY/2 , maxZ);
drawCubeFill();
glPopMatrix();
if (useEnvmap)
{
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
}
And this is the texture:
Thanks