Hi all,
Ive created a flat square matrix and ive mapped a bitmap onto it. It views fine. However what I want to do is map the bitmap onto the back of the flat square so both sides of the square have the same bitmap on and both are facing the correct way. Here is the code i have so far
glRotatef(over,0,1,0);
glBegin(GL_POLYGON);
//Side1
glTexCoord2f(0.0,0.0);glVertex3f(0.9, 0.628,(cardNum*0.01));
glTexCoord2f(1.0,0.0);glVertex3f(1.12, 0.628,(cardNum*0.01));
glTexCoord2f(1.0,1.0);glVertex3f(1.12, 0.921,(cardNum*0.01));
glTexCoord2f(0.0,1.0);glVertex3f(0.9, 0.921,(cardNum*0.01));
glEnd();
glBegin(GL_POLYGON);
//Side2
glTexCoord2f(0.0,0.0);glVertex3f(0.9, 0.628,(cardNum*0.01));
glTexCoord2f(0.0,1.0);glVertex3f(0.9, 0.921,(cardNum*0.01));
glTexCoord2f(1.0,1.0);glVertex3f(1.12, 0.921,(cardNum*0.01));
glTexCoord2f(1.0,0.0);glVertex3f(1.12, 0.628,(cardNum*0.01));
glEnd();
As you can see side1 has been drawn counterclockwise with the texture also being drawn counterclockwise and side2 has been drawn clockwise along with its texture.
This doesnt work because when the square is rotated (hence the glRotate command), the back image is facing the wrong way and even if i remove the “side2” polygon from the code and recompile still exactly the same happens (the image on the back is the wrong way round).
Howcome?
Second question? WIth the rotate command the image is rotated around the Y axis, which is correct. However it is rotated massively across the screen and i only want it to turn around itself, how can i change this?
Thanks
EDIT:
Ive done some reading around and realised that the problem might be with my projection and my camera. Can anyone see if the following piece of code could be causing the problem, because no matter how big or small i make the y variable in glRotatef it always rotates the same width
void changeSize(int w, int h) {
// Prevent a divide by zero, when window is too short
// (you cant make a window of zero width).
if(h == 0)
h = 1;
float ratio = 1.0* w / h;
// Reset the coordinate system before modifying
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Set the viewport to be the entire window
glViewport(0,0, w, h);
// Set the correct perspective.
gluPerspective(45,ratio,1,1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//gluLookAt(0.5,0.5,1.2, 0.5,0.5,0.0, 0.0,1.0,0.0);
gluLookAt(0.5,0.5,3.2, 0.5,0.5,0.0, 0.0,1.0,0.0);
}
or maybe here
void main (int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(800,600);
glutCreateWindow("Example");
glutDisplayFunc(renderScene);
// glutIdleFunc(renderScene);
glutReshapeFunc(changeSize);
glutSpecialFunc(processSpecialKeys);
// enable depth testing
glEnable(GL_DEPTH_TEST);
glutMainLoop();
}
Thanks