0027860: Visualization - clean up Transformation Persistence API
[occt.git] / src / OpenGl / OpenGl_View.hxx
CommitLineData
b311480e 1// Created on: 2011-09-20
2// Created by: Sergey ZERCHANINOV
973c2be1 3// Copyright (c) 2011-2014 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_View_Header
17#define _OpenGl_View_Header
18
19#include <MMgt_TShared.hxx>
ec357c5c 20#include <Standard_Type.hxx>
2166f0fa
SK
21
22#include <TColStd_Array2OfReal.hxx>
23#include <NCollection_List.hxx>
189f85a3 24#include <math_BullardGenerator.hxx>
2166f0fa
SK
25
26#include <Quantity_NameOfColor.hxx>
27#include <Aspect_FillMethod.hxx>
28#include <Aspect_GradientFillMethod.hxx>
29#include <Aspect_TypeOfTriedronPosition.hxx>
2166f0fa 30
2166f0fa 31#include <Graphic3d_CView.hxx>
a79f67f8 32#include <Graphic3d_GraduatedTrihedron.hxx>
51b10cd4 33#include <Graphic3d_SequenceOfHClipPlane.hxx>
c357e426 34#include <Graphic3d_TypeOfShadingModel.hxx>
825aa485 35#include <Graphic3d_WorldViewProjState.hxx>
c5751993 36#include <Graphic3d_ZLayerSettings.hxx>
2166f0fa 37
0b0320e7 38#include <OpenGl_AspectFace.hxx>
39#include <OpenGl_BackgroundArray.hxx>
b7cd4ba7 40#include <OpenGl_BVHTreeSelector.hxx>
c357e426 41#include <OpenGl_Context.hxx>
42#include <OpenGl_FrameBuffer.hxx>
43#include <OpenGl_GraduatedTrihedron.hxx>
59f45b7c 44#include <OpenGl_LayerList.hxx>
2166f0fa 45#include <OpenGl_Light.hxx>
73192b37 46#include <OpenGl_LineAttributes.hxx>
c357e426 47#include <OpenGl_SceneGeometry.hxx>
48#include <OpenGl_Structure.hxx>
536d98e2 49#include <OpenGl_Trihedron.hxx>
c357e426 50#include <OpenGl_Window.hxx>
51#include <OpenGl_Workspace.hxx>
2166f0fa 52
c357e426 53#include <map>
54#include <set>
2166f0fa 55
b5ac8292 56struct OpenGl_Matrix;
2166f0fa 57
c357e426 58class Graphic3d_StructureManager;
59class OpenGl_GraphicDriver;
60class OpenGl_StateCounter;
61class OpenGl_RaytraceMaterial;
62class OpenGl_TriangleSet;
63class OpenGl_Workspace;
c04c30b3 64class OpenGl_View;
c357e426 65DEFINE_STANDARD_HANDLE(OpenGl_View,Graphic3d_CView)
c04c30b3 66
c357e426 67//! Implementation of OpenGl view.
68class OpenGl_View : public Graphic3d_CView
2166f0fa 69{
c357e426 70
71public:
72
73 //! Constructor.
74 Standard_EXPORT OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
75 const Handle(OpenGl_GraphicDriver)& theDriver,
76 const Handle(OpenGl_Caps)& theCaps,
77 Standard_Boolean& theDeviceLostFlag,
78 OpenGl_StateCounter* theCounter);
79
80 //! Default destructor.
81 Standard_EXPORT virtual ~OpenGl_View();
2166f0fa 82
62e1beed 83 Standard_EXPORT void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
bf75be98 84
c357e426 85 //! Deletes and erases the view.
86 Standard_EXPORT virtual void Remove() Standard_OVERRIDE;
87
88 //! @param theDrawToFrontBuffer Advanced option to modify rendering mode:
89 //! 1. TRUE. Drawing immediate mode structures directly to the front buffer over the scene image.
90 //! Fast, so preferred for interactive work (used by default).
91 //! However these extra drawings will be missed in image dump since it is performed from back buffer.
92 //! Notice that since no pre-buffering used the V-Sync will be ignored and rendering could be seen
93 //! in run-time (in case of slow hardware) and/or tearing may appear.
94 //! So this is strongly recommended to draw only simple (fast) structures.
95 //! 2. FALSE. Drawing immediate mode structures to the back buffer.
96 //! The complete scene is redrawn first, so this mode is slower if scene contains complex data and/or V-Sync
97 //! is turned on. But it works in any case and is especially useful for view dump because the dump image is read
98 //! from the back buffer.
99 //! @return previous mode.
100 Standard_EXPORT Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer) Standard_OVERRIDE;
101
102 //! Creates and maps rendering window to the view.
c357e426 103 //! @param theWindow [in] the window.
104 //! @param theContext [in] the rendering context. If NULL the context will be created internally.
a521d90d 105 Standard_EXPORT virtual void SetWindow (const Handle(Aspect_Window)& theWindow,
106 const Aspect_RenderingContext theContext) Standard_OVERRIDE;
c357e426 107
108 //! Returns window associated with the view.
79104795 109 virtual Handle(Aspect_Window) Window() const Standard_OVERRIDE
110 { return myWindow->PlatformWindow(); }
c357e426 111
112 //! Returns True if the window associated to the view is defined.
79104795 113 virtual Standard_Boolean IsDefined() const Standard_OVERRIDE
114 { return !myWindow.IsNull(); }
c357e426 115
116 //! Handle changing size of the rendering window.
117 Standard_EXPORT virtual void Resized() Standard_OVERRIDE;
118
119 //! Redraw content of the view.
120 Standard_EXPORT virtual void Redraw() Standard_OVERRIDE;
121
122 //! Redraw immediate content of the view.
123 Standard_EXPORT virtual void RedrawImmediate() Standard_OVERRIDE;
124
125 //! Marks BVH tree for given priority list as dirty and marks primitive set for rebuild.
126 Standard_EXPORT virtual void Invalidate() Standard_OVERRIDE;
127
128 //! Return true if view content cache has been invalidated.
d2eddacc 129 virtual Standard_Boolean IsInvalidated() Standard_OVERRIDE { return !myBackBufferRestored; }
c357e426 130
131 //! Displays z-buffer trihedron.
132 Standard_EXPORT virtual void TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition = Aspect_TOTP_CENTER,
133 const Quantity_NameOfColor theColor = Quantity_NOC_WHITE,
134 const Standard_Real theScale = 0.02,
135 const Standard_Boolean theAsWireframe = Standard_True) Standard_OVERRIDE;
136
137 //! Erases z-buffer trihedron.
138 Standard_EXPORT virtual void TriedronErase() Standard_OVERRIDE;
139
140 //! Setup parameters of z-buffer trihedron.
141 Standard_EXPORT virtual void ZBufferTriedronSetup (const Quantity_NameOfColor theXColor = Quantity_NOC_RED,
142 const Quantity_NameOfColor theYColor = Quantity_NOC_GREEN,
143 const Quantity_NameOfColor theZColor = Quantity_NOC_BLUE1,
144 const Standard_Real theSizeRatio = 0.8,
145 const Standard_Real theAxisDiametr = 0.05,
146 const Standard_Integer theNbFacettes = 12) Standard_OVERRIDE;
147
148 //! Displays trihedron echo.
149 Standard_EXPORT virtual void TriedronEcho (const Aspect_TypeOfTriedronEcho theType = Aspect_TOTE_NONE) Standard_OVERRIDE;
150
151 //! Returns data of a graduated trihedron
79104795 152 const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() Standard_OVERRIDE
153 { return myGTrihedronData; }
c357e426 154
155 //! Displays Graduated Trihedron.
156 Standard_EXPORT virtual void GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData) Standard_OVERRIDE;
157
158 //! Erases Graduated Trihedron.
159 Standard_EXPORT virtual void GraduatedTrihedronErase() Standard_OVERRIDE;
160
161 //! Sets minimum and maximum points of scene bounding box for Graduated Trihedron stored in graphic view object.
162 //! @param theMin [in] the minimum point of scene.
163 //! @param theMax [in] the maximum point of scene.
164 Standard_EXPORT virtual void GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax) Standard_OVERRIDE;
165
c357e426 166 //! Dump active rendering buffer into specified memory buffer.
167 Standard_EXPORT virtual Standard_Boolean BufferDump (Image_PixMap& theImage,
168 const Graphic3d_BufferType& theBufferType) Standard_OVERRIDE;
169
c357e426 170 //! Export scene into the one of the Vector graphics formats (SVG, PS, PDF...).
171 //! In contrast to Bitmaps, Vector graphics is scalable (so you may got quality benefits
172 //! on printing to laser printer). Notice however that results may differ a lot and
173 //! do not contain some elements.
174 Standard_EXPORT virtual Standard_Boolean Export (const Standard_CString theFileName,
175 const Graphic3d_ExportFormat theFormat,
176 const Graphic3d_SortType theSortType = Graphic3d_ST_BSP_Tree) Standard_OVERRIDE;
177
178 //! Marks BVH tree and the set of BVH primitives of correspondent priority list with id theLayerId as outdated.
179 Standard_EXPORT virtual void InvalidateBVHData (const Standard_Integer theLayerId) Standard_OVERRIDE;
180
181 //! Insert a new top-level z layer with the given ID.
182 Standard_EXPORT virtual void AddZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
183
184 //! Remove a z layer with the given ID.
185 Standard_EXPORT virtual void RemoveZLayer (const Graphic3d_ZLayerId theLayerId) Standard_OVERRIDE;
2166f0fa 186
c357e426 187 //! Sets the settings for a single Z layer of specified view.
188 Standard_EXPORT virtual void SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
189 const Graphic3d_ZLayerSettings& theSettings) Standard_OVERRIDE;
b5ac8292 190
50d06d8f 191 //! Returns the maximum Z layer ID.
192 //! First layer ID is Graphic3d_ZLayerId_Default, last ID is ZLayerMax().
193 Standard_EXPORT virtual Standard_Integer ZLayerMax() const Standard_OVERRIDE;
194
195 //! Returns the bounding box of all structures displayed in the Z layer.
196 //! Never fails. If Z layer does not exist nothing happens.
197 Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId) const Standard_OVERRIDE;
198
199 //! Returns the bounding box of all structures displayed in the Z layer.
3fe9ce0e 200 //! If Z layer does not exist the empty box is returned.
201 //! @param theLayerId layer identifier
202 //! @param theCamera camera definition
203 //! @param theWindowWidth viewport width (for applying transformation-persistence)
204 //! @param theWindowHeight viewport height (for applying transformation-persistence)
205 //! @param theToIncludeAuxiliary consider also auxiliary presentations (with infinite flag or with trihedron transformation persistence)
206 //! @return computed bounding box
50d06d8f 207 Standard_EXPORT virtual Graphic3d_BndBox4f ZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId,
208 const Handle(Graphic3d_Camera)& theCamera,
209 const Standard_Integer theWindowWidth,
210 const Standard_Integer theWindowHeight,
3fe9ce0e 211 const Standard_Boolean theToIncludeAuxiliary) const Standard_OVERRIDE;
50d06d8f 212
c357e426 213 //! Returns pointer to an assigned framebuffer object.
b128c892 214 Standard_EXPORT virtual Handle(Standard_Transient) FBO() const Standard_OVERRIDE;
2166f0fa 215
c357e426 216 //! Sets framebuffer object for offscreen rendering.
b128c892 217 Standard_EXPORT virtual void SetFBO (const Handle(Standard_Transient)& theFbo) Standard_OVERRIDE;
2166f0fa 218
c357e426 219 //! Generate offscreen FBO in the graphic library.
220 //! If not supported on hardware returns NULL.
b128c892 221 Standard_EXPORT virtual Handle(Standard_Transient) FBOCreate (const Standard_Integer theWidth,
222 const Standard_Integer theHeight) Standard_OVERRIDE;
2166f0fa 223
c357e426 224 //! Remove offscreen FBO from the graphic library
b128c892 225 Standard_EXPORT virtual void FBORelease (Handle(Standard_Transient)& theFbo) Standard_OVERRIDE;
2166f0fa 226
c357e426 227 //! Read offscreen FBO configuration.
b128c892 228 Standard_EXPORT virtual void FBOGetDimensions (const Handle(Standard_Transient)& theFbo,
c357e426 229 Standard_Integer& theWidth,
230 Standard_Integer& theHeight,
231 Standard_Integer& theWidthMax,
232 Standard_Integer& theHeightMax) Standard_OVERRIDE;
233
234 //! Change offscreen FBO viewport.
b128c892 235 Standard_EXPORT virtual void FBOChangeViewport (const Handle(Standard_Transient)& theFbo,
c357e426 236 const Standard_Integer theWidth,
237 const Standard_Integer theHeight) Standard_OVERRIDE;
2166f0fa 238
c357e426 239public:
2166f0fa 240
c357e426 241 //! Returns background fill color.
242 Standard_EXPORT virtual Aspect_Background Background() const Standard_OVERRIDE;
59f45b7c 243
c357e426 244 //! Sets background fill color.
245 Standard_EXPORT virtual void SetBackground (const Aspect_Background& theBackground) Standard_OVERRIDE;
59f45b7c 246
c357e426 247 //! Returns gradient background fill colors.
248 Standard_EXPORT virtual Aspect_GradientBackground GradientBackground() const Standard_OVERRIDE;
2166f0fa 249
c357e426 250 //! Sets gradient background fill colors.
251 Standard_EXPORT virtual void SetGradientBackground (const Aspect_GradientBackground& theBackground) Standard_OVERRIDE;
252
253 //! Returns background image texture file path.
254 Standard_EXPORT virtual TCollection_AsciiString BackgroundImage() Standard_OVERRIDE { return myBackgroundImagePath; }
255
256 //! Sets background image texture file path.
257 Standard_EXPORT virtual void SetBackgroundImage (const TCollection_AsciiString& theFilePath) Standard_OVERRIDE;
258
259 //! Returns background image fill style.
260 Standard_EXPORT virtual Aspect_FillMethod BackgroundImageStyle() const Standard_OVERRIDE;
261
262 //! Sets background image fill style.
263 Standard_EXPORT virtual void SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle) Standard_OVERRIDE;
264
265 //! Returns environment texture set for the view.
266 Standard_EXPORT virtual Handle(Graphic3d_TextureEnv) TextureEnv() const Standard_OVERRIDE { return myTextureEnvData; }
267
268 //! Sets environment texture for the view.
269 Standard_EXPORT virtual void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTextureEnv) Standard_OVERRIDE;
270
271 //! Returns the state of frustum culling optimization.
272 virtual Standard_Boolean IsCullingEnabled() const Standard_OVERRIDE { return myCulling; }
273
274 //! Enables or disables frustum culling optimization.
275 virtual void SetCullingEnabled (const Standard_Boolean theIsEnabled) Standard_OVERRIDE { myCulling = theIsEnabled; }
276
277 //! Returns shading model of the view.
278 virtual Graphic3d_TypeOfShadingModel ShadingModel() const Standard_OVERRIDE { return myShadingModel; }
279
280 //! Sets shading model of the view.
281 virtual void SetShadingModel (const Graphic3d_TypeOfShadingModel theModel) Standard_OVERRIDE { myShadingModel = theModel; }
282
c357e426 283 //! Return backfacing model used for the view.
284 virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const Standard_OVERRIDE { return myBackfacing; }
285
286 //! Sets backfacing model for the view.
287 virtual void SetBackfacingModel (const Graphic3d_TypeOfBackfacingModel theModel) Standard_OVERRIDE { myBackfacing = theModel; }
288
289 //! Returns camera object of the view.
290 virtual const Handle(Graphic3d_Camera)& Camera() const Standard_OVERRIDE { return myCamera; }
291
292 //! Sets camera used by the view.
293 virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) Standard_OVERRIDE { myCamera = theCamera; }
294
c357e426 295 //! Returns true if GL lighting is enabled.
296 virtual Standard_Boolean IsGLLightEnabled() const Standard_OVERRIDE { return myUseGLLight; }
297
298 //! Sets GL lighting enabled or disable state.
299 virtual void SetGLLightEnabled (const Standard_Boolean theIsEnabled) Standard_OVERRIDE { myUseGLLight = theIsEnabled; }
300
301 //! Returns list of lights of the view.
302 virtual const Graphic3d_ListOfCLight& Lights() const Standard_OVERRIDE { return myLights; }
303
304 //! Sets list of lights for the view.
305 virtual void SetLights (const Graphic3d_ListOfCLight& theLights) Standard_OVERRIDE
306 {
307 myLights = theLights;
308 myCurrLightSourceState = myStateCounter->Increment();
309 }
310
311 //! Returns list of clip planes set for the view.
3202bf1e 312 virtual const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const Standard_OVERRIDE { return myClipPlanes; }
c357e426 313
314 //! Sets list of clip planes for the view.
3202bf1e 315 virtual void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) Standard_OVERRIDE { myClipPlanes = thePlanes; }
c357e426 316
26d9c835 317 //! Fill in the dictionary with diagnostic info.
318 //! Should be called within rendering thread.
319 //!
320 //! This API should be used only for user output or for creating automated reports.
321 //! The format of returned information (e.g. key-value layout)
322 //! is NOT part of this API and can be changed at any time.
323 //! Thus application should not parse returned information to weed out specific parameters.
324 Standard_EXPORT virtual void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
325 Graphic3d_DiagnosticInfo theFlags) const Standard_OVERRIDE;
326
c357e426 327public:
328
329 //! Returns background color.
b6472664 330 const Quantity_ColorRGBA& BackgroundColor() const { return myBgColor; }
c357e426 331
332 //! Change trihedron.
333 OpenGl_Trihedron& ChangeTrihedron() { return myTrihedron; }
334
335 //! Change graduated trihedron.
336 OpenGl_GraduatedTrihedron& ChangeGraduatedTrihedron() { return myGraduatedTrihedron; }
337
338 void SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
339 const Handle(Graphic3d_TextureEnv)& theTexture);
340
2166f0fa 341 void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
c357e426 342
2166f0fa 343 void SetBackgroundGradient (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AType);
2166f0fa 344
c357e426 345 void SetBackgroundGradientType (const Aspect_GradientFillMethod AType);
2166f0fa 346
e276548b 347 //! Returns list of OpenGL Z-layers.
348 const OpenGl_LayerList& LayerList() const { return myZLayers; }
349
350 //! Returns list of openGL light sources.
351 const OpenGl_ListOfLight& LightList() const { return myLights; }
352
c357e426 353 //! Returns OpenGL window implementation.
354 const Handle(OpenGl_Window) GlWindow() const { return myWindow; }
e276548b 355
c357e426 356 //! Returns OpenGL environment map.
357 const Handle(OpenGl_Texture)& GlTextureEnv() const { return myTextureEnv; }
e276548b 358
b7cd4ba7 359 //! Returns selector for BVH tree, providing a possibility to store information
360 //! about current view volume and to detect which objects are overlapping it.
361 OpenGl_BVHTreeSelector& BVHTreeSelector() { return myBVHSelector; }
362
a1954302 363 //! Returns true if there are immediate structures to display
364 bool HasImmediateStructures() const
365 {
c3282ec1 366 return myZLayers.NbImmediateStructures() != 0;
a1954302 367 }
368
c357e426 369protected: //! @name Internal methods for managing GL resources
370
371 //! Initializes OpenGl resource for environment texture.
372 void initTextureEnv (const Handle(OpenGl_Context)& theContext);
373
a521d90d 374protected: //! @name low-level redrawing sub-routines
c357e426 375
376 //! Redraws view for the given monographic camera projection, or left/right eye.
a521d90d 377 Standard_EXPORT virtual void redraw (const Graphic3d_Camera::Projection theProjection,
378 OpenGl_FrameBuffer* theReadDrawFbo);
2166f0fa 379
c357e426 380 //! Redraws view for the given monographic camera projection, or left/right eye.
381 //!
382 //! Method will blit snapshot containing main scene (myMainSceneFbos or BackBuffer)
383 //! into presentation buffer (myMainSceneFbos -> offscreen FBO or
384 //! myMainSceneFbos -> BackBuffer or BackBuffer -> FrontBuffer),
385 //! and redraw immediate structures on top.
386 //!
387 //! When scene caching is disabled (myTransientDrawToFront, no double buffer in window, etc.),
388 //! the first step (blitting) will be skipped.
389 //!
390 //! @return false if immediate structures has been rendered directly into FrontBuffer
391 //! and Buffer Swap should not be called.
a521d90d 392 Standard_EXPORT virtual bool redrawImmediate (const Graphic3d_Camera::Projection theProjection,
393 OpenGl_FrameBuffer* theReadFbo,
394 OpenGl_FrameBuffer* theDrawFbo,
395 const Standard_Boolean theIsPartialUpdate = Standard_False);
b5ac8292 396
c357e426 397 //! Blit image from/to specified buffers.
a521d90d 398 Standard_EXPORT bool blitBuffers (OpenGl_FrameBuffer* theReadFbo,
399 OpenGl_FrameBuffer* theDrawFbo,
400 const Standard_Boolean theToFlip = Standard_False);
2166f0fa 401
c357e426 402 //! Setup default FBO.
a521d90d 403 Standard_EXPORT void bindDefaultFbo (OpenGl_FrameBuffer* theCustomFbo = NULL);
2166f0fa 404
c357e426 405protected: //! @name Rendering of GL graphics (with prepared drawing buffer).
2166f0fa 406
c357e426 407 //! Renders the graphical contents of the view into the preprepared window or framebuffer.
408 //! @param theProjection [in] the projection that should be used for rendering.
409 //! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
410 //! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
a521d90d 411 Standard_EXPORT virtual void render (Graphic3d_Camera::Projection theProjection,
412 OpenGl_FrameBuffer* theReadDrawFbo,
413 const Standard_Boolean theToDrawImmediate);
2166f0fa 414
c357e426 415 //! Renders the graphical scene.
bf02aa7d 416 //! @param theProjection [in] the projection that is used for rendering.
c357e426 417 //! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
418 //! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
bf02aa7d 419 Standard_EXPORT virtual void renderScene (Graphic3d_Camera::Projection theProjection,
420 OpenGl_FrameBuffer* theReadDrawFbo,
a521d90d 421 const Standard_Boolean theToDrawImmediate);
422
423 //! Draw background (gradient / image)
424 Standard_EXPORT virtual void drawBackground (const Handle(OpenGl_Workspace)& theWorkspace);
2166f0fa 425
c357e426 426 //! Render set of structures presented in the view.
bf02aa7d 427 //! @param theProjection [in] the projection that is used for rendering.
c357e426 428 //! @param theReadDrawFbo [in] the framebuffer for rendering graphics.
429 //! @param theToDrawImmediate [in] the flag indicates whether the rendering performs in immediate mode.
bf02aa7d 430 Standard_EXPORT virtual void renderStructs (Graphic3d_Camera::Projection theProjection,
431 OpenGl_FrameBuffer* theReadDrawFbo,
a521d90d 432 const Standard_Boolean theToDrawImmediate);
2166f0fa 433
c357e426 434 //! Renders trihedron.
435 void renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace);
2166f0fa 436
c357e426 437private:
392ac980 438
c357e426 439 //! Adds the structure to display lists of the view.
440 Standard_EXPORT virtual void displayStructure (const Handle(Graphic3d_CStructure)& theStructure,
441 const Standard_Integer thePriority) Standard_OVERRIDE;
442
443 //! Erases the structure from display lists of the view.
444 Standard_EXPORT virtual void eraseStructure (const Handle(Graphic3d_CStructure)& theStructure) Standard_OVERRIDE;
445
446 //! Change Z layer of a structure already presented in view.
447 Standard_EXPORT virtual void changeZLayer (const Handle(Graphic3d_CStructure)& theCStructure,
448 const Graphic3d_ZLayerId theNewLayerId) Standard_OVERRIDE;
449
450 //! Changes the priority of a structure within its Z layer in the specified view.
451 Standard_EXPORT virtual void changePriority (const Handle(Graphic3d_CStructure)& theCStructure,
452 const Standard_Integer theNewPriority) Standard_OVERRIDE;
453
50d06d8f 454 //! Returns zoom-scale factor.
455 Standard_EXPORT virtual Standard_Real considerZoomPersistenceObjects (const Graphic3d_ZLayerId theLayerId,
456 const Handle(Graphic3d_Camera)& theCamera,
457 const Standard_Integer theWindowWidth,
3fe9ce0e 458 const Standard_Integer theWindowHeight) const Standard_OVERRIDE;
50d06d8f 459
a521d90d 460private:
461
462 //! Copy content of Back buffer to the Front buffer.
463 void copyBackToFront();
464
465 //! Initialize blit quad.
466 OpenGl_VertexBuffer* initBlitQuad (const Standard_Boolean theToFlip);
467
468 //! Blend together views pair into stereo image.
3c4b62a4 469 void drawStereoPair (OpenGl_FrameBuffer* theDrawFbo);
a521d90d 470
c357e426 471protected:
472
473 OpenGl_GraphicDriver* myDriver;
474 Handle(OpenGl_Window) myWindow;
475 Handle(OpenGl_Workspace) myWorkspace;
476 Handle(OpenGl_Caps) myCaps;
477 Standard_Boolean& myDeviceLostFlag;
478 Standard_Boolean myWasRedrawnGL;
479
c357e426 480 Standard_Boolean myCulling;
481 Graphic3d_TypeOfShadingModel myShadingModel;
c357e426 482 Graphic3d_TypeOfBackfacingModel myBackfacing;
b6472664 483 Quantity_ColorRGBA myBgColor;
3202bf1e 484 Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
c357e426 485 Handle(Graphic3d_Camera) myCamera;
b128c892 486 Handle(OpenGl_FrameBuffer) myFBO;
c357e426 487 Standard_Boolean myUseGLLight;
488 Standard_Boolean myToShowTrihedron;
489 Standard_Boolean myToShowGradTrihedron;
490 TCollection_AsciiString myBackgroundImagePath;
491 Handle(Graphic3d_TextureEnv) myTextureEnvData;
492 Graphic3d_GraduatedTrihedron myGTrihedronData;
493
016e5959 494 OpenGl_ListOfLight myNoShadingLight;
c357e426 495 OpenGl_ListOfLight myLights;
496 OpenGl_LayerList myZLayers; //!< main list of displayed structure, sorted by layers
497
498 Graphic3d_WorldViewProjState myWorldViewProjState; //!< camera modification state
499 OpenGl_StateCounter* myStateCounter;
500 Standard_Size myCurrLightSourceState;
392ac980 501
502 typedef std::pair<Standard_Size, Standard_Size> StateInfo;
503
504 StateInfo myLastOrientationState;
505 StateInfo myLastViewMappingState;
506 StateInfo myLastLightSourceState;
30f0ad28 507
b7cd4ba7 508 //! Is needed for selection of overlapping objects and storage of the current view volume
509 OpenGl_BVHTreeSelector myBVHSelector;
510
c357e426 511 OpenGl_Trihedron myTrihedron;
512 OpenGl_GraduatedTrihedron myGraduatedTrihedron;
513
514 Handle(OpenGl_Texture) myTextureEnv;
515
c357e426 516protected: //! @name Rendering properties
517
518 //! Two framebuffers (left and right views) store cached main presentation
519 //! of the view (without presentation of immediate layers).
3c4b62a4 520 GLint myFboColorFormat; //!< sized format for color attachments
521 GLint myFboDepthFormat; //!< sized format for depth-stencil attachments
c357e426 522 Handle(OpenGl_FrameBuffer) myMainSceneFbos[2];
523 Handle(OpenGl_FrameBuffer) myImmediateSceneFbos[2]; //!< Additional buffers for immediate layer in stereo mode.
524 OpenGl_VertexBuffer myFullScreenQuad; //!< Vertices for full-screen quad rendering.
525 OpenGl_VertexBuffer myFullScreenQuadFlip;
526 Standard_Boolean myToFlipOutput; //!< Flag to draw result image upside-down
527 unsigned int myFrameCounter; //!< redraw counter, for debugging
7ccf8676 528 Standard_Boolean myHasFboBlit; //!< disable FBOs on failure
529 Standard_Boolean myToDisableMSAA; //!< disable MSAA after failure
c357e426 530 Standard_Boolean myTransientDrawToFront; //!< optimization flag for immediate mode (to render directly to the front buffer)
531 Standard_Boolean myBackBufferRestored;
532 Standard_Boolean myIsImmediateDrawn; //!< flag indicates that immediate mode buffer contains some data
533
0b0320e7 534protected: //! @name Background parameters
535
536 OpenGl_AspectFace* myTextureParams; //!< Stores texture and its parameters for textured background
537 OpenGl_BackgroundArray* myBgGradientArray; //!< Primitive array for gradient background
538 OpenGl_BackgroundArray* myBgTextureArray; //!< Primitive array for texture background
539
91c60b57 540protected: //! @name data types related to ray-tracing
541
542 //! Result of OpenGL shaders initialization.
543 enum RaytraceInitStatus
544 {
545 OpenGl_RT_NONE,
546 OpenGl_RT_INIT,
547 OpenGl_RT_FAIL
548 };
549
550 //! Describes update mode (state).
551 enum RaytraceUpdateMode
552 {
553 OpenGl_GUM_CHECK, //!< check geometry state
554 OpenGl_GUM_PREPARE, //!< collect unchanged objects
555 OpenGl_GUM_REBUILD //!< rebuild changed and new objects
556 };
557
558 //! Defines frequently used shader variables.
559 enum ShaderVariableIndex
560 {
561 OpenGl_RT_aPosition,
562
189f85a3 563 // camera position
91c60b57 564 OpenGl_RT_uOriginLT,
565 OpenGl_RT_uOriginLB,
566 OpenGl_RT_uOriginRT,
567 OpenGl_RT_uOriginRB,
568 OpenGl_RT_uDirectLT,
569 OpenGl_RT_uDirectLB,
570 OpenGl_RT_uDirectRT,
571 OpenGl_RT_uDirectRB,
1d865689 572 OpenGl_RT_uViewMat,
91c60b57 573 OpenGl_RT_uUnviewMat,
574
189f85a3 575 // 3D scene params
91c60b57 576 OpenGl_RT_uSceneRad,
577 OpenGl_RT_uSceneEps,
578 OpenGl_RT_uLightAmbnt,
579 OpenGl_RT_uLightCount,
580
189f85a3 581 // background params
582 OpenGl_RT_uBackColorTop,
583 OpenGl_RT_uBackColorBot,
91c60b57 584
189f85a3 585 // ray-tracing params
586 OpenGl_RT_uShadowsEnabled,
587 OpenGl_RT_uReflectEnabled,
588 OpenGl_RT_uSphereMapEnabled,
589 OpenGl_RT_uSphereMapForBack,
590 OpenGl_RT_uTexSamplersArray,
8c820969 591 OpenGl_RT_uBlockedRngEnabled,
189f85a3 592
593 // sampled frame params
594 OpenGl_RT_uSampleWeight,
595 OpenGl_RT_uFrameRndSeed,
596
597 // adaptive FSAA params
91c60b57 598 OpenGl_RT_uOffsetX,
599 OpenGl_RT_uOffsetY,
600 OpenGl_RT_uSamples,
91c60b57 601
602 OpenGl_RT_NbVariables // special field
603 };
604
605 //! Defines texture samplers.
606 enum ShaderSamplerNames
607 {
608 OpenGl_RT_SceneNodeInfoTexture = 0,
609 OpenGl_RT_SceneMinPointTexture = 1,
610 OpenGl_RT_SceneMaxPointTexture = 2,
611 OpenGl_RT_SceneTransformTexture = 3,
612
613 OpenGl_RT_GeometryVertexTexture = 4,
614 OpenGl_RT_GeometryNormalTexture = 5,
615 OpenGl_RT_GeometryTexCrdTexture = 6,
616 OpenGl_RT_GeometryTriangTexture = 7,
617
618 OpenGl_RT_EnvironmentMapTexture = 8,
619
620 OpenGl_RT_RaytraceMaterialTexture = 9,
621 OpenGl_RT_RaytraceLightSrcTexture = 10,
622
189f85a3 623 OpenGl_RT_FsaaInputTexture = 11,
624 OpenGl_RT_PrevAccumTexture = 12,
1d865689 625 OpenGl_RT_DepthTexture = 13,
91c60b57 626
1d865689 627 OpenGl_RT_OpenGlColorTexture = 14,
628 OpenGl_RT_OpenGlDepthTexture = 15
91c60b57 629 };
630
631 //! Tool class for management of shader sources.
632 class ShaderSource
633 {
634 public:
635
189f85a3 636 //! Default shader prefix - empty string.
637 static const TCollection_AsciiString EMPTY_PREFIX;
638
91c60b57 639 //! Creates new uninitialized shader source.
640 ShaderSource()
641 {
642 //
643 }
644
73722cc9 645 public:
189f85a3 646
73722cc9 647 //! Returns error description in case of load fail.
648 const TCollection_AsciiString& ErrorDescription() const
649 {
650 return myError;
91c60b57 651 }
652
91c60b57 653 //! Returns prefix to insert before the source.
654 const TCollection_AsciiString& Prefix() const
655 {
656 return myPrefix;
657 }
658
659 //! Sets prefix to insert before the source.
660 void SetPrefix (const TCollection_AsciiString& thePrefix)
661 {
662 myPrefix = thePrefix;
663 }
664
665 //! Returns shader source combined with prefix.
666 TCollection_AsciiString Source() const;
667
668 //! Loads shader source from specified files.
73722cc9 669 Standard_Boolean Load (const TCollection_AsciiString* theFileNames, const TCollection_AsciiString& thePrefix = EMPTY_PREFIX);
91c60b57 670
671 private:
672
673 TCollection_AsciiString mySource; //!< Source string of the shader object
674 TCollection_AsciiString myPrefix; //!< Prefix to insert before the source
73722cc9 675 TCollection_AsciiString myError; //!< error state
91c60b57 676
677 };
678
679 //! Default ray-tracing depth.
680 static const Standard_Integer THE_DEFAULT_NB_BOUNCES = 3;
681
682 //! Default size of traversal stack.
f2474958 683 static const Standard_Integer THE_DEFAULT_STACK_SIZE = 10;
91c60b57 684
685 //! Compile-time ray-tracing parameters.
686 struct RaytracingParams
687 {
688 //! Actual size of traversal stack in shader program.
689 Standard_Integer StackSize;
690
691 //! Actual ray-tracing depth (number of ray bounces).
692 Standard_Integer NbBounces;
693
f483f2ed 694 //! Enables/disables light propagation through transparent media.
91c60b57 695 Standard_Boolean TransparentShadows;
696
189f85a3 697 //! Enables/disables global illumination (GI) effects.
698 Standard_Boolean GlobalIllumination;
699
f483f2ed 700 //! Enables/disables the use of OpenGL bindless textures.
701 Standard_Boolean UseBindlessTextures;
702
91c60b57 703 //! Creates default compile-time ray-tracing parameters.
704 RaytracingParams()
705 : StackSize (THE_DEFAULT_STACK_SIZE),
706 NbBounces (THE_DEFAULT_NB_BOUNCES),
f483f2ed 707 TransparentShadows (Standard_False),
189f85a3 708 GlobalIllumination (Standard_False),
f483f2ed 709 UseBindlessTextures (Standard_False)
91c60b57 710 {
711 //
712 }
713 };
714
d4aaad5b 715 //! Describes state of OpenGL structure.
716 struct StructState
717 {
718 Standard_Size StructureState;
719 Standard_Size InstancedState;
720
721 //! Creates new structure state.
722 StructState (const Standard_Size theStructureState = 0,
723 const Standard_Size theInstancedState = 0)
724 : StructureState (theStructureState),
725 InstancedState (theInstancedState)
726 {
727 //
728 }
729
730 //! Creates new structure state.
731 StructState (const OpenGl_Structure* theStructure)
732 {
733 StructureState = theStructure->ModificationState();
734
735 InstancedState = theStructure->InstancedStructure() != NULL ?
736 theStructure->InstancedStructure()->ModificationState() : 0;
737 }
738 };
739
91c60b57 740protected: //! @name methods related to ray-tracing
741
742 //! Updates 3D scene geometry for ray-tracing.
743 Standard_Boolean updateRaytraceGeometry (const RaytraceUpdateMode theMode,
744 const Standard_Integer theViewId,
745 const Handle(OpenGl_Context)& theGlContext);
746
747 //! Updates 3D scene light sources for ray-tracing.
748 Standard_Boolean updateRaytraceLightSources (const OpenGl_Mat4& theInvModelView, const Handle(OpenGl_Context)& theGlContext);
749
750 //! Updates environment map for ray-tracing.
751 Standard_Boolean updateRaytraceEnvironmentMap (const Handle(OpenGl_Context)& theGlContext);
752
753 //! Checks to see if the OpenGL structure is modified.
754 Standard_Boolean toUpdateStructure (const OpenGl_Structure* theStructure);
755
756 //! Adds OpenGL structure to ray-traced scene geometry.
757 Standard_Boolean addRaytraceStructure (const OpenGl_Structure* theStructure,
758 const Handle(OpenGl_Context)& theGlContext);
759
760 //! Adds OpenGL groups to ray-traced scene geometry.
8c820969 761 Standard_Boolean addRaytraceGroups (const OpenGl_Structure* theStructure,
762 const OpenGl_RaytraceMaterial& theStructMat,
6bd94e0d 763 const Graphic3d_Mat4* theTransform,
8c820969 764 const Handle(OpenGl_Context)& theGlContext);
91c60b57 765
766 //! Creates ray-tracing material properties.
767 OpenGl_RaytraceMaterial convertMaterial (const OpenGl_AspectFace* theAspect,
768 const Handle(OpenGl_Context)& theGlContext);
769
770 //! Adds OpenGL primitive array to ray-traced scene geometry.
771 OpenGl_TriangleSet* addRaytracePrimitiveArray (const OpenGl_PrimitiveArray* theArray,
772 const Standard_Integer theMatID,
773 const OpenGl_Mat4* theTrans);
774
775 //! Adds vertex indices from OpenGL primitive array to ray-traced scene geometry.
776 Standard_Boolean addRaytraceVertexIndices (OpenGl_TriangleSet& theSet,
777 const Standard_Integer theMatID,
778 const Standard_Integer theCount,
779 const Standard_Integer theOffset,
780 const OpenGl_PrimitiveArray& theArray);
781
782 //! Adds OpenGL triangle array to ray-traced scene geometry.
783 Standard_Boolean addRaytraceTriangleArray (OpenGl_TriangleSet& theSet,
784 const Standard_Integer theMatID,
785 const Standard_Integer theCount,
786 const Standard_Integer theOffset,
787 const Handle(Graphic3d_IndexBuffer)& theIndices);
788
789 //! Adds OpenGL triangle fan array to ray-traced scene geometry.
790 Standard_Boolean addRaytraceTriangleFanArray (OpenGl_TriangleSet& theSet,
791 const Standard_Integer theMatID,
792 const Standard_Integer theCount,
793 const Standard_Integer theOffset,
794 const Handle(Graphic3d_IndexBuffer)& theIndices);
795
796 //! Adds OpenGL triangle strip array to ray-traced scene geometry.
797 Standard_Boolean addRaytraceTriangleStripArray (OpenGl_TriangleSet& theSet,
798 const Standard_Integer theMatID,
799 const Standard_Integer theCount,
800 const Standard_Integer theOffset,
801 const Handle(Graphic3d_IndexBuffer)& theIndices);
802
803 //! Adds OpenGL quadrangle array to ray-traced scene geometry.
804 Standard_Boolean addRaytraceQuadrangleArray (OpenGl_TriangleSet& theSet,
805 const Standard_Integer theMatID,
806 const Standard_Integer theCount,
807 const Standard_Integer theOffset,
808 const Handle(Graphic3d_IndexBuffer)& theIndices);
809
810 //! Adds OpenGL quadrangle strip array to ray-traced scene geometry.
811 Standard_Boolean addRaytraceQuadrangleStripArray (OpenGl_TriangleSet& theSet,
812 const Standard_Integer theMatID,
813 const Standard_Integer theCount,
814 const Standard_Integer theOffset,
815 const Handle(Graphic3d_IndexBuffer)& theIndices);
816
817 //! Adds OpenGL polygon array to ray-traced scene geometry.
818 Standard_Boolean addRaytracePolygonArray (OpenGl_TriangleSet& theSet,
819 const Standard_Integer theMatID,
820 const Standard_Integer theCount,
821 const Standard_Integer theOffset,
822 const Handle(Graphic3d_IndexBuffer)& theIndices);
823
824 //! Uploads ray-trace data to the GPU.
825 Standard_Boolean uploadRaytraceData (const Handle(OpenGl_Context)& theGlContext);
826
827 //! Generates shader prefix based on current ray-tracing options.
828 TCollection_AsciiString generateShaderPrefix (const Handle(OpenGl_Context)& theGlContext) const;
829
830 //! Performs safe exit when shaders initialization fails.
831 Standard_Boolean safeFailBack (const TCollection_ExtendedString& theMessage,
832 const Handle(OpenGl_Context)& theGlContext);
833
834 //! Loads and compiles shader object from specified source.
835 Handle(OpenGl_ShaderObject) initShader (const GLenum theType,
836 const ShaderSource& theSource,
837 const Handle(OpenGl_Context)& theGlContext);
838
189f85a3 839 //! Creates shader program from the given vertex and fragment shaders.
840 Handle(OpenGl_ShaderProgram) initProgram (const Handle(OpenGl_Context)& theGlContext,
841 const Handle(OpenGl_ShaderObject)& theVertShader,
842 const Handle(OpenGl_ShaderObject)& theFragShader);
843
91c60b57 844 //! Initializes OpenGL/GLSL shader programs.
c357e426 845 Standard_Boolean initRaytraceResources (const Handle(OpenGl_Context)& theGlContext);
91c60b57 846
847 //! Releases OpenGL/GLSL shader programs.
848 void releaseRaytraceResources (const Handle(OpenGl_Context)& theGlContext);
849
bf02aa7d 850 //! Updates auxiliary OpenGL frame buffers.
851 Standard_Boolean updateRaytraceBuffers (const Standard_Integer theSizeX,
91c60b57 852 const Standard_Integer theSizeY,
853 const Handle(OpenGl_Context)& theGlContext);
854
855 //! Generates viewing rays for corners of screen quad.
856 void updateCamera (const OpenGl_Mat4& theOrientation,
857 const OpenGl_Mat4& theViewMapping,
858 OpenGl_Vec3* theOrigins,
859 OpenGl_Vec3* theDirects,
1d865689 860 OpenGl_Mat4& theView,
91c60b57 861 OpenGl_Mat4& theUnView);
862
863 //! Binds ray-trace textures to corresponding texture units.
864 void bindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext);
865
866 //! Unbinds ray-trace textures from corresponding texture unit.
867 void unbindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext);
868
869 //! Sets uniform state for the given ray-tracing shader program.
c357e426 870 Standard_Boolean setUniformState (const OpenGl_Vec3* theOrigins,
91c60b57 871 const OpenGl_Vec3* theDirects,
1d865689 872 const OpenGl_Mat4& theViewMat,
91c60b57 873 const OpenGl_Mat4& theUnviewMat,
874 const Standard_Integer theProgramId,
875 const Handle(OpenGl_Context)& theGlContext);
876
877 //! Runs ray-tracing shader programs.
c357e426 878 Standard_Boolean runRaytraceShaders (const Standard_Integer theSizeX,
91c60b57 879 const Standard_Integer theSizeY,
880 const OpenGl_Vec3* theOrigins,
881 const OpenGl_Vec3* theDirects,
1d865689 882 const OpenGl_Mat4& theViewMat,
91c60b57 883 const OpenGl_Mat4& theUnviewMat,
bf02aa7d 884 Graphic3d_Camera::Projection theProjection,
38a0206f 885 OpenGl_FrameBuffer* theReadDrawFbo,
91c60b57 886 const Handle(OpenGl_Context)& theGlContext);
887
888 //! Redraws the window using OpenGL/GLSL ray-tracing.
c357e426 889 Standard_Boolean raytrace (const Standard_Integer theSizeX,
91c60b57 890 const Standard_Integer theSizeY,
bf02aa7d 891 Graphic3d_Camera::Projection theProjection,
38a0206f 892 OpenGl_FrameBuffer* theReadDrawFbo,
91c60b57 893 const Handle(OpenGl_Context)& theGlContext);
894
895protected: //! @name fields related to ray-tracing
896
897 //! Result of shaders initialization.
898 RaytraceInitStatus myRaytraceInitStatus;
899
900 //! Is geometry data valid?
901 Standard_Boolean myIsRaytraceDataValid;
902
903 //! Warning about missing extension GL_ARB_bindless_texture has been displayed?
904 Standard_Boolean myIsRaytraceWarnTextures;
905
906 //! 3D scene geometry data for ray-tracing.
907 OpenGl_RaytraceGeometry myRaytraceGeometry;
908
909 //! Compile-time ray-tracing parameters.
910 RaytracingParams myRaytraceParameters;
911
912 //! Radius of bounding sphere of the scene.
913 Standard_ShortReal myRaytraceSceneRadius;
914 //! Scene epsilon to prevent self-intersections.
915 Standard_ShortReal myRaytraceSceneEpsilon;
916
917 //! OpenGL/GLSL source of ray-tracing fragment shader.
918 ShaderSource myRaytraceShaderSource;
919 //! OpenGL/GLSL source of adaptive-AA fragment shader.
920 ShaderSource myPostFSAAShaderSource;
921
922 //! OpenGL/GLSL ray-tracing fragment shader.
923 Handle(OpenGl_ShaderObject) myRaytraceShader;
924 //! OpenGL/GLSL adaptive-AA fragment shader.
925 Handle(OpenGl_ShaderObject) myPostFSAAShader;
926
927 //! OpenGL/GLSL ray-tracing shader program.
928 Handle(OpenGl_ShaderProgram) myRaytraceProgram;
929 //! OpenGL/GLSL adaptive-AA shader program.
930 Handle(OpenGl_ShaderProgram) myPostFSAAProgram;
189f85a3 931 //! OpenGL/GLSL program for displaying texture.
932 Handle(OpenGl_ShaderProgram) myOutImageProgram;
91c60b57 933
934 //! Texture buffer of data records of bottom-level BVH nodes.
935 Handle(OpenGl_TextureBufferArb) mySceneNodeInfoTexture;
936 //! Texture buffer of minimum points of bottom-level BVH nodes.
937 Handle(OpenGl_TextureBufferArb) mySceneMinPointTexture;
938 //! Texture buffer of maximum points of bottom-level BVH nodes.
939 Handle(OpenGl_TextureBufferArb) mySceneMaxPointTexture;
940 //! Texture buffer of transformations of high-level BVH nodes.
941 Handle(OpenGl_TextureBufferArb) mySceneTransformTexture;
942
943 //! Texture buffer of vertex coords.
944 Handle(OpenGl_TextureBufferArb) myGeometryVertexTexture;
945 //! Texture buffer of vertex normals.
946 Handle(OpenGl_TextureBufferArb) myGeometryNormalTexture;
947 //! Texture buffer of vertex UV coords.
948 Handle(OpenGl_TextureBufferArb) myGeometryTexCrdTexture;
949 //! Texture buffer of triangle indices.
950 Handle(OpenGl_TextureBufferArb) myGeometryTriangTexture;
951
952 //! Texture buffer of material properties.
953 Handle(OpenGl_TextureBufferArb) myRaytraceMaterialTexture;
954 //! Texture buffer of light source properties.
955 Handle(OpenGl_TextureBufferArb) myRaytraceLightSrcTexture;
956
957 //! 1st framebuffer (FBO) to perform adaptive FSAA.
bf02aa7d 958 Handle(OpenGl_FrameBuffer) myRaytraceFBO1[2];
91c60b57 959 //! 2nd framebuffer (FBO) to perform adaptive FSAA.
bf02aa7d 960 Handle(OpenGl_FrameBuffer) myRaytraceFBO2[2];
91c60b57 961 //! Framebuffer (FBO) for preliminary OpenGL output.
962 Handle(OpenGl_FrameBuffer) myOpenGlFBO;
3c4b62a4 963 Handle(OpenGl_FrameBuffer) myOpenGlFBO2;
91c60b57 964
965 //! Vertex buffer (VBO) for drawing dummy quad.
966 OpenGl_VertexBuffer myRaytraceScreenQuad;
967
968 //! Cached locations of frequently used uniform variables.
969 Standard_Integer myUniformLocations[2][OpenGl_RT_NbVariables];
970
971 //! State of OpenGL structures reflected to ray-tracing.
d4aaad5b 972 std::map<const OpenGl_Structure*, StructState> myStructureStates;
91c60b57 973
974 //! PrimitiveArray to TriangleSet map for scene partial update.
975 std::map<Standard_Size, OpenGl_TriangleSet*> myArrayToTrianglesMap;
976
189f85a3 977 //! Set of IDs of non-raytracable elements (to detect updates).
978 std::set<Standard_Integer> myNonRaytraceStructureIDs;
979
980 //! Render filter to filter out all raytracable structures.
91c60b57 981 Handle(OpenGl_RaytraceFilter) myRaytraceFilter;
982
983 //! Marks if environment map should be updated.
984 Standard_Boolean myToUpdateEnvironmentMap;
985
986 //! State of OpenGL layer list.
189f85a3 987 Standard_Size myLayerListState;
988
989 //! Number of accumulated frames (for progressive rendering).
990 Standard_Integer myAccumFrames;
991
992 //! Stored ray origins used for detection of camera movements.
993 OpenGl_Vec3 myPreviousOrigins[3];
994
995 //! Bullard RNG to produce random sequence.
996 math_BullardGenerator myRNG;
91c60b57 997
679ecdee 998public:
999
1c35b92f 1000 DEFINE_STANDARD_ALLOC
92efcf78 1001 DEFINE_STANDARD_RTTIEXT(OpenGl_View,Graphic3d_CView) // Type definition
679ecdee 1002
c357e426 1003 friend class OpenGl_GraphicDriver;
a89742cf 1004 friend class OpenGl_Workspace;
2166f0fa
SK
1005};
1006
679ecdee 1007#endif // _OpenGl_View_Header