1
0
Fork 0

Syd Adams:

- 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...
This commit is contained in:
curt 2006-09-05 20:28:48 +00:00
parent 789779d532
commit 2c193be0ca

View 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 ()
// end of panel.cxx