Hello there! I’m a total ogl noob so please do excuse my noobcode I’m trying to get a really simple projective mapping example working based on various posts from around the web. I think I have all the elements, but am probably missing something or doing something in the wrong order. Some help would be very much appreciated! The texture is definitely loading OK, I can map it using regular co-ordinates, but the projective bit isn’t working. Here’s what I’ve got. Thanks in advance, sCam
void drawScene() {
// clear canvas
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// enable and prime our loaded texture
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, _textureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// switch to texture mode for projective mapping
glMatrixMode (GL_TEXTURE);
glLoadIdentity ();
// converts -1 to 1 into 0 to 1
glTranslatef (1.0f, 1.0f, 1.0f);
glScalef (0.5f, 0.5f, 0.5f);
// our projectors setup and position
gluPerspective (90.0f, 1.0f, 0.1f, 1.0f);
gluLookAt(0.0f, 0.0f, -5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
// generate the texture stuff
glEnable (GL_TEXTURE_GEN_S);
glEnable (GL_TEXTURE_GEN_T);
glEnable (GL_TEXTURE_GEN_R);
glEnable (GL_TEXTURE_GEN_Q);
glTexGenf (GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenf (GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenf (GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenf (GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
// goto our plane location and draw
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -5.0f);
glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);
glVertex3f(1.0f, -1.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 0.0f);
glVertex3f(-1.0f, 1.0f, 0.0f);
glEnd();
glutSwapBuffers();
}