fixed stars drawing (were drawing above the UI widgets

3d_asteroids
Martin Felis 2011-10-03 17:09:52 +02:00
parent 90ff61da00
commit c05d85badb
1 changed files with 6 additions and 1 deletions

View File

@ -257,6 +257,7 @@ void View::DrawStars() {
glColor3f (1., 1., 1.); glColor3f (1., 1., 1.);
glPointSize(2.); glPointSize(2.);
glBegin(GL_POINTS); glBegin(GL_POINTS);
float z_value; float z_value;
for (i = 0; i < mBackgroundStars.size(); i++) { for (i = 0; i < mBackgroundStars.size(); i++) {
// glPointSize (2. + 300. *mBackgroundStars.at(i).position[1]); // glPointSize (2. + 300. *mBackgroundStars.at(i).position[1]);
@ -264,7 +265,7 @@ void View::DrawStars() {
glColor3f (z_value, z_value, z_value); glColor3f (z_value, z_value, z_value);
glVertex3f (mBackgroundStars.at(i).position[0] * world_width, glVertex3f (mBackgroundStars.at(i).position[0] * world_width,
-1., -10.,
mBackgroundStars.at(i).position[2] * world_height); mBackgroundStars.at(i).position[2] * world_height);
mBackgroundStars.at(i).position -= vector3d(Engine::GetFrameDuration() * 0.7 * mBackgroundStars.at(i).position[1] / world_width, 0., 0.); mBackgroundStars.at(i).position -= vector3d(Engine::GetFrameDuration() * 0.7 * mBackgroundStars.at(i).position[1] / world_width, 0., 0.);
@ -302,7 +303,9 @@ void View::Draw() {
unsigned int game_state = game_model->GetGameState(); unsigned int game_state = game_model->GetGameState();
unsigned int view_state = GetViewState(); unsigned int view_state = GetViewState();
glEnable (GL_DEPTH_TEST);
DrawStars (); DrawStars ();
glDisable (GL_DEPTH_TEST);
if ( game_state == GameStateRunning if ( game_state == GameStateRunning
|| view_state == ViewStateLevelIntro || view_state == ViewStateLevelIntro
@ -455,6 +458,7 @@ void View::DrawUi () {
glMatrixMode (GL_MODELVIEW); glMatrixMode (GL_MODELVIEW);
glPushMatrix (); glPushMatrix ();
glLoadIdentity (); glLoadIdentity ();
glTranslatef (0., 1., 0.);
unsigned int game_state = GetModel()->GetGameState(); unsigned int game_state = GetModel()->GetGameState();
@ -704,6 +708,7 @@ void View::DrawUiLevelIntro() {
GetModel()->SetPlayerLives(100); GetModel()->SetPlayerLives(100);
} }
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND); glEnable(GL_BLEND);
stringstream level_info_stream; stringstream level_info_stream;