Thanks for the explanation. I have modelview matrices set up. I have posted my code so that you can see what might be the problem. Thanks in advanced.
This is the code from the init function
void init_OpenGL()
{
glfwEnable( GLFW_MOUSE_CURSOR ); // Enable mouse cursor
glEnable(GL_TEXTURE_2D); // Enable texturing
glEnable(GL_CULL_FACE); // Enable back face culling
glEnable(GL_DEPTH_TEST); // Enable depth test (for 3D drawing)
glfwSetKeyCallback(keyhandler); // Register keyboard controls
glfwEnable(GLFW_KEY_REPEAT); // Allow keys to repeat whilst pressed down
glClearColor(0.0, 0.0, 0.0, 0.0); // Set background colour to black
glMatrixMode(GL_PROJECTION); // Switch to projection matrix mode
glLoadIdentity(); // Reloads the matrix
glOrtho(-400.0, 400.0, -300.0, 300.0, -100.0, 100.0); // We are using Ortho view and one unit is 1 pixel.
}
Here is the code for render the screen in question.
void atGameScreen()
{
// When the level is completed, run this statement
if (percentCompleted == 100){ // if the level is completed
gameBrightness -= 0.005; // slowly fade out the screen
if (gameBrightness <= 0.0f){ // once completely faded
BACKSPACEpressed(); // simulate a backspace key press to reset variables
}
// When the level starts, run this statement
}else if (gameBrightness <= 2.0){ // if the game screen is not at 100% brightness
gameBrightness += 0.005; // slowly fade in the screen
}else if (areYouReadyPos >=800.0f){ // If the "ARE YOU READY" sign is gone freom view
a += 0.05; // expand the background stars to simulate slying through space
b -= 0.05;
c += 0.05;
}
glPushMatrix();
glColor3f(gameBrightness, gameBrightness, gameBrightness);
glEnable(GL_TEXTURE_2D);
// Draw the arrow bar underlay at the top of the screen
glBindTexture(GL_TEXTURE_2D, g_Texture[0]);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 0.0f); glVertex3f(400.0f, 200.0f, -0.2f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(400.0f, 300.0f, -0.2f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-400.0f, 300.0f, -0.2f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-400.0f, 200.0f, -0.2f);
glEnd();
// Draw the status panel
glBindTexture(GL_TEXTURE_2D, g_Texture[1]);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 0.0f); glVertex3f(a, b, -90.2f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(a, c, -90.2f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-a, c, -90.2f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-a, b, -90.2f);
glEnd();
// Draw the song thumbnail image
glBindTexture(GL_TEXTURE_2D, thumb_Texture[index]);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 0.0f); glVertex3f(390, 206, -0.1f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(390, 279, -0.1f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(317, 279, -0.1f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(317, 206, -0.1f);
glEnd();
// This deals the the flashing of the target line
glDisable(GL_TEXTURE_2D);
if (time >= 0.08){
glColor3f(gameBrightness - 1.65f, gameBrightness - 1.65f, gameBrightness - 1.65f);
}else if (time >= songs[index].getBeatTime() - timeSkip - 0.08){
glColor3f(gameBrightness, gameBrightness, gameBrightness);
}else{
glColor3f(gameBrightness, gameBrightness, gameBrightness);
}
// Draw the left arrow of the target line
glBegin(GL_TRIANGLES);
glVertex3f(-400, -248, 0.0f);
glVertex3f(-370, -239, 0.0f);
glVertex3f(-400, -230, 0.0f);
glEnd();
// Draw the target line across the screen
glBegin(GL_TRIANGLES);
glVertex3f(370, -239, 0.0f);
glVertex3f(400, -248, 0.0f);
glVertex3f(400, -230, 0.0f);
glEnd();
// Draw the right arrow of the target line
glBegin(GL_QUADS);
glVertex3f(400, -240, 0.0f);
glVertex3f(400, -238, 0.0f);
glVertex3f(-400, -238, 0.0f);
glVertex3f(-400, -240, 0.0f);
glEnd();
// The following draws the beat on the arrow bar on top of the screen
if (beat == 1){ // If beat count is 1 then
glColor3f(0.0,gameBrightness, 0.0); // Draw green beat bar (Beat 1)
glBegin(GL_QUADS);
glVertex3f(-201.0f, 291.0f, 0.0f);
glVertex3f(-201.0f, 300.0f, 0.0f);
glVertex3f(-399.0f, 300.0f, 0.0f);
glVertex3f(-399.0f, 291.0f, 0.0f);
glEnd();
}else if (beat == 2){ // If beat count is 2 then
glColor3f(gameBrightness,gameBrightness, 0.0);// Draw green yellow bar (Beat 2)
glBegin(GL_QUADS);
glVertex3f(-1.0f, 291.0f, 0.0f);
glVertex3f(-1.0f, 300.0f, 0.0f);
glVertex3f(-199.0f, 300.0f, 0.0f);
glVertex3f(-199.0f, 291.0f, 0.0f);
glEnd();
}else if (beat == 3){ // If beat count is 3 then
glColor3f(gameBrightness,gameBrightness, 0.0);// Draw green yellow bar (Beat 3)
glBegin(GL_QUADS);
glVertex3f(199.0f, 291.0f, 0.0f);
glVertex3f(199.0f, 300.0f, 0.0f);
glVertex3f(1.0f, 300.0f, 0.0f);
glVertex3f(1.0f, 291.0f, 0.0f);
glEnd();
}else if (beat ==4){ // If beat count is 4 then
glColor3f(gameBrightness,gameBrightness, 0.0);// Draw green yellow bar (Beat 4)
glBegin(GL_QUADS);
glVertex3f(399.0f, 291.0f, 0.0f);
glVertex3f(399.0f, 300.0f, 0.0f);
glVertex3f(201.0f, 300.0f, 0.0f);
glVertex3f(201.0f, 291.0f, 0.0f);
glEnd();
}
drawGameText();
glPopMatrix();
// FINISHED ORTHO DRAWING AND BEGIN USING 3D VIEW
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPerspective(45.0f,800/600, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(1.0f, 0.0f, 0.0f); // Draw red quad
glBegin(GL_QUADS);
glVertex3f(0, -380, -3.6);
glVertex3f(0, -100, -3.6 );
glVertex3f(-180, -100, -3.6 );
glVertex3f(-180, -380, -3.6);
glEnd();
glColor3f(1.0f, 1.0f, 0.0f); // Draw yellow quad
glBegin(GL_QUADS);
glVertex3f(0, -380, -5.6);
glVertex3f(0, -100, -5.6 );
glVertex3f(-100, -100, -5.6 );
glVertex3f(-100, -380, -5.6);
glEnd();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}