1 // Created on: 2013-08-25
2 // Created by: Kirill GAVRILOV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef OpenGl_Caps_HeaderFile
17 #define OpenGl_Caps_HeaderFile
19 #include <Standard_Type.hxx>
20 #include <Standard_Transient.hxx>
21 #include <OpenGl_ShaderProgramDumpLevel.hxx>
23 //! Class to define graphic driver capabilities.
24 //! Notice that these options will be ignored if particular functionality does not provided by GL driver
25 class OpenGl_Caps : public Standard_Transient
28 public: //! @name flags to disable particular functionality, should be used only for testing purposes!
30 Standard_Boolean sRGBDisable; //!< Disables sRGB rendering (OFF by default)
31 Standard_Boolean compressedTexturesDisable; //!< Disables uploading of compressed texture formats native to GPU (OFF by default)
32 Standard_Boolean vboDisable; //!< disallow VBO usage for debugging purposes (OFF by default)
33 Standard_Boolean pntSpritesDisable; //!< flag permits Point Sprites usage, will significantly affect performance (OFF by default)
34 Standard_Boolean keepArrayData; //!< Disables freeing CPU memory after building VBOs (OFF by default)
35 Standard_Boolean ffpEnable; //!< Enables FFP (fixed-function pipeline), do not use built-in GLSL programs (OFF by default)
36 Standard_Boolean usePolygonMode; //!< Enables Polygon Mode instead of built-in GLSL programs (OFF by default; unsupported on OpenGL ES)
37 Standard_Boolean useSystemBuffer; //!< Enables usage of system backbuffer for blitting (OFF by default on desktop OpenGL and ON on OpenGL ES for testing)
38 Standard_Integer swapInterval; //!< controls swap interval - 0 for VSync off and 1 for VSync on, 1 by default
39 Standard_Boolean useZeroToOneDepth; //!< use [0, 1] depth range instead of [-1, 1] range, when possible (OFF by default)
41 public: //! @name context creation parameters
44 * Specify that driver should not swap back/front buffers at the end of frame.
45 * Useful when OCCT Viewer is integrated into existing OpenGL rendering pipeline as part,
46 * thus swapping part is performed outside.
50 Standard_Boolean buffersNoSwap;
53 * Specify whether alpha component within color buffer should be written or not.
54 * With alpha write enabled, background is considered transparent by default
55 * and overridden by alpha value of last drawn object
56 * (e.g. it could be opaque or not in case of transparent material).
57 * With alpha writes disabled, color buffer will be kept opaque.
61 Standard_Boolean buffersOpaqueAlpha;
64 * Specify whether deep color format (10-bit per component / 30-bit RGB) should be used
65 * instead of standard color format (8-bit per component / 24-bit RGB) when available.
66 * Deep color provides higher accuracy within the same color range (sRGB)
67 * and doesn't enable wide color gamut / HDR support.
68 * Higher precision helps eliminating banding effect on smooth gradients.
70 * Effect of the flag will vary depending on platform:
71 * - used as a hint on systems with 24-bit RGB color defined as preferred pixels format
72 * but with 30-bit RGB color being activated systemwide (e.g. Windows);
73 * - ignored on systems with deep color defined as preferred pixel format (e.g. Linux / X11),
74 * deep 30-bit RGB color will be used regardless of the flag value;
75 * - ignored on configurations not supporting deep color (incompatible display / system / GPU / driver),
76 * standard 24-bit RGB color will be used instead.
80 Standard_Boolean buffersDeepColor;
83 * Request stereoscopic context (with Quad Buffer). This flag requires support in OpenGL driver.
87 Standard_Boolean contextStereo;
90 * Request debug GL context. This flag requires support in OpenGL driver.
92 * When turned on OpenGL driver emits error and warning messages to provided callback
93 * (see OpenGl_Context - messages will be printed to standard output).
94 * Affects performance - thus should not be turned on by products in released state.
98 Standard_Boolean contextDebug;
101 * Request debug GL context to emit messages within main thread (when contextDebug is specified!).
103 * Some implementations performs GL rendering within dedicated thread(s),
104 * in this case debug messages will be pushed from unknown thread making call stack useless,
105 * since it does not interconnected to application calls.
106 * This option asks GL driver to switch into synchronized implementation.
107 * Affects performance - thus should not be turned on by products in released state.
111 Standard_Boolean contextSyncDebug;
114 * Disable hardware acceleration.
116 * This flag overrides default behavior, when accelerated context always preferred over software ones:
117 * - on Windows will force Microsoft software implementation;
118 * - on Mac OS X, forces Apple software implementation.
120 * Software implementations are dramatically slower - should never be used.
122 * OFF by default. Currently implemented only for Windows (WGL) and Mac OS X (Cocoa).
124 Standard_Boolean contextNoAccel;
127 * Request backward-compatible GL context. This flag requires support in OpenGL driver.
129 * Backward-compatible profile includes deprecated functionality like FFP (fixed-function pipeline),
130 * and might be useful for compatibility with application OpenGL code.
132 * Most drivers support all features within backward-compatibility profile,
133 * but some limit functionality to OpenGL 2.1 (e.g. OS X) when core profile is not explicitly requested.
135 * Requires OpenGL 3.2+ drivers.
136 * Has no effect on OpenGL ES 2.0+ drivers (which do not provide FFP compatibility).
137 * Interacts with ffpEnable option, which should be disabled within core profile.
141 Standard_Boolean contextCompatible;
144 * Disallow using OpenGL extensions.
145 * Should be used for debugging purposes only!
149 Standard_Boolean contextNoExtensions;
152 * Synthetically restrict upper version of OpenGL functionality to be used.
153 * Should be used for debugging purposes only!
155 * (-1, -1) by default, which means no restriction.
157 Standard_Integer contextMajorVersionUpper;
158 Standard_Integer contextMinorVersionUpper;
161 * Define if 2D texture UV coordinates are defined top-down or bottom-up. FALSE by default.
163 * Proper rendering requires image texture uploading and UV texture coordinates being consistent,
164 * otherwise texture mapping might appear vertically flipped.
165 * Historically, OCCT used image library loading images bottom-up,
166 * so that applications have to generate UV accordingly (flip V when necessary, V' = 1.0 - V).
168 * Graphic driver now compares this flag with image layout reported by Image_PixMap::IsTopDown(),
169 * and in case of mismatch applies implicit texture coordinates conversion in GLSL program.
171 Standard_Boolean isTopDownTextureUV;
173 public: //! @name flags to activate verbose output
175 //! Print GLSL program compilation/linkage warnings, if any. OFF by default.
176 Standard_Boolean glslWarnings;
178 //! Suppress redundant messages from debug GL context. ON by default.
179 Standard_Boolean suppressExtraMsg;
181 //! Print GLSL program source code. OFF by default.
182 OpenGl_ShaderProgramDumpLevel glslDumpLevel;
184 public: //! @name class methods
186 //! Default constructor - initialize with most optimal values.
187 Standard_EXPORT OpenGl_Caps();
190 Standard_EXPORT virtual ~OpenGl_Caps();
193 Standard_EXPORT OpenGl_Caps& operator= (const OpenGl_Caps& theCopy);
198 OpenGl_Caps (const OpenGl_Caps& );
202 DEFINE_STANDARD_RTTIEXT(OpenGl_Caps,Standard_Transient) // Type definition
206 DEFINE_STANDARD_HANDLE(OpenGl_Caps, Standard_Transient)
208 #endif // _OpenGl_Caps_H__