1 // Created on: 2011-09-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _OpenGl_View_Header
17 #define _OpenGl_View_Header
19 #include <MMgt_TShared.hxx>
20 #include <Standard_DefineHandle.hxx>
22 #include <TColStd_Array2OfReal.hxx>
23 #include <NCollection_List.hxx>
25 #include <Quantity_NameOfColor.hxx>
26 #include <Aspect_FillMethod.hxx>
27 #include <Aspect_GradientFillMethod.hxx>
28 #include <Aspect_TypeOfTriedronPosition.hxx>
29 #include <Aspect_CLayer2d.hxx>
31 #include <InterfaceGraphic_Graphic3d.hxx>
32 #include <InterfaceGraphic_Visual3d.hxx>
34 #include <Graphic3d_CView.hxx>
35 #include <Graphic3d_GraduatedTrihedron.hxx>
36 #include <Graphic3d_SequenceOfHClipPlane.hxx>
37 #include <Graphic3d_ZLayerSettings.hxx>
38 #include <Visual3d_TypeOfSurfaceDetail.hxx>
39 #include <Visual3d_TypeOfModel.hxx>
41 #include <OpenGl_AspectFace.hxx>
42 #include <OpenGl_BackgroundArray.hxx>
43 #include <OpenGl_BVHTreeSelector.hxx>
44 #include <OpenGl_LayerList.hxx>
45 #include <OpenGl_Light.hxx>
46 #include <OpenGl_LineAttributes.hxx>
47 #include <OpenGl_Trihedron.hxx>
48 #include <OpenGl_GraduatedTrihedron.hxx>
50 #include <Handle_OpenGl_Context.hxx>
51 #include <Handle_OpenGl_GraphicDriver.hxx>
52 #include <Handle_OpenGl_Workspace.hxx>
53 #include <Handle_OpenGl_View.hxx>
54 #include <Handle_OpenGl_Texture.hxx>
59 Standard_Boolean IsOn;
60 Standard_ShortReal Limit; /* in the range [0., 1.] */
63 Standard_Boolean IsOn;
64 Standard_ShortReal Limit; /* in the range [0., 1.] */
70 Standard_Boolean IsOn;
71 Standard_ShortReal Front; /* in the range [0., 1.] */
72 Standard_ShortReal Back; /* in the range [0., 1.] */
77 class OpenGl_Structure;
78 class Handle(OpenGl_PrinterContext);
79 class OpenGl_StateCounter;
81 class OpenGl_View : public MMgt_TShared
84 OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext, OpenGl_StateCounter* theCounter);
85 virtual ~OpenGl_View ();
87 void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
89 void SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
90 const Handle(Graphic3d_TextureEnv)& theTexture);
91 void SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail AMode);
92 void SetBackfacing (const Standard_Integer AMode);
93 void SetLights (const CALL_DEF_VIEWCONTEXT &AContext);
94 void SetAntiAliasing (const Standard_Boolean AMode) { myAntiAliasing = AMode; }
95 void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane &thePlanes) { myClipPlanes = thePlanes; }
96 void SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext);
98 const Handle(Graphic3d_Camera)& Camera() { return myCamera; }
99 void SetCamera (const Handle(Graphic3d_Camera)& theCamera) { myCamera = theCamera; }
101 void SetClipLimit (const Graphic3d_CView& theCView);
103 void SetFog (const Graphic3d_CView& theCView, const Standard_Boolean theFlag);
105 OpenGl_Trihedron& ChangeTrihedron() { return myTrihedron; }
106 void TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition,
107 const Quantity_NameOfColor theColor,
108 const Standard_Real theScale,
109 const Standard_Boolean theAsWireframe);
110 void TriedronErase (const Handle(OpenGl_Context)& theCtx);
112 OpenGl_GraduatedTrihedron& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; }
113 void GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx,
114 const Graphic3d_GraduatedTrihedron& theCubic);
115 void GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx);
117 Standard_Real Height () const { return myCamera->ViewDimensions().X(); }
118 Standard_Real Width () const { return myCamera->ViewDimensions().Y(); }
120 Standard_Integer Backfacing () const { return myBackfacing; }
122 const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence (const Handle(OpenGl_Context)& theCtx,
123 const TEL_TRANSFORM_PERSISTENCE *theTransPers,
124 Standard_Integer theWidth,
125 Standard_Integer theHeight);
126 void EndTransformPersistence (const Handle(OpenGl_Context)& theCtx);
128 //! Add structure to display list with specified priority.
129 //! The structure will be added to associated with it z layer.
130 //! If the z layer is not presented in the view, the structure will
131 //! be displayed in default bottom-level z layer.
132 void DisplayStructure (const Handle(Graphic3d_Structure)& theStructure,
133 const Standard_Integer thePriority);
135 //! Erase structure from display list.
136 void EraseStructure (const Handle(Graphic3d_Structure)& theStructure);
138 //! Add structure to the list of immediate structures.
139 void DisplayImmediateStructure (const Handle(Graphic3d_Structure)& theStructure);
141 //! Erase structure from display list.
142 void EraseImmediateStructure (const OpenGl_Structure* theStructure);
144 //! Insert a new top-level z layer with ID <theLayerId>
145 void AddZLayer (const Graphic3d_ZLayerId theLayerId);
147 //! Remove a z layer with ID <theLayerId>
148 void RemoveZLayer (const Graphic3d_ZLayerId theLayerId);
150 //! Display structure in z layer with ID <theNewLayerId>
151 //! If the layer with ID <theNewLayerId> is not presented in the view,
152 //! the structure will be displayed in default bottom-level layer.
153 void ChangeZLayer (const OpenGl_Structure* theStructure,
154 const Graphic3d_ZLayerId theNewLayerId);
156 //! Sets the settings for a single Z layer of specified view.
157 void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
158 const Graphic3d_ZLayerSettings& theSettings);
160 //! Changes the priority of a structure within its ZLayer
161 void ChangePriority (const OpenGl_Structure* theStructure,
162 const Standard_Integer theNewPriority);
164 void CreateBackgroundTexture (const Standard_CString AFileName,
165 const Aspect_FillMethod AFillStyle);
167 void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
168 void SetBackgroundGradient (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AType);
169 void SetBackgroundGradientType (const Aspect_GradientFillMethod AType);
171 void Render (const Handle(OpenGl_PrinterContext)& thePrintContext,
172 const Handle(OpenGl_Workspace)& theWorkspace,
173 OpenGl_FrameBuffer* theReadDrawFbo,
174 Graphic3d_Camera::Projection theProjection,
175 const Graphic3d_CView& theCView,
176 const Aspect_CLayer2d& theCUnderLayer,
177 const Aspect_CLayer2d& theCOverLayer,
178 const Standard_Boolean theToDrawImmediate);
181 void DrawBackground (const Handle(OpenGl_Workspace)& theWorkspace);
183 //! Returns list of OpenGL Z-layers.
184 const OpenGl_LayerList& LayerList() const { return myZLayers; }
186 //! Returns list of openGL light sources.
187 const OpenGl_ListOfLight& LightList() const { return myLights; }
189 //! Returns OpenGL environment map.
190 const Handle(OpenGl_Texture)& TextureEnv() const { return myTextureEnv; }
192 //! Returns visualization mode for objects in the view.
193 Visual3d_TypeOfSurfaceDetail SurfaceDetail() const { return mySurfaceDetail; }
195 //! Returns selector for BVH tree, providing a possibility to store information
196 //! about current view volume and to detect which objects are overlapping it.
197 OpenGl_BVHTreeSelector& BVHTreeSelector() { return myBVHSelector; }
199 //! Marks BVH tree for given priority list as dirty and
200 //! marks primitive set for rebuild.
201 void InvalidateBVHData (const Standard_Integer theLayerId);
203 //! Returns list of immediate structures rendered on top of main presentation
204 const OpenGl_SequenceOfStructure& ImmediateStructures() const
206 return myImmediateList;
209 //! Returns true if there are immediate structures to display
210 bool HasImmediateStructures() const
212 return !myImmediateList.IsEmpty()
213 || myZLayers.NbImmediateStructures() != 0;
218 void RenderStructs (const Handle(OpenGl_Workspace)& theWorkspace,
219 OpenGl_FrameBuffer* theReadDrawFbo,
220 const Graphic3d_CView& theCView,
221 const Standard_Boolean theToDrawImmediate);
223 void RedrawLayer2d (const Handle(OpenGl_PrinterContext)& thePrintContext,
224 const Handle(OpenGl_Workspace)& theWorkspace,
225 const Graphic3d_CView& theCView,
226 const Aspect_CLayer2d& theCLayer);
228 void RedrawTrihedron (const Handle(OpenGl_Workspace) &theWorkspace);
230 //! Redraw contents of model scene: clipping planes,
231 //! lights, structures. The peculiar properties of "scene" is that
232 //! it requires empty Z-Buffer and uses projection and orientation
233 //! matrices supplied by 3d view.
234 void RedrawScene (const Handle(OpenGl_PrinterContext)& thePrintContext,
235 const Handle(OpenGl_Workspace)& theWorkspace,
236 OpenGl_FrameBuffer* theReadDrawFbo,
237 const Graphic3d_CView& theCView,
238 const Standard_Boolean theToDrawImmediate);
240 Handle(OpenGl_LineAttributes) myLineAttribs;
241 Handle(OpenGl_Texture) myTextureEnv;
242 Visual3d_TypeOfSurfaceDetail mySurfaceDetail;
243 Standard_Integer myBackfacing;
245 OPENGL_ZCLIP myZClip;
247 Graphic3d_SequenceOfHClipPlane myClipPlanes;
249 Handle(Graphic3d_Camera) myCamera;
252 OpenGl_Trihedron myTrihedron;
253 OpenGl_GraduatedTrihedron myGraduatedTrihedron;
254 bool myToShowTrihedron;
255 bool myToShowGradTrihedron;
257 //View_LABViewContext
259 Visual3d_TypeOfModel myShadingModel; //!< lighting shading model
262 OpenGl_ListOfLight myLights;
266 Standard_Boolean myAntiAliasing;
268 //View_LABDepthCueing - fixed index used
270 OpenGl_LayerList myZLayers; //!< main list of displayed structure, sorted by layers
271 OpenGl_SequenceOfStructure myImmediateList; //!< list of immediate structures rendered on top of main presentation
273 const TEL_TRANSFORM_PERSISTENCE *myTransPers;
274 Standard_Boolean myIsTransPers;
276 //! Modification state
277 Standard_Size myProjectionState;
278 Standard_Size myModelViewState;
279 OpenGl_StateCounter* myStateCounter;
281 Standard_Size myCurrLightSourceState;
283 typedef std::pair<Standard_Size, Standard_Size> StateInfo;
285 StateInfo myLastOrientationState;
286 StateInfo myLastViewMappingState;
287 StateInfo myLastLightSourceState;
289 //! Is needed for selection of overlapping objects and storage of the current view volume
290 OpenGl_BVHTreeSelector myBVHSelector;
292 protected: //! @name Background parameters
294 OpenGl_AspectFace* myTextureParams; //!< Stores texture and its parameters for textured background
295 OpenGl_BackgroundArray* myBgGradientArray; //!< Primitive array for gradient background
296 OpenGl_BackgroundArray* myBgTextureArray; //!< Primitive array for texture background
298 protected: //! @name data types related to ray-tracing
300 //! Result of OpenGL shaders initialization.
301 enum RaytraceInitStatus
308 //! Describes update mode (state).
309 enum RaytraceUpdateMode
311 OpenGl_GUM_CHECK, //!< check geometry state
312 OpenGl_GUM_PREPARE, //!< collect unchanged objects
313 OpenGl_GUM_REBUILD //!< rebuild changed and new objects
316 //! Defines frequently used shader variables.
317 enum ShaderVariableIndex
329 OpenGl_RT_uUnviewMat,
333 OpenGl_RT_uLightAmbnt,
334 OpenGl_RT_uLightCount,
336 OpenGl_RT_uShadEnabled,
337 OpenGl_RT_uReflEnabled,
338 OpenGl_RT_uEnvMapEnable,
348 OpenGl_RT_NbVariables // special field
351 //! Defines texture samplers.
352 enum ShaderSamplerNames
354 OpenGl_RT_SceneNodeInfoTexture = 0,
355 OpenGl_RT_SceneMinPointTexture = 1,
356 OpenGl_RT_SceneMaxPointTexture = 2,
357 OpenGl_RT_SceneTransformTexture = 3,
359 OpenGl_RT_GeometryVertexTexture = 4,
360 OpenGl_RT_GeometryNormalTexture = 5,
361 OpenGl_RT_GeometryTexCrdTexture = 6,
362 OpenGl_RT_GeometryTriangTexture = 7,
364 OpenGl_RT_EnvironmentMapTexture = 8,
366 OpenGl_RT_RaytraceMaterialTexture = 9,
367 OpenGl_RT_RaytraceLightSrcTexture = 10,
369 OpenGl_RT_FSAAInputTexture = 11,
371 OpenGl_RT_OpenGlColorTexture = 12,
372 OpenGl_RT_OpenGlDepthTexture = 13
375 //! Tool class for management of shader sources.
380 //! Creates new uninitialized shader source.
386 //! Creates new shader source from specified file.
387 ShaderSource (const TCollection_AsciiString& theFileName)
389 Load (&theFileName, 1);
394 //! Returns prefix to insert before the source.
395 const TCollection_AsciiString& Prefix() const
400 //! Sets prefix to insert before the source.
401 void SetPrefix (const TCollection_AsciiString& thePrefix)
403 myPrefix = thePrefix;
406 //! Returns shader source combined with prefix.
407 TCollection_AsciiString Source() const;
409 //! Loads shader source from specified files.
410 void Load (const TCollection_AsciiString* theFileNames, const Standard_Integer theCount);
414 TCollection_AsciiString mySource; //!< Source string of the shader object
415 TCollection_AsciiString myPrefix; //!< Prefix to insert before the source
419 //! Default ray-tracing depth.
420 static const Standard_Integer THE_DEFAULT_NB_BOUNCES = 3;
422 //! Default size of traversal stack.
423 static const Standard_Integer THE_DEFAULT_STACK_SIZE = 24;
425 //! Compile-time ray-tracing parameters.
426 struct RaytracingParams
428 //! Actual size of traversal stack in shader program.
429 Standard_Integer StackSize;
431 //! Actual ray-tracing depth (number of ray bounces).
432 Standard_Integer NbBounces;
434 //! Enables/disables light propagation through transparent media.
435 Standard_Boolean TransparentShadows;
437 //! Enables/disables the use of OpenGL bindless textures.
438 Standard_Boolean UseBindlessTextures;
440 //! Creates default compile-time ray-tracing parameters.
442 : StackSize (THE_DEFAULT_STACK_SIZE),
443 NbBounces (THE_DEFAULT_NB_BOUNCES),
444 TransparentShadows (Standard_False),
445 UseBindlessTextures (Standard_False)
451 protected: //! @name methods related to ray-tracing
453 //! Updates 3D scene geometry for ray-tracing.
454 Standard_Boolean updateRaytraceGeometry (const RaytraceUpdateMode theMode,
455 const Standard_Integer theViewId,
456 const Handle(OpenGl_Context)& theGlContext);
458 //! Updates 3D scene light sources for ray-tracing.
459 Standard_Boolean updateRaytraceLightSources (const OpenGl_Mat4& theInvModelView, const Handle(OpenGl_Context)& theGlContext);
461 //! Updates environment map for ray-tracing.
462 Standard_Boolean updateRaytraceEnvironmentMap (const Handle(OpenGl_Context)& theGlContext);
464 //! Checks to see if the OpenGL structure is modified.
465 Standard_Boolean toUpdateStructure (const OpenGl_Structure* theStructure);
467 //! Adds OpenGL structure to ray-traced scene geometry.
468 Standard_Boolean addRaytraceStructure (const OpenGl_Structure* theStructure,
469 const Handle(OpenGl_Context)& theGlContext);
471 //! Adds OpenGL groups to ray-traced scene geometry.
472 Standard_Boolean addRaytraceGroups (const OpenGl_Structure* theStructure,
473 const Standard_Integer theStructMat,
474 const Standard_ShortReal* theTransform,
475 const Handle(OpenGl_Context)& theGlContext);
477 //! Creates ray-tracing material properties.
478 OpenGl_RaytraceMaterial convertMaterial (const OpenGl_AspectFace* theAspect,
479 const Handle(OpenGl_Context)& theGlContext);
481 //! Adds OpenGL primitive array to ray-traced scene geometry.
482 OpenGl_TriangleSet* addRaytracePrimitiveArray (const OpenGl_PrimitiveArray* theArray,
483 const Standard_Integer theMatID,
484 const OpenGl_Mat4* theTrans);
486 //! Adds vertex indices from OpenGL primitive array to ray-traced scene geometry.
487 Standard_Boolean addRaytraceVertexIndices (OpenGl_TriangleSet& theSet,
488 const Standard_Integer theMatID,
489 const Standard_Integer theCount,
490 const Standard_Integer theOffset,
491 const OpenGl_PrimitiveArray& theArray);
493 //! Adds OpenGL triangle array to ray-traced scene geometry.
494 Standard_Boolean addRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
495 const Standard_Integer theMatID,
496 const Standard_Integer theCount,
497 const Standard_Integer theOffset,
498 const Handle(Graphic3d_IndexBuffer)& theIndices);
500 //! Adds OpenGL triangle fan array to ray-traced scene geometry.
501 Standard_Boolean addRaytraceTriangleFanArray (OpenGl_TriangleSet& theSet,
502 const Standard_Integer theMatID,
503 const Standard_Integer theCount,
504 const Standard_Integer theOffset,
505 const Handle(Graphic3d_IndexBuffer)& theIndices);
507 //! Adds OpenGL triangle strip array to ray-traced scene geometry.
508 Standard_Boolean addRaytraceTriangleStripArray (OpenGl_TriangleSet& theSet,
509 const Standard_Integer theMatID,
510 const Standard_Integer theCount,
511 const Standard_Integer theOffset,
512 const Handle(Graphic3d_IndexBuffer)& theIndices);
514 //! Adds OpenGL quadrangle array to ray-traced scene geometry.
515 Standard_Boolean addRaytraceQuadrangleArray (OpenGl_TriangleSet& theSet,
516 const Standard_Integer theMatID,
517 const Standard_Integer theCount,
518 const Standard_Integer theOffset,
519 const Handle(Graphic3d_IndexBuffer)& theIndices);
521 //! Adds OpenGL quadrangle strip array to ray-traced scene geometry.
522 Standard_Boolean addRaytraceQuadrangleStripArray (OpenGl_TriangleSet& theSet,
523 const Standard_Integer theMatID,
524 const Standard_Integer theCount,
525 const Standard_Integer theOffset,
526 const Handle(Graphic3d_IndexBuffer)& theIndices);
528 //! Adds OpenGL polygon array to ray-traced scene geometry.
529 Standard_Boolean addRaytracePolygonArray (OpenGl_TriangleSet& theSet,
530 const Standard_Integer theMatID,
531 const Standard_Integer theCount,
532 const Standard_Integer theOffset,
533 const Handle(Graphic3d_IndexBuffer)& theIndices);
535 //! Uploads ray-trace data to the GPU.
536 Standard_Boolean uploadRaytraceData (const Handle(OpenGl_Context)& theGlContext);
538 //! Generates shader prefix based on current ray-tracing options.
539 TCollection_AsciiString generateShaderPrefix (const Handle(OpenGl_Context)& theGlContext) const;
541 //! Performs safe exit when shaders initialization fails.
542 Standard_Boolean safeFailBack (const TCollection_ExtendedString& theMessage,
543 const Handle(OpenGl_Context)& theGlContext);
545 //! Loads and compiles shader object from specified source.
546 Handle(OpenGl_ShaderObject) initShader (const GLenum theType,
547 const ShaderSource& theSource,
548 const Handle(OpenGl_Context)& theGlContext);
550 //! Initializes OpenGL/GLSL shader programs.
551 Standard_Boolean initRaytraceResources (const Graphic3d_CView& theCView,
552 const Handle(OpenGl_Context)& theGlContext);
554 //! Releases OpenGL/GLSL shader programs.
555 void releaseRaytraceResources (const Handle(OpenGl_Context)& theGlContext);
557 //! Resizes OpenGL frame buffers.
558 Standard_Boolean resizeRaytraceBuffers (const Standard_Integer theSizeX,
559 const Standard_Integer theSizeY,
560 const Handle(OpenGl_Context)& theGlContext);
562 //! Generates viewing rays for corners of screen quad.
563 void updateCamera (const OpenGl_Mat4& theOrientation,
564 const OpenGl_Mat4& theViewMapping,
565 OpenGl_Vec3* theOrigins,
566 OpenGl_Vec3* theDirects,
567 OpenGl_Mat4& theUnView);
569 //! Binds ray-trace textures to corresponding texture units.
570 void bindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext);
572 //! Unbinds ray-trace textures from corresponding texture unit.
573 void unbindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext);
575 //! Sets uniform state for the given ray-tracing shader program.
576 Standard_Boolean setUniformState (const Graphic3d_CView& theCView,
577 const OpenGl_Vec3* theOrigins,
578 const OpenGl_Vec3* theDirects,
579 const OpenGl_Mat4& theUnviewMat,
580 const Standard_Integer theProgramId,
581 const Handle(OpenGl_Context)& theGlContext);
583 //! Runs ray-tracing shader programs.
584 Standard_Boolean runRaytraceShaders (const Graphic3d_CView& theCView,
585 const Standard_Integer theSizeX,
586 const Standard_Integer theSizeY,
587 const OpenGl_Vec3* theOrigins,
588 const OpenGl_Vec3* theDirects,
589 const OpenGl_Mat4& theUnviewMat,
590 OpenGl_FrameBuffer* theReadDrawFbo,
591 const Handle(OpenGl_Context)& theGlContext);
593 //! Redraws the window using OpenGL/GLSL ray-tracing.
594 Standard_Boolean raytrace (const Graphic3d_CView& theCView,
595 const Standard_Integer theSizeX,
596 const Standard_Integer theSizeY,
597 OpenGl_FrameBuffer* theReadDrawFbo,
598 const Handle(OpenGl_Context)& theGlContext);
600 protected: //! @name fields related to ray-tracing
602 //! Result of shaders initialization.
603 RaytraceInitStatus myRaytraceInitStatus;
605 //! Is geometry data valid?
606 Standard_Boolean myIsRaytraceDataValid;
608 //! Warning about missing extension GL_ARB_bindless_texture has been displayed?
609 Standard_Boolean myIsRaytraceWarnTextures;
611 //! 3D scene geometry data for ray-tracing.
612 OpenGl_RaytraceGeometry myRaytraceGeometry;
614 //! Compile-time ray-tracing parameters.
615 RaytracingParams myRaytraceParameters;
617 //! Radius of bounding sphere of the scene.
618 Standard_ShortReal myRaytraceSceneRadius;
619 //! Scene epsilon to prevent self-intersections.
620 Standard_ShortReal myRaytraceSceneEpsilon;
622 //! OpenGL/GLSL source of ray-tracing fragment shader.
623 ShaderSource myRaytraceShaderSource;
624 //! OpenGL/GLSL source of adaptive-AA fragment shader.
625 ShaderSource myPostFSAAShaderSource;
627 //! OpenGL/GLSL ray-tracing fragment shader.
628 Handle(OpenGl_ShaderObject) myRaytraceShader;
629 //! OpenGL/GLSL adaptive-AA fragment shader.
630 Handle(OpenGl_ShaderObject) myPostFSAAShader;
632 //! OpenGL/GLSL ray-tracing shader program.
633 Handle(OpenGl_ShaderProgram) myRaytraceProgram;
634 //! OpenGL/GLSL adaptive-AA shader program.
635 Handle(OpenGl_ShaderProgram) myPostFSAAProgram;
637 //! Texture buffer of data records of bottom-level BVH nodes.
638 Handle(OpenGl_TextureBufferArb) mySceneNodeInfoTexture;
639 //! Texture buffer of minimum points of bottom-level BVH nodes.
640 Handle(OpenGl_TextureBufferArb) mySceneMinPointTexture;
641 //! Texture buffer of maximum points of bottom-level BVH nodes.
642 Handle(OpenGl_TextureBufferArb) mySceneMaxPointTexture;
643 //! Texture buffer of transformations of high-level BVH nodes.
644 Handle(OpenGl_TextureBufferArb) mySceneTransformTexture;
646 //! Texture buffer of vertex coords.
647 Handle(OpenGl_TextureBufferArb) myGeometryVertexTexture;
648 //! Texture buffer of vertex normals.
649 Handle(OpenGl_TextureBufferArb) myGeometryNormalTexture;
650 //! Texture buffer of vertex UV coords.
651 Handle(OpenGl_TextureBufferArb) myGeometryTexCrdTexture;
652 //! Texture buffer of triangle indices.
653 Handle(OpenGl_TextureBufferArb) myGeometryTriangTexture;
655 //! Texture buffer of material properties.
656 Handle(OpenGl_TextureBufferArb) myRaytraceMaterialTexture;
657 //! Texture buffer of light source properties.
658 Handle(OpenGl_TextureBufferArb) myRaytraceLightSrcTexture;
660 //! 1st framebuffer (FBO) to perform adaptive FSAA.
661 Handle(OpenGl_FrameBuffer) myRaytraceFBO1;
662 //! 2nd framebuffer (FBO) to perform adaptive FSAA.
663 Handle(OpenGl_FrameBuffer) myRaytraceFBO2;
664 //! Framebuffer (FBO) for preliminary OpenGL output.
665 Handle(OpenGl_FrameBuffer) myOpenGlFBO;
667 //! Vertex buffer (VBO) for drawing dummy quad.
668 OpenGl_VertexBuffer myRaytraceScreenQuad;
670 //! Cached locations of frequently used uniform variables.
671 Standard_Integer myUniformLocations[2][OpenGl_RT_NbVariables];
673 //! State of OpenGL structures reflected to ray-tracing.
674 std::map<const OpenGl_Structure*, Standard_Size> myStructureStates;
676 //! PrimitiveArray to TriangleSet map for scene partial update.
677 std::map<Standard_Size, OpenGl_TriangleSet*> myArrayToTrianglesMap;
679 //! Graphical ray-tracing filter to filter out all raytracable structures.
680 Handle(OpenGl_RaytraceFilter) myRaytraceFilter;
682 //! Marks if environment map should be updated.
683 Standard_Boolean myToUpdateEnvironmentMap;
685 //! State of OpenGL layer list.
686 Standard_Size myLayersModificationStatus;
690 DEFINE_STANDARD_ALLOC
691 DEFINE_STANDARD_RTTI(OpenGl_View) // Type definition
693 friend class OpenGl_Workspace;
697 #endif // _OpenGl_View_Header