Commit | Line | Data |
---|---|---|
6aca4d39 | 1 | // Created on: 2012-01-26 |
b311480e | 2 | // Created by: Kirill GAVRILOV |
6aca4d39 | 3 | // Copyright (c) 2012-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_Context_H__ |
17 | #define _OpenGl_Context_H__ | |
18 | ||
2bd4c032 | 19 | #include <Aspect_Handle.hxx> |
6d0e6be5 | 20 | #include <Aspect_HatchStyle.hxx> |
2bd4c032 | 21 | #include <Aspect_Drawable.hxx> |
22 | #include <Aspect_Display.hxx> | |
23 | #include <Aspect_RenderingContext.hxx> | |
ac116c22 | 24 | #include <Aspect_TypeOfLine.hxx> |
5e27df78 | 25 | #include <NCollection_DataMap.hxx> |
26d9c835 | 26 | #include <Graphic3d_DiagnosticInfo.hxx> |
cc8cbabe | 27 | #include <Graphic3d_TextureUnit.hxx> |
4269bd1b | 28 | #include <NCollection_Map.hxx> |
5e27df78 | 29 | #include <NCollection_Handle.hxx> |
3125ebb6 | 30 | #include <NCollection_List.hxx> |
a1073ae2 | 31 | #include <NCollection_SparseArray.hxx> |
cbf18624 | 32 | #include <Message.hxx> |
58655684 | 33 | #include <OpenGl_Caps.hxx> |
6d0e6be5 | 34 | #include <OpenGl_LineAttributes.hxx> |
8613985b | 35 | #include <OpenGl_Material.hxx> |
825aa485 | 36 | #include <OpenGl_MatrixState.hxx> |
8625ef7e | 37 | #include <OpenGl_Vec.hxx> |
5e27df78 | 38 | #include <OpenGl_Resource.hxx> |
cc8cbabe | 39 | #include <OpenGl_TextureSet.hxx> |
2166f0fa | 40 | #include <Standard_Transient.hxx> |
26d9c835 | 41 | #include <TColStd_IndexedDataMapOfStringString.hxx> |
c87535af | 42 | #include <TColStd_PackedMapOfInteger.hxx> |
30f0ad28 | 43 | #include <OpenGl_Clipping.hxx> |
b5ac8292 | 44 | #include <OpenGl_GlCore11.hxx> |
c04c30b3 | 45 | |
46 | #include <NCollection_Shared.hxx> | |
2166f0fa | 47 | |
5f8b738e | 48 | //! Forward declarations |
a2e4f780 | 49 | #if defined(__APPLE__) |
50 | #import <TargetConditionals.h> | |
51 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE | |
52 | #ifdef __OBJC__ | |
53 | @class EAGLContext; | |
54 | #else | |
55 | struct EAGLContext; | |
56 | #endif | |
57 | #else | |
58 | #ifdef __OBJC__ | |
59 | @class NSOpenGLContext; | |
60 | #else | |
61 | struct NSOpenGLContext; | |
62 | #endif | |
63 | #endif | |
64 | #endif | |
65 | ||
01ca42b2 | 66 | struct OpenGl_GlFunctions; |
5e27df78 | 67 | struct OpenGl_ArbTBO; |
68 | struct OpenGl_ArbIns; | |
58655684 | 69 | struct OpenGl_ArbDbg; |
01ca42b2 | 70 | struct OpenGl_ArbFBO; |
b86bb3df | 71 | struct OpenGl_ArbFBOBlit; |
cc8cbabe | 72 | struct OpenGl_ArbSamplerObject; |
25ef750e | 73 | struct OpenGl_ArbTexBindless; |
cc8cbabe | 74 | struct OpenGl_ExtGS; |
2166f0fa | 75 | |
01ca42b2 | 76 | template<typename theBaseClass_t> struct OpenGl_TmplCore12; |
77 | typedef OpenGl_TmplCore12<OpenGl_GlCore11> OpenGl_GlCore12; | |
78 | typedef OpenGl_TmplCore12<OpenGl_GlCore11Fwd> OpenGl_GlCore12Fwd; | |
79 | ||
80 | struct OpenGl_GlCore13; | |
81 | struct OpenGl_GlCore13Fwd; | |
82 | ||
83 | template<typename theBaseClass_t> struct OpenGl_TmplCore14; | |
84 | typedef OpenGl_TmplCore14<OpenGl_GlCore13> OpenGl_GlCore14; | |
85 | typedef OpenGl_TmplCore14<OpenGl_GlCore13Fwd> OpenGl_GlCore14Fwd; | |
86 | ||
87 | template<typename theBaseClass_t> struct OpenGl_TmplCore15; | |
88 | typedef OpenGl_TmplCore15<OpenGl_GlCore14> OpenGl_GlCore15; | |
89 | typedef OpenGl_TmplCore15<OpenGl_GlCore14Fwd> OpenGl_GlCore15Fwd; | |
90 | ||
91 | template<typename theBaseClass_t> struct OpenGl_TmplCore20; | |
92 | typedef OpenGl_TmplCore20<OpenGl_GlCore15> OpenGl_GlCore20; | |
93 | typedef OpenGl_TmplCore20<OpenGl_GlCore15Fwd> OpenGl_GlCore20Fwd; | |
94 | ||
95 | template<typename theBaseClass_t> struct OpenGl_TmplCore21; | |
96 | typedef OpenGl_TmplCore21<OpenGl_GlCore20> OpenGl_GlCore21; | |
97 | typedef OpenGl_TmplCore21<OpenGl_GlCore20Fwd> OpenGl_GlCore21Fwd; | |
98 | ||
99 | template<typename theBaseClass_t> struct OpenGl_TmplCore30; | |
100 | typedef OpenGl_TmplCore30<OpenGl_GlCore21> OpenGl_GlCore30; | |
101 | typedef OpenGl_TmplCore30<OpenGl_GlCore21Fwd> OpenGl_GlCore30Fwd; | |
102 | ||
103 | template<typename theBaseClass_t> struct OpenGl_TmplCore31; | |
104 | typedef OpenGl_TmplCore31<OpenGl_GlCore30> OpenGl_GlCore31Back; | |
105 | typedef OpenGl_TmplCore31<OpenGl_GlCore30Fwd> OpenGl_GlCore31; | |
106 | ||
107 | template<typename theBaseClass_t> struct OpenGl_TmplCore32; | |
108 | typedef OpenGl_TmplCore32<OpenGl_GlCore31Back> OpenGl_GlCore32Back; | |
109 | typedef OpenGl_TmplCore32<OpenGl_GlCore31> OpenGl_GlCore32; | |
110 | ||
111 | template<typename theBaseClass_t> struct OpenGl_TmplCore33; | |
112 | typedef OpenGl_TmplCore33<OpenGl_GlCore32Back> OpenGl_GlCore33Back; | |
113 | typedef OpenGl_TmplCore33<OpenGl_GlCore32> OpenGl_GlCore33; | |
114 | ||
115 | template<typename theBaseClass_t> struct OpenGl_TmplCore40; | |
116 | typedef OpenGl_TmplCore40<OpenGl_GlCore33Back> OpenGl_GlCore40Back; | |
117 | typedef OpenGl_TmplCore40<OpenGl_GlCore33> OpenGl_GlCore40; | |
118 | ||
119 | template<typename theBaseClass_t> struct OpenGl_TmplCore41; | |
120 | typedef OpenGl_TmplCore41<OpenGl_GlCore40Back> OpenGl_GlCore41Back; | |
121 | typedef OpenGl_TmplCore41<OpenGl_GlCore40> OpenGl_GlCore41; | |
122 | ||
123 | template<typename theBaseClass_t> struct OpenGl_TmplCore42; | |
124 | typedef OpenGl_TmplCore42<OpenGl_GlCore41Back> OpenGl_GlCore42Back; | |
125 | typedef OpenGl_TmplCore42<OpenGl_GlCore41> OpenGl_GlCore42; | |
126 | ||
127 | template<typename theBaseClass_t> struct OpenGl_TmplCore43; | |
128 | typedef OpenGl_TmplCore43<OpenGl_GlCore42Back> OpenGl_GlCore43Back; | |
129 | typedef OpenGl_TmplCore43<OpenGl_GlCore42> OpenGl_GlCore43; | |
130 | ||
131 | template<typename theBaseClass_t> struct OpenGl_TmplCore44; | |
132 | typedef OpenGl_TmplCore44<OpenGl_GlCore43Back> OpenGl_GlCore44Back; | |
133 | typedef OpenGl_TmplCore44<OpenGl_GlCore43> OpenGl_GlCore44; | |
134 | ||
9491df8c | 135 | template<typename theBaseClass_t> struct OpenGl_TmplCore45; |
136 | typedef OpenGl_TmplCore45<OpenGl_GlCore44Back> OpenGl_GlCore45Back; | |
137 | typedef OpenGl_TmplCore45<OpenGl_GlCore44> OpenGl_GlCore45; | |
138 | ||
f838dac4 | 139 | class Graphic3d_PresentationAttributes; |
bf5f0ca2 | 140 | class OpenGl_Aspects; |
cc8cbabe | 141 | class OpenGl_FrameBuffer; |
142 | class OpenGl_Sampler; | |
143 | class OpenGl_ShaderProgram; | |
144 | class OpenGl_ShaderManager; | |
15669413 | 145 | class OpenGl_FrameStats; |
c04c30b3 | 146 | |
a1073ae2 | 147 | enum OpenGl_FeatureFlag |
148 | { | |
149 | OpenGl_FeatureNotAvailable = 0, //!< Feature is not supported by OpenGl implementation. | |
150 | OpenGl_FeatureInExtensions = 1, //!< Feature is supported as extension. | |
151 | OpenGl_FeatureInCore = 2 //!< Feature is supported as part of core profile. | |
152 | }; | |
153 | ||
c04c30b3 | 154 | DEFINE_STANDARD_HANDLE(OpenGl_Context, Standard_Transient) |
155 | ||
5f8b738e | 156 | //! This class generalize access to the GL context and available extensions. |
157 | //! | |
4e1523ef | 158 | //! Functions related to specific OpenGL version or extension are grouped into structures which can be accessed as fields of this class. |
159 | //! The most simple way to check that required functionality is available - is NULL check for the group: | |
5f8b738e | 160 | //! @code |
161 | //! if (myContext->core20 != NULL) | |
162 | //! { | |
163 | //! myGlProgram = myContext->core20->glCreateProgram(); | |
164 | //! .. do more stuff .. | |
165 | //! } | |
166 | //! else | |
167 | //! { | |
168 | //! .. compatibility with outdated configurations .. | |
169 | //! } | |
170 | //! @endcode | |
171 | //! | |
4e1523ef | 172 | //! Current implementation provide access to OpenGL core functionality up to 4.4 version (core12, core13, core14, core15, fields core20) |
173 | //! as well as several extensions (arbTBO, arbFBO, etc.). | |
174 | //! | |
175 | //! OpenGL context might be initialized in Core Profile. In this case deprecated functionality become unavailable. | |
176 | //! To make code easily adaptable to wide range of OpenGL versions, function sets related to each version has two kinds of suffixes: | |
177 | //! - "back" for version 3.2+. | |
178 | //! Represents function set for Backward-Compatible Profile. | |
179 | //! Function sets without this suffix represents core profile. | |
180 | //! - "fwd" for version 3.0-. | |
181 | //! Represents non-deprecated function set of earlier OpenGL versions, which are still available within OpenGL 3.2 Core Profile. | |
182 | //! Function sets without this suffix represents complete list of functions related to specific OpenGL version. | |
183 | //! | |
184 | //! To select which core** function set should be used in specific case: | |
185 | //! - Determine the minimal OpenGL version required for implemented functionality and use it to access all functions. | |
186 | //! For example, if algorithm requires OpenGL 2.1+, it is better to write core20fwd->glEnable() rather than core11fwd->glEnable() for uniformity. | |
187 | //! - If functionality will work within Core Profile, use function sets with appropriate suffix. | |
188 | //! - Validate minimal requirements at initialization/creation time and omit checks within code where algorithm should be already initialized. | |
189 | //! Properly escape code incompatible with Core Profile. The simplest way to check Core Profile is "if (core11 == NULL)". | |
5f8b738e | 190 | //! |
191 | //! Simplified extensions classification: | |
192 | //! - prefixed with NV, AMD, ATI are vendor-specific (however may be provided by other vendors in some cases); | |
193 | //! - prefixed with EXT are accepted by 2+ vendors; | |
194 | //! - prefixed with ARB are accepted by Architecture Review Board and are candidates | |
195 | //! for inclusion into GL core functionality. | |
196 | //! Some functionality can be represented in several extensions simultaneously. | |
197 | //! In this case developer should be careful because different specification may differ | |
198 | //! in aspects (like enumeration values and error-handling). | |
199 | //! | |
4e1523ef | 200 | //! Notice that some systems provide mechanisms to simultaneously incorporate with GL contexts with different capabilities. |
201 | //! For this reason OpenGl_Context should be initialized and used for each GL context independently. | |
2166f0fa SK |
202 | class OpenGl_Context : public Standard_Transient |
203 | { | |
8613985b | 204 | DEFINE_STANDARD_RTTIEXT(OpenGl_Context, Standard_Transient) |
205 | friend class OpenGl_Window; | |
a174a3c5 | 206 | public: |
207 | ||
15669413 | 208 | typedef NCollection_Shared< NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_Resource)> > OpenGl_ResourcesMap; |
209 | ||
a174a3c5 | 210 | //! Function for getting power of to number larger or equal to input number. |
211 | //! @param theNumber number to 'power of two' | |
212 | //! @param theThreshold upper threshold | |
213 | //! @return power of two number | |
214 | inline static Standard_Integer GetPowerOfTwo (const Standard_Integer theNumber, | |
215 | const Standard_Integer theThreshold) | |
216 | { | |
217 | for (Standard_Integer p2 = 2; p2 <= theThreshold; p2 <<= 1) | |
218 | { | |
219 | if (theNumber <= p2) | |
220 | { | |
221 | return p2; | |
222 | } | |
223 | } | |
224 | return theThreshold; | |
225 | } | |
226 | ||
2166f0fa SK |
227 | public: |
228 | ||
5f8b738e | 229 | //! Empty constructor. You should call Init() to perform initialization with bound GL context. |
58655684 | 230 | Standard_EXPORT OpenGl_Context (const Handle(OpenGl_Caps)& theCaps = NULL); |
5f8b738e | 231 | |
232 | //! Destructor. | |
233 | Standard_EXPORT virtual ~OpenGl_Context(); | |
2166f0fa | 234 | |
05e2200b | 235 | //! Release all resources, including shared ones |
236 | Standard_EXPORT void forcedRelease(); | |
237 | ||
5e27df78 | 238 | //! Share GL context resources. |
239 | //! theShareCtx - handle to context to retrieve handles to shared resources. | |
240 | Standard_EXPORT void Share (const Handle(OpenGl_Context)& theShareCtx); | |
241 | ||
7e7c2f0b | 242 | //! Initialize class from currently bound OpenGL context. Method should be called only once. |
243 | //! @return false if no GL context is bound to the current thread | |
4e1523ef | 244 | Standard_EXPORT Standard_Boolean Init (const Standard_Boolean theIsCoreProfile = Standard_False); |
2166f0fa | 245 | |
fd4a6963 | 246 | //! @return true if this context is valid (has been initialized) |
247 | inline Standard_Boolean IsValid() const | |
248 | { | |
249 | return myIsInitialized; | |
250 | } | |
251 | ||
da8bb41d | 252 | #if defined(HAVE_EGL) |
253 | //! Initialize class from specified surface and rendering context. Method should be called only once. | |
254 | //! @return false if OpenGL context can not be bound to specified surface | |
255 | Standard_EXPORT Standard_Boolean Init (const Aspect_Drawable theEglSurface, | |
256 | const Aspect_Display theEglDisplay, | |
4e1523ef | 257 | const Aspect_RenderingContext theEglContext, |
258 | const Standard_Boolean theIsCoreProfile = Standard_False); | |
da8bb41d | 259 | #elif defined(_WIN32) |
7e7c2f0b | 260 | //! Initialize class from specified window and rendering context. Method should be called only once. |
261 | //! @return false if OpenGL context can not be bound to specified window | |
f0430952 | 262 | Standard_EXPORT Standard_Boolean Init (const Aspect_Handle theWindow, |
263 | const Aspect_Handle theWindowDC, | |
4e1523ef | 264 | const Aspect_RenderingContext theGContext, |
265 | const Standard_Boolean theIsCoreProfile = Standard_False); | |
7e7c2f0b | 266 | |
267 | //! @return the window handle (HWND) currently bound to this OpenGL context | |
268 | inline Aspect_Handle Window() const | |
269 | { | |
270 | return myWindow; | |
271 | } | |
272 | ||
4fe56619 | 273 | #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) |
a2e4f780 | 274 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
275 | ||
276 | //! Initialize class from specified OpenGL ES context (EAGLContext). Method should be called only once. | |
277 | Standard_EXPORT Standard_Boolean Init (EAGLContext* theGContext, | |
278 | const Standard_Boolean theIsCoreProfile = Standard_False); | |
279 | #else | |
280 | ||
7e7c2f0b | 281 | //! Initialize class from specified OpenGL context (NSOpenGLContext). Method should be called only once. |
a2e4f780 | 282 | Standard_EXPORT Standard_Boolean Init (NSOpenGLContext* theGContext, |
4e1523ef | 283 | const Standard_Boolean theIsCoreProfile = Standard_False); |
a2e4f780 | 284 | #endif |
2bd4c032 | 285 | #else |
a2e4f780 | 286 | |
7e7c2f0b | 287 | //! Initialize class from specified window and rendering context. Method should be called only once. |
288 | //! @return false if OpenGL context can not be bound to specified window | |
f0430952 | 289 | Standard_EXPORT Standard_Boolean Init (const Aspect_Drawable theWindow, |
290 | const Aspect_Display theDisplay, | |
4e1523ef | 291 | const Aspect_RenderingContext theGContext, |
292 | const Standard_Boolean theIsCoreProfile = Standard_False); | |
7e7c2f0b | 293 | |
294 | //! @return the window handle (GLXDrawable) currently bound to this OpenGL context | |
295 | inline Aspect_Drawable Window() const | |
296 | { | |
297 | return myWindow; | |
298 | } | |
2bd4c032 | 299 | #endif |
300 | ||
4e1523ef | 301 | //! Read OpenGL version information from active context. |
302 | Standard_EXPORT static void ReadGlVersion (Standard_Integer& theGlVerMajor, | |
303 | Standard_Integer& theGlVerMinor); | |
304 | ||
5f8b738e | 305 | //! Check if theExtName extension is supported by active GL context. |
2bd4c032 | 306 | Standard_EXPORT Standard_Boolean CheckExtension (const char* theExtName) const; |
2166f0fa | 307 | |
58655684 | 308 | //! Check if theExtName extension is in extensions string. |
309 | Standard_EXPORT static Standard_Boolean CheckExtension (const char* theExtString, | |
310 | const char* theExtName); | |
311 | ||
2166f0fa | 312 | //! Auxiliary template to retrieve GL function pointer. |
5f8b738e | 313 | //! Pointer to function retrieved from library is statically casted |
314 | //! to requested type - there no way to check real signature of exported function. | |
2166f0fa | 315 | //! The context should be bound before call. |
0ae9ac21 | 316 | //! @param theLastFailFuncName [out] set to theFuncName in case of failure, unmodified on success |
317 | //! @param theFuncName [in] function name to find | |
318 | //! @param theFuncPtr [out] retrieved function pointer | |
319 | //! @return TRUE on success | |
320 | template <typename FuncType_t> | |
321 | Standard_Boolean FindProcVerbose (const char*& theLastFailFuncName, | |
322 | const char* theFuncName, | |
323 | FuncType_t& theFuncPtr) | |
324 | { | |
325 | theFuncPtr = (FuncType_t )findProc (theFuncName); | |
326 | if (theFuncPtr == NULL) | |
327 | { | |
328 | theLastFailFuncName = theFuncName; | |
329 | return Standard_False; | |
330 | } | |
331 | return Standard_True; | |
332 | } | |
333 | ||
334 | //! Auxiliary template to retrieve GL function pointer. | |
335 | //! Same as FindProcVerbose() but without auxiliary last function name argument. | |
2166f0fa | 336 | template <typename FuncType_t> |
5f8b738e | 337 | Standard_Boolean FindProc (const char* theFuncName, |
338 | FuncType_t& theFuncPtr) | |
2166f0fa | 339 | { |
5f8b738e | 340 | theFuncPtr = (FuncType_t )findProc (theFuncName); |
2166f0fa SK |
341 | return (theFuncPtr != NULL); |
342 | } | |
343 | ||
2bd4c032 | 344 | //! @return true if detected GL version is greater or equal to requested one. |
345 | inline Standard_Boolean IsGlGreaterEqual (const Standard_Integer theVerMajor, | |
7e7c2f0b | 346 | const Standard_Integer theVerMinor) const |
5f8b738e | 347 | { |
348 | return (myGlVerMajor > theVerMajor) | |
349 | || (myGlVerMajor == theVerMajor && myGlVerMinor >= theVerMinor); | |
350 | } | |
351 | ||
26d9c835 | 352 | //! Return cached GL version major number. |
353 | Standard_Integer VersionMajor() const { return myGlVerMajor; } | |
354 | ||
355 | //! Return cached GL version minor number. | |
356 | Standard_Integer VersionMinor() const { return myGlVerMinor; } | |
357 | ||
f978241f | 358 | //! Access entire map of loaded OpenGL functions. |
359 | const OpenGl_GlFunctions* Functions() const { return myFuncs.operator->(); } | |
360 | ||
5f8b738e | 361 | //! Clean up errors stack for this GL context (glGetError() in loop). |
f9f740d6 | 362 | //! @return true if some error has been cleared |
363 | Standard_EXPORT bool ResetErrors (const bool theToPrintErrors = false); | |
5f8b738e | 364 | |
86fa64d9 | 365 | //! This method uses system-dependent API to retrieve information |
366 | //! about GL context bound to the current thread. | |
367 | //! @return true if current thread is bound to this GL context | |
368 | Standard_EXPORT Standard_Boolean IsCurrent() const; | |
369 | ||
2bd4c032 | 370 | //! Activates current context. |
371 | //! Class should be initialized with appropriate info. | |
372 | Standard_EXPORT Standard_Boolean MakeCurrent(); | |
373 | ||
5e27df78 | 374 | //! Swap front/back buffers for this GL context (should be activated before!). |
375 | Standard_EXPORT void SwapBuffers(); | |
376 | ||
f978241f | 377 | //! Setup swap interval (VSync). |
378 | Standard_EXPORT Standard_Boolean SetSwapInterval (const Standard_Integer theInterval); | |
379 | ||
b5ac8292 | 380 | //! Return true if active mode is GL_RENDER (cached state) |
381 | Standard_Boolean IsRender() const | |
382 | { | |
ca3c13d1 | 383 | #if !defined(GL_ES_VERSION_2_0) |
b5ac8292 | 384 | return myRenderMode == GL_RENDER; |
ca3c13d1 | 385 | #else |
386 | return Standard_True; | |
387 | #endif | |
b5ac8292 | 388 | } |
664cae74 | 389 | |
b5ac8292 | 390 | //! Return true if active mode is GL_FEEDBACK (cached state) |
391 | Standard_Boolean IsFeedback() const | |
392 | { | |
ca3c13d1 | 393 | #if !defined(GL_ES_VERSION_2_0) |
b5ac8292 | 394 | return myRenderMode == GL_FEEDBACK; |
ca3c13d1 | 395 | #else |
396 | return Standard_False; | |
397 | #endif | |
b5ac8292 | 398 | } |
664cae74 | 399 | |
f0430952 | 400 | //! This function retrieves information from GL about free GPU memory that is: |
401 | //! - OS-dependent. On some OS it is per-process and on others - for entire system. | |
402 | //! - Vendor-dependent. Currently available only on NVIDIA and AMD/ATi drivers only. | |
403 | //! - Numbers meaning may vary. | |
404 | //! You should use this info only for diagnostics purposes. | |
405 | //! @return free GPU dedicated memory in bytes. | |
406 | Standard_EXPORT Standard_Size AvailableMemory() const; | |
407 | ||
408 | //! This function retrieves information from GL about GPU memory | |
409 | //! and contains more vendor-specific values than AvailableMemory(). | |
410 | Standard_EXPORT TCollection_AsciiString MemoryInfo() const; | |
411 | ||
26d9c835 | 412 | //! This function retrieves information from GL about GPU memory. |
413 | Standard_EXPORT void MemoryInfo (TColStd_IndexedDataMapOfStringString& theDict) const; | |
414 | ||
415 | //! Fill in the dictionary with OpenGL info. | |
416 | //! Should be called with bound context. | |
417 | Standard_EXPORT void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict, | |
418 | Graphic3d_DiagnosticInfo theFlags) const; | |
419 | ||
5e27df78 | 420 | //! Access shared resource by its name. |
421 | //! @param theKey - unique identifier; | |
422 | //! @return handle to shared resource or NULL. | |
423 | Standard_EXPORT const Handle(OpenGl_Resource)& GetResource (const TCollection_AsciiString& theKey) const; | |
424 | ||
425 | //! Access shared resource by its name. | |
426 | //! @param theKey - unique identifier; | |
427 | //! @param theValue - handle to fill; | |
428 | //! @return true if resource was shared. | |
429 | template<typename TheHandleType> | |
430 | Standard_Boolean GetResource (const TCollection_AsciiString& theKey, | |
431 | TheHandleType& theValue) const | |
432 | { | |
433 | const Handle(OpenGl_Resource)& aResource = GetResource (theKey); | |
434 | if (aResource.IsNull()) | |
435 | { | |
436 | return Standard_False; | |
437 | } | |
438 | ||
439 | theValue = TheHandleType::DownCast (aResource); | |
440 | return !theValue.IsNull(); | |
441 | } | |
442 | ||
443 | //! Register shared resource. | |
444 | //! Notice that after registration caller shouldn't release it by himself - | |
445 | //! it will be automatically released on context destruction. | |
446 | //! @param theKey - unique identifier, shouldn't be empty; | |
447 | //! @param theResource - new resource to register, shouldn't be NULL. | |
448 | Standard_EXPORT Standard_Boolean ShareResource (const TCollection_AsciiString& theKey, | |
449 | const Handle(OpenGl_Resource)& theResource); | |
450 | ||
451 | //! Release shared resource. | |
452 | //! If there are more than one reference to this resource | |
453 | //! (also used by some other existing object) then call will be ignored. | |
454 | //! This means that current object itself should nullify handle before this call. | |
455 | //! Notice that this is unrecommended operation at all and should be used | |
456 | //! only in case of fat resources to release memory for other needs. | |
a174a3c5 | 457 | //! @param theKey unique identifier |
458 | //! @param theToDelay postpone release until next redraw call | |
459 | Standard_EXPORT void ReleaseResource (const TCollection_AsciiString& theKey, | |
460 | const Standard_Boolean theToDelay = Standard_False); | |
5e27df78 | 461 | |
462 | //! Append resource to queue for delayed clean up. | |
463 | //! Resources in this queue will be released at next redraw call. | |
aa00364d | 464 | template <class T> |
465 | void DelayedRelease (Handle(T)& theResource) | |
466 | { | |
467 | myUnusedResources->Prepend (theResource); | |
468 | theResource.Nullify(); | |
469 | } | |
5e27df78 | 470 | |
471 | //! Clean up the delayed release queue. | |
472 | Standard_EXPORT void ReleaseDelayed(); | |
473 | ||
15669413 | 474 | //! Return map of shared resources. |
475 | const OpenGl_ResourcesMap& SharedResources() const { return *mySharedResources; } | |
476 | ||
4269bd1b | 477 | //! @return tool for management of clippings within this context. |
30f0ad28 | 478 | inline OpenGl_Clipping& ChangeClipping() { return myClippingState; } |
4269bd1b | 479 | |
480 | //! @return tool for management of clippings within this context. | |
30f0ad28 | 481 | inline const OpenGl_Clipping& Clipping() const { return myClippingState; } |
482 | ||
483 | //! @return tool for management of shader programs within this context. | |
484 | inline const Handle(OpenGl_ShaderManager)& ShaderManager() const { return myShaderManager; } | |
4269bd1b | 485 | |
486 | public: | |
487 | ||
ca3c13d1 | 488 | //! Either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1). |
489 | Standard_Integer TextureWrapClamp() const { return myTexClamp; } | |
490 | ||
bf75be98 | 491 | //! @return maximum degree of anisotropy texture filter |
3c4b62a4 | 492 | Standard_Integer MaxDegreeOfAnisotropy() const { return myAnisoMax; } |
bf75be98 | 493 | |
494 | //! @return value for GL_MAX_TEXTURE_SIZE | |
3c4b62a4 | 495 | Standard_Integer MaxTextureSize() const { return myMaxTexDim; } |
496 | ||
cc8cbabe | 497 | //! @return value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS |
498 | Standard_Integer MaxCombinedTextureUnits() const { return myMaxTexCombined; } | |
499 | ||
5c225e8e | 500 | //! This method returns the multi-texture limit for obsolete fixed-function pipeline. |
501 | //! Use MaxCombinedTextureUnits() instead for limits for using programmable pipeline. | |
502 | //! @return value for GL_MAX_TEXTURE_UNITS | |
503 | Standard_Integer MaxTextureUnitsFFP() const { return myMaxTexUnitsFFP; } | |
504 | ||
72f6dc61 | 505 | //! Return texture unit to be used for sprites (Graphic3d_TextureUnit_PointSprite by default). |
737e9a8d | 506 | Graphic3d_TextureUnit SpriteTextureUnit() const { return mySpriteTexUnit; } |
507 | ||
3c4b62a4 | 508 | //! @return value for GL_MAX_SAMPLES |
509 | Standard_Integer MaxMsaaSamples() const { return myMaxMsaaSamples; } | |
bf75be98 | 510 | |
6997ff1c | 511 | //! @return maximum FBO width for image dump |
512 | Standard_Integer MaxDumpSizeX() const { return myMaxDumpSizeX; } | |
513 | ||
514 | //! @return maximum FBO height for image dump | |
515 | Standard_Integer MaxDumpSizeY() const { return myMaxDumpSizeY; } | |
516 | ||
a1073ae2 | 517 | //! @return value for GL_MAX_DRAW_BUFFERS |
518 | Standard_Integer MaxDrawBuffers() const { return myMaxDrawBuffers; } | |
519 | ||
520 | //! @return value for GL_MAX_COLOR_ATTACHMENTS | |
521 | Standard_Integer MaxColorAttachments() const { return myMaxColorAttachments; } | |
522 | ||
4269bd1b | 523 | //! Get maximum number of clip planes supported by OpenGl. |
7e7c2f0b | 524 | //! This value is implementation dependent. At least 6 |
4269bd1b | 525 | //! planes should be supported by OpenGl (see specs). |
526 | //! @return value for GL_MAX_CLIP_PLANES | |
3c4b62a4 | 527 | Standard_Integer MaxClipPlanes() const { return myMaxClipPlanes; } |
4269bd1b | 528 | |
3a9b5dc8 | 529 | //! @return TRUE if ray tracing mode is supported |
530 | Standard_Boolean HasRayTracing() const { return myHasRayTracing; } | |
531 | ||
532 | //! @return TRUE if textures in ray tracing mode are supported | |
533 | Standard_Boolean HasRayTracingTextures() const { return myHasRayTracingTextures; } | |
534 | ||
535 | //! @return TRUE if adaptive screen sampling in ray tracing mode is supported | |
536 | Standard_Boolean HasRayTracingAdaptiveSampling() const { return myHasRayTracingAdaptiveSampling; } | |
537 | ||
e084dbbc | 538 | //! @return TRUE if atomic adaptive screen sampling in ray tracing mode is supported |
539 | Standard_Boolean HasRayTracingAdaptiveSamplingAtomic() const { return myHasRayTracingAdaptiveSamplingAtomic; } | |
540 | ||
ba00aab7 | 541 | //! Returns TRUE if sRGB rendering is supported. |
542 | bool HasSRGB() const | |
543 | { | |
544 | return hasTexSRGB | |
545 | && hasFboSRGB; | |
546 | } | |
547 | ||
548 | //! Returns TRUE if sRGB rendering is supported and permitted. | |
549 | bool ToRenderSRGB() const | |
550 | { | |
551 | return HasSRGB() | |
552 | && !caps->sRGBDisable | |
553 | && !caps->ffpEnable; | |
554 | } | |
555 | ||
556 | //! Returns TRUE if window/surface buffer is sRGB-ready. | |
557 | //! | |
558 | //! When offscreen FBOs are created in sRGB, but window is not sRGB-ready, | |
559 | //! blitting into window should be done with manual gamma correction. | |
560 | //! | |
561 | //! In desktop OpenGL, window buffer can be considered as sRGB-ready by default, | |
562 | //! even when application has NOT requested sRGB-ready pixel format, | |
563 | //! and rendering is managed via GL_FRAMEBUFFER_SRGB state. | |
564 | //! | |
565 | //! In OpenGL ES, sRGB-ready window surface should be explicitly requested on construction, | |
566 | //! and cannot be disabled/enabled without GL_EXT_sRGB_write_control extension afterwards | |
567 | //! (GL_FRAMEBUFFER_SRGB can be considered as always tuned ON). | |
568 | bool IsWindowSRGB() const { return myIsSRgbWindow; } | |
569 | ||
570 | //! Convert Quantity_ColorRGBA into vec4 | |
571 | //! with conversion or no conversion into non-linear sRGB | |
572 | //! basing on ToRenderSRGB() flag. | |
573 | OpenGl_Vec4 Vec4FromQuantityColor (const OpenGl_Vec4& theColor) const | |
574 | { | |
565baee6 | 575 | return myIsSRgbActive |
ba00aab7 | 576 | ? Vec4LinearFromQuantityColor(theColor) |
577 | : Vec4sRGBFromQuantityColor (theColor); | |
578 | } | |
579 | ||
580 | //! Convert Quantity_ColorRGBA into vec4. | |
581 | //! Quantity_Color is expected to be linear RGB, hence conversion is NOT required | |
582 | const OpenGl_Vec4& Vec4LinearFromQuantityColor (const OpenGl_Vec4& theColor) const { return theColor; } | |
583 | ||
584 | //! Convert Quantity_ColorRGBA (linear RGB) into non-linear sRGB vec4. | |
585 | OpenGl_Vec4 Vec4sRGBFromQuantityColor (const OpenGl_Vec4& theColor) const | |
586 | { | |
587 | return Quantity_ColorRGBA::Convert_LinearRGB_To_sRGB (theColor); | |
588 | } | |
589 | ||
67312b79 | 590 | //! Returns TRUE if PBR shading model is supported. |
591 | //! Basically, feature requires OpenGL 3.0+ / OpenGL ES 3.0+ hardware; more precisely: | |
592 | //! - Graphics hardware with moderate capabilities for compiling long enough GLSL program. | |
593 | //! - FBO (e.g. for baking environment). | |
594 | //! - Multi-texturing with >= 4 units (LUT and IBL textures). | |
595 | //! - GL_RG32F texture format (arbTexRG + arbTexFloat) | |
596 | //! - Cubemap texture lookup textureCubeLod()/textureLod() with LOD index within Fragment Shader, | |
597 | //! which requires GLSL OpenGL 3.0+ / OpenGL ES 3.0+ or OpenGL 2.1 + GL_EXT_gpu_shader4 extension. | |
598 | Standard_Boolean HasPBR() const { return myHasPBR; } | |
599 | ||
600 | //! Returns texture unit where Environment Lookup Table is expected to be bound, or 0 if PBR is unavailable. | |
601 | Graphic3d_TextureUnit PBREnvLUTTexUnit() const { return myPBREnvLUTTexUnit; } | |
602 | ||
603 | //! Returns texture unit where Diffuse (irradiance) IBL map's spherical harmonics coefficients is expected to be bound, or 0 if PBR is unavailable. | |
604 | Graphic3d_TextureUnit PBRDiffIBLMapSHTexUnit() const { return myPBRDiffIBLMapSHTexUnit; } | |
605 | ||
606 | //! Returns texture unit where Specular IBL map is expected to be bound, or 0 if PBR is unavailable. | |
607 | Graphic3d_TextureUnit PBRSpecIBLMapTexUnit() const { return myPBRSpecIBLMapTexUnit; } | |
608 | ||
7d3e64ef | 609 | //! Returns true if VBO is supported and permitted. |
610 | inline bool ToUseVbo() const | |
611 | { | |
612 | return core15fwd != NULL | |
613 | && !caps->vboDisable; | |
614 | } | |
615 | ||
7d9e854b | 616 | //! @return cached state of GL_NORMALIZE. |
617 | Standard_Boolean IsGlNormalizeEnabled() const { return myIsGlNormalizeEnabled; } | |
618 | ||
619 | //! Sets GL_NORMALIZE enabled or disabled. | |
620 | //! @return old value of the flag | |
621 | Standard_EXPORT Standard_Boolean SetGlNormalizeEnabled (Standard_Boolean isEnabled); | |
622 | ||
6d0e6be5 | 623 | //! @return cached state of polygon rasterization mode (glPolygonMode()). |
624 | Standard_Integer PolygonMode() const { return myPolygonMode; } | |
625 | ||
626 | //! Sets polygon rasterization mode (glPolygonMode() function). | |
627 | //! @return old value of the rasterization mode. | |
628 | Standard_EXPORT Standard_Integer SetPolygonMode (const Standard_Integer theMode); | |
629 | ||
630 | //! @return cached enabled state of polygon hatching rasterization. | |
631 | bool IsPolygonHatchEnabled() const | |
632 | { | |
633 | return !myHatchStyles.IsNull() && myHatchStyles->TypeOfHatch() != 0; | |
634 | } | |
635 | ||
636 | //! Sets enabled state of polygon hatching rasterization | |
637 | //! without affecting currently selected hatching pattern. | |
638 | //! @return previous state of polygon hatching mode. | |
639 | Standard_EXPORT bool SetPolygonHatchEnabled (const bool theIsEnabled); | |
640 | ||
641 | //! @return cached state of polygon hatch type. | |
642 | Standard_Integer PolygonHatchStyle() const | |
643 | { | |
644 | return myHatchStyles.IsNull() ? Aspect_HS_SOLID : myHatchStyles->TypeOfHatch(); | |
645 | } | |
646 | ||
647 | //! Sets polygon hatch pattern. | |
648 | //! Zero-index value is a default alias for solid filling. | |
649 | //! @param the type of hatch supported by base implementation of | |
650 | //! OpenGl_LineAttributes (Aspect_HatchStyle) or the type supported by custom | |
651 | //! implementation derived from OpenGl_LineAttributes class. | |
652 | //! @return old type of hatch. | |
640d5fe2 | 653 | Standard_EXPORT Standard_Integer SetPolygonHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle); |
6d0e6be5 | 654 | |
8d1a539c | 655 | //! Sets and applies current polygon offset. |
656 | Standard_EXPORT void SetPolygonOffset (const Graphic3d_PolygonOffset& theOffset); | |
657 | ||
658 | //! Returns currently applied polygon offset parameters. | |
659 | const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; } | |
660 | ||
c827ea3a | 661 | //! Applies matrix stored in ModelWorldState to OpenGl. |
5e94009d | 662 | Standard_EXPORT void ApplyModelWorldMatrix(); |
c827ea3a | 663 | |
664 | //! Applies matrix stored in WorldViewState to OpenGl. | |
5e94009d | 665 | Standard_EXPORT void ApplyWorldViewMatrix(); |
c827ea3a | 666 | |
667 | //! Applies combination of matrices stored in ModelWorldState and WorldViewState to OpenGl. | |
5e94009d | 668 | Standard_EXPORT void ApplyModelViewMatrix(); |
c827ea3a | 669 | |
670 | //! Applies matrix stored in ProjectionState to OpenGl. | |
5e94009d | 671 | Standard_EXPORT void ApplyProjectionMatrix(); |
c827ea3a | 672 | |
cbf18624 | 673 | public: |
674 | ||
7e7c2f0b | 675 | //! @return messenger instance |
857ffd5e | 676 | inline const Handle(Message_Messenger)& Messenger() const |
cbf18624 | 677 | { |
8fa64b52 | 678 | return ::Message::DefaultMessenger(); |
cbf18624 | 679 | } |
680 | ||
681 | //! Callback for GL_ARB_debug_output extension | |
682 | //! @param theSource message source within GL_DEBUG_SOURCE_ enumeration | |
683 | //! @param theType message type within GL_DEBUG_TYPE_ enumeration | |
684 | //! @param theId message ID within source | |
685 | //! @param theSeverity message severity within GL_DEBUG_SEVERITY_ enumeration | |
686 | //! @param theMessage the message itself | |
687 | Standard_EXPORT void PushMessage (const unsigned int theSource, | |
688 | const unsigned int theType, | |
689 | const unsigned int theId, | |
690 | const unsigned int theSeverity, | |
691 | const TCollection_ExtendedString& theMessage); | |
692 | ||
c87535af | 693 | //! Adds a filter for messages with theId and theSource (GL_DEBUG_SOURCE_) |
694 | Standard_EXPORT Standard_Boolean ExcludeMessage (const unsigned int theSource, | |
695 | const unsigned int theId); | |
b5ac8292 | 696 | |
c87535af | 697 | //! Removes a filter for messages with theId and theSource (GL_DEBUG_SOURCE_) |
698 | Standard_EXPORT Standard_Boolean IncludeMessage (const unsigned int theSource, | |
699 | const unsigned int theId); | |
b5ac8292 | 700 | |
701 | //! @return true if OpenGl context supports left and | |
702 | //! right rendering buffers. | |
703 | Standard_Boolean HasStereoBuffers() const | |
704 | { | |
ca3c13d1 | 705 | #if !defined(GL_ES_VERSION_2_0) |
b5ac8292 | 706 | return myIsStereoBuffers; |
ca3c13d1 | 707 | #else |
708 | return Standard_False; | |
709 | #endif | |
b5ac8292 | 710 | } |
711 | ||
7d3e64ef | 712 | public: //! @name methods to alter or retrieve current state |
713 | ||
15669413 | 714 | //! Return structure holding frame statistics. |
715 | const Handle(OpenGl_FrameStats)& FrameStats() const { return myFrameStats; } | |
716 | ||
5e30547b | 717 | //! Set structure holding frame statistics. |
718 | //! This call makes sense only if application defines OpenGl_FrameStats sub-class. | |
719 | void SetFrameStats (const Handle(OpenGl_FrameStats)& theStats) { myFrameStats = theStats; } | |
720 | ||
3bffef55 | 721 | //! Return cached viewport definition (x, y, width, height). |
722 | const Standard_Integer* Viewport() const { return myViewport; } | |
723 | ||
724 | //! Resize the viewport (alias for glViewport). | |
725 | //! @param theRect viewport definition (x, y, width, height) | |
726 | Standard_EXPORT void ResizeViewport (const Standard_Integer theRect[4]); | |
727 | ||
56689b27 | 728 | //! Return virtual viewport definition (x, y, width, height). |
729 | const Standard_Integer* VirtualViewport() const { return myViewportVirt; } | |
730 | ||
38a0206f | 731 | //! Return active read buffer. |
732 | Standard_Integer ReadBuffer() { return myReadBuffer; } | |
b5ac8292 | 733 | |
38a0206f | 734 | //! Switch read buffer, wrapper for ::glReadBuffer(). |
735 | Standard_EXPORT void SetReadBuffer (const Standard_Integer theReadBuffer); | |
b5ac8292 | 736 | |
a1073ae2 | 737 | //! Return active draw buffer attached to a render target referred by index (layout location). |
c3487460 | 738 | Standard_Integer DrawBuffer (Standard_Integer theIndex = 0) const |
a1073ae2 | 739 | { |
c3487460 | 740 | return theIndex >= myDrawBuffers.Lower() |
741 | && theIndex <= myDrawBuffers.Upper() | |
742 | ? myDrawBuffers.Value (theIndex) | |
743 | : GL_NONE; | |
a1073ae2 | 744 | } |
38a0206f | 745 | |
746 | //! Switch draw buffer, wrapper for ::glDrawBuffer(). | |
747 | Standard_EXPORT void SetDrawBuffer (const Standard_Integer theDrawBuffer); | |
748 | ||
a1073ae2 | 749 | //! Switch draw buffer, wrapper for ::glDrawBuffers (GLsizei, const GLenum*). |
750 | Standard_EXPORT void SetDrawBuffers (const Standard_Integer theNb, const Standard_Integer* theDrawBuffers); | |
751 | ||
38a0206f | 752 | //! Switch read/draw buffers. |
753 | void SetReadDrawBuffer (const Standard_Integer theBuffer) | |
754 | { | |
755 | SetReadBuffer (theBuffer); | |
756 | SetDrawBuffer (theBuffer); | |
757 | } | |
b5ac8292 | 758 | |
ba00aab7 | 759 | //! Returns cached GL_FRAMEBUFFER_SRGB state. |
760 | //! If TRUE, GLSL program is expected to write linear RGB color. | |
761 | //! Otherwise, GLSL program might need manually converting result color into sRGB color space. | |
762 | bool IsFrameBufferSRGB() const { return myIsSRgbActive; } | |
763 | ||
764 | //! Enables/disables GL_FRAMEBUFFER_SRGB flag. | |
765 | //! This flag can be set to: | |
766 | //! - TRUE when writing into offscreen FBO (always expected to be in sRGB or RGBF formats). | |
767 | //! - TRUE when writing into sRGB-ready window buffer (might require choosing proper pixel format on window creation). | |
768 | //! - FALSE if sRGB rendering is not supported or sRGB-not-ready window buffer is used for drawing. | |
769 | //! @param theIsFbo [in] flag indicating writing into offscreen FBO (always expected sRGB-ready when sRGB FBO is supported) | |
770 | //! or into window buffer (FALSE, sRGB-readiness might vary). | |
771 | Standard_EXPORT void SetFrameBufferSRGB (bool theIsFbo); | |
772 | ||
f88457e6 | 773 | //! Return cached flag indicating writing into color buffer is enabled or disabled (glColorMask). |
774 | bool ColorMask() const { return myColorMask; } | |
775 | ||
776 | //! Enable/disable writing into color buffer (wrapper for glColorMask). | |
777 | Standard_EXPORT bool SetColorMask (bool theToWriteColor); | |
778 | ||
2a332745 | 779 | //! Return TRUE if GL_SAMPLE_ALPHA_TO_COVERAGE usage is allowed. |
780 | bool AllowSampleAlphaToCoverage() const { return myAllowAlphaToCov; } | |
781 | ||
782 | //! Allow GL_SAMPLE_ALPHA_TO_COVERAGE usage. | |
783 | void SetAllowSampleAlphaToCoverage (bool theToEnable) { myAllowAlphaToCov = theToEnable; } | |
784 | ||
c40eb6b9 | 785 | //! Return GL_SAMPLE_ALPHA_TO_COVERAGE state. |
786 | bool SampleAlphaToCoverage() const { return myAlphaToCoverage; } | |
787 | ||
788 | //! Enable/disable GL_SAMPLE_ALPHA_TO_COVERAGE. | |
789 | Standard_EXPORT bool SetSampleAlphaToCoverage (bool theToEnable); | |
790 | ||
b6472664 | 791 | //! Return back face culling state. |
792 | bool ToCullBackFaces() const { return myToCullBackFaces; } | |
793 | ||
794 | //! Enable or disable back face culling (glEnable (GL_CULL_FACE)). | |
795 | Standard_EXPORT void SetCullBackFaces (bool theToEnable); | |
796 | ||
b5ac8292 | 797 | //! Fetch OpenGl context state. This class tracks value of several OpenGl |
798 | //! state variables. Consulting the cached values is quicker than | |
799 | //! doing the same via OpenGl API. Call this method if any of the controlled | |
800 | //! OpenGl state variables has a possibility of being out-of-date. | |
801 | Standard_EXPORT void FetchState(); | |
802 | ||
cc8cbabe | 803 | //! @return active textures |
804 | const Handle(OpenGl_TextureSet)& ActiveTextures() const { return myActiveTextures; } | |
805 | ||
72f6dc61 | 806 | //! Bind specified texture set to current context taking into account active GLSL program. |
807 | Standard_DEPRECATED("BindTextures() with explicit GLSL program should be used instead") | |
808 | Handle(OpenGl_TextureSet) BindTextures (const Handle(OpenGl_TextureSet)& theTextures) | |
809 | { | |
810 | return BindTextures (theTextures, myActiveProgram); | |
811 | } | |
812 | ||
813 | //! Bind specified texture set to current context, or unbind previous one when NULL specified. | |
814 | //! @param theTextures [in] texture set to bind | |
815 | //! @param theProgram [in] program attributes; when not NULL, | |
816 | //! mock textures will be bound to texture units expected by GLSL program, but undefined by texture set | |
817 | //! @return previous texture set | |
818 | Standard_EXPORT Handle(OpenGl_TextureSet) BindTextures (const Handle(OpenGl_TextureSet)& theTextures, | |
819 | const Handle(OpenGl_ShaderProgram)& theProgram); | |
cc8cbabe | 820 | |
7d3e64ef | 821 | //! @return active GLSL program |
822 | const Handle(OpenGl_ShaderProgram)& ActiveProgram() const | |
823 | { | |
824 | return myActiveProgram; | |
825 | } | |
826 | ||
827 | //! Bind specified program to current context, | |
828 | //! or unbind previous one when NULL specified. | |
8625ef7e | 829 | //! @return true if some program is bound to context |
830 | Standard_EXPORT Standard_Boolean BindProgram (const Handle(OpenGl_ShaderProgram)& theProgram); | |
831 | ||
299e0ab9 | 832 | //! Setup current shading material. |
bf5f0ca2 | 833 | Standard_EXPORT void SetShadingMaterial (const OpenGl_Aspects* theAspect, |
a1073ae2 | 834 | const Handle(Graphic3d_PresentationAttributes)& theHighlight); |
835 | ||
836 | //! Checks if transparency is required for the given aspect and highlight style. | |
bf5f0ca2 | 837 | Standard_EXPORT static Standard_Boolean CheckIsTransparent (const OpenGl_Aspects* theAspect, |
a1073ae2 | 838 | const Handle(Graphic3d_PresentationAttributes)& theHighlight, |
a71a71de | 839 | Standard_ShortReal& theAlphaFront, |
840 | Standard_ShortReal& theAlphaBack); | |
841 | ||
842 | //! Checks if transparency is required for the given aspect and highlight style. | |
bf5f0ca2 | 843 | static Standard_Boolean CheckIsTransparent (const OpenGl_Aspects* theAspect, |
a71a71de | 844 | const Handle(Graphic3d_PresentationAttributes)& theHighlight) |
845 | { | |
846 | Standard_ShortReal anAlphaFront = 1.0f, anAlphaBack = 1.0f; | |
847 | return CheckIsTransparent (theAspect, theHighlight, anAlphaFront, anAlphaBack); | |
848 | } | |
299e0ab9 | 849 | |
8625ef7e | 850 | //! Setup current color. |
851 | Standard_EXPORT void SetColor4fv (const OpenGl_Vec4& theColor); | |
852 | ||
ac116c22 | 853 | //! Setup type of line. |
854 | Standard_EXPORT void SetTypeOfLine (const Aspect_TypeOfLine theType, | |
855 | const Standard_ShortReal theFactor = 1.0f); | |
856 | ||
3f1675c9 | 857 | //! Setup stipple line pattern with 1.0f factor; wrapper for glLineStipple(). |
858 | void SetLineStipple (const uint16_t thePattern) { SetLineStipple (1.0f, thePattern); } | |
859 | ||
860 | //! Setup type of line; wrapper for glLineStipple(). | |
861 | Standard_EXPORT void SetLineStipple (const Standard_ShortReal theFactor, | |
862 | const uint16_t thePattern); | |
863 | ||
ac116c22 | 864 | //! Setup width of line. |
865 | Standard_EXPORT void SetLineWidth (const Standard_ShortReal theWidth); | |
866 | ||
8625ef7e | 867 | //! Setup point size. |
868 | Standard_EXPORT void SetPointSize (const Standard_ShortReal theSize); | |
7d3e64ef | 869 | |
fd59283a | 870 | //! Setup point sprite origin using GL_POINT_SPRITE_COORD_ORIGIN state: |
871 | //! - GL_UPPER_LEFT when GLSL program is active; | |
872 | //! flipping should be handled in GLSL program for compatibility with OpenGL ES | |
873 | //! - GL_LOWER_LEFT for FFP | |
874 | Standard_EXPORT void SetPointSpriteOrigin(); | |
875 | ||
79f4f036 | 876 | //! Setup texture matrix to active GLSL program or to FFP global state using glMatrixMode (GL_TEXTURE). |
877 | Standard_EXPORT void SetTextureMatrix (const Handle(Graphic3d_TextureParams)& theParams); | |
878 | ||
4e1523ef | 879 | //! Bind default Vertex Array Object |
880 | Standard_EXPORT void BindDefaultVao(); | |
881 | ||
a2e4f780 | 882 | //! Default Frame Buffer Object. |
883 | const Handle(OpenGl_FrameBuffer)& DefaultFrameBuffer() const | |
884 | { | |
885 | return myDefaultFbo; | |
886 | } | |
887 | ||
888 | //! Setup new Default Frame Buffer Object and return previously set. | |
889 | //! This call doesn't change Active FBO! | |
890 | Standard_EXPORT Handle(OpenGl_FrameBuffer) SetDefaultFrameBuffer (const Handle(OpenGl_FrameBuffer)& theFbo); | |
891 | ||
4e1523ef | 892 | //! Return debug context initialization state. |
893 | Standard_Boolean IsDebugContext() const | |
894 | { | |
895 | return myIsGlDebugCtx; | |
896 | } | |
897 | ||
c357e426 | 898 | Standard_EXPORT void EnableFeatures() const; |
899 | ||
900 | Standard_EXPORT void DisableFeatures() const; | |
901 | ||
56689b27 | 902 | //! Return resolution for rendering text. |
903 | unsigned int Resolution() const { return myResolution; } | |
904 | ||
905 | //! Resolution scale factor (rendered resolution to standard resolution). | |
906 | //! This scaling factor for parameters like text size to be properly displayed on device (screen / printer). | |
907 | Standard_ShortReal ResolutionRatio() const { return myResolutionRatio; } | |
908 | ||
909 | //! Rendering scale factor (rendering viewport height to real window buffer height). | |
910 | Standard_ShortReal RenderScale() const { return myRenderScale; } | |
911 | ||
912 | //! Return TRUE if rendering scale factor is not 1. | |
913 | Standard_Boolean HasRenderScale() const { return Abs (myRenderScale - 1.0f) > 0.0001f; } | |
914 | ||
915 | //! Rendering scale factor (inverted value). | |
916 | Standard_ShortReal RenderScaleInv() const { return myRenderScaleInv; } | |
917 | ||
2a332745 | 918 | //! Return scale factor for line width. |
919 | Standard_ShortReal LineWidthScale() const { return myLineWidthScale; } | |
920 | ||
56689b27 | 921 | //! Set resolution ratio. |
922 | //! Note that this method rounds @theRatio to nearest integer. | |
923 | void SetResolution (unsigned int theResolution, | |
924 | Standard_ShortReal theRatio, | |
925 | Standard_ShortReal theScale) | |
926 | { | |
927 | myResolution = (unsigned int )(theScale * theResolution + 0.5f); | |
928 | myRenderScale = theScale; | |
929 | myRenderScaleInv = 1.0f / theScale; | |
930 | SetResolutionRatio (theRatio * theScale); | |
931 | } | |
932 | ||
75c262a9 | 933 | //! Set resolution ratio. |
934 | //! Note that this method rounds @theRatio to nearest integer. | |
935 | void SetResolutionRatio (const Standard_ShortReal theRatio) | |
936 | { | |
56689b27 | 937 | myResolutionRatio = theRatio; |
938 | myLineWidthScale = Max (1.0f, std::floor (theRatio + 0.5f)); | |
75c262a9 | 939 | } |
940 | ||
2a332745 | 941 | //! Return line feater width in pixels. |
942 | Standard_ShortReal LineFeather() const { return myLineFeather; } | |
943 | ||
944 | //! Set line feater width. | |
945 | void SetLineFeather(Standard_ShortReal theValue) { myLineFeather = theValue; } | |
946 | ||
c39bb31b | 947 | //! Return Graphics Driver's vendor. |
948 | const TCollection_AsciiString& Vendor() const { return myVendor; } | |
949 | ||
5f8b738e | 950 | private: |
951 | ||
952 | //! Wrapper to system function to retrieve GL function pointer by name. | |
953 | Standard_EXPORT void* findProc (const char* theFuncName); | |
954 | ||
ee51a9fe | 955 | //! Print error if not all functions have been exported by context for reported version. |
956 | //! Note that this will never happen when using GLX, since returned functions can not be validated. | |
957 | //! @param theGlVerMajor the OpenGL major version with missing functions | |
958 | //! @param theGlVerMinor the OpenGL minor version with missing functions | |
0ae9ac21 | 959 | //! @param theLastFailedProc function name which cannot be found |
960 | Standard_EXPORT void checkWrongVersion (Standard_Integer theGlVerMajor, Standard_Integer theGlVerMinor, | |
961 | const char* theLastFailedProc); | |
ee51a9fe | 962 | |
5f8b738e | 963 | //! Private initialization function that should be called only once. |
4e1523ef | 964 | Standard_EXPORT void init (const Standard_Boolean theIsCoreProfile); |
5f8b738e | 965 | |
01ca42b2 | 966 | public: //! @name core profiles |
967 | ||
968 | OpenGl_GlCore11* core11; //!< OpenGL 1.1 core functionality | |
969 | OpenGl_GlCore11Fwd* core11fwd; //!< OpenGL 1.1 without deprecated entry points | |
970 | OpenGl_GlCore15* core15; //!< OpenGL 1.5 core functionality | |
971 | OpenGl_GlCore15Fwd* core15fwd; //!< OpenGL 1.5 without deprecated entry points | |
972 | OpenGl_GlCore20* core20; //!< OpenGL 2.0 core functionality (includes 1.5) | |
973 | OpenGl_GlCore20Fwd* core20fwd; //!< OpenGL 2.0 without deprecated entry points | |
974 | OpenGl_GlCore32* core32; //!< OpenGL 3.2 core profile | |
975 | OpenGl_GlCore32Back* core32back; //!< OpenGL 3.2 backward compatibility profile | |
25ef750e | 976 | OpenGl_GlCore33* core33; //!< OpenGL 3.3 core profile |
977 | OpenGl_GlCore33Back* core33back; //!< OpenGL 3.3 backward compatibility profile | |
01ca42b2 | 978 | OpenGl_GlCore41* core41; //!< OpenGL 4.1 core profile |
979 | OpenGl_GlCore41Back* core41back; //!< OpenGL 4.1 backward compatibility profile | |
980 | OpenGl_GlCore42* core42; //!< OpenGL 4.2 core profile | |
981 | OpenGl_GlCore42Back* core42back; //!< OpenGL 4.2 backward compatibility profile | |
982 | OpenGl_GlCore43* core43; //!< OpenGL 4.3 core profile | |
983 | OpenGl_GlCore43Back* core43back; //!< OpenGL 4.3 backward compatibility profile | |
984 | OpenGl_GlCore44* core44; //!< OpenGL 4.4 core profile | |
985 | OpenGl_GlCore44Back* core44back; //!< OpenGL 4.4 backward compatibility profile | |
9491df8c | 986 | OpenGl_GlCore45* core45; //!< OpenGL 4.5 core profile |
987 | OpenGl_GlCore45Back* core45back; //!< OpenGL 4.5 backward compatibility profile | |
5f8b738e | 988 | |
58655684 | 989 | Handle(OpenGl_Caps) caps; //!< context options |
990 | ||
01ca42b2 | 991 | public: //! @name extensions |
5f8b738e | 992 | |
a1073ae2 | 993 | Standard_Boolean hasHighp; //!< highp in GLSL ES fragment shader is supported |
994 | Standard_Boolean hasUintIndex; //!< GLuint for index buffer is supported (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_element_index_uint) | |
995 | Standard_Boolean hasTexRGBA8; //!< always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_rgb8_rgba8 | |
67312b79 | 996 | Standard_Boolean hasTexFloatLinear; //!< texture-filterable state for 32-bit floating texture formats (always on desktop, GL_OES_texture_float_linear within OpenGL ES) |
ba00aab7 | 997 | Standard_Boolean hasTexSRGB; //!< sRGB texture formats (desktop OpenGL 2.0, OpenGL ES 3.0 or GL_EXT_texture_sRGB) |
998 | Standard_Boolean hasFboSRGB; //!< sRGB FBO render targets (desktop OpenGL 2.1, OpenGL ES 3.0) | |
999 | Standard_Boolean hasSRGBControl; //!< sRGB write control (any desktop OpenGL, OpenGL ES + GL_EXT_sRGB_write_control extension) | |
c39bb31b | 1000 | OpenGl_FeatureFlag hasFlatShading; //!< Complex flag indicating support of Flat shading (Graphic3d_TOSM_FACET) (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_standard_derivatives) |
59515ca6 | 1001 | OpenGl_FeatureFlag hasGlslBitwiseOps; //!< GLSL supports bitwise operations; OpenGL 3.0 / OpenGL ES 3.0 (GLSL 130 / GLSL ES 300) or OpenGL 2.1 + GL_EXT_gpu_shader4 |
a1073ae2 | 1002 | OpenGl_FeatureFlag hasDrawBuffers; //!< Complex flag indicating support of multiple draw buffers (desktop OpenGL 2.0, OpenGL ES 3.0, GL_ARB_draw_buffers, GL_EXT_draw_buffers) |
1003 | OpenGl_FeatureFlag hasFloatBuffer; //!< Complex flag indicating support of float color buffer format (desktop OpenGL 3.0, GL_ARB_color_buffer_float, GL_EXT_color_buffer_float) | |
1004 | OpenGl_FeatureFlag hasHalfFloatBuffer; //!< Complex flag indicating support of half-float color buffer format (desktop OpenGL 3.0, GL_ARB_color_buffer_float, GL_EXT_color_buffer_half_float) | |
1005 | OpenGl_FeatureFlag hasSampleVariables; //!< Complex flag indicating support of MSAA variables in GLSL shader (desktop OpenGL 4.0, GL_ARB_sample_shading) | |
2a332745 | 1006 | OpenGl_FeatureFlag hasGeometryStage; //!< Complex flag indicating support of Geometry shader (desktop OpenGL 3.2, OpenGL ES 3.2, GL_EXT_geometry_shader) |
a1073ae2 | 1007 | Standard_Boolean arbDrawBuffers; //!< GL_ARB_draw_buffers |
1008 | Standard_Boolean arbNPTW; //!< GL_ARB_texture_non_power_of_two | |
1009 | Standard_Boolean arbTexRG; //!< GL_ARB_texture_rg | |
67312b79 | 1010 | Standard_Boolean arbTexFloat; //!< GL_ARB_texture_float (on desktop OpenGL - since 3.0 or as extension GL_ARB_texture_float; on OpenGL ES - since 3.0); @sa hasTexFloatLinear for linear filtering support |
cc8cbabe | 1011 | OpenGl_ArbSamplerObject* arbSamplerObject; //!< GL_ARB_sampler_objects (on desktop OpenGL - since 3.3 or as extension GL_ARB_sampler_objects; on OpenGL ES - since 3.0) |
a1073ae2 | 1012 | OpenGl_ArbTexBindless* arbTexBindless; //!< GL_ARB_bindless_texture |
1013 | OpenGl_ArbTBO* arbTBO; //!< GL_ARB_texture_buffer_object | |
1014 | Standard_Boolean arbTboRGB32; //!< GL_ARB_texture_buffer_object_rgb32 (3-component TBO), in core since 4.0 | |
1015 | OpenGl_ArbIns* arbIns; //!< GL_ARB_draw_instanced | |
1016 | OpenGl_ArbDbg* arbDbg; //!< GL_ARB_debug_output | |
1017 | OpenGl_ArbFBO* arbFBO; //!< GL_ARB_framebuffer_object | |
1018 | OpenGl_ArbFBOBlit* arbFBOBlit; //!< glBlitFramebuffer function, moved out from OpenGl_ArbFBO structure for compatibility with OpenGL ES 2.0 | |
1019 | Standard_Boolean arbSampleShading; //!< GL_ARB_sample_shading | |
1020 | Standard_Boolean extFragDepth; //!< GL_EXT_frag_depth on OpenGL ES 2.0 (gl_FragDepthEXT built-in variable, before OpenGL ES 3.0) | |
1021 | Standard_Boolean extDrawBuffers; //!< GL_EXT_draw_buffers | |
1022 | OpenGl_ExtGS* extGS; //!< GL_EXT_geometry_shader4 | |
1023 | Standard_Boolean extBgra; //!< GL_EXT_bgra or GL_EXT_texture_format_BGRA8888 on OpenGL ES | |
1024 | Standard_Boolean extAnis; //!< GL_EXT_texture_filter_anisotropic | |
1025 | Standard_Boolean extPDS; //!< GL_EXT_packed_depth_stencil | |
1026 | Standard_Boolean atiMem; //!< GL_ATI_meminfo | |
1027 | Standard_Boolean nvxMem; //!< GL_NVX_gpu_memory_info | |
1028 | Standard_Boolean oesSampleVariables; //!< GL_OES_sample_variables | |
8c3237d4 | 1029 | Standard_Boolean oesStdDerivatives; //!< GL_OES_standard_derivatives |
5f8b738e | 1030 | |
8613985b | 1031 | public: //! @name public properties tracking current state |
1032 | ||
1033 | OpenGl_MatrixState<Standard_ShortReal> ModelWorldState; //!< state of orientation matrix | |
1034 | OpenGl_MatrixState<Standard_ShortReal> WorldViewState; //!< state of orientation matrix | |
1035 | OpenGl_MatrixState<Standard_ShortReal> ProjectionState; //!< state of projection matrix | |
1036 | ||
5e27df78 | 1037 | private: // system-dependent fields |
2166f0fa | 1038 | |
da8bb41d | 1039 | #if defined(HAVE_EGL) |
1040 | Aspect_Drawable myWindow; //!< EGL surface : EGLSurface | |
1041 | Aspect_Display myDisplay; //!< EGL connection to the Display : EGLDisplay | |
1042 | Aspect_RenderingContext myGContext; //!< EGL rendering context : EGLContext | |
1043 | #elif defined(_WIN32) | |
2bd4c032 | 1044 | Aspect_Handle myWindow; //!< window handle (owner of GL context) : HWND |
1045 | Aspect_Handle myWindowDC; //!< Device Descriptor handle : HDC | |
1046 | Aspect_RenderingContext myGContext; //!< Rendering Context handle : HGLRC | |
4fe56619 | 1047 | #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) |
a2e4f780 | 1048 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
1049 | EAGLContext* myGContext; //!< Rendering Context handle | |
1050 | #else | |
1051 | NSOpenGLContext* myGContext; //!< Rendering Context handle | |
1052 | #endif | |
2bd4c032 | 1053 | #else |
1054 | Aspect_Drawable myWindow; //!< window handle (owner of GL context) : GLXDrawable | |
1055 | Aspect_Display myDisplay; //!< connection to the X-server : Display* | |
1056 | Aspect_RenderingContext myGContext; //!< X-GLX rendering context : GLXContext | |
1057 | #endif | |
1058 | ||
5e27df78 | 1059 | private: // context info |
1060 | ||
c04c30b3 | 1061 | typedef NCollection_Shared< NCollection_DataMap<TCollection_AsciiString, Standard_Integer> > OpenGl_DelayReleaseMap; |
c04c30b3 | 1062 | typedef NCollection_Shared< NCollection_List<Handle(OpenGl_Resource)> > OpenGl_ResourcesStack; |
5e27df78 | 1063 | |
a174a3c5 | 1064 | Handle(OpenGl_ResourcesMap) mySharedResources; //!< shared resources with unique identification key |
1065 | Handle(OpenGl_DelayReleaseMap) myDelayed; //!< shared resources for delayed release | |
3125ebb6 | 1066 | Handle(OpenGl_ResourcesStack) myUnusedResources; //!< stack of resources for delayed clean up |
5e27df78 | 1067 | |
30f0ad28 | 1068 | OpenGl_Clipping myClippingState; //!< state of clip planes |
4269bd1b | 1069 | |
7d9e854b | 1070 | void* myGlLibHandle; //!< optional handle to GL library |
01ca42b2 | 1071 | NCollection_Handle<OpenGl_GlFunctions> |
7d9e854b | 1072 | myFuncs; //!< mega structure for all GL functions |
1073 | Standard_Integer myAnisoMax; //!< maximum level of anisotropy texture filter | |
1074 | Standard_Integer myTexClamp; //!< either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1) | |
1075 | Standard_Integer myMaxTexDim; //!< value for GL_MAX_TEXTURE_SIZE | |
cc8cbabe | 1076 | Standard_Integer myMaxTexCombined; //!< value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS |
5c225e8e | 1077 | Standard_Integer myMaxTexUnitsFFP; //!< value for GL_MAX_TEXTURE_UNITS (fixed-function pipeline only) |
6997ff1c | 1078 | Standard_Integer myMaxDumpSizeX; //!< maximum FBO width for image dump |
1079 | Standard_Integer myMaxDumpSizeY; //!< maximum FBO height for image dump | |
7d9e854b | 1080 | Standard_Integer myMaxClipPlanes; //!< value for GL_MAX_CLIP_PLANES |
3c4b62a4 | 1081 | Standard_Integer myMaxMsaaSamples; //!< value for GL_MAX_SAMPLES |
a1073ae2 | 1082 | Standard_Integer myMaxDrawBuffers; //!< value for GL_MAX_DRAW_BUFFERS |
1083 | Standard_Integer myMaxColorAttachments; //!< value for GL_MAX_COLOR_ATTACHMENTS | |
7d9e854b | 1084 | Standard_Integer myGlVerMajor; //!< cached GL version major number |
1085 | Standard_Integer myGlVerMinor; //!< cached GL version minor number | |
1086 | Standard_Boolean myIsInitialized; //!< flag indicates initialization state | |
1087 | Standard_Boolean myIsStereoBuffers; //!< context supports stereo buffering | |
1088 | Standard_Boolean myIsGlNormalizeEnabled; //!< GL_NORMALIZE flag | |
1089 | //!< Used to tell OpenGl that normals should be normalized | |
72f6dc61 | 1090 | Graphic3d_TextureUnit mySpriteTexUnit; //!< sampler2D occSamplerPointSprite, texture unit for point sprite texture |
2166f0fa | 1091 | |
e084dbbc | 1092 | Standard_Boolean myHasRayTracing; //! indicates whether ray tracing mode is supported |
1093 | Standard_Boolean myHasRayTracingTextures; //! indicates whether textures in ray tracing mode are supported | |
1094 | Standard_Boolean myHasRayTracingAdaptiveSampling; //! indicates whether adaptive screen sampling in ray tracing mode is supported | |
1095 | Standard_Boolean myHasRayTracingAdaptiveSamplingAtomic; //! indicates whether atomic adaptive screen sampling in ray tracing mode is supported | |
3a9b5dc8 | 1096 | |
67312b79 | 1097 | Standard_Boolean myHasPBR; //!< indicates whether PBR shading model is supported |
72f6dc61 | 1098 | Graphic3d_TextureUnit myPBREnvLUTTexUnit; //!< sampler2D occEnvLUT, texture unit where environment lookup table is expected to be binded (0 if PBR is not supported) |
1099 | Graphic3d_TextureUnit myPBRDiffIBLMapSHTexUnit; //!< sampler2D occDiffIBLMapSHCoeffs, texture unit where diffuse (irradiance) IBL map's spherical harmonics coefficients is expected to be binded | |
67312b79 | 1100 | //! (0 if PBR is not supported) |
72f6dc61 | 1101 | Graphic3d_TextureUnit myPBRSpecIBLMapTexUnit; //!< samplerCube occSpecIBLMap, texture unit where specular IBL map is expected to be binded (0 if PBR is not supported) |
67312b79 | 1102 | |
30f0ad28 | 1103 | Handle(OpenGl_ShaderManager) myShaderManager; //! support object for managing shader programs |
1104 | ||
7d3e64ef | 1105 | private: //! @name fields tracking current state |
1106 | ||
15669413 | 1107 | Handle(OpenGl_FrameStats) myFrameStats; //!< structure accumulating frame statistics |
6d0e6be5 | 1108 | Handle(OpenGl_ShaderProgram) myActiveProgram; //!< currently active GLSL program |
cc8cbabe | 1109 | Handle(OpenGl_TextureSet) myActiveTextures; //!< currently bound textures |
1110 | //!< currently active sampler objects | |
72f6dc61 | 1111 | Standard_Integer myActiveMockTextures; //!< currently active mock sampler objects |
6d0e6be5 | 1112 | Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object |
1113 | Handle(OpenGl_LineAttributes) myHatchStyles; //!< resource holding predefined hatch styles patterns | |
72f6dc61 | 1114 | Handle(OpenGl_Texture) myTextureRgbaBlack;//!< mock black texture returning (0, 0, 0, 0) |
1115 | Handle(OpenGl_Texture) myTextureRgbaWhite;//!< mock white texture returning (1, 1, 1, 1) | |
3bffef55 | 1116 | Standard_Integer myViewport[4]; //!< current viewport |
56689b27 | 1117 | Standard_Integer myViewportVirt[4]; //!< virtual viewport |
6d0e6be5 | 1118 | Standard_Integer myPointSpriteOrig; //!< GL_POINT_SPRITE_COORD_ORIGIN state (GL_UPPER_LEFT by default) |
1119 | Standard_Integer myRenderMode; //!< value for active rendering mode | |
1120 | Standard_Integer myPolygonMode; //!< currently used polygon rasterization mode (glPolygonMode) | |
8d1a539c | 1121 | Graphic3d_PolygonOffset myPolygonOffset; //!< currently applied polygon offset |
6d0e6be5 | 1122 | bool myToCullBackFaces; //!< back face culling mode enabled state (glIsEnabled (GL_CULL_FACE)) |
1123 | Standard_Integer myReadBuffer; //!< current read buffer | |
c3487460 | 1124 | NCollection_Array1<Standard_Integer> |
1125 | myDrawBuffers; //!< current draw buffers | |
6d0e6be5 | 1126 | unsigned int myDefaultVao; //!< default Vertex Array Object |
f88457e6 | 1127 | Standard_Boolean myColorMask; //!< flag indicating writing into color buffer is enabled or disabled (glColorMask) |
2a332745 | 1128 | Standard_Boolean myAllowAlphaToCov; //!< flag allowing GL_SAMPLE_ALPHA_TO_COVERAGE usage |
c40eb6b9 | 1129 | Standard_Boolean myAlphaToCoverage; //!< flag indicating GL_SAMPLE_ALPHA_TO_COVERAGE state |
6d0e6be5 | 1130 | Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state |
ba00aab7 | 1131 | Standard_Boolean myIsSRgbWindow; //!< indicates that window buffer is sRGB-ready |
1132 | Standard_Boolean myIsSRgbActive; //!< flag indicating GL_FRAMEBUFFER_SRGB state | |
6d0e6be5 | 1133 | TCollection_AsciiString myVendor; //!< Graphics Driver's vendor |
1134 | TColStd_PackedMapOfInteger myFilters[6]; //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB) | |
56689b27 | 1135 | unsigned int myResolution; //!< Pixels density (PPI), defines scaling factor for parameters like text size |
6d0e6be5 | 1136 | Standard_ShortReal myResolutionRatio; //!< scaling factor for parameters like text size |
56689b27 | 1137 | //! to be properly displayed on device (screen / printer) |
1138 | Standard_ShortReal myLineWidthScale; //!< scaling factor for line width | |
2a332745 | 1139 | Standard_ShortReal myLineFeather; //!< line feater width in pixels |
56689b27 | 1140 | Standard_ShortReal myRenderScale; //!< scaling factor for rendering resolution |
1141 | Standard_ShortReal myRenderScaleInv; //!< scaling factor for rendering resolution (inverted value) | |
8613985b | 1142 | OpenGl_Material myMatFront; //!< current front material state (cached to reduce GL context updates) |
1143 | OpenGl_Material myMatBack; //!< current back material state | |
c827ea3a | 1144 | |
5e27df78 | 1145 | private: |
1146 | ||
1147 | //! Copying allowed only within Handles | |
1148 | OpenGl_Context (const OpenGl_Context& ); | |
1149 | OpenGl_Context& operator= (const OpenGl_Context& ); | |
1150 | ||
2166f0fa SK |
1151 | }; |
1152 | ||
1153 | #endif // _OpenGl_Context_H__ |