PDA

View Full Version : Projective texturing



okapota
04-29-2002, 02:20 AM
im trying to get a little projective texturing demo to work, but it doesnt, and i dont find a reason. here is my code for setting up the texture matrix, is it ok?

GLenum coord[] = {GL_S, GL_T, GL_R, GL_Q };
float m[4][4] = {1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f};
for (int i=0;i<4;i++)
glTexGenfv(coord[i], GL_OBJECT_PLANE, m[i]);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_GEN_Q);


glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(.5, .5, 0);
glScalef(.5, .5, 1);
gluPerspective(45.0f, 1, .1, 1);
glTranslatef(0.0f, -6.0f, 0.0f);
glMatrixMode(GL_MODELVIEW);

okapota
04-29-2002, 09:08 AM
someone must know, should reset the modelview to identity before that? no, i guess.

PH
04-29-2002, 09:28 AM
I always use GL_OBJECT_LINEAR for projective texturing on GeForce level hardware ( just a matter of preference ). Try just changing GL_EYE_LINEAR to GL_OBJECT_LINEAR.

PH
04-29-2002, 09:59 AM
I just noticed that you are using GL_OBJECT_PLANE with eye linear texgen. If you want to use GL_EYE_LINEAR, then change

glTexGenfv(coord[i], GL_OBJECT_PLANE, m[i]);

to

glTexGenfv(coord[i], GL_EYE_PLANE, m[i]);