]> git.mxchange.org Git - flightgear.git/commitdiff
Syd Adams:
authorcurt <curt>
Tue, 5 Sep 2006 20:28:48 +0000 (20:28 +0000)
committercurt <curt>
Tue, 5 Sep 2006 20:28:48 +0000 (20:28 +0000)
- Well I finally licked it, the clipping works great now, in 16 and 32
  bpp mode, on 2d and 3d panels.
- I tried glScissors, didnt work because clipping was done in screen
  co-ordinates.
- Stencil buffer methods worked great for 2d panel, but messed up 3d
  panels,(depth buffer problems I think), and only worked in 32 bpp mode.
- I then tried clip planes , and so far it appears to work with no
  problem, and no framerate drop like I had with the stencil buffer
  method...

I'm attaching the panel.cxx file for testing...

src/Cockpit/panel.cxx

index 5f7580e3fde97d9fd9a1f5aa425c4fa57f2b2266..90c5e200025eff066d6994636140a5f043089da4 100644 (file)
@@ -65,7 +65,7 @@
 // The number of polygon-offset "units" to place between layers.  In
 // principle, one is supposed to be enough.  In practice, I find that
 // my hardware/driver requires many more.
-#define POFF_UNITS 4
+#define POFF_UNITS 8
 
 ////////////////////////////////////////////////////////////////////////
 // Local functions.
@@ -419,17 +419,46 @@ FGPanel::draw()
   }
 
   // Draw the instruments.
+  // Syd Adams: added instrument clipping
   instrument_list_type::const_iterator current = _instruments.begin();
   instrument_list_type::const_iterator end = _instruments.end();
 
+  GLdouble blx[4]={1.0,0.0,0.0,0.0};
+  GLdouble bly[4]={0.0,1.0,0.0,0.0};
+  GLdouble urx[4]={-1.0,0.0,0.0,0.0};
+  GLdouble ury[4]={0.0,-1.0,0.0,0.0};
+
   for ( ; current != end; current++) {
     FGPanelInstrument * instr = *current;
     glPushMatrix();
     glTranslated(instr->getXPos(), instr->getYPos(), 0);
+
+    int ix= instr->getWidth();
+    int iy= instr->getHeight();
+    glPushMatrix();
+    glTranslated(-ix/2,-iy/2,0);
+    glClipPlane(GL_CLIP_PLANE0,blx);
+    glClipPlane(GL_CLIP_PLANE1,bly);
+    glEnable(GL_CLIP_PLANE0);
+    glEnable(GL_CLIP_PLANE1);
+
+    glTranslated(ix,iy,0);
+    glClipPlane(GL_CLIP_PLANE2,urx);
+    glClipPlane(GL_CLIP_PLANE3,ury);
+    glEnable(GL_CLIP_PLANE2);
+    glEnable(GL_CLIP_PLANE3);
+    glPopMatrix();
     instr->draw();
+
     glPopMatrix();
   }
 
+  glDisable(GL_CLIP_PLANE0);
+  glDisable(GL_CLIP_PLANE1);
+  glDisable(GL_CLIP_PLANE2);
+  glDisable(GL_CLIP_PLANE3);
+
+
   // Draw yellow "hotspots" if directed to.  This is a panel authoring
   // feature; not intended to be high performance or to look good.
   if ( fgGetBool("/sim/panel-hotspots") ) {
@@ -1174,6 +1203,3 @@ FGSwitchLayer::draw ()
 
 \f
 // end of panel.cxx
-
-
-