0027943: Visualization - fix broken shading by positional light for object with local...
[occt.git] / src / OpenGl / OpenGl_Caps.hxx
1 // Created on: 2013-08-25
2 // Created by: Kirill GAVRILOV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _OpenGl_Caps_H__
17 #define _OpenGl_Caps_H__
18
19 #include <Standard_Type.hxx>
20 #include <Standard_Transient.hxx>
21
22 //! Class to define graphic driver capabilities.
23 //! Notice that these options will be ignored if particular functionality does not provided by GL driver
24 class OpenGl_Caps : public Standard_Transient
25 {
26
27 public: //! @name flags to disable particular functionality, should be used only for testing purposes!
28
29   Standard_Boolean vboDisable;        //!< flag permits VBO usage, will significantly affect performance (OFF by default)
30   Standard_Boolean pntSpritesDisable; //!< flag permits Point Sprites usage, will significantly affect performance (OFF by default)
31   Standard_Boolean keepArrayData;     //!< Disables freeing CPU memory after building VBOs (OFF by default)
32   Standard_Boolean ffpEnable;         //!< Enables FFP (fixed-function pipeline), do not use built-in GLSL programs (ON by default on desktop OpenGL and OFF on OpenGL ES)
33   Standard_Boolean useSystemBuffer;   //!< Enables usage of system backbuffer for blitting (OFF by default on desktop OpenGL and ON on OpenGL ES for testing)
34   Standard_Integer swapInterval;      //!< controls swap interval - 0 for VSync off and 1 for VSync on, 1 by default
35
36 public: //! @name context creation parameters
37
38   /**
39    * Specify that driver should not swap back/front buffers at the end of frame.
40    * Useful when OCCT Viewer is integrated into existing OpenGL rendering pipeline as part,
41    * thus swapping part is performed outside.
42    *
43    * OFF by default.
44    */
45   Standard_Boolean buffersNoSwap;
46
47   /**
48    * Request stereoscopic context (with Quad Buffer). This flag requires support in OpenGL driver.
49    *
50    * OFF by default.
51    */
52   Standard_Boolean contextStereo;
53
54   /**
55    * Request debug GL context. This flag requires support in OpenGL driver.
56    *
57    * When turned on OpenGL driver emits error and warning messages to provided callback
58    * (see OpenGl_Context - messages will be printed to standard output).
59    * Affects performance - thus should not be turned on by products in released state.
60    *
61    * OFF by default. Currently implemented only for Windows (WGL).
62    */
63   Standard_Boolean contextDebug;
64
65   /**
66    * Request debug GL context to emit messages within main thread (when contextDebug is specified!).
67    *
68    * Some implementations performs GL rendering within dedicated thread(s),
69    * in this case debug messages will be pushed from unknown thread making call stack useless,
70    * since it does not interconnected to application calls.
71    * This option asks GL driver to switch into synchronized implementation.
72    * Affects performance - thus should not be turned on by products in released state.
73    *
74    * OFF by default.
75    */
76   Standard_Boolean contextSyncDebug;
77
78   /**
79    * Disable hardware acceleration.
80    *
81    * This flag overrides default behavior, when accelerated context always preferred over software ones:
82    * - on Windows will force Microsoft software implementation;
83    * - on Mac OS X, forces Apple software implementation.
84    *
85    * Software implementations are dramatically slower - should never be used.
86    *
87    * OFF by default. Currently implemented only for Windows (WGL) and Mac OS X (Cocoa).
88    */
89   Standard_Boolean contextNoAccel;
90
91   /**
92    * Request backward-compatible GL context. This flag requires support in OpenGL driver.
93    *
94    * Backward-compatible profile includes deprecated functionality like FFP (fixed-function pipeline),
95    * and might be useful for compatibility with application OpenGL code.
96    *
97    * Most drivers support all features within backward-compatibility profile,
98    * but some limit functionality to OpenGL 2.1 (e.g. OS X) when core profile is not explicitly requested.
99    *
100    * Requires OpenGL 3.2+ drivers.
101    * Has no effect on OpenGL ES 2.0+ drivers (which do not provie FFP compatibility).
102    * Interacts with ffpEnable option, which should be disabled within core profile.
103    *
104    * ON by default.
105    */
106   Standard_Boolean contextCompatible;
107
108 public: //! @name flags to activate verbose output
109
110   //! Print GLSL program compilation/linkage warnings, if any. OFF by default.
111   Standard_Boolean glslWarnings;
112
113   //! Suppress redundant messages from debug GL context. ON by default.
114   Standard_Boolean suppressExtraMsg;
115
116 public: //! @name class methods
117
118   //! Default constructor - initialize with most optimal values.
119   Standard_EXPORT OpenGl_Caps();
120
121   //! Destructor.
122   Standard_EXPORT virtual ~OpenGl_Caps();
123
124   //! Copy maker.
125   Standard_EXPORT OpenGl_Caps& operator= (const OpenGl_Caps& theCopy);
126
127 private:
128
129   //! Not implemented
130   OpenGl_Caps (const OpenGl_Caps& );
131
132 public:
133
134   DEFINE_STANDARD_RTTIEXT(OpenGl_Caps,Standard_Transient) // Type definition
135
136 };
137
138 DEFINE_STANDARD_HANDLE(OpenGl_Caps, Standard_Transient)
139
140 #endif // _OpenGl_Caps_H__