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