I''ve run into a rather small but very heavy problem. It all begun when I changed the camera settings.
From the beginning I had the camera setup at the location: 0.0, 0.0, -98. And when I rendered a field, which consists of two rectangles I could see the field.
But then I realized that my coordinate-system was uppside down because of the camera position. So I changed the camera to: 0.0, 0.0, 98.
Then the whole field disappeared! Everything just went black!
So after some experimentation I succeded in making one of the rects visible. But the other one is not working and I do not know how the first is working
.
And I can only speculate what the problem is. Is OpenGL thining that the negative Z vector is the frontside of all objects or what?
Here is the Draw() in main.cpp:
int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // Clear Screen, Depth And Stencil Buffer.
glLoadIdentity(); // Reset The Current Modelview Matrix
float elapsedSeconds = timer->getElapsedSeconds(); // Get elapsed seconds.
if(g_angle >= 360.0)
g_angle = 0.0;
g_angle +=1.5;
input.Update(); // Update the inputsystem.
timer->LockFPS(60); // The app runs at maximum 60 fps.
gluLookAt(0.0, 0.0, 92.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0);
//gameField->Animate(elapsedSeconds);
backPaddel1->Move(input, elapsedSeconds);
backPaddel2->Move(input, elapsedSeconds);
frontPaddel1->Move(input, elapsedSeconds);
frontPaddel2->Move(input, elapsedSeconds);
//fireball->Animate(elapsedSeconds);
//mainball->Animate(elapsedSeconds);
gameField->Draw();
fireball->Draw2(g_angle);
mainball->Draw2(g_angle);
backPaddel1->Draw();
backPaddel2->Draw();
frontPaddel1->Draw();
frontPaddel2->Draw();
glFlush();
return TRUE; // Everything Went OK
}
And the CField::Draw():
void CField::Draw()
{
glPushMatrix();
glTranslatef(pos.x, pos.y, pos.z); // Moves the origo of the coordinatesystem to the fields position.
glColor3f(1.0, 1.0, 1.0); // Sets the color and transparacy.
// This rect does not work
glBegin(GL_QUADS);
glNormal3f(0.0, 0.0, 1.0);
glVertex3f(-50.0, 25.0, Z);
glVertex3f(0.0, 25.0, Z);
glVertex3f(0.0, -25.0, Z);
glVertex3f(-50.0, -25.0, Z);
glEnd();
// This rect is working!
glBegin(GL_QUADS);
glNormal3f(0.0, 0.0, 1.0);
glVertex3f(50.0, 25.0, Z);
glVertex3f(0.0, 25.0, Z);
glVertex3f(0.0, -25.0, Z);
glVertex3f(50, -25.0, Z);
glEnd();
glPopMatrix();
}
Please help!
Does: C++ combined with OpenGL games and other visuals. Dream: To become a REAL gameprogrammer. Yeah!