0024887: Visualization - revise and extend Raytracing controls
[occt.git] / src / OpenGl / OpenGl_Workspace.hxx
CommitLineData
b311480e 1// Created on: 2011-09-20
2// Created by: Sergey ZERCHANINOV
1981cb22 3// Copyright (c) 2011-2013 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
2166f0fa
SK
16#ifndef _OpenGl_Workspace_Header
17#define _OpenGl_Workspace_Header
18
fc73a202 19#include <map>
20#include <set>
e276548b 21
2166f0fa
SK
22#include <Handle_OpenGl_Workspace.hxx>
23#include <OpenGl_Window.hxx>
24
25#include <TColStd_Array2OfReal.hxx>
26#include <Quantity_Color.hxx>
bf75be98 27#include <Graphic3d_CView.hxx>
2166f0fa 28#include <Graphic3d_TypeOfComposition.hxx>
bf75be98 29#include <Graphic3d_TypeOfTexture.hxx>
30#include <Graphic3d_PtrFrameBuffer.hxx>
31#include <Graphic3d_BufferType.hxx>
32#include <Handle_Graphic3d_TextureParams.hxx>
2166f0fa 33
2166f0fa
SK
34#include <Aspect_CLayer2d.hxx>
35#include <Aspect_Handle.hxx>
36#include <Aspect_PrintAlgo.hxx>
550f3b8b 37#include <Aspect_PolygonOffsetMode.hxx>
2166f0fa
SK
38
39#include <InterfaceGraphic_Graphic3d.hxx>
40#include <InterfaceGraphic_Visual3d.hxx>
41
1981cb22 42#include <NCollection_Sequence.hxx>
43
bf75be98 44#include <OpenGl_AspectFace.hxx>
fc73a202 45#include <OpenGl_FrameBuffer.hxx>
2166f0fa
SK
46#include <OpenGl_Matrix.hxx>
47#include <OpenGl_NamedStatus.hxx>
a174a3c5 48#include <OpenGl_PrinterContext.hxx>
fc73a202 49#include <OpenGl_SceneGeometry.hxx>
2166f0fa 50#include <OpenGl_TextParam.hxx>
4269bd1b 51#include <OpenGl_RenderFilter.hxx>
0adbd30f 52#include <OpenGl_Vec.hxx>
73192b37 53#include <OpenGl_LineAttributes.hxx>
2166f0fa
SK
54
55#include <Handle_OpenGl_View.hxx>
bf75be98 56#include <Handle_OpenGl_Texture.hxx>
2166f0fa 57
fc73a202 58#include <OpenGl_ShaderObject.hxx>
59#include <OpenGl_ShaderProgram.hxx>
60#include <OpenGl_TextureBufferArb.hxx>
61
2166f0fa 62class OpenGl_AspectLine;
2166f0fa
SK
63class OpenGl_AspectMarker;
64class OpenGl_AspectText;
65class OpenGl_FrameBuffer;
66class OpenGl_Structure;
4269bd1b 67class OpenGl_Element;
692613e5 68class Image_PixMap;
2166f0fa 69
0adbd30f 70//! OpenGL material definition
71struct OpenGl_Material
72{
73
74 OpenGl_Vec4 Ambient; //!< ambient reflection coefficient
75 OpenGl_Vec4 Diffuse; //!< diffuse reflection coefficient
76 OpenGl_Vec4 Specular; //!< glossy reflection coefficient
77 OpenGl_Vec4 Emission; //!< material emission
78 OpenGl_Vec4 Params; //!< extra packed parameters
79
80 Standard_ShortReal Shine() const { return Params.x(); }
81 Standard_ShortReal& ChangeShine() { return Params.x(); }
82
83 Standard_ShortReal Transparency() const { return Params.y(); }
84 Standard_ShortReal& ChangeTransparency() { return Params.y(); }
85
86 //! Initialize material
87 void Init (const OPENGL_SURF_PROP& theProps);
88
89 //! Returns packed (serialized) representation of material properties
90 const OpenGl_Vec4* Packed() const { return reinterpret_cast<const OpenGl_Vec4*> (this); }
91 static Standard_Integer NbOfVec4() { return 5; }
92
93};
94
e276548b 95//! Represents window with GL context.
96//! Provides methods to render primitives and maintain GL state.
2166f0fa
SK
97class OpenGl_Workspace : public OpenGl_Window
98{
99public:
100
101 //! Main constructor - prepare GL context for specified window.
73192b37 102 OpenGl_Workspace (const Handle(Aspect_DisplayConnection)& theDisplayConnection,
2166f0fa 103 const CALL_DEF_WINDOW& theCWindow,
5e27df78 104 Aspect_RenderingContext theGContext,
58655684 105 const Handle(OpenGl_Caps)& theCaps,
5e27df78 106 const Handle(OpenGl_Context)& theShareCtx);
2166f0fa
SK
107
108 //! Destructor
109 virtual ~OpenGl_Workspace();
110
111 void SetActiveView (const Handle(OpenGl_View)& theView) { myView = theView; }
112 const Handle(OpenGl_View)& ActiveView () const { return myView; }
113
114 //! Redraw the window.
115 void Redraw (const Graphic3d_CView& theCView,
116 const Aspect_CLayer2d& theCUnderLayer,
117 const Aspect_CLayer2d& theCOverLayer);
118
679ecdee 119 Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer);
120 void RedrawImmediate (const Graphic3d_CView& theCView,
121 const Aspect_CLayer2d& theCUnderLayer,
122 const Aspect_CLayer2d& theCOverLayer,
123 const Standard_Boolean theToForce = Standard_False);
124
125 void Invalidate (const Graphic3d_CView& /*theCView*/)
2166f0fa 126 {
679ecdee 127 myBackBufferRestored = Standard_False;
2166f0fa
SK
128 }
129
130 //! Special method to perform printing.
131 //! System-specific and currently only Win platform implemented.
a174a3c5 132 Standard_Boolean Print (const Handle(OpenGl_PrinterContext)& thePrintContext,
133 const Graphic3d_CView& theCView,
bf75be98 134 const Aspect_CLayer2d& theCUnderLayer,
2166f0fa
SK
135 const Aspect_CLayer2d& theCOverLayer,
136 const Aspect_Handle theHPrintDC,
137 const Standard_Boolean theToShowBackground,
138 const Standard_CString theFileName,
139 const Aspect_PrintAlgo thePrintAlgorithm,
140 const Standard_Real theScaleFactor);
141
a174a3c5 142 const Handle(OpenGl_PrinterContext)& PrinterContext() const
143 {
144 return myPrintContext;
145 }
146
2166f0fa
SK
147 void DisplayCallback (const Graphic3d_CView& theCView, int theReason);
148
2166f0fa
SK
149 Graphic3d_PtrFrameBuffer FBOCreate (const Standard_Integer theWidth, const Standard_Integer theHeight);
150 void FBORelease (Graphic3d_PtrFrameBuffer theFBOPtr);
692613e5 151 Standard_Boolean BufferDump (OpenGl_FrameBuffer* theFBOPtr,
152 Image_PixMap& theImage,
153 const Graphic3d_BufferType& theBufferType);
2166f0fa 154
2166f0fa
SK
155 void UseTransparency (const Standard_Boolean theFlag);
156 Standard_Boolean& UseZBuffer() { return myUseZBuffer; }
157 Standard_Boolean& UseDepthTest() { return myUseDepthTest; }
158 Standard_Boolean& UseGLLight() { return myUseGLLight; }
159
73192b37 160 Standard_Integer AntiAliasingMode() const { return myAntiAliasingMode; }
161
2166f0fa
SK
162 //// RELATED TO STATUS ////
163
164 Standard_Integer NamedStatus;
165
2166f0fa
SK
166 const TEL_COLOUR* HighlightColor;
167
168 const OpenGl_Matrix* SetViewMatrix (const OpenGl_Matrix* );
30f0ad28 169 const OpenGl_Matrix* SetStructureMatrix (const OpenGl_Matrix*, bool aRevert = false);
2166f0fa 170
0f8c0fb8 171 //! Updates current model-view matrix
172 //! replacing it with StructureMatrixT*ViewMatrix from the workspace.
173 const void UpdateModelViewMatrix();
174
2166f0fa
SK
175 const OpenGl_AspectLine* SetAspectLine (const OpenGl_AspectLine* theAspect);
176 const OpenGl_AspectFace* SetAspectFace (const OpenGl_AspectFace* theAspect);
177 const OpenGl_AspectMarker* SetAspectMarker (const OpenGl_AspectMarker* theAspect);
178 const OpenGl_AspectText* SetAspectText (const OpenGl_AspectText* theAspect);
179
180 void SetTextParam (const OpenGl_TextParam* theParam) { TextParam_set = theParam; }
181
3946774d 182 //// THESE METHODS ARE EXPORTED AS THEY PROVIDE STATE INFO TO USERDRAW
183 Standard_EXPORT const OpenGl_AspectLine* AspectLine (const Standard_Boolean theWithApply);
184 Standard_EXPORT const OpenGl_AspectFace* AspectFace (const Standard_Boolean theWithApply);
185 Standard_EXPORT const OpenGl_AspectMarker* AspectMarker (const Standard_Boolean theWithApply);
186 Standard_EXPORT const OpenGl_AspectText* AspectText (const Standard_Boolean theWithApply);
a174a3c5 187 inline const OpenGl_TextParam* AspectTextParams() const
188 {
189 return TextParam_applied;
190 }
2166f0fa 191
34a44cbd 192 //! Clear the applied aspect state.
193 void ResetAppliedAspect();
194
bf75be98 195 Standard_EXPORT Handle(OpenGl_Texture) DisableTexture();
196 Standard_EXPORT Handle(OpenGl_Texture) EnableTexture (const Handle(OpenGl_Texture)& theTexture,
197 const Handle(Graphic3d_TextureParams)& theParams = NULL);
198
4269bd1b 199 //! Set filter for restricting rendering of particular elements.
200 //! Filter can be applied for rendering passes used by recursive
201 //! rendering algorithms for rendering elements of groups.
202 //! @param theFilter [in] the filter instance.
203 inline void SetRenderFilter (const Handle(OpenGl_RenderFilter)& theFilter)
204 {
5322131b 205 myRenderFilter = theFilter;
4269bd1b 206 }
207
208 //! Get rendering filter.
209 //! @return filter instance.
5322131b 210 inline const Handle(OpenGl_RenderFilter)& GetRenderFilter() const
211 {
212 return myRenderFilter;
4269bd1b 213 }
214
215 //! @return applied view matrix.
216 inline const OpenGl_Matrix* ViewMatrix() const { return ViewMatrix_applied; }
217
218 //! @return applied model structure matrix.
219 inline const OpenGl_Matrix* ModelMatrix() const { return StructureMatrix_applied; }
220
550f3b8b 221 //! Sets and applies current polygon offset.
222 void SetPolygonOffset (int theMode, Standard_ShortReal theFactor, Standard_ShortReal theUnits);
223
224 //! Returns currently applied polygon offset params.
225 const TEL_POFFSET_PARAM& AppliedPolygonOffset() { return PolygonOffset_applied; }
226
2166f0fa
SK
227protected:
228
679ecdee 229 //! Copy content of Back buffer to the Front buffer
230 void copyBackToFront();
2166f0fa
SK
231
232 virtual Standard_Boolean Activate();
233
679ecdee 234 void redraw1 (const Graphic3d_CView& theCView,
bf75be98 235 const Aspect_CLayer2d& theCUnderLayer,
2166f0fa 236 const Aspect_CLayer2d& theCOverLayer,
679ecdee 237 const int theToSwap);
2166f0fa 238
0adbd30f 239 void updateMaterial (const int theFlag);
2166f0fa 240
bf75be98 241 void setTextureParams (Handle(OpenGl_Texture)& theTexture,
242 const Handle(Graphic3d_TextureParams)& theParams);
2166f0fa 243
fc73a202 244protected:
e276548b 245
fc73a202 246 //! Result of OpenGL shaders initialization.
247 enum RaytraceInitStatus
248 {
249 OpenGl_RT_NONE,
250 OpenGl_RT_INIT,
251 OpenGl_RT_FAIL
252 };
e276548b 253
84c71f29 254 //! Describes update mode (state).
255 enum GeomUpdateMode
256 {
257 OpenGl_GUM_CHECK, //!< check if geometry update is necessary
258 OpenGl_GUM_PREPARE, //!< collect unchanged objects
259 OpenGl_GUM_UPDATE //!< update raytracing data, rebuild changed objects
260 };
261
fc73a202 262 //! Defines frequently used shader variables.
263 enum ShaderVariableIndex
264 {
265 OpenGl_RT_aPosition,
266
267 OpenGl_RT_uOriginLT,
268 OpenGl_RT_uOriginLB,
269 OpenGl_RT_uOriginRT,
270 OpenGl_RT_uOriginRB,
271
272 OpenGl_RT_uDirectLT,
273 OpenGl_RT_uDirectLB,
274 OpenGl_RT_uDirectRT,
275 OpenGl_RT_uDirectRB,
276
277 OpenGl_RT_uSceneRad,
278 OpenGl_RT_uSceneEps,
279
280 OpenGl_RT_uLightAmbnt,
281 OpenGl_RT_uLightCount,
282
283 OpenGl_RT_uShadEnabled,
284 OpenGl_RT_uReflEnabled,
285
286 OpenGl_RT_uInputTexture,
287
288 OpenGl_RT_uOffsetX,
289 OpenGl_RT_uOffsetY,
290 OpenGl_RT_uSamples,
291
84c71f29 292 OpenGl_RT_uEnvironmentEnable,
293
fc73a202 294 OpenGl_RT_NbVariables // special field
295 };
e276548b 296
fc73a202 297 //! Defines texture samplers.
298 enum ShaderSamplerNames
299 {
300 OpenGl_RT_SceneNodeInfoTexture = 0,
301 OpenGl_RT_SceneMinPointTexture = 1,
302 OpenGl_RT_SceneMaxPointTexture = 2,
303
304 OpenGl_RT_ObjectNodeInfoTexture = 3,
305 OpenGl_RT_ObjectMinPointTexture = 4,
306 OpenGl_RT_ObjectMaxPointTexture = 5,
307
308 OpenGl_RT_GeometryVertexTexture = 6,
309 OpenGl_RT_GeometryNormalTexture = 7,
310 OpenGl_RT_GeometryTriangTexture = 8,
e276548b 311
fc73a202 312 OpenGl_RT_EnvironmentMapTexture = 9,
313
314 OpenGl_RT_RaytraceMaterialTexture = 10,
315 OpenGl_RT_RaytraceLightSrcTexture = 11,
316
84c71f29 317 OpenGl_RT_FSAAInputTexture = 12,
318
319 OpenGl_RT_SceneTransformTexture = 13
fc73a202 320 };
321
322 //! Tool class for management of shader sources.
323 class ShaderSource
e276548b 324 {
fc73a202 325 public:
326
327 //! Creates new uninitialized shader source.
328 ShaderSource()
329 {
330 //
331 }
332
333 //! Creates new shader source from specified file.
334 ShaderSource (const TCollection_AsciiString& theFileName)
335 {
336 Load (&theFileName, 1);
337 }
338
339 public:
340
341 //! Returns prefix to insert before the source.
342 const TCollection_AsciiString& Prefix() const
343 {
344 return myPrefix;
345 }
346
347 //! Sets prefix to insert before the source.
348 void SetPrefix (const TCollection_AsciiString& thePrefix)
349 {
350 myPrefix = thePrefix;
351 }
352
353 //! Returns shader source combined with prefix.
354 TCollection_AsciiString Source() const;
355
356 //! Loads shader source from specified files.
357 void Load (const TCollection_AsciiString* theFileNames, const Standard_Integer theCount);
358
359 private:
360
361 TCollection_AsciiString mySource; //!< Source string of the shader object
362 TCollection_AsciiString myPrefix; //!< Prefix to insert before the source
363
e276548b 364 };
365
bc8c79bb 366 //! Default ray-tracing depth.
367 static const Standard_Integer THE_DEFAULT_RAY_DEPTH = 3;
368
fc73a202 369 //! Default size of traversal stack.
370 static const Standard_Integer THE_DEFAULT_STACK_SIZE = 24;
371
bc8c79bb 372 //! Compile-time ray-tracing parameters.
373 struct RaytracingParams
374 {
375 //! Actual size of traversal stack in shader program.
376 Standard_Integer StackSize;
377
378 //! Actual ray-tracing depth (number of ray bounces).
379 Standard_Integer TraceDepth;
380
381 //! Sets light propagation through transparent media.
382 Standard_Boolean TransparentShadows;
383
384 //! Creates default compile-time ray-tracing parameters.
385 RaytracingParams()
386 : StackSize (THE_DEFAULT_STACK_SIZE),
387 TraceDepth (THE_DEFAULT_RAY_DEPTH),
388 TransparentShadows (Standard_False)
389 {
390 //
391 }
392 };
393
e276548b 394protected: //! @name methods related to ray-tracing
395
396 //! Updates 3D scene geometry for ray-tracing.
84c71f29 397 Standard_Boolean UpdateRaytraceGeometry (GeomUpdateMode theMode);
e276548b 398
399 //! Checks to see if the structure is modified.
400 Standard_Boolean CheckRaytraceStructure (const OpenGl_Structure* theStructure);
401
402 //! Updates 3D scene light sources for ray-tracing.
403 Standard_Boolean UpdateRaytraceLightSources (const GLdouble theInvModelView[16]);
404
405 //! Updates environment map for ray-tracing.
406 Standard_Boolean UpdateRaytraceEnvironmentMap();
5322131b 407
e276548b 408 //! Adds OpenGL structure to ray-traced scene geometry.
265d4508 409 Standard_Boolean AddRaytraceStructure (const OpenGl_Structure* theStructure,
410 const Standard_ShortReal* theTransform, std::set<const OpenGl_Structure*>& theElements);
e276548b 411
412 //! Adds OpenGL primitive array to ray-traced scene geometry.
265d4508 413 OpenGl_TriangleSet* AddRaytracePrimitiveArray (
84c71f29 414 const OpenGl_PrimitiveArray* theArray, int theMatID, const Standard_ShortReal* theTrans);
e276548b 415
416 //! Adds vertex indices from OpenGL primitive array to ray-traced scene geometry.
871fa103 417 Standard_Boolean AddRaytraceVertexIndices (OpenGl_TriangleSet& theSet,
418 const OpenGl_PrimitiveArray& theArray,
419 Standard_Integer theOffset,
420 Standard_Integer theCount,
421 Standard_Integer theMatID);
e276548b 422
423 //! Adds OpenGL triangle array to ray-traced scene geometry.
871fa103 424 Standard_Boolean AddRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
425 const Handle(Graphic3d_IndexBuffer)& theIndices,
426 Standard_Integer theOffset,
427 Standard_Integer theCount,
428 Standard_Integer theMatID);
e276548b 429
430 //! Adds OpenGL triangle fan array to ray-traced scene geometry.
871fa103 431 Standard_Boolean AddRaytraceTriangleFanArray (OpenGl_TriangleSet& theSet,
432 const Handle(Graphic3d_IndexBuffer)& theIndices,
433 Standard_Integer theOffset,
434 Standard_Integer theCount,
435 Standard_Integer theMatID);
e276548b 436
265d4508 437 //! Adds OpenGL triangle strip array to ray-traced scene geometry.
871fa103 438 Standard_Boolean AddRaytraceTriangleStripArray (OpenGl_TriangleSet& theSet,
439 const Handle(Graphic3d_IndexBuffer)& theIndices,
440 Standard_Integer theOffset,
441 Standard_Integer theCount,
442 Standard_Integer theMatID);
e276548b 443
444 //! Adds OpenGL quadrangle array to ray-traced scene geometry.
871fa103 445 Standard_Boolean AddRaytraceQuadrangleArray (OpenGl_TriangleSet& theSet,
446 const Handle(Graphic3d_IndexBuffer)& theIndices,
447 Standard_Integer theOffset,
448 Standard_Integer theCount,
449 Standard_Integer theMatID);
e276548b 450
451 //! Adds OpenGL quadrangle strip array to ray-traced scene geometry.
871fa103 452 Standard_Boolean AddRaytraceQuadrangleStripArray (OpenGl_TriangleSet& theSet,
453 const Handle(Graphic3d_IndexBuffer)& theIndices,
454 Standard_Integer theOffset,
455 Standard_Integer theCount,
456 Standard_Integer theMatID);
e276548b 457
458 //! Adds OpenGL polygon array to ray-traced scene geometry.
871fa103 459 Standard_Boolean AddRaytracePolygonArray (OpenGl_TriangleSet& theSet,
460 const Handle(Graphic3d_IndexBuffer)& theIndices,
461 Standard_Integer theOffset,
462 Standard_Integer theCount,
463 Standard_Integer theMatID);
e276548b 464
fc73a202 465 //! Loads and compiles shader object from specified source.
466 Handle(OpenGl_ShaderObject) LoadShader (const ShaderSource& theSource, GLenum theType);
467
468 //! Performs safe exit when shaders initialization fails.
469 Standard_Boolean SafeFailBack (const TCollection_ExtendedString& theMessage);
470
471 //! Initializes OpenGL/GLSL shader programs.
bc8c79bb 472 Standard_Boolean InitRaytraceResources (const Graphic3d_CView& theCView);
5322131b 473
fc73a202 474 //! Releases OpenGL/GLSL shader programs.
475 void ReleaseRaytraceResources();
e276548b 476
fc73a202 477 //! Uploads ray-trace data to the GPU.
478 Standard_Boolean UploadRaytraceData();
e276548b 479
fc73a202 480 //! Resizes OpenGL frame buffers.
481 Standard_Boolean ResizeRaytraceBuffers (const Standard_Integer theSizeX,
482 const Standard_Integer theSizeY);
e276548b 483
fc73a202 484 //! Generates viewing rays for corners of screen quad.
485 void UpdateCamera (const NCollection_Mat4<GLdouble>& theOrientation,
486 const NCollection_Mat4<GLdouble>& theViewMapping,
487 OpenGl_Vec3 theOrigins[4],
488 OpenGl_Vec3 theDirects[4]);
e276548b 489
fc73a202 490 //! Runs ray-tracing shader programs.
491 Standard_Boolean RunRaytraceShaders (const Graphic3d_CView& theCView,
492 const Standard_Integer theSizeX,
493 const Standard_Integer theSizeY,
494 const OpenGl_Vec3 theOrigins[4],
495 const OpenGl_Vec3 theDirects[4],
496 OpenGl_FrameBuffer* theFrameBuffer);
265d4508 497
fc73a202 498 //! Redraws the window using OpenGL/GLSL ray-tracing.
e276548b 499 Standard_Boolean Raytrace (const Graphic3d_CView& theCView,
fc73a202 500 const Standard_Integer theSizeX,
501 const Standard_Integer theSizeY,
502 const Standard_Boolean theToSwap,
503 OpenGl_FrameBuffer* theFrameBuffer);
e276548b 504
505protected: //! @name fields related to ray-tracing
506
fc73a202 507 //! Result of shaders initialization.
508 RaytraceInitStatus myComputeInitStatus;
e276548b 509
510 //! Is geometry data valid?
511 Standard_Boolean myIsRaytraceDataValid;
5322131b 512
e276548b 513 //! 3D scene geometry data for ray-tracing.
265d4508 514 OpenGl_RaytraceGeometry myRaytraceGeometry;
e276548b 515
516 //! Radius of bounding sphere of the scene.
265d4508 517 Standard_ShortReal myRaytraceSceneRadius;
e276548b 518 //! Scene epsilon to prevent self-intersections.
265d4508 519 Standard_ShortReal myRaytraceSceneEpsilon;
e276548b 520
bc8c79bb 521 //! Compile-time ray-tracing parameters.
522 RaytracingParams myRaytraceParameters;
fc73a202 523
524 //! OpenGL/GLSL source of ray-tracing fragment shader.
525 ShaderSource myRaytraceShaderSource;
526 //! OpenGL/GLSL source of adaptive-AA fragment shader.
527 ShaderSource myPostFSAAShaderSource;
528
529 //! OpenGL/GLSL ray-tracing fragment shader.
530 Handle(OpenGl_ShaderObject) myRaytraceShader;
531 //! OpenGL/GLSL adaptive-AA fragment shader.
532 Handle(OpenGl_ShaderObject) myPostFSAAShader;
533
534 //! OpenGL/GLSL ray-tracing shader program.
535 Handle(OpenGl_ShaderProgram) myRaytraceProgram;
536 //! OpenGL/GLSL adaptive-AA shader program.
537 Handle(OpenGl_ShaderProgram) myPostFSAAProgram;
538
539 //! Texture buffer of data records of high-level BVH nodes.
540 Handle(OpenGl_TextureBufferArb) mySceneNodeInfoTexture;
541 //! Texture buffer of minimum points of high-level BVH nodes.
542 Handle(OpenGl_TextureBufferArb) mySceneMinPointTexture;
543 //! Texture buffer of maximum points of high-level BVH nodes.
544 Handle(OpenGl_TextureBufferArb) mySceneMaxPointTexture;
84c71f29 545 //! Texture buffer of transformations of high-level BVH nodes.
546 Handle(OpenGl_TextureBufferArb) mySceneTransformTexture;
fc73a202 547
548 //! Texture buffer of data records of bottom-level BVH nodes.
549 Handle(OpenGl_TextureBufferArb) myObjectNodeInfoTexture;
550 //! Texture buffer of minimum points of bottom-level BVH nodes.
551 Handle(OpenGl_TextureBufferArb) myObjectMinPointTexture;
552 //! Texture buffer of maximum points of bottom-level BVH nodes.
553 Handle(OpenGl_TextureBufferArb) myObjectMaxPointTexture;
554
555 //! Texture buffer of vertex coords.
556 Handle(OpenGl_TextureBufferArb) myGeometryVertexTexture;
557 //! Texture buffer of vertex normals.
558 Handle(OpenGl_TextureBufferArb) myGeometryNormalTexture;
559 //! Texture buffer of triangle indices.
560 Handle(OpenGl_TextureBufferArb) myGeometryTriangTexture;
561
562 //! Texture buffer of material properties.
563 Handle(OpenGl_TextureBufferArb) myRaytraceMaterialTexture;
564 //! Texture buffer of light source properties.
565 Handle(OpenGl_TextureBufferArb) myRaytraceLightSrcTexture;
566
567 //! Vertex buffer (VBO) for drawing dummy quad.
568 OpenGl_VertexBuffer myRaytraceScreenQuad;
569
570 //! Framebuffer (FBO) to perform adaptive FSAA.
571 Handle(OpenGl_FrameBuffer) myRaytraceFBO1;
572 //! Framebuffer (FBO) to perform adaptive FSAA.
573 Handle(OpenGl_FrameBuffer) myRaytraceFBO2;
265d4508 574
e276548b 575 //! State of OpenGL view.
576 Standard_Size myViewModificationStatus;
e276548b 577 //! State of OpenGL layer list.
578 Standard_Size myLayersModificationStatus;
579
265d4508 580 //! State of OpenGL structures reflected to ray-tracing.
e276548b 581 std::map<const OpenGl_Structure*, Standard_Size> myStructureStates;
582
84c71f29 583 //! PrimitiveArray to TriangleSet map for scene partial update.
584 std::map<const OpenGl_PrimitiveArray*, OpenGl_TriangleSet*> myArrayToTrianglesMap;
585
fc73a202 586 //! Cached locations of frequently used uniform variables.
587 Standard_Integer myUniformLocations[2][OpenGl_RT_NbVariables];
e276548b 588
bf75be98 589protected: //! @name protected fields
2166f0fa 590
a174a3c5 591 Handle(OpenGl_PrinterContext) myPrintContext;
73192b37 592 Handle(OpenGl_View) myView;
593 Handle(OpenGl_LineAttributes) myLineAttribs;
594 Standard_Integer myAntiAliasingMode;
1981cb22 595 Standard_Boolean myTransientDrawToFront; //!< optimization flag for immediate mode (to render directly to the front buffer)
679ecdee 596 Standard_Boolean myBackBufferRestored;
597 Standard_Boolean myIsImmediateDrawn; //!< flag indicates that immediate mode buffer contains some data
bf75be98 598 Standard_Boolean myUseTransparency;
599 Standard_Boolean myUseZBuffer;
600 Standard_Boolean myUseDepthTest;
601 Standard_Boolean myUseGLLight;
2166f0fa 602
bf75be98 603protected: //! @name fields related to status
604
4269bd1b 605 Handle(OpenGl_RenderFilter) myRenderFilter;
bf75be98 606 Handle(OpenGl_Texture) myTextureBound; //!< currently bound texture (managed by OpenGl_AspectFace and OpenGl_View environment texture)
2166f0fa
SK
607 const OpenGl_AspectLine *AspectLine_set, *AspectLine_applied;
608 const OpenGl_AspectFace *AspectFace_set, *AspectFace_applied;
609 const OpenGl_AspectMarker *AspectMarker_set, *AspectMarker_applied;
610 const OpenGl_AspectText *AspectText_set, *AspectText_applied;
611
612 const OpenGl_TextParam *TextParam_set, *TextParam_applied;
613
614 const OpenGl_Matrix* ViewMatrix_applied;
615 const OpenGl_Matrix* StructureMatrix_applied;
616
3b1817a9 617 OpenGl_Material myMatFront; //!< current front material state (cached to reduce GL context updates)
618 OpenGl_Material myMatBack; //!< current back material state
619 OpenGl_Material myMatTmp; //!< temporary variable
620 TelCullMode myCullingMode; //!< back face culling mode, applied from face aspect
0adbd30f 621
550f3b8b 622 OpenGl_Matrix myModelViewMatrix; //!< Model matrix with applied structure transformations
0f8c0fb8 623
550f3b8b 624 TEL_POFFSET_PARAM PolygonOffset_applied; //!< Currently applied polygon offset.
2166f0fa 625
550f3b8b 626 OpenGl_AspectFace myAspectFaceHl; //!< Hiddenline aspect
bf75be98 627
628public: //! @name type definition
2166f0fa 629
bf75be98 630 DEFINE_STANDARD_RTTI(OpenGl_Workspace)
1c35b92f 631 DEFINE_STANDARD_ALLOC
2166f0fa
SK
632
633};
634
bf75be98 635#endif // _OpenGl_Workspace_Header