From 44fda9805b117207eaf3341be441a33130507f0a Mon Sep 17 00:00:00 2001 From: ehofman Date: Tue, 16 Sep 2003 10:02:32 +0000 Subject: [PATCH] Enable back face culling for cockpit instruments, disable depth buffer writes for 2d instruments but enable depth buffer writes for the magnetic compass. Does anyone care to create a 3d magnetic compass? --- src/Cockpit/built_in/FGMagRibbon.cxx | 4 ++++ src/Cockpit/panel.cxx | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Cockpit/built_in/FGMagRibbon.cxx b/src/Cockpit/built_in/FGMagRibbon.cxx index fe8d971d7..76e9483dd 100644 --- a/src/Cockpit/built_in/FGMagRibbon.cxx +++ b/src/Cockpit/built_in/FGMagRibbon.cxx @@ -67,7 +67,11 @@ FGMagRibbon::draw () FGCroppedTexture &t = getTexture(); t.setCrop(xoffset, yoffset, xoffset + 0.5, yoffset + 0.25); + + glPushAttrib(GL_DEPTH_BUFFER_BIT); + glDepthMask(GL_TRUE); FGTexturedLayer::draw(); + glPopAttrib(); } // end of FGMagRibbon.cxx diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index 4483dfa2a..0ec6523db 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -346,9 +346,7 @@ FGPanel::update (GLfloat winx, GLfloat winw, GLfloat winy, GLfloat winh) glTranslated(x_offset, y_offset, 0); - glDepthMask(GL_FALSE); draw(); - glDepthMask(GL_TRUE); glMatrixMode(GL_PROJECTION); glPopMatrix(); @@ -370,7 +368,8 @@ FGPanel::draw() // save some state glPushAttrib( GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT - | GL_TEXTURE_BIT | GL_PIXEL_MODE_BIT ); + | GL_TEXTURE_BIT | GL_PIXEL_MODE_BIT | GL_CULL_FACE + | GL_DEPTH_BUFFER_BIT ); // Draw the background glEnable(GL_TEXTURE_2D); @@ -378,6 +377,8 @@ FGPanel::draw() glEnable(GL_BLEND); glEnable(GL_ALPHA_TEST); glEnable(GL_COLOR_MATERIAL); + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); sgVec4 panel_color; sgCopyVec4( panel_color, cur_light_params.scene_diffuse ); if ( fgGetDouble("/systems/electrical/outputs/instrument-lights") > 1.0 ) { @@ -424,6 +425,10 @@ FGPanel::draw() instrument_list_type::const_iterator current = _instruments.begin(); instrument_list_type::const_iterator end = _instruments.end(); + // Don't let the instruments be visible trhought the roof of the c310-3d + // This does hurt the magnetic compass in the default c172-3d, + // but we need a real 3d compass anyway. + glDepthMask(GL_FALSE); for ( ; current != end; current++) { FGPanelInstrument * instr = *current; glPushMatrix();