From c05d85badbd63fa9b979a83742774a8489445200 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Mon, 3 Oct 2011 17:09:52 +0200 Subject: [PATCH] fixed stars drawing (were drawing above the UI widgets --- asteroids/View.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/asteroids/View.cc b/asteroids/View.cc index 4b0c36c..b596e30 100644 --- a/asteroids/View.cc +++ b/asteroids/View.cc @@ -257,6 +257,7 @@ void View::DrawStars() { glColor3f (1., 1., 1.); glPointSize(2.); glBegin(GL_POINTS); + float z_value; for (i = 0; i < mBackgroundStars.size(); i++) { // glPointSize (2. + 300. *mBackgroundStars.at(i).position[1]); @@ -264,7 +265,7 @@ void View::DrawStars() { glColor3f (z_value, z_value, z_value); glVertex3f (mBackgroundStars.at(i).position[0] * world_width, - -1., + -10., 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.); @@ -302,7 +303,9 @@ void View::Draw() { unsigned int game_state = game_model->GetGameState(); unsigned int view_state = GetViewState(); + glEnable (GL_DEPTH_TEST); DrawStars (); + glDisable (GL_DEPTH_TEST); if ( game_state == GameStateRunning || view_state == ViewStateLevelIntro @@ -455,6 +458,7 @@ void View::DrawUi () { glMatrixMode (GL_MODELVIEW); glPushMatrix (); glLoadIdentity (); + glTranslatef (0., 1., 0.); unsigned int game_state = GetModel()->GetGameState(); @@ -704,6 +708,7 @@ void View::DrawUiLevelIntro() { GetModel()->SetPlayerLives(100); } + glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); stringstream level_info_stream;