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