]> git.mxchange.org Git - flightgear.git/commitdiff
Fix the rendering of the KLN89 on the 2D panel that was broken during the move to...
authordaveluff <daveluff>
Wed, 22 Jul 2009 21:00:43 +0000 (21:00 +0000)
committerTim Moore <timoore@redhat.com>
Mon, 27 Jul 2009 21:52:32 +0000 (23:52 +0200)
src/Cockpit/panel.cxx
src/Instrumentation/dclgps.cxx
src/Instrumentation/dclgps.hxx
src/Instrumentation/render_area_2d.cxx
src/Instrumentation/render_area_2d.hxx

index 3754d7911ff695a47f0001c0f52431c528fc0e8a..cd68b342a074128d49267137b6ed7805ec72e521 100644 (file)
@@ -914,7 +914,7 @@ FGSpecialInstrument::~FGSpecialInstrument ()
 void
 FGSpecialInstrument::draw (osg::State& state)
 {
-  complex->draw();
+  complex->draw(state);
 }
 
 
index 9d6ccc67575c00232718435535497ecb28e7383a..f3bbfc2a6479bc746e0f7b1575dfd10db5c5ba56 100644 (file)
@@ -356,9 +356,8 @@ DCLGPS::~DCLGPS() {
        // TODO - may need to delete the approach database!!
 }
 
-void DCLGPS::draw() {
-       //cout << "draw called!\n";
-       _instrument->draw();
+void DCLGPS::draw(osg::State& state) {
+       _instrument->draw(state);
 }
 
 void DCLGPS::init() {
index 435f7899a25e51f53e5ca4ed2a229a8eee3bcfac..a7b6e05688983b6f305af621eebb45553ce1853c 100644 (file)
@@ -251,7 +251,7 @@ public:
        DCLGPS(RenderArea2D* instrument);
        virtual ~DCLGPS() = 0;
        
-       virtual void draw();
+       virtual void draw(osg::State& state);
        
        virtual void init();
        virtual void bind();
index ae8784c542ace2433402bd9bb615d8541171db54..5a08009a1b297721a818e15313dfa629623bd578 100644 (file)
@@ -62,24 +62,31 @@ RenderArea2D::RenderArea2D(int logx, int logy, int sizex, int sizey, int posx, i
        _ra2d_debug = false;
 }
 
-void RenderArea2D::draw() {
-#if 0
-    glDisable(GL_TEXTURE_2D);
-       /*
-    glColor3f(1, 1, 0);
+void RenderArea2D::draw(osg::State& state) {
        
-       float x1 = _posx;
-       float x2 = _posx + _sizex;
-       float y1 = _posy;
-       float y2 = _posy + _sizey;
+       static osg::ref_ptr<osg::StateSet> renderArea2DStateSet;
+       if(!renderArea2DStateSet.valid()) {
+               renderArea2DStateSet = new osg::StateSet;
+               renderArea2DStateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::OFF);
+               renderArea2DStateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
+       }
+       
+       state.pushStateSet(renderArea2DStateSet.get());
+       state.apply();
+       state.setActiveTextureUnit(0);
+       state.setClientActiveTextureUnit(0);
+       
+       // DCL - the 2 lines below are copied verbatim from the hotspot drawing code.
+       // I am not sure if they are needed here or not.
+       glPushAttrib(GL_ENABLE_BIT);
+       glDisable(GL_COLOR_MATERIAL);
        
-       glBegin(GL_LINE_LOOP);
-    glVertex2f(x1, y1);
-    glVertex2f(x1, y2);
-    glVertex2f(x2, y2);
-    glVertex2f(x2, y1);
-    glEnd();
-       */
+       // FIXME - disabling all clip planes causes bleed-through through the splash screen.
+       glDisable(GL_CLIP_PLANE0);
+       glDisable(GL_CLIP_PLANE1);
+       glDisable(GL_CLIP_PLANE2);
+       glDisable(GL_CLIP_PLANE3);
+
        oldDrawBackground();
        
        for(unsigned int i = 0; i < drawing_list.size(); ++i) {
@@ -101,8 +108,12 @@ void RenderArea2D::draw() {
                }
        }
        
-       glEnable(GL_TEXTURE_2D);
-#endif
+       glPopAttrib();
+       
+       state.popStateSet();
+       state.apply();
+       state.setActiveTextureUnit(0);
+       state.setClientActiveTextureUnit(0);
 }
 
 // Set clipping region in logical units
@@ -336,34 +347,24 @@ void RenderArea2D::Flush() {
 // -----------------------------------------
 
 void RenderArea2D::doSetColor( const float *rgba ) {
-  //OSGFIXME
-#if 0
   glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, rgba);
   glColor4fv( rgba );
-#endif
 }
 
 void RenderArea2D::doDrawQuad( const sgVec2 *p, const sgVec3 *normals ) {
-       //cout << "doDrawQuad: " << *p[0] << ", " << *(p[0]+1) << ", " << *p[1] << ", " << *(p[1]+1) << ", " << *p[2] << ", " << *p([2]+1) << ", " << *p[3] << ", " << *p([3]+1) <<'\n';
-  //OSGFIXME
-#if 0
   glBegin(GL_QUADS);
   glNormal3fv( normals[0] ); glVertex2fv( p[0] );
   glNormal3fv( normals[1] ); glVertex2fv( p[1] );
   glNormal3fv( normals[2] ); glVertex2fv( p[2] );
   glNormal3fv( normals[3] ); glVertex2fv( p[3] );
   glEnd();
-#endif
 }
 
 void RenderArea2D::doDrawQuad( const sgVec2 *p, const sgVec3 *normals, const sgVec4 *color ) {
-  //OSGFIXME
-#if 0
   glBegin(GL_QUADS);
     glColor4fv( color[0] );glNormal3fv( normals[0] ); glVertex2fv( p[0] );
     glColor4fv( color[1] );glNormal3fv( normals[1] ); glVertex2fv( p[1] );
     glColor4fv( color[2] );glNormal3fv( normals[2] ); glVertex2fv( p[2] );
     glColor4fv( color[3] );glNormal3fv( normals[3] ); glVertex2fv( p[3] );
   glEnd();
-#endif
 }
index 6b4dc32301ada3cf10b25ad5bd2de73edd7d5360..44c5c0db2dbcc22c13b4270b5768984b82fafd5a 100644 (file)
 #  include <config.h>
 #endif
 
+#include <osg/ref_ptr>
+#include <osg/State>
+#include <osg/StateSet>
+
 #include <plib/sg.h>
 #include <simgear/compiler.h>
 
@@ -56,7 +60,7 @@ public:
        RenderArea2D(int logx, int logy, int sizex, int sizey, int posx, int posy);
        ~RenderArea2D();
        
-       void draw();
+       void draw(osg::State& state);
        
        void SetPixelColor(const float* rgba);
        void SetBackgroundColor(const float* rgba);