]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/HUD/HUD.cxx
Merge branch 'next' into durk-atc
[flightgear.git] / src / Instrumentation / HUD / HUD.cxx
1 // HUD.cxx -- Head Up Display
2 //
3 // Written by Michele America, started September 1997.
4 //
5 // Copyright (C) 1997  Michele F. America  [micheleamerica#geocities:com]
6 // Copyright (C) 2006  Melchior FRANZ  [mfranz#aon:at]
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
22 #include <simgear/compiler.h>
23 #include <simgear/structure/exception.hxx>
24
25 #include <string>
26 #include <fstream>
27
28 #ifdef HAVE_CONFIG_H
29 #  include <config.h>
30 #endif
31
32 #include <simgear/constants.h>
33 #include <simgear/misc/sg_path.hxx>
34 #include <osg/GLU>
35
36 #include <Main/globals.hxx>
37 #include <Main/viewmgr.hxx>
38 #include <Main/viewer.hxx>
39
40 #include "HUD.hxx"
41
42
43 static float clamp(float f)
44 {
45     return f < 0.0f ? 0.0f : f > 1.0f ? 1.0f : f;
46 }
47
48
49 HUD::HUD() :
50     _path(fgGetNode("/sim/hud/path[1]", "Huds/default.xml")),
51     _current(fgGetNode("/sim/hud/current-color", true)),
52     _visibility(fgGetNode("/sim/hud/visibility[1]", true)),
53     _3DenabledN(fgGetNode("/sim/hud/enable3d[1]", true)),
54     _antialiasing(fgGetNode("/sim/hud/color/antialiased", true)),
55     _transparency(fgGetNode("/sim/hud/color/transparent", true)),
56     _red(fgGetNode("/sim/hud/color/red", true)),
57     _green(fgGetNode("/sim/hud/color/green", true)),
58     _blue(fgGetNode("/sim/hud/color/blue", true)),
59     _alpha(fgGetNode("/sim/hud/color/alpha", true)),
60     _alpha_clamp(fgGetNode("/sim/hud/color/alpha-clamp", true)),
61     _brightness(fgGetNode("/sim/hud/color/brightness", true)),
62     _visible(false),
63     _antialiased(false),
64     _transparent(false),
65     _a(0.67),                                                                   // FIXME better names
66     _cl(0.01),
67     //
68     _scr_widthN(fgGetNode("/sim/startup/xsize", true)),
69     _scr_heightN(fgGetNode("/sim/startup/ysize", true)),
70     _unitsN(fgGetNode("/sim/startup/units", true)),
71     _timer(0.0),
72     //
73     _font_renderer(new fntRenderer()),
74     _font(0),
75     _font_size(0.0),
76     _style(0),
77     _listener_active(false),
78     _clip_box(0)
79 {
80     SG_LOG(SG_COCKPIT, SG_INFO, "Initializing HUD Instrument");
81
82     _path->addChangeListener(this);
83     _visibility->addChangeListener(this);
84     _3DenabledN->addChangeListener(this);
85     _antialiasing->addChangeListener(this);
86     _transparency->addChangeListener(this);
87     _red->addChangeListener(this);
88     _green->addChangeListener(this);
89     _blue->addChangeListener(this);
90     _alpha->addChangeListener(this);
91     _alpha_clamp->addChangeListener(this);
92     _brightness->addChangeListener(this);
93     _current->addChangeListener(this);
94     _scr_widthN->addChangeListener(this);
95     _scr_heightN->addChangeListener(this);
96     _unitsN->addChangeListener(this, true);
97 }
98
99
100 HUD::~HUD()
101 {
102     _path->removeChangeListener(this);
103     _visibility->removeChangeListener(this);
104     _3DenabledN->removeChangeListener(this);
105     _antialiasing->removeChangeListener(this);
106     _transparency->removeChangeListener(this);
107     _red->removeChangeListener(this);
108     _green->removeChangeListener(this);
109     _blue->removeChangeListener(this);
110     _alpha->removeChangeListener(this);
111     _alpha_clamp->removeChangeListener(this);
112     _brightness->removeChangeListener(this);
113     _current->removeChangeListener(this);
114     _scr_widthN->removeChangeListener(this);
115     _scr_heightN->removeChangeListener(this);
116     _unitsN->removeChangeListener(this);
117     delete _font_renderer;
118     
119     deinit();
120 }
121
122
123 void HUD::init()
124 {
125     const char* fontName = 0;
126     _font_cache = globals->get_fontcache();
127     if (!_font) {
128         fontName = fgGetString("/sim/hud/font/name", "Helvetica.txf");
129         _font = _font_cache->getTexFont(fontName);
130     }
131     if (!_font)
132         throw sg_io_exception("/sim/hud/font/name is not a texture font",
133                               sg_location(fontName));
134
135     _font_size = fgGetFloat("/sim/hud/font/size", 8);
136     _font_renderer->setFont(_font);
137     _font_renderer->setPointSize(_font_size);
138     _text_list.setFont(_font_renderer);
139
140     currentColorChanged();
141     
142     _path->fireValueChanged();
143 }
144
145 void HUD::deinit()
146 {
147   deque<Item *>::const_iterator it, end = _items.end();
148     for (it = _items.begin(); it != end; ++it)
149         delete *it;
150     end = _ladders.end();
151     for (it = _ladders.begin(); it != end; ++it)
152         delete *it;
153         
154   _items.clear();
155   _ladders.clear();
156   
157   delete _clip_box;
158   _clip_box = NULL;
159 }
160
161 void HUD::reinit()
162 {
163     deinit();
164     _path->fireValueChanged();
165 }
166
167 void HUD::update(double dt)
168 {
169     _timer += dt;
170 }
171
172
173 void HUD::draw(osg::State&)
174 {
175     if (!isVisible())
176         return;
177
178     if (!_items.size() && !_ladders.size())
179         return;
180
181     if (is3D()) {
182         draw3D();
183         return;
184     }
185
186     const float normal_aspect = 640.0f / 480.0f;
187     // note: aspect_ratio is Y/X
188     float current_aspect = 1.0f / globals->get_current_view()->get_aspect_ratio();
189     if (current_aspect > normal_aspect) {
190         float aspect_adjust = current_aspect / normal_aspect;
191         float adjust = 320.0f * aspect_adjust - 320.0f;
192         draw2D(-adjust, 0.0f, 640.0f + adjust, 480.0f);
193
194     } else {
195         float aspect_adjust = normal_aspect / current_aspect;
196         float adjust = 240.0f * aspect_adjust - 240.0f;
197         draw2D(0.0f, -adjust, 640.0f, 480.0f + adjust);
198     }
199
200     glViewport(0, 0, _scr_width, _scr_height);
201 }
202
203
204 void HUD::draw3D()
205 {
206     using namespace osg;
207     FGViewer* view = globals->get_current_view();
208
209     // Standard fgfs projection, with essentially meaningless clip
210     // planes (we'll map the whole HUD plane to z=-1)
211     glMatrixMode(GL_PROJECTION);
212     glPushMatrix();
213     Matrixf proj
214         = Matrixf::perspective(view->get_v_fov(), 1/view->get_aspect_ratio(),
215                                0.1, 10);
216     glLoadMatrix(proj.ptr());
217
218     glMatrixMode(GL_MODELVIEW);
219     glPushMatrix();
220
221     // Standard fgfs view direction computation
222     Vec3f lookat;
223     lookat[0] = -sin(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg());
224     lookat[1] = tan(SG_DEGREES_TO_RADIANS * view->getPitchOffset_deg());
225     lookat[2] = -cos(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg());
226     if (fabs(lookat[1]) > 9999)
227         lookat[1] = 9999; // FPU sanity
228     Matrixf mv = Matrixf::lookAt(Vec3f(0.0, 0.0, 0.0), lookat,
229                                  Vec3f(0.0, 1.0, 0.0));
230     glLoadMatrix(mv.ptr());
231
232     // Map the -1:1 square to a 55.0x41.25 degree wide patch at z=1.
233     // This is the default fgfs field of view, which the HUD files are
234     // written to assume.
235     float dx = 0.52056705; // tan(55/2)
236     float dy = dx * 0.75;  // assumes 4:3 aspect ratio
237     float m[16];
238     m[0] = dx, m[4] =  0, m[ 8] = 0, m[12] = 0;
239     m[1] =  0, m[5] = dy, m[ 9] = 0, m[13] = 0;
240     m[2] =  0, m[6] =  0, m[10] = 1, m[14] = 0;
241     m[3] =  0, m[7] =  0, m[11] = 0, m[15] = 1;
242     glMultMatrixf(m);
243
244     // Convert the 640x480 "HUD standard" coordinate space to a square
245     // about the origin in the range [-1:1] at depth of -1
246     glScalef(1.0 / 320, 1.0 / 240, 1);
247     glTranslatef(-320, -240, -1);
248
249     common_draw();
250
251     glMatrixMode(GL_PROJECTION);
252     glPopMatrix();
253     glMatrixMode(GL_MODELVIEW);
254     glPopMatrix();
255 }
256
257
258 void HUD::draw2D(GLfloat x_start, GLfloat y_start, GLfloat x_end, GLfloat y_end)
259 {
260     using namespace osg;
261     glMatrixMode(GL_PROJECTION);
262     glPushMatrix();
263     Matrixf proj = Matrixf::ortho2D(x_start, x_end, y_start, y_end);
264     glLoadMatrix(proj.ptr());
265
266     glMatrixMode(GL_MODELVIEW);
267     glPushMatrix();
268     glLoadIdentity();
269
270     common_draw();
271
272     glMatrixMode(GL_PROJECTION);
273     glPopMatrix();
274     glMatrixMode(GL_MODELVIEW);
275     glPopMatrix();
276 }
277
278
279 void HUD::common_draw()
280 {
281     _text_list.erase();
282     _line_list.erase();
283     _stipple_line_list.erase();
284
285     glDisable(GL_DEPTH_TEST);
286     glDisable(GL_LIGHTING);
287
288     glEnable(GL_BLEND);
289     if (isTransparent())
290         glBlendFunc(GL_SRC_ALPHA, GL_ONE);
291     else
292         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
293
294     if (isAntialiased()) {
295         glEnable(GL_LINE_SMOOTH);
296         glAlphaFunc(GL_GREATER, alphaClamp());
297         glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
298         //glLineWidth(1.5);
299     } else {
300         //glLineWidth(1.0);
301     }
302
303     setColor();
304     _clip_box->set();
305
306     deque<Item *>::const_iterator it, end = _items.end();
307     for (it = _items.begin(); it != end; ++it)
308         if ((*it)->isEnabled())
309             (*it)->draw();
310
311     _text_list.draw();
312     _line_list.draw();
313
314     if (_stipple_line_list.size()) {
315         glEnable(GL_LINE_STIPPLE);
316         glLineStipple(1, 0x00FF);
317         _stipple_line_list.draw();
318         glDisable(GL_LINE_STIPPLE);
319     }
320
321     // ladders last, as they can have their own clip planes
322     end = _ladders.end();
323     for (it = _ladders.begin(); it != end; ++it)
324         if ((*it)->isEnabled())
325             (*it)->draw();
326
327     _clip_box->unset();
328
329     if (isAntialiased()) {
330         glDisable(GL_ALPHA_TEST);
331         glDisable(GL_LINE_SMOOTH);
332         //glLineWidth(1.0);
333     }
334
335     if (isTransparent())
336         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
337
338     glEnable(GL_DEPTH_TEST);
339     glEnable(GL_LIGHTING);
340 }
341
342
343 int HUD::load(const char *file, float x, float y, int level, const string& indent)
344 {
345     const sgDebugPriority TREE = SG_INFO;
346     const int MAXNEST = 10;
347
348     SGPath path(globals->resolve_maybe_aircraft_path(file));
349     if (path.isNull())
350     {
351         SG_LOG(SG_INPUT, SG_ALERT, "HUD: Cannot find configuration file '" << file << "'.");
352         return 0x2;
353     }
354
355     if (!level) {
356         SG_LOG(SG_INPUT, TREE, endl << "load " << file);
357         _items.erase(_items.begin(), _items.end());
358         _ladders.erase(_ladders.begin(), _ladders.end());
359     } else if (level > MAXNEST) {
360         SG_LOG(SG_INPUT, SG_ALERT, "HUD: files nested more than " << MAXNEST << " levels");
361         return 0x1;
362     } else if (!file || !file[0]) {
363         SG_LOG(SG_INPUT, SG_ALERT, "HUD: invalid filename ");
364         return 0x2;
365     }
366
367     int ret = 0;
368     ifstream input(path.c_str());
369     if (!input.good()) {
370         SG_LOG(SG_INPUT, SG_ALERT, "HUD: Cannot read configuration from '" << path.c_str() << "'");
371         return 0x4;
372     }
373
374     SGPropertyNode root;
375     try {
376         readProperties(input, &root);
377     } catch (const sg_exception &e) {
378         input.close();
379         guiErrorMessage("HUD: Error ", e);
380         return 0x8;
381     }
382
383     delete _clip_box;
384     _clip_box = new ClipBox(fgGetNode("/sim/hud/clipping"), x, y);
385
386     for (int i = 0; i < root.nChildren(); i++) {
387         SGPropertyNode *n = root.getChild(i);
388         const char *d = n->getStringValue("name", 0);
389         string desc;
390         if (d)
391             desc = string(": \"") + d + '"';
392
393         const char *name = n->getName();
394         if (!strcmp(name, "name")) {
395             continue;
396
397         } else if (!strcmp(name, "enable3d")) {
398             // set in the tree so that valueChanged() picks it up
399             _3DenabledN->setBoolValue(n->getBoolValue());
400             continue;
401
402         } else if (!strcmp(name, "import")) {
403             const char *fn = n->getStringValue("path", "");
404             float xoffs = n->getFloatValue("x-offset", 0.0f);
405             float yoffs = n->getFloatValue("y-offset", 0.0f);
406
407             SG_LOG(SG_INPUT, TREE, indent << "|__import " << fn << desc);
408
409             string ind = indent + string(i + 1 < root.nChildren() ? "|    " : "     ");
410             ret |= load(fn, x + xoffs, y + yoffs, level + 1, ind);
411             continue;
412         }
413
414         SG_LOG(SG_INPUT, TREE, indent << "|__" << name << desc);
415
416         Item *item;
417         if (!strcmp(name, "label")) {
418             item = static_cast<Item *>(new Label(this, n, x, y));
419         } else if (!strcmp(name, "gauge")) {
420             item = static_cast<Item *>(new Gauge(this, n, x, y));
421         } else if (!strcmp(name, "tape")) {
422             item = static_cast<Item *>(new Tape(this, n, x, y));
423         } else if (!strcmp(name, "dial")) {
424             item = static_cast<Item *>(new Dial(this, n, x, y));
425         } else if (!strcmp(name, "turn-bank-indicator")) {
426             item = static_cast<Item *>(new TurnBankIndicator(this, n, x, y));
427         } else if (!strcmp(name, "ladder")) {
428             item = static_cast<Item *>(new Ladder(this, n, x, y));
429             _ladders.insert(_ladders.begin(), item);
430             continue;
431         } else if (!strcmp(name, "runway")) {
432             item = static_cast<Item *>(new Runway(this, n, x, y));
433         } else if (!strcmp(name, "aiming-reticle")) {
434             item = static_cast<Item *>(new AimingReticle(this, n, x, y));
435         } else {
436             SG_LOG(SG_INPUT, TREE, indent << "      \\...unsupported!");
437             continue;
438         }
439         _items.insert(_items.begin(), item);
440     }
441     input.close();
442     SG_LOG(SG_INPUT, TREE, indent);
443     return ret;
444 }
445
446
447 void HUD::valueChanged(SGPropertyNode *node)
448 {
449     if (_listener_active)
450         return;
451     _listener_active = true;
452     if (!strcmp(node->getName(), "path"))
453         load(fgGetString("/sim/hud/path[1]", "Huds/default.xml"));
454
455     if (!strcmp(node->getName(), "current-color")) {
456         currentColorChanged();
457     }
458     
459     _scr_width = _scr_widthN->getIntValue();
460     _scr_height = _scr_heightN->getIntValue();
461
462     _visible = _visibility->getBoolValue();
463     _3Denabled = _3DenabledN->getBoolValue();
464     _transparent = _transparency->getBoolValue();
465     _antialiased = _antialiasing->getBoolValue();
466     float brt = _brightness->getFloatValue();
467     _r = clamp(brt * _red->getFloatValue());
468     _g = clamp(brt * _green->getFloatValue());
469     _b = clamp(brt * _blue->getFloatValue());
470     _a = clamp(_alpha->getFloatValue());
471     _cl = clamp(_alpha_clamp->getFloatValue());
472
473     _units = strcmp(_unitsN->getStringValue(), "feet") ? METER : FEET;
474     _listener_active = false;
475 }
476
477 void HUD::currentColorChanged()
478 {
479   SGPropertyNode *n = fgGetNode("/sim/hud/palette", true);
480   int index = _current->getIntValue();
481   if (index < 0) {
482     index = 0;
483   }
484   
485   n = n->getChild("color", index, false);
486   if (!n) {
487     return;
488   }
489   
490   if (n->hasValue("red"))
491       _red->setFloatValue(n->getFloatValue("red", 1.0));
492   if (n->hasValue("green"))
493       _green->setFloatValue(n->getFloatValue("green", 1.0));
494   if (n->hasValue("blue"))
495       _blue->setFloatValue(n->getFloatValue("blue", 1.0));
496   if (n->hasValue("alpha"))
497       _alpha->setFloatValue(n->getFloatValue("alpha", 0.67));
498   if (n->hasValue("alpha-clamp"))
499       _alpha_clamp->setFloatValue(n->getFloatValue("alpha-clamp", 0.01));
500   if (n->hasValue("brightness"))
501       _brightness->setFloatValue(n->getFloatValue("brightness", 0.75));
502   if (n->hasValue("antialiased"))
503       _antialiasing->setBoolValue(n->getBoolValue("antialiased", false));
504   if (n->hasValue("transparent"))
505       _transparency->setBoolValue(n->getBoolValue("transparent", false));
506 }
507
508 void HUD::setColor() const
509 {
510     if (_antialiased)
511         glColor4f(_r, _g, _b, _a);
512     else
513         glColor3f(_r, _g, _b);
514 }
515
516
517 void HUD::textAlign(fntRenderer *rend, const char *s, int align,
518         float *x, float *y, float *l, float *r, float *b, float *t)
519 {
520     fntFont *font = rend->getFont();
521     float gap = font->getGap();
522     float left, right, bot, top;
523     font->getBBox(s, rend->getPointSize(), rend->getSlant(), &left, &right, &bot, &top);
524
525     if (align & HUD::HCENTER)
526         *x -= left - gap + (right - left - gap) / 2.0;
527     else if (align & HUD::RIGHT)
528         *x -= right;
529     else if (align & HUD::LEFT)
530         *x -= left;
531
532     if (align & HUD::VCENTER)
533         *y -= bot + (top - bot) / 2.0;
534     else if (align & HUD::TOP)
535         *y -= top;
536     else if (align & HUD::BOTTOM)
537         *y -= bot;
538
539     *l = *x + left;
540     *r = *x + right;
541     *b = *y + bot;
542     *t = *y + top;
543 }
544
545
546
547
548 // HUDText -- text container for TextList vector
549
550
551 HUDText::HUDText(fntRenderer *fnt, float x, float y, const char *s, int align, int d) :
552     _fnt(fnt),
553     _x(x),
554     _y(y),
555     _digits(d)
556 {
557     strncpy(_msg, s, BUFSIZE);
558     if (!align || !s[0])
559         return;
560     float ign;
561     HUD::textAlign(fnt, s, align, &_x, &_y, &ign, &ign, &ign, &ign);
562 }
563
564
565 void HUDText::draw()
566 {
567     if (!_digits) { // show all digits in same size
568         _fnt->start2f(_x, _y);
569         _fnt->puts(_msg);
570         return;
571     }
572
573     // FIXME
574     // this code is changed to display Numbers with big/small digits
575     // according to MIL Standards for example Altitude above 10000 ft
576     // is shown as 10ooo.
577
578     int c = 0, i = 0;
579     char *t = _msg;
580     int p = 4;
581
582     if (t[0] == '-') {
583         //if negative value then increase the c and p values
584         //for '-' sign.
585         c++; // was moved to the comment. Unintentionally?   TODO
586         p++;
587     }
588     char *tmp = _msg;
589     while (tmp[i] != '\0') {
590         if ((tmp[i] >= '0') && (tmp[i] <= '9'))
591             c++;
592         i++;
593     }
594
595     float orig_size = _fnt->getPointSize();
596     if (c > p) {
597         _fnt->setPointSize(orig_size * 0.8);
598         int p1 = c - 3;
599         char *tmp1 = _msg + p1;
600         int p2 = p1 * 8;
601
602         _fnt->start2f(_x + p2, _y);
603         _fnt->puts(tmp1);
604
605         _fnt->setPointSize(orig_size * 1.2);
606         char tmp2[BUFSIZE];
607         strncpy(tmp2, _msg, p1);
608         tmp2[p1] = '\0';
609
610         _fnt->start2f(_x, _y);
611         _fnt->puts(tmp2);
612     } else {
613         _fnt->setPointSize(orig_size * 1.2);
614         _fnt->start2f(_x, _y);
615         _fnt->puts(tmp);
616     }
617     _fnt->setPointSize(orig_size);
618 }
619
620
621 void TextList::align(const char *s, int align, float *x, float *y,
622         float *l, float *r, float *b, float *t) const
623 {
624     HUD::textAlign(_font, s, align, x, y, l, r, b, t);
625 }
626
627
628 void TextList::draw()
629 {
630     assert(_font);
631
632     // FIXME
633     glPushAttrib(GL_COLOR_BUFFER_BIT);
634     glEnable(GL_BLEND);
635
636     _font->begin();
637     vector<HUDText>::iterator it, end = _list.end();
638     for (it = _list.begin(); it != end; ++it)
639         it->draw();
640     _font->end();
641
642     glDisable(GL_TEXTURE_2D);
643     glPopAttrib();
644 }
645
646
647 ClipBox::ClipBox(const SGPropertyNode *n, float xoffset, float yoffset) :
648     _active(false),
649     _xoffs(xoffset),
650     _yoffs(yoffset)
651 {
652     if (!n)
653         return;
654
655     // const_cast is necessary because ATM there's no matching getChild(const ...)
656     // prototype and getNode(const ..., <bool>) is wrongly interpreted as
657     // getNode(const ..., <int>)
658     _top_node = (const_cast<SGPropertyNode *>(n))->getChild("top", 0, true);
659     _bot_node = (const_cast<SGPropertyNode *>(n))->getChild("bottom", 0, true);
660     _left_node = (const_cast<SGPropertyNode *>(n))->getChild("left", 0, true);
661     _right_node = (const_cast<SGPropertyNode *>(n))->getChild("right", 0, true);
662
663     _left[0] = 1.0, _left[1] = _left[2] = 0.0;
664     _right[0] = -1.0, _right[1] = _right[2] = 0.0;
665     _top[0] = 0.0, _top[1] = -1.0, _top[2] = 0.0;
666     _bot[0] = 0.0, _bot[1] = 1.0, _bot[2] = 0.0;
667     _active = true;
668 }
669
670
671 void ClipBox::set()
672 {
673     if (!_active)
674         return;
675
676     _left[3] = -_left_node->getDoubleValue() - _xoffs;
677     _right[3] = _right_node->getDoubleValue() + _xoffs;
678     _bot[3] = -_bot_node->getDoubleValue() - _yoffs;
679     _top[3] = _top_node->getDoubleValue() + _yoffs;
680
681     glClipPlane(GL_CLIP_PLANE0, _top);
682     glEnable(GL_CLIP_PLANE0);
683     glClipPlane(GL_CLIP_PLANE1, _bot);
684     glEnable(GL_CLIP_PLANE1);
685     glClipPlane(GL_CLIP_PLANE2, _left);
686     glEnable(GL_CLIP_PLANE2);
687     glClipPlane(GL_CLIP_PLANE3, _right);
688     glEnable(GL_CLIP_PLANE3);
689 }
690
691
692 void ClipBox::unset()
693 {
694     if (_active) {
695         glDisable(GL_CLIP_PLANE0);
696         glDisable(GL_CLIP_PLANE1);
697         glDisable(GL_CLIP_PLANE2);
698         glDisable(GL_CLIP_PLANE3);
699     }
700 }