gui24a
08-23-2008, 09:04 PM
Hello again friends.
I was just trying to map a texture to a glut solid sphere using automatic texture coordinates. After some hours studying, I realize this won't be so easy (holy sh*t!! there is no ease way with gfx!). The way to go right is using cube map, but I'm struggling to figure out how the hell this thing work!
After loading a texture and building it with gluMipmap2D, I just set the following lines of code before drawing the sphere:
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
//Do I really need the R coordinate???
glEnable(GL_TEXTURE_GEN_R);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_WRA P_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_WRA P_T,GL_REPEAT);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_WRA P_R,GL_REPEAT);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_MAG _FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_MIN _FILTER,GL_LINEAR_MIPMAP_LINEAR);
glEnable(GL_TEXTURE_CUBE_MAP);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, TextEstrada);
glutSolidSphere(10,32,16);
The problem is as follows:
http://img47.imageshack.us/img47/3113/sidenz1.th.jpg (http://img47.imageshack.us/my.php?image=sidenz1.jpg)
this is Mars, lol. I can see the side of Mars, until...
http://img58.imageshack.us/img58/773/facingmeis5.th.jpg (http://img58.imageshack.us/my.php?image=facingmeis5.jpg)
...I turn the camera! The texture is always facing me!
PS> I didn't set the 6 sides for the textures 'cause I tried this and I had a problem, the render got crazy and the problem above didn't go.
Regards!
I was just trying to map a texture to a glut solid sphere using automatic texture coordinates. After some hours studying, I realize this won't be so easy (holy sh*t!! there is no ease way with gfx!). The way to go right is using cube map, but I'm struggling to figure out how the hell this thing work!
After loading a texture and building it with gluMipmap2D, I just set the following lines of code before drawing the sphere:
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
//Do I really need the R coordinate???
glEnable(GL_TEXTURE_GEN_R);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_WRA P_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_WRA P_T,GL_REPEAT);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_WRA P_R,GL_REPEAT);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_MAG _FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP,GL_TEXTURE_MIN _FILTER,GL_LINEAR_MIPMAP_LINEAR);
glEnable(GL_TEXTURE_CUBE_MAP);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, TextEstrada);
glutSolidSphere(10,32,16);
The problem is as follows:
http://img47.imageshack.us/img47/3113/sidenz1.th.jpg (http://img47.imageshack.us/my.php?image=sidenz1.jpg)
this is Mars, lol. I can see the side of Mars, until...
http://img58.imageshack.us/img58/773/facingmeis5.th.jpg (http://img58.imageshack.us/my.php?image=facingmeis5.jpg)
...I turn the camera! The texture is always facing me!
PS> I didn't set the 6 sides for the textures 'cause I tried this and I had a problem, the render got crazy and the problem above didn't go.
Regards!