0020716: Eliminate usage of "config.h" header file
[occt.git] / src / ViewerTest / ViewerTest_OpenGlCommands.cxx
CommitLineData
6aca4d39 1// Created on: 2012-04-09
3946774d 2// Created by: Sergey ANIKIN
6aca4d39 3// Copyright (c) 2012-2014 OPEN CASCADE SAS
3946774d 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
3946774d 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
3946774d 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
3946774d 15
3946774d 16#include <ViewerTest.hxx>
17
392ac980 18#include <AIS_Drawer.hxx>
5e27df78 19#include <AIS_InteractiveContext.hxx>
3946774d 20#include <AIS_InteractiveObject.hxx>
21#include <Draw.hxx>
22#include <Draw_Interpretor.hxx>
23#include <Graphic3d_Group.hxx>
392ac980 24#include <Graphic3d_ShaderObject.hxx>
25#include <Graphic3d_ShaderProgram.hxx>
3946774d 26#include <OpenGl_AspectFace.hxx>
27#include <OpenGl_AspectLine.hxx>
28#include <OpenGl_AspectMarker.hxx>
29#include <OpenGl_AspectText.hxx>
3946774d 30#include <OpenGl_Context.hxx>
31#include <OpenGl_Element.hxx>
3946774d 32#include <OpenGl_GlCore20.hxx>
5e27df78 33#include <OpenGl_GraphicDriver.hxx>
3946774d 34#include <OpenGl_Workspace.hxx>
392ac980 35#include <OSD_Environment.hxx>
36#include <OSD_File.hxx>
3946774d 37#include <Prs3d_Presentation.hxx>
38#include <Prs3d_Root.hxx>
392ac980 39#include <Prs3d_ShadingAspect.hxx>
3946774d 40#include <Select3D_SensitiveCurve.hxx>
41#include <SelectMgr_EntityOwner.hxx>
42#include <SelectMgr_Selection.hxx>
43#include <TCollection_AsciiString.hxx>
3c4153af 44#include <V3d_View.hxx>
392ac980 45#include <V3d_Viewer.hxx>
1981cb22 46#include <Visual3d_View.hxx>
392ac980 47#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
48#include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
3946774d 49
50extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
51 const Handle(AIS_InteractiveObject)& theAISObj,
52 Standard_Boolean theReplaceIfExists = Standard_True);
392ac980 53extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
3946774d 54
55//=======================================================================
56//function : VUserDraw
57//purpose : Checks availability and operation of UserDraw feature
58//=======================================================================
59DEFINE_STANDARD_HANDLE(VUserDrawObj, AIS_InteractiveObject)
60
61class VUserDrawObj : public AIS_InteractiveObject
62{
63public:
64 // CASCADE RTTI
65 DEFINE_STANDARD_RTTI(VUserDrawObj);
66
67 VUserDrawObj()
68 {
69 myCoords[0] = -10.;
70 myCoords[1] = -20.;
71 myCoords[2] = -30.;
72 myCoords[3] = 10.;
73 myCoords[4] = 20.;
74 myCoords[5] = 30.;
75 }
76
77public:
78 class Element : public OpenGl_Element
79 {
80 private:
81 Handle(VUserDrawObj) myIObj;
82
83 public:
84 Element (const Handle(VUserDrawObj)& theIObj,
b7cd4ba7 85 Graphic3d_BndBox4f* theBounds)
3946774d 86 : myIObj( theIObj )
87 {
88 if (!myIObj.IsNull())
89 myIObj->GetBounds(theBounds);
90 }
91
92 virtual ~Element ()
93 {
94 }
95
96 virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const
97 {
98 if (!myIObj.IsNull())
99 myIObj->Render(theWorkspace);
100 }
101
10b9c7df 102 virtual void Release (OpenGl_Context*)
5e27df78 103 {
104 //
105 }
106
3946774d 107 public:
108 DEFINE_STANDARD_ALLOC
109 };
110
111private:
112 // Virtual methods implementation
113 void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
114 const Handle(Prs3d_Presentation)& thePresentation,
115 const Standard_Integer theMode);
116
117 void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
118 const Standard_Integer theMode);
119
120 // Called by VUserDrawElement
121 void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
b7cd4ba7 122 void GetBounds(Graphic3d_BndBox4f* theBounds);
3946774d 123
124 GLfloat myCoords[6];
125
126 friend class Element;
127};
128IMPLEMENT_STANDARD_HANDLE(VUserDrawObj, AIS_InteractiveObject)
129IMPLEMENT_STANDARD_RTTIEXT(VUserDrawObj, AIS_InteractiveObject)
130
35e08fe8 131void VUserDrawObj::Compute(const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
3946774d 132 const Handle(Prs3d_Presentation)& thePresentation,
35e08fe8 133 const Standard_Integer /*theMode*/)
3946774d 134{
135 thePresentation->Clear();
136
137 Handle(Graphic3d_Group) aGrp = Prs3d_Root::CurrentGroup(thePresentation);
138 aGrp->UserDraw(this, Standard_True, Standard_True);
139}
140
141void VUserDrawObj::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
35e08fe8 142 const Standard_Integer /*theMode*/)
3946774d 143{
144 Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this);
145 Handle(TColgp_HArray1OfPnt) aPnts = new TColgp_HArray1OfPnt(1, 5);
146 aPnts->SetValue(1, gp_Pnt(myCoords[0], myCoords[1], myCoords[2]));
147 aPnts->SetValue(2, gp_Pnt(myCoords[3], myCoords[4], myCoords[2]));
148 aPnts->SetValue(3, gp_Pnt(myCoords[3], myCoords[4], myCoords[5]));
149 aPnts->SetValue(4, gp_Pnt(myCoords[0], myCoords[1], myCoords[5]));
150 aPnts->SetValue(5, gp_Pnt(myCoords[0], myCoords[1], myCoords[2]));
151 Handle(Select3D_SensitiveCurve) aSensitive = new Select3D_SensitiveCurve(anEntityOwner, aPnts);
152 theSelection->Add(aSensitive);
153}
154
b7cd4ba7 155void VUserDrawObj::GetBounds(Graphic3d_BndBox4f* theBounds)
3946774d 156{
157 if (theBounds)
158 {
b7cd4ba7 159 Graphic3d_Vec4 aMinPt (myCoords[0], myCoords[1], myCoords[2], 1.0f);
160 Graphic3d_Vec4 aMaxPt (myCoords[3], myCoords[4], myCoords[5], 1.0f);
161 if (!theBounds->IsValid())
162 {
163 theBounds->Combine (Graphic3d_BndBox4f (aMinPt, aMaxPt));
164 }
165 else
166 {
167 theBounds->CornerMin() = aMinPt;
168 theBounds->CornerMax() = aMaxPt;
169 }
3946774d 170 }
171}
172
173void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
174{
175 // To test linking against OpenGl_Workspace and all aspect classes
176 const OpenGl_AspectLine* aLA = theWorkspace->AspectLine(0);
3946774d 177 const OpenGl_AspectMarker* aMA = theWorkspace->AspectMarker(0);
178 aMA->Type();
179 const OpenGl_AspectText* aTA = theWorkspace->AspectText(0);
a174a3c5 180 aTA->FontName();
3946774d 181 TEL_COLOUR aColor = theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT ?
182 *(theWorkspace->HighlightColor) : aLA->Color();
183
184 // To test OpenGl_Window
5e27df78 185 //Handle(OpenGl_Context) aCtx = theWorkspace->GetGlContext();
3946774d 186
187 // Finally draw something to make sure UserDraw really works
188 glPushAttrib(GL_ENABLE_BIT);
189 glDisable(GL_LIGHTING);
190 glColor4fv(aColor.rgb);
191 glBegin(GL_LINE_LOOP);
192 glVertex3f(myCoords[0], myCoords[1], myCoords[2]);
193 glVertex3f(myCoords[3], myCoords[4], myCoords[2]);
194 glVertex3f(myCoords[3], myCoords[4], myCoords[5]);
195 glVertex3f(myCoords[0], myCoords[1], myCoords[5]);
196 glEnd();
197 glPopAttrib();
198}
199
3946774d 200OpenGl_Element* VUserDrawCallback(const CALL_DEF_USERDRAW * theUserDraw)
201{
202 Handle(VUserDrawObj) anIObj = (VUserDrawObj*)theUserDraw->Data;
203 if (anIObj.IsNull())
204 {
205 std::cout << "VUserDrawCallback error: null object passed, the custom scene element will not be rendered" << std::endl;
206 }
207
208 return new VUserDrawObj::Element(anIObj, theUserDraw->Bounds);
209}
210
211static Standard_Integer VUserDraw (Draw_Interpretor& di,
212 Standard_Integer argc,
213 const char ** argv)
214{
215 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
216 if (aContext.IsNull())
217 {
218 di << argv[0] << "Call 'vinit' before!\n";
219 return 1;
220 }
221
dc3fe572 222 Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aContext->CurrentViewer()->Driver());
5e27df78 223 if (aDriver.IsNull())
224 {
225 std::cerr << "Graphic driver not available.\n";
226 return 1;
227 }
228
3946774d 229 if (argc > 2)
230 {
231 di << argv[0] << "Wrong number of arguments, only the object name expected\n";
232 return 1;
233 }
234
235 TCollection_AsciiString aName (argv[1]);
236 VDisplayAISObject(aName, Handle(AIS_InteractiveObject)());
237
238 // register the custom element factory function
5e27df78 239 aDriver->UserDrawCallback() = VUserDrawCallback;
3946774d 240
241 Handle(VUserDrawObj) anIObj = new VUserDrawObj();
242 VDisplayAISObject(aName, anIObj);
243
244 return 0;
245}
246
3c4153af 247//==============================================================================
248//function : VFeedback
249//purpose :
250//==============================================================================
251
252static int VFeedback (Draw_Interpretor& theDI,
35e08fe8 253 Standard_Integer /*theArgNb*/,
254 const char** /*theArgVec*/)
3c4153af 255{
256 // get the active view
257 Handle(V3d_View) aView = ViewerTest::CurrentView();
258 if (aView.IsNull())
259 {
260 std::cerr << "No active view. Please call vinit.\n";
261 return 1;
262 }
263
264 unsigned int aBufferSize = 1024 * 1024;
265 for (;;)
266 {
267 size_t aBytes = (size_t )aBufferSize * sizeof(GLfloat);
268 if (aBytes / sizeof(GLfloat) != (size_t )aBufferSize)
269 {
270 // finito la commedia
271 std::cerr << "Can not allocate buffer - requested size ("
272 << (double(aBufferSize / (1024 * 1024)) * double(sizeof(GLfloat)))
273 << " MiB) is out of address space\n";
274 return 1;
275 }
276
277 GLfloat* aBuffer = (GLfloat* )Standard::Allocate (aBytes);
278 if (aBuffer == NULL)
279 {
280 // finito la commedia
281 std::cerr << "Can not allocate buffer with size ("
282 << (double(aBufferSize / (1024 * 1024)) * double(sizeof(GLfloat)))
283 << " MiB)\n";
284 return 1;
285 }
286
287 glFeedbackBuffer ((GLsizei )aBufferSize, GL_2D, aBuffer);
288 glRenderMode (GL_FEEDBACK);
289
290 aView->Redraw();
291
292 GLint aResult = glRenderMode (GL_RENDER);
293 if (aResult < 0)
294 {
295 aBufferSize *= 2;
296
297 void* aPtr = aBuffer;
298 Standard::Free (aPtr);
299 aBuffer = NULL;
300 continue;
301 }
302
303 std::cout << "FeedBack result= " << aResult << "\n";
304 GLint aPntNb = 0;
305 GLint aTriNb = 0;
306 GLint aQuadsNb = 0;
307 GLint aPolyNb = 0;
308 GLint aNodesNb = 0;
309 GLint aLinesNb = 0;
310 GLint aBitmapsNb = 0;
311 GLint aPassThrNb = 0;
312 GLint aUnknownNb = 0;
313 const GLint NODE_VALUES = 2; // GL_2D
314 for (GLint anIter = 0; anIter < aResult;)
315 {
316 const GLfloat aPos = aBuffer[anIter];
317 switch ((GLint )aPos)
318 {
319 case GL_POINT_TOKEN:
320 {
321 ++aPntNb;
322 ++aNodesNb;
323 anIter += 1 + NODE_VALUES;
324 break;
325 }
326 case GL_LINE_RESET_TOKEN:
327 case GL_LINE_TOKEN:
328 {
329 ++aLinesNb;
330 aNodesNb += 2;
331 anIter += 1 + 2 * NODE_VALUES;
332 break;
333 }
334 case GL_POLYGON_TOKEN:
335 {
336 const GLint aCount = (GLint )aBuffer[++anIter];
337 aNodesNb += aCount;
338 anIter += aCount * NODE_VALUES + 1;
339 if (aCount == 3)
340 {
341 ++aTriNb;
342 }
343 else if (aCount == 4)
344 {
345 ++aQuadsNb;
346 }
347 else
348 {
349 ++aPolyNb;
350 }
351 break;
352 }
353 case GL_BITMAP_TOKEN:
354 case GL_DRAW_PIXEL_TOKEN:
355 case GL_COPY_PIXEL_TOKEN:
356 {
357 ++aBitmapsNb;
358 anIter += 1 + NODE_VALUES;
359 break;
360 }
361 case GL_PASS_THROUGH_TOKEN:
362 {
363 ++aPassThrNb;
364 anIter += 2; // header + value
365 break;
366 }
367 default:
368 {
369 ++anIter;
370 ++aUnknownNb;
371 break;
372 }
373 }
374 }
375 void* aPtr = aBuffer;
376 Standard::Free (aPtr);
377
378 // return statistics
379 theDI << "Total nodes: " << aNodesNb << "\n"
380 << "Points: " << aPntNb << "\n"
381 << "Line segments: " << aLinesNb << "\n"
382 << "Triangles: " << aTriNb << "\n"
383 << "Quads: " << aQuadsNb << "\n"
384 << "Polygons: " << aPolyNb << "\n"
385 << "Bitmap tokens: " << aBitmapsNb << "\n"
386 << "Pass through: " << aPassThrNb << "\n"
387 << "UNKNOWN: " << aUnknownNb << "\n";
388
389 double aLen2D = double(aNodesNb * 2 + aPntNb + aLinesNb * 2 + (aTriNb + aQuadsNb + aPolyNb) * 2 + aBitmapsNb + aPassThrNb);
390 double aLen3D = double(aNodesNb * 3 + aPntNb + aLinesNb * 2 + (aTriNb + aQuadsNb + aPolyNb) * 2 + aBitmapsNb + aPassThrNb);
391 double aLen3D_rgba = double(aNodesNb * 7 + aPntNb + aLinesNb * 2 + (aTriNb + aQuadsNb + aPolyNb) * 2 + aBitmapsNb + aPassThrNb);
392 theDI << "Buffer size GL_2D: " << aLen2D * double(sizeof(GLfloat)) / double(1024 * 1024) << " MiB\n"
393 << "Buffer size GL_3D: " << aLen3D * double(sizeof(GLfloat)) / double(1024 * 1024) << " MiB\n"
394 << "Buffer size GL_3D_COLOR: " << aLen3D_rgba * double(sizeof(GLfloat)) / double(1024 * 1024) << " MiB\n";
395 return 0;
396 }
397}
398
1981cb22 399//==============================================================================
400//function : VImmediateFront
401//purpose :
402//==============================================================================
403
35e08fe8 404static int VImmediateFront (Draw_Interpretor& /*theDI*/,
1981cb22 405 Standard_Integer theArgNb,
406 const char** theArgVec)
407{
408 // get the context
409 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
410 if (aContextAIS.IsNull())
411 {
412 std::cerr << "No active view. Please call vinit.\n";
413 return 1;
414 }
415
dc3fe572 416 Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver();
417
1981cb22 418 if (aDriver.IsNull())
419 {
420 std::cerr << "Graphic driver not available.\n";
421 return 1;
422 }
423
424 if (theArgNb < 2)
425 {
1981cb22 426 std::cerr << "Wrong number of arguments.\n";
427 return 1;
428 }
429
430 Graphic3d_CView* aCView = (Graphic3d_CView* )(ViewerTest::CurrentView()->View()->CView());
431 aDriver->SetImmediateModeDrawToFront (*aCView, atoi(theArgVec[1]) != 0);
432 return 0;
433}
434
dac04bfa 435//==============================================================================
436//function : VGlInfo
437//purpose :
438//==============================================================================
439
440static int VGlInfo (Draw_Interpretor& theDI,
441 Standard_Integer theArgNb,
442 const char** theArgVec)
443{
444 // get the active view
445 Handle(V3d_View) aView = ViewerTest::CurrentView();
446 if (aView.IsNull())
447 {
448 std::cerr << "No active view. Please call vinit.\n";
449 return 1;
450 }
451
452 if (theArgNb <= 1)
453 {
58655684 454 Standard_CString aDebugInfo = OpenGl_Context::CheckExtension ((const char* )glGetString (GL_EXTENSIONS),
455 "GL_ARB_debug_output")
456 ? " GLdebug = ON\n" : "";
dac04bfa 457 theDI << "OpenGL info:\n"
458 << " GLvendor = '" << (const char* )glGetString(GL_VENDOR) << "'\n"
459 << " GLdevice = '" << (const char* )glGetString(GL_RENDERER) << "'\n"
460 << " GLversion = '" << (const char* )glGetString(GL_VERSION) << "'\n"
58655684 461 << " GLSLversion = '" << (const char* )glGetString(GL_SHADING_LANGUAGE_VERSION) << "'\n"
462 << aDebugInfo;
dac04bfa 463 return 0;
464 }
465
466 const Standard_Boolean isList = theArgNb >= 3;
467 for (Standard_Integer anIter = 1; anIter < theArgNb; ++anIter)
468 {
469 TCollection_AsciiString aName (theArgVec[anIter]);
470 aName.UpperCase();
471 const char* aValue = NULL;
472 if (aName.Search ("VENDOR") != -1)
473 {
474 aValue = (const char* )glGetString (GL_VENDOR);
475 }
476 else if (aName.Search ("RENDERER") != -1)
477 {
478 aValue = (const char* )glGetString (GL_RENDERER);
479 }
480 else if (aName.Search ("SHADING_LANGUAGE_VERSION") != -1
481 || aName.Search ("GLSL") != -1)
482 {
483 aValue = (const char* )glGetString (GL_SHADING_LANGUAGE_VERSION);
484 }
485 else if (aName.Search ("VERSION") != -1)
486 {
487 aValue = (const char* )glGetString (GL_VERSION);
488 }
489 else if (aName.Search ("EXTENSIONS") != -1)
490 {
491 aValue = (const char* )glGetString (GL_EXTENSIONS);
492 }
493 else
494 {
495 std::cerr << "Unknown key '" << aName.ToCString() << "'\n";
496 return 1;
497 }
498
499 if (isList)
500 {
501 theDI << "{" << aValue << "} ";
502 }
503 else
504 {
505 theDI << aValue;
506 }
507 }
508
509 return 0;
510}
511
392ac980 512
513//==============================================================================
514//function : VShaderProg
515//purpose : Sets the pair of vertex and fragment shaders for the object
516//==============================================================================
517static Standard_Integer VShaderProg (Draw_Interpretor& /*theDI*/,
518 Standard_Integer theArgNb,
519 const char** theArgVec)
520{
521 Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
522 if (aCtx.IsNull())
523 {
524 std::cerr << "Use 'vinit' command before " << theArgVec[0] << "\n";
525 return 1;
526 }
527 else if (theArgNb < 2)
528 {
529 std::cerr << theArgVec[0] << " syntax error: lack of arguments\n";
530 return 1;
531 }
532
533 TCollection_AsciiString aLastArg (theArgVec[theArgNb - 1]);
534 aLastArg.UpperCase();
535 const Standard_Boolean toTurnOff = aLastArg == "OFF";
536 Standard_Integer anArgsNb = theArgNb - 1;
537 Handle(Graphic3d_ShaderProgram) aProgram;
538 if (!toTurnOff
539 && aLastArg == "PHONG")
540 {
541 aProgram = new Graphic3d_ShaderProgram (Graphic3d_ShaderProgram::ShaderName_Phong);
542 }
543 if (!toTurnOff
544 && aProgram.IsNull())
545 {
546 if (theArgNb < 3)
547 {
548 std::cerr << theArgVec[0] << " syntax error: lack of arguments\n";
549 return 1;
550 }
551
552 const TCollection_AsciiString aSrcVert = theArgVec[theArgNb - 2];
553 const TCollection_AsciiString aSrcFrag = theArgVec[theArgNb - 1];
554 if (!aSrcVert.IsEmpty()
555 && !OSD_File (aSrcVert).Exists())
556 {
557 std::cerr << "Non-existing vertex shader source\n";
558 return 1;
559 }
560 if (!aSrcFrag.IsEmpty()
561 && !OSD_File (aSrcFrag).Exists())
562 {
563 std::cerr << "Non-existing fragment shader source\n";
564 return 1;
565 }
566
567 aProgram = new Graphic3d_ShaderProgram();
568 aProgram->AttachShader (Graphic3d_ShaderObject::CreateFromFile (Graphic3d_TOS_VERTEX, aSrcVert));
569 aProgram->AttachShader (Graphic3d_ShaderObject::CreateFromFile (Graphic3d_TOS_FRAGMENT, aSrcFrag));
570 anArgsNb = theArgNb - 2;
571 }
572
573 Handle(AIS_InteractiveObject) anIO;
574 if (anArgsNb <= 1
575 || *theArgVec[1] == '*')
576 {
577 for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIter (GetMapOfAIS());
578 anIter.More(); anIter.Next())
579 {
580 anIO = Handle(AIS_InteractiveObject)::DownCast (anIter.Key1());
581 if (!anIO.IsNull())
582 {
583 anIO->Attributes()->ShadingAspect()->Aspect()->SetShaderProgram (aProgram);
584 aCtx->Redisplay (anIO, Standard_False);
585 }
586 }
587 aCtx->UpdateCurrentViewer();
588 return 0;
589 }
590
591 for (Standard_Integer anArgIter = 1; anArgIter < anArgsNb; ++anArgIter)
592 {
593 const TCollection_AsciiString aName (theArgVec[anArgIter]);
594 if (!GetMapOfAIS().IsBound2 (aName))
595 {
596 std::cerr << "Warning: " << aName.ToCString() << " is not displayed\n";
597 continue;
598 }
599 anIO = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (aName));
600 if (anIO.IsNull())
601 {
602 std::cerr << "Warning: " << aName.ToCString() << " is not an AIS object\n";
603 continue;
604 }
605 anIO->Attributes()->ShadingAspect()->Aspect()->SetShaderProgram (aProgram);
606 aCtx->Redisplay (anIO, Standard_False);
607 }
608
609 aCtx->UpdateCurrentViewer();
610 return 0;
611}
612
3946774d 613//=======================================================================
614//function : OpenGlCommands
615//purpose :
616//=======================================================================
617
618void ViewerTest::OpenGlCommands(Draw_Interpretor& theCommands)
619{
620 const char* aGroup ="Commands for low-level TKOpenGl features";
621
622 theCommands.Add("vuserdraw",
623 "vuserdraw : name - simulates drawing with help of UserDraw",
624 __FILE__, VUserDraw, aGroup);
3c4153af 625 theCommands.Add("vfeedback",
626 "vfeedback : perform test GL feedback rendering",
627 __FILE__, VFeedback, aGroup);
1981cb22 628 theCommands.Add("vimmediatefront",
629 "vimmediatefront : render immediate mode to front buffer or to back buffer",
630 __FILE__, VImmediateFront, aGroup);
dac04bfa 631 theCommands.Add("vglinfo",
632 "vglinfo [GL_VENDOR] [GL_RENDERER] [GL_VERSION] [GL_SHADING_LANGUAGE_VERSION] [GL_EXTENSIONS]"
633 " : prints GL info",
634 __FILE__, VGlInfo, aGroup);
392ac980 635 theCommands.Add("vshaderprog",
636 " 'vshaderprog [name] pathToVertexShader pathToFragmentShader'"
637 "\n\t\t: or 'vshaderprog [name] off' to disable GLSL program"
638 "\n\t\t: or 'vshaderprog [name] phong' to enable per-pixel lighting calculations"
639 "\n\t\t: * might be used to specify all displayed objects",
640 __FILE__, VShaderProg, aGroup);
3946774d 641}