1 // Created on: 2012-01-26
2 // Created by: Kirill GAVRILOV
3 // Copyright (c) 2012-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_Context_H__
17 #define _OpenGl_Context_H__
19 #include <Aspect_Handle.hxx>
20 #include <Aspect_HatchStyle.hxx>
21 #include <Aspect_Drawable.hxx>
22 #include <Aspect_Display.hxx>
23 #include <Aspect_RenderingContext.hxx>
24 #include <Aspect_TypeOfLine.hxx>
25 #include <NCollection_DataMap.hxx>
26 #include <Graphic3d_DiagnosticInfo.hxx>
27 #include <Graphic3d_TextureUnit.hxx>
28 #include <NCollection_Map.hxx>
29 #include <NCollection_Handle.hxx>
30 #include <NCollection_List.hxx>
31 #include <NCollection_SparseArray.hxx>
32 #include <Message.hxx>
33 #include <OpenGl_Caps.hxx>
34 #include <OpenGl_LineAttributes.hxx>
35 #include <OpenGl_Material.hxx>
36 #include <OpenGl_MatrixState.hxx>
37 #include <OpenGl_Vec.hxx>
38 #include <OpenGl_Resource.hxx>
39 #include <OpenGl_TextureSet.hxx>
40 #include <Standard_Transient.hxx>
41 #include <TColStd_IndexedDataMapOfStringString.hxx>
42 #include <TColStd_PackedMapOfInteger.hxx>
43 #include <OpenGl_Clipping.hxx>
44 #include <OpenGl_GlCore11.hxx>
46 #include <NCollection_Shared.hxx>
48 //! Forward declarations
49 #if defined(__APPLE__)
50 #import <TargetConditionals.h>
51 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
59 @class NSOpenGLContext;
61 struct NSOpenGLContext;
66 struct OpenGl_GlFunctions;
71 struct OpenGl_ArbFBOBlit;
72 struct OpenGl_ArbSamplerObject;
73 struct OpenGl_ArbTexBindless;
76 template<typename theBaseClass_t> struct OpenGl_TmplCore12;
77 typedef OpenGl_TmplCore12<OpenGl_GlCore11> OpenGl_GlCore12;
78 typedef OpenGl_TmplCore12<OpenGl_GlCore11Fwd> OpenGl_GlCore12Fwd;
80 struct OpenGl_GlCore13;
81 struct OpenGl_GlCore13Fwd;
83 template<typename theBaseClass_t> struct OpenGl_TmplCore14;
84 typedef OpenGl_TmplCore14<OpenGl_GlCore13> OpenGl_GlCore14;
85 typedef OpenGl_TmplCore14<OpenGl_GlCore13Fwd> OpenGl_GlCore14Fwd;
87 template<typename theBaseClass_t> struct OpenGl_TmplCore15;
88 typedef OpenGl_TmplCore15<OpenGl_GlCore14> OpenGl_GlCore15;
89 typedef OpenGl_TmplCore15<OpenGl_GlCore14Fwd> OpenGl_GlCore15Fwd;
91 template<typename theBaseClass_t> struct OpenGl_TmplCore20;
92 typedef OpenGl_TmplCore20<OpenGl_GlCore15> OpenGl_GlCore20;
93 typedef OpenGl_TmplCore20<OpenGl_GlCore15Fwd> OpenGl_GlCore20Fwd;
95 template<typename theBaseClass_t> struct OpenGl_TmplCore21;
96 typedef OpenGl_TmplCore21<OpenGl_GlCore20> OpenGl_GlCore21;
97 typedef OpenGl_TmplCore21<OpenGl_GlCore20Fwd> OpenGl_GlCore21Fwd;
99 template<typename theBaseClass_t> struct OpenGl_TmplCore30;
100 typedef OpenGl_TmplCore30<OpenGl_GlCore21> OpenGl_GlCore30;
101 typedef OpenGl_TmplCore30<OpenGl_GlCore21Fwd> OpenGl_GlCore30Fwd;
103 template<typename theBaseClass_t> struct OpenGl_TmplCore31;
104 typedef OpenGl_TmplCore31<OpenGl_GlCore30> OpenGl_GlCore31Back;
105 typedef OpenGl_TmplCore31<OpenGl_GlCore30Fwd> OpenGl_GlCore31;
107 template<typename theBaseClass_t> struct OpenGl_TmplCore32;
108 typedef OpenGl_TmplCore32<OpenGl_GlCore31Back> OpenGl_GlCore32Back;
109 typedef OpenGl_TmplCore32<OpenGl_GlCore31> OpenGl_GlCore32;
111 template<typename theBaseClass_t> struct OpenGl_TmplCore33;
112 typedef OpenGl_TmplCore33<OpenGl_GlCore32Back> OpenGl_GlCore33Back;
113 typedef OpenGl_TmplCore33<OpenGl_GlCore32> OpenGl_GlCore33;
115 template<typename theBaseClass_t> struct OpenGl_TmplCore40;
116 typedef OpenGl_TmplCore40<OpenGl_GlCore33Back> OpenGl_GlCore40Back;
117 typedef OpenGl_TmplCore40<OpenGl_GlCore33> OpenGl_GlCore40;
119 template<typename theBaseClass_t> struct OpenGl_TmplCore41;
120 typedef OpenGl_TmplCore41<OpenGl_GlCore40Back> OpenGl_GlCore41Back;
121 typedef OpenGl_TmplCore41<OpenGl_GlCore40> OpenGl_GlCore41;
123 template<typename theBaseClass_t> struct OpenGl_TmplCore42;
124 typedef OpenGl_TmplCore42<OpenGl_GlCore41Back> OpenGl_GlCore42Back;
125 typedef OpenGl_TmplCore42<OpenGl_GlCore41> OpenGl_GlCore42;
127 template<typename theBaseClass_t> struct OpenGl_TmplCore43;
128 typedef OpenGl_TmplCore43<OpenGl_GlCore42Back> OpenGl_GlCore43Back;
129 typedef OpenGl_TmplCore43<OpenGl_GlCore42> OpenGl_GlCore43;
131 template<typename theBaseClass_t> struct OpenGl_TmplCore44;
132 typedef OpenGl_TmplCore44<OpenGl_GlCore43Back> OpenGl_GlCore44Back;
133 typedef OpenGl_TmplCore44<OpenGl_GlCore43> OpenGl_GlCore44;
135 template<typename theBaseClass_t> struct OpenGl_TmplCore45;
136 typedef OpenGl_TmplCore45<OpenGl_GlCore44Back> OpenGl_GlCore45Back;
137 typedef OpenGl_TmplCore45<OpenGl_GlCore44> OpenGl_GlCore45;
139 class Graphic3d_PresentationAttributes;
140 class OpenGl_Aspects;
141 class OpenGl_FrameBuffer;
142 class OpenGl_Sampler;
143 class OpenGl_ShaderProgram;
144 class OpenGl_ShaderManager;
145 class OpenGl_FrameStats;
147 enum OpenGl_FeatureFlag
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.
154 DEFINE_STANDARD_HANDLE(OpenGl_Context, Standard_Transient)
156 //! This class generalize access to the GL context and available extensions.
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:
161 //! if (myContext->core20 != NULL)
163 //! myGlProgram = myContext->core20->glCreateProgram();
164 //! .. do more stuff ..
168 //! .. compatibility with outdated configurations ..
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.).
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.
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)".
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).
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.
202 class OpenGl_Context : public Standard_Transient
204 DEFINE_STANDARD_RTTIEXT(OpenGl_Context, Standard_Transient)
205 friend class OpenGl_Window;
208 typedef NCollection_Shared< NCollection_DataMap<TCollection_AsciiString, Handle(OpenGl_Resource)> > OpenGl_ResourcesMap;
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)
217 for (Standard_Integer p2 = 2; p2 <= theThreshold; p2 <<= 1)
229 //! Empty constructor. You should call Init() to perform initialization with bound GL context.
230 Standard_EXPORT OpenGl_Context (const Handle(OpenGl_Caps)& theCaps = NULL);
233 Standard_EXPORT virtual ~OpenGl_Context();
235 //! Release all resources, including shared ones
236 Standard_EXPORT void forcedRelease();
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);
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
244 Standard_EXPORT Standard_Boolean Init (const Standard_Boolean theIsCoreProfile = Standard_False);
246 //! @return true if this context is valid (has been initialized)
247 inline Standard_Boolean IsValid() const
249 return myIsInitialized;
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,
257 const Aspect_RenderingContext theEglContext,
258 const Standard_Boolean theIsCoreProfile = Standard_False);
259 #elif defined(_WIN32)
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
262 Standard_EXPORT Standard_Boolean Init (const Aspect_Handle theWindow,
263 const Aspect_Handle theWindowDC,
264 const Aspect_RenderingContext theGContext,
265 const Standard_Boolean theIsCoreProfile = Standard_False);
267 //! @return the window handle (HWND) currently bound to this OpenGL context
268 inline Aspect_Handle Window() const
273 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
274 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
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);
281 //! Initialize class from specified OpenGL context (NSOpenGLContext). Method should be called only once.
282 Standard_EXPORT Standard_Boolean Init (NSOpenGLContext* theGContext,
283 const Standard_Boolean theIsCoreProfile = Standard_False);
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
289 Standard_EXPORT Standard_Boolean Init (const Aspect_Drawable theWindow,
290 const Aspect_Display theDisplay,
291 const Aspect_RenderingContext theGContext,
292 const Standard_Boolean theIsCoreProfile = Standard_False);
294 //! @return the window handle (GLXDrawable) currently bound to this OpenGL context
295 inline Aspect_Drawable Window() const
301 //! Read OpenGL version information from active context.
302 Standard_EXPORT static void ReadGlVersion (Standard_Integer& theGlVerMajor,
303 Standard_Integer& theGlVerMinor);
305 //! Check if theExtName extension is supported by active GL context.
306 Standard_EXPORT Standard_Boolean CheckExtension (const char* theExtName) const;
308 //! Check if theExtName extension is in extensions string.
309 Standard_EXPORT static Standard_Boolean CheckExtension (const char* theExtString,
310 const char* theExtName);
312 //! Auxiliary template to retrieve GL function pointer.
313 //! Pointer to function retrieved from library is statically casted
314 //! to requested type - there no way to check real signature of exported function.
315 //! The context should be bound before call.
316 template <typename FuncType_t>
317 Standard_Boolean FindProc (const char* theFuncName,
318 FuncType_t& theFuncPtr)
320 theFuncPtr = (FuncType_t )findProc (theFuncName);
321 return (theFuncPtr != NULL);
324 //! @return true if detected GL version is greater or equal to requested one.
325 inline Standard_Boolean IsGlGreaterEqual (const Standard_Integer theVerMajor,
326 const Standard_Integer theVerMinor) const
328 return (myGlVerMajor > theVerMajor)
329 || (myGlVerMajor == theVerMajor && myGlVerMinor >= theVerMinor);
332 //! Return cached GL version major number.
333 Standard_Integer VersionMajor() const { return myGlVerMajor; }
335 //! Return cached GL version minor number.
336 Standard_Integer VersionMinor() const { return myGlVerMinor; }
338 //! Access entire map of loaded OpenGL functions.
339 const OpenGl_GlFunctions* Functions() const { return myFuncs.operator->(); }
341 //! Clean up errors stack for this GL context (glGetError() in loop).
342 //! @return true if some error has been cleared
343 Standard_EXPORT bool ResetErrors (const bool theToPrintErrors = false);
345 //! This method uses system-dependent API to retrieve information
346 //! about GL context bound to the current thread.
347 //! @return true if current thread is bound to this GL context
348 Standard_EXPORT Standard_Boolean IsCurrent() const;
350 //! Activates current context.
351 //! Class should be initialized with appropriate info.
352 Standard_EXPORT Standard_Boolean MakeCurrent();
354 //! Swap front/back buffers for this GL context (should be activated before!).
355 Standard_EXPORT void SwapBuffers();
357 //! Setup swap interval (VSync).
358 Standard_EXPORT Standard_Boolean SetSwapInterval (const Standard_Integer theInterval);
360 //! Return true if active mode is GL_RENDER (cached state)
361 Standard_Boolean IsRender() const
363 #if !defined(GL_ES_VERSION_2_0)
364 return myRenderMode == GL_RENDER;
366 return Standard_True;
370 //! Return true if active mode is GL_FEEDBACK (cached state)
371 Standard_Boolean IsFeedback() const
373 #if !defined(GL_ES_VERSION_2_0)
374 return myRenderMode == GL_FEEDBACK;
376 return Standard_False;
380 //! This function retrieves information from GL about free GPU memory that is:
381 //! - OS-dependent. On some OS it is per-process and on others - for entire system.
382 //! - Vendor-dependent. Currently available only on NVIDIA and AMD/ATi drivers only.
383 //! - Numbers meaning may vary.
384 //! You should use this info only for diagnostics purposes.
385 //! @return free GPU dedicated memory in bytes.
386 Standard_EXPORT Standard_Size AvailableMemory() const;
388 //! This function retrieves information from GL about GPU memory
389 //! and contains more vendor-specific values than AvailableMemory().
390 Standard_EXPORT TCollection_AsciiString MemoryInfo() const;
392 //! This function retrieves information from GL about GPU memory.
393 Standard_EXPORT void MemoryInfo (TColStd_IndexedDataMapOfStringString& theDict) const;
395 //! Fill in the dictionary with OpenGL info.
396 //! Should be called with bound context.
397 Standard_EXPORT void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
398 Graphic3d_DiagnosticInfo theFlags) const;
400 //! Access shared resource by its name.
401 //! @param theKey - unique identifier;
402 //! @return handle to shared resource or NULL.
403 Standard_EXPORT const Handle(OpenGl_Resource)& GetResource (const TCollection_AsciiString& theKey) const;
405 //! Access shared resource by its name.
406 //! @param theKey - unique identifier;
407 //! @param theValue - handle to fill;
408 //! @return true if resource was shared.
409 template<typename TheHandleType>
410 Standard_Boolean GetResource (const TCollection_AsciiString& theKey,
411 TheHandleType& theValue) const
413 const Handle(OpenGl_Resource)& aResource = GetResource (theKey);
414 if (aResource.IsNull())
416 return Standard_False;
419 theValue = TheHandleType::DownCast (aResource);
420 return !theValue.IsNull();
423 //! Register shared resource.
424 //! Notice that after registration caller shouldn't release it by himself -
425 //! it will be automatically released on context destruction.
426 //! @param theKey - unique identifier, shouldn't be empty;
427 //! @param theResource - new resource to register, shouldn't be NULL.
428 Standard_EXPORT Standard_Boolean ShareResource (const TCollection_AsciiString& theKey,
429 const Handle(OpenGl_Resource)& theResource);
431 //! Release shared resource.
432 //! If there are more than one reference to this resource
433 //! (also used by some other existing object) then call will be ignored.
434 //! This means that current object itself should nullify handle before this call.
435 //! Notice that this is unrecommended operation at all and should be used
436 //! only in case of fat resources to release memory for other needs.
437 //! @param theKey unique identifier
438 //! @param theToDelay postpone release until next redraw call
439 Standard_EXPORT void ReleaseResource (const TCollection_AsciiString& theKey,
440 const Standard_Boolean theToDelay = Standard_False);
442 //! Append resource to queue for delayed clean up.
443 //! Resources in this queue will be released at next redraw call.
445 void DelayedRelease (Handle(T)& theResource)
447 myUnusedResources->Prepend (theResource);
448 theResource.Nullify();
451 //! Clean up the delayed release queue.
452 Standard_EXPORT void ReleaseDelayed();
454 //! Return map of shared resources.
455 const OpenGl_ResourcesMap& SharedResources() const { return *mySharedResources; }
457 //! @return tool for management of clippings within this context.
458 inline OpenGl_Clipping& ChangeClipping() { return myClippingState; }
460 //! @return tool for management of clippings within this context.
461 inline const OpenGl_Clipping& Clipping() const { return myClippingState; }
463 //! @return tool for management of shader programs within this context.
464 inline const Handle(OpenGl_ShaderManager)& ShaderManager() const { return myShaderManager; }
468 //! Either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1).
469 Standard_Integer TextureWrapClamp() const { return myTexClamp; }
471 //! @return maximum degree of anisotropy texture filter
472 Standard_Integer MaxDegreeOfAnisotropy() const { return myAnisoMax; }
474 //! @return value for GL_MAX_TEXTURE_SIZE
475 Standard_Integer MaxTextureSize() const { return myMaxTexDim; }
477 //! @return value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
478 Standard_Integer MaxCombinedTextureUnits() const { return myMaxTexCombined; }
480 //! @return texture unit to be used for sprites
481 Graphic3d_TextureUnit SpriteTextureUnit() const { return mySpriteTexUnit; }
483 //! @return value for GL_MAX_SAMPLES
484 Standard_Integer MaxMsaaSamples() const { return myMaxMsaaSamples; }
486 //! @return maximum FBO width for image dump
487 Standard_Integer MaxDumpSizeX() const { return myMaxDumpSizeX; }
489 //! @return maximum FBO height for image dump
490 Standard_Integer MaxDumpSizeY() const { return myMaxDumpSizeY; }
492 //! @return value for GL_MAX_DRAW_BUFFERS
493 Standard_Integer MaxDrawBuffers() const { return myMaxDrawBuffers; }
495 //! @return value for GL_MAX_COLOR_ATTACHMENTS
496 Standard_Integer MaxColorAttachments() const { return myMaxColorAttachments; }
498 //! Get maximum number of clip planes supported by OpenGl.
499 //! This value is implementation dependent. At least 6
500 //! planes should be supported by OpenGl (see specs).
501 //! @return value for GL_MAX_CLIP_PLANES
502 Standard_Integer MaxClipPlanes() const { return myMaxClipPlanes; }
504 //! @return TRUE if ray tracing mode is supported
505 Standard_Boolean HasRayTracing() const { return myHasRayTracing; }
507 //! @return TRUE if textures in ray tracing mode are supported
508 Standard_Boolean HasRayTracingTextures() const { return myHasRayTracingTextures; }
510 //! @return TRUE if adaptive screen sampling in ray tracing mode is supported
511 Standard_Boolean HasRayTracingAdaptiveSampling() const { return myHasRayTracingAdaptiveSampling; }
513 //! @return TRUE if atomic adaptive screen sampling in ray tracing mode is supported
514 Standard_Boolean HasRayTracingAdaptiveSamplingAtomic() const { return myHasRayTracingAdaptiveSamplingAtomic; }
516 //! Returns true if VBO is supported and permitted.
517 inline bool ToUseVbo() const
519 return core15fwd != NULL
520 && !caps->vboDisable;
523 //! @return cached state of GL_NORMALIZE.
524 Standard_Boolean IsGlNormalizeEnabled() const { return myIsGlNormalizeEnabled; }
526 //! Sets GL_NORMALIZE enabled or disabled.
527 //! @return old value of the flag
528 Standard_EXPORT Standard_Boolean SetGlNormalizeEnabled (Standard_Boolean isEnabled);
530 //! @return cached state of polygon rasterization mode (glPolygonMode()).
531 Standard_Integer PolygonMode() const { return myPolygonMode; }
533 //! Sets polygon rasterization mode (glPolygonMode() function).
534 //! @return old value of the rasterization mode.
535 Standard_EXPORT Standard_Integer SetPolygonMode (const Standard_Integer theMode);
537 //! @return cached enabled state of polygon hatching rasterization.
538 bool IsPolygonHatchEnabled() const
540 return !myHatchStyles.IsNull() && myHatchStyles->TypeOfHatch() != 0;
543 //! Sets enabled state of polygon hatching rasterization
544 //! without affecting currently selected hatching pattern.
545 //! @return previous state of polygon hatching mode.
546 Standard_EXPORT bool SetPolygonHatchEnabled (const bool theIsEnabled);
548 //! @return cached state of polygon hatch type.
549 Standard_Integer PolygonHatchStyle() const
551 return myHatchStyles.IsNull() ? Aspect_HS_SOLID : myHatchStyles->TypeOfHatch();
554 //! Sets polygon hatch pattern.
555 //! Zero-index value is a default alias for solid filling.
556 //! @param the type of hatch supported by base implementation of
557 //! OpenGl_LineAttributes (Aspect_HatchStyle) or the type supported by custom
558 //! implementation derived from OpenGl_LineAttributes class.
559 //! @return old type of hatch.
560 Standard_EXPORT Standard_Integer SetPolygonHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle);
562 //! Sets and applies current polygon offset.
563 Standard_EXPORT void SetPolygonOffset (const Graphic3d_PolygonOffset& theOffset);
565 //! Returns currently applied polygon offset parameters.
566 const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; }
568 //! Applies matrix stored in ModelWorldState to OpenGl.
569 Standard_EXPORT void ApplyModelWorldMatrix();
571 //! Applies matrix stored in WorldViewState to OpenGl.
572 Standard_EXPORT void ApplyWorldViewMatrix();
574 //! Applies combination of matrices stored in ModelWorldState and WorldViewState to OpenGl.
575 Standard_EXPORT void ApplyModelViewMatrix();
577 //! Applies matrix stored in ProjectionState to OpenGl.
578 Standard_EXPORT void ApplyProjectionMatrix();
582 //! @return messenger instance
583 inline const Handle(Message_Messenger)& Messenger() const
585 return ::Message::DefaultMessenger();
588 //! Callback for GL_ARB_debug_output extension
589 //! @param theSource message source within GL_DEBUG_SOURCE_ enumeration
590 //! @param theType message type within GL_DEBUG_TYPE_ enumeration
591 //! @param theId message ID within source
592 //! @param theSeverity message severity within GL_DEBUG_SEVERITY_ enumeration
593 //! @param theMessage the message itself
594 Standard_EXPORT void PushMessage (const unsigned int theSource,
595 const unsigned int theType,
596 const unsigned int theId,
597 const unsigned int theSeverity,
598 const TCollection_ExtendedString& theMessage);
600 //! Adds a filter for messages with theId and theSource (GL_DEBUG_SOURCE_)
601 Standard_EXPORT Standard_Boolean ExcludeMessage (const unsigned int theSource,
602 const unsigned int theId);
604 //! Removes a filter for messages with theId and theSource (GL_DEBUG_SOURCE_)
605 Standard_EXPORT Standard_Boolean IncludeMessage (const unsigned int theSource,
606 const unsigned int theId);
608 //! @return true if OpenGl context supports left and
609 //! right rendering buffers.
610 Standard_Boolean HasStereoBuffers() const
612 #if !defined(GL_ES_VERSION_2_0)
613 return myIsStereoBuffers;
615 return Standard_False;
619 public: //! @name methods to alter or retrieve current state
621 //! Return structure holding frame statistics.
622 const Handle(OpenGl_FrameStats)& FrameStats() const { return myFrameStats; }
624 //! Set structure holding frame statistics.
625 //! This call makes sense only if application defines OpenGl_FrameStats sub-class.
626 void SetFrameStats (const Handle(OpenGl_FrameStats)& theStats) { myFrameStats = theStats; }
628 //! Return cached viewport definition (x, y, width, height).
629 const Standard_Integer* Viewport() const { return myViewport; }
631 //! Resize the viewport (alias for glViewport).
632 //! @param theRect viewport definition (x, y, width, height)
633 Standard_EXPORT void ResizeViewport (const Standard_Integer theRect[4]);
635 //! Return virtual viewport definition (x, y, width, height).
636 const Standard_Integer* VirtualViewport() const { return myViewportVirt; }
638 //! Return active read buffer.
639 Standard_Integer ReadBuffer() { return myReadBuffer; }
641 //! Switch read buffer, wrapper for ::glReadBuffer().
642 Standard_EXPORT void SetReadBuffer (const Standard_Integer theReadBuffer);
644 //! Return active draw buffer attached to a render target referred by index (layout location).
645 Standard_Integer DrawBuffer (Standard_Integer theIndex = 0) const
647 return theIndex >= myDrawBuffers.Lower()
648 && theIndex <= myDrawBuffers.Upper()
649 ? myDrawBuffers.Value (theIndex)
653 //! Switch draw buffer, wrapper for ::glDrawBuffer().
654 Standard_EXPORT void SetDrawBuffer (const Standard_Integer theDrawBuffer);
656 //! Switch draw buffer, wrapper for ::glDrawBuffers (GLsizei, const GLenum*).
657 Standard_EXPORT void SetDrawBuffers (const Standard_Integer theNb, const Standard_Integer* theDrawBuffers);
659 //! Switch read/draw buffers.
660 void SetReadDrawBuffer (const Standard_Integer theBuffer)
662 SetReadBuffer (theBuffer);
663 SetDrawBuffer (theBuffer);
666 //! Return cached flag indicating writing into color buffer is enabled or disabled (glColorMask).
667 bool ColorMask() const { return myColorMask; }
669 //! Enable/disable writing into color buffer (wrapper for glColorMask).
670 Standard_EXPORT bool SetColorMask (bool theToWriteColor);
672 //! Return TRUE if GL_SAMPLE_ALPHA_TO_COVERAGE usage is allowed.
673 bool AllowSampleAlphaToCoverage() const { return myAllowAlphaToCov; }
675 //! Allow GL_SAMPLE_ALPHA_TO_COVERAGE usage.
676 void SetAllowSampleAlphaToCoverage (bool theToEnable) { myAllowAlphaToCov = theToEnable; }
678 //! Return GL_SAMPLE_ALPHA_TO_COVERAGE state.
679 bool SampleAlphaToCoverage() const { return myAlphaToCoverage; }
681 //! Enable/disable GL_SAMPLE_ALPHA_TO_COVERAGE.
682 Standard_EXPORT bool SetSampleAlphaToCoverage (bool theToEnable);
684 //! Return back face culling state.
685 bool ToCullBackFaces() const { return myToCullBackFaces; }
687 //! Enable or disable back face culling (glEnable (GL_CULL_FACE)).
688 Standard_EXPORT void SetCullBackFaces (bool theToEnable);
690 //! Fetch OpenGl context state. This class tracks value of several OpenGl
691 //! state variables. Consulting the cached values is quicker than
692 //! doing the same via OpenGl API. Call this method if any of the controlled
693 //! OpenGl state variables has a possibility of being out-of-date.
694 Standard_EXPORT void FetchState();
696 //! @return active textures
697 const Handle(OpenGl_TextureSet)& ActiveTextures() const { return myActiveTextures; }
699 //! Bind specified texture set to current context,
700 //! or unbind previous one when NULL specified.
701 Standard_EXPORT Handle(OpenGl_TextureSet) BindTextures (const Handle(OpenGl_TextureSet)& theTextures);
703 //! @return active GLSL program
704 const Handle(OpenGl_ShaderProgram)& ActiveProgram() const
706 return myActiveProgram;
709 //! Bind specified program to current context,
710 //! or unbind previous one when NULL specified.
711 //! @return true if some program is bound to context
712 Standard_EXPORT Standard_Boolean BindProgram (const Handle(OpenGl_ShaderProgram)& theProgram);
714 //! Setup current shading material.
715 Standard_EXPORT void SetShadingMaterial (const OpenGl_Aspects* theAspect,
716 const Handle(Graphic3d_PresentationAttributes)& theHighlight);
718 //! Checks if transparency is required for the given aspect and highlight style.
719 Standard_EXPORT static Standard_Boolean CheckIsTransparent (const OpenGl_Aspects* theAspect,
720 const Handle(Graphic3d_PresentationAttributes)& theHighlight,
721 Standard_ShortReal& theAlphaFront,
722 Standard_ShortReal& theAlphaBack);
724 //! Checks if transparency is required for the given aspect and highlight style.
725 static Standard_Boolean CheckIsTransparent (const OpenGl_Aspects* theAspect,
726 const Handle(Graphic3d_PresentationAttributes)& theHighlight)
728 Standard_ShortReal anAlphaFront = 1.0f, anAlphaBack = 1.0f;
729 return CheckIsTransparent (theAspect, theHighlight, anAlphaFront, anAlphaBack);
732 //! Setup current color.
733 Standard_EXPORT void SetColor4fv (const OpenGl_Vec4& theColor);
735 //! Setup type of line.
736 Standard_EXPORT void SetTypeOfLine (const Aspect_TypeOfLine theType,
737 const Standard_ShortReal theFactor = 1.0f);
739 //! Setup width of line.
740 Standard_EXPORT void SetLineWidth (const Standard_ShortReal theWidth);
742 //! Setup point size.
743 Standard_EXPORT void SetPointSize (const Standard_ShortReal theSize);
745 //! Setup point sprite origin using GL_POINT_SPRITE_COORD_ORIGIN state:
746 //! - GL_UPPER_LEFT when GLSL program is active;
747 //! flipping should be handled in GLSL program for compatibility with OpenGL ES
748 //! - GL_LOWER_LEFT for FFP
749 Standard_EXPORT void SetPointSpriteOrigin();
751 //! Setup texture matrix to active GLSL program or to FFP global state using glMatrixMode (GL_TEXTURE).
752 Standard_EXPORT void SetTextureMatrix (const Handle(Graphic3d_TextureParams)& theParams);
754 //! Bind default Vertex Array Object
755 Standard_EXPORT void BindDefaultVao();
757 //! Default Frame Buffer Object.
758 const Handle(OpenGl_FrameBuffer)& DefaultFrameBuffer() const
763 //! Setup new Default Frame Buffer Object and return previously set.
764 //! This call doesn't change Active FBO!
765 Standard_EXPORT Handle(OpenGl_FrameBuffer) SetDefaultFrameBuffer (const Handle(OpenGl_FrameBuffer)& theFbo);
767 //! Return debug context initialization state.
768 Standard_Boolean IsDebugContext() const
770 return myIsGlDebugCtx;
773 Standard_EXPORT void EnableFeatures() const;
775 Standard_EXPORT void DisableFeatures() const;
777 //! Return resolution for rendering text.
778 unsigned int Resolution() const { return myResolution; }
780 //! Resolution scale factor (rendered resolution to standard resolution).
781 //! This scaling factor for parameters like text size to be properly displayed on device (screen / printer).
782 Standard_ShortReal ResolutionRatio() const { return myResolutionRatio; }
784 //! Rendering scale factor (rendering viewport height to real window buffer height).
785 Standard_ShortReal RenderScale() const { return myRenderScale; }
787 //! Return TRUE if rendering scale factor is not 1.
788 Standard_Boolean HasRenderScale() const { return Abs (myRenderScale - 1.0f) > 0.0001f; }
790 //! Rendering scale factor (inverted value).
791 Standard_ShortReal RenderScaleInv() const { return myRenderScaleInv; }
793 //! Return scale factor for line width.
794 Standard_ShortReal LineWidthScale() const { return myLineWidthScale; }
796 //! Set resolution ratio.
797 //! Note that this method rounds @theRatio to nearest integer.
798 void SetResolution (unsigned int theResolution,
799 Standard_ShortReal theRatio,
800 Standard_ShortReal theScale)
802 myResolution = (unsigned int )(theScale * theResolution + 0.5f);
803 myRenderScale = theScale;
804 myRenderScaleInv = 1.0f / theScale;
805 SetResolutionRatio (theRatio * theScale);
808 //! Set resolution ratio.
809 //! Note that this method rounds @theRatio to nearest integer.
810 void SetResolutionRatio (const Standard_ShortReal theRatio)
812 myResolutionRatio = theRatio;
813 myLineWidthScale = Max (1.0f, std::floor (theRatio + 0.5f));
816 //! Return line feater width in pixels.
817 Standard_ShortReal LineFeather() const { return myLineFeather; }
819 //! Set line feater width.
820 void SetLineFeather(Standard_ShortReal theValue) { myLineFeather = theValue; }
822 //! Return Graphics Driver's vendor.
823 const TCollection_AsciiString& Vendor() const { return myVendor; }
827 //! Wrapper to system function to retrieve GL function pointer by name.
828 Standard_EXPORT void* findProc (const char* theFuncName);
830 //! Print error if not all functions have been exported by context for reported version.
831 //! Note that this will never happen when using GLX, since returned functions can not be validated.
832 //! @param theGlVerMajor the OpenGL major version with missing functions
833 //! @param theGlVerMinor the OpenGL minor version with missing functions
834 Standard_EXPORT void checkWrongVersion (const Standard_Integer theGlVerMajor,
835 const Standard_Integer theGlVerMinor);
837 //! Private initialization function that should be called only once.
838 Standard_EXPORT void init (const Standard_Boolean theIsCoreProfile);
840 public: //! @name core profiles
842 OpenGl_GlCore11* core11; //!< OpenGL 1.1 core functionality
843 OpenGl_GlCore11Fwd* core11fwd; //!< OpenGL 1.1 without deprecated entry points
844 OpenGl_GlCore15* core15; //!< OpenGL 1.5 core functionality
845 OpenGl_GlCore15Fwd* core15fwd; //!< OpenGL 1.5 without deprecated entry points
846 OpenGl_GlCore20* core20; //!< OpenGL 2.0 core functionality (includes 1.5)
847 OpenGl_GlCore20Fwd* core20fwd; //!< OpenGL 2.0 without deprecated entry points
848 OpenGl_GlCore32* core32; //!< OpenGL 3.2 core profile
849 OpenGl_GlCore32Back* core32back; //!< OpenGL 3.2 backward compatibility profile
850 OpenGl_GlCore33* core33; //!< OpenGL 3.3 core profile
851 OpenGl_GlCore33Back* core33back; //!< OpenGL 3.3 backward compatibility profile
852 OpenGl_GlCore41* core41; //!< OpenGL 4.1 core profile
853 OpenGl_GlCore41Back* core41back; //!< OpenGL 4.1 backward compatibility profile
854 OpenGl_GlCore42* core42; //!< OpenGL 4.2 core profile
855 OpenGl_GlCore42Back* core42back; //!< OpenGL 4.2 backward compatibility profile
856 OpenGl_GlCore43* core43; //!< OpenGL 4.3 core profile
857 OpenGl_GlCore43Back* core43back; //!< OpenGL 4.3 backward compatibility profile
858 OpenGl_GlCore44* core44; //!< OpenGL 4.4 core profile
859 OpenGl_GlCore44Back* core44back; //!< OpenGL 4.4 backward compatibility profile
860 OpenGl_GlCore45* core45; //!< OpenGL 4.5 core profile
861 OpenGl_GlCore45Back* core45back; //!< OpenGL 4.5 backward compatibility profile
863 Handle(OpenGl_Caps) caps; //!< context options
865 public: //! @name extensions
867 Standard_Boolean hasHighp; //!< highp in GLSL ES fragment shader is supported
868 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)
869 Standard_Boolean hasTexRGBA8; //!< always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_rgb8_rgba8
870 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)
871 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)
872 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)
873 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)
874 OpenGl_FeatureFlag hasSampleVariables; //!< Complex flag indicating support of MSAA variables in GLSL shader (desktop OpenGL 4.0, GL_ARB_sample_shading)
875 OpenGl_FeatureFlag hasGeometryStage; //!< Complex flag indicating support of Geometry shader (desktop OpenGL 3.2, OpenGL ES 3.2, GL_EXT_geometry_shader)
876 Standard_Boolean arbDrawBuffers; //!< GL_ARB_draw_buffers
877 Standard_Boolean arbNPTW; //!< GL_ARB_texture_non_power_of_two
878 Standard_Boolean arbTexRG; //!< GL_ARB_texture_rg
879 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)
880 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)
881 OpenGl_ArbTexBindless* arbTexBindless; //!< GL_ARB_bindless_texture
882 OpenGl_ArbTBO* arbTBO; //!< GL_ARB_texture_buffer_object
883 Standard_Boolean arbTboRGB32; //!< GL_ARB_texture_buffer_object_rgb32 (3-component TBO), in core since 4.0
884 OpenGl_ArbIns* arbIns; //!< GL_ARB_draw_instanced
885 OpenGl_ArbDbg* arbDbg; //!< GL_ARB_debug_output
886 OpenGl_ArbFBO* arbFBO; //!< GL_ARB_framebuffer_object
887 OpenGl_ArbFBOBlit* arbFBOBlit; //!< glBlitFramebuffer function, moved out from OpenGl_ArbFBO structure for compatibility with OpenGL ES 2.0
888 Standard_Boolean arbSampleShading; //!< GL_ARB_sample_shading
889 Standard_Boolean extFragDepth; //!< GL_EXT_frag_depth on OpenGL ES 2.0 (gl_FragDepthEXT built-in variable, before OpenGL ES 3.0)
890 Standard_Boolean extDrawBuffers; //!< GL_EXT_draw_buffers
891 OpenGl_ExtGS* extGS; //!< GL_EXT_geometry_shader4
892 Standard_Boolean extBgra; //!< GL_EXT_bgra or GL_EXT_texture_format_BGRA8888 on OpenGL ES
893 Standard_Boolean extAnis; //!< GL_EXT_texture_filter_anisotropic
894 Standard_Boolean extPDS; //!< GL_EXT_packed_depth_stencil
895 Standard_Boolean atiMem; //!< GL_ATI_meminfo
896 Standard_Boolean nvxMem; //!< GL_NVX_gpu_memory_info
897 Standard_Boolean oesSampleVariables; //!< GL_OES_sample_variables
898 Standard_Boolean oesStdDerivatives; //!< GL_OES_standard_derivatives
900 public: //! @name public properties tracking current state
902 OpenGl_MatrixState<Standard_ShortReal> ModelWorldState; //!< state of orientation matrix
903 OpenGl_MatrixState<Standard_ShortReal> WorldViewState; //!< state of orientation matrix
904 OpenGl_MatrixState<Standard_ShortReal> ProjectionState; //!< state of projection matrix
906 private: // system-dependent fields
908 #if defined(HAVE_EGL)
909 Aspect_Drawable myWindow; //!< EGL surface : EGLSurface
910 Aspect_Display myDisplay; //!< EGL connection to the Display : EGLDisplay
911 Aspect_RenderingContext myGContext; //!< EGL rendering context : EGLContext
912 #elif defined(_WIN32)
913 Aspect_Handle myWindow; //!< window handle (owner of GL context) : HWND
914 Aspect_Handle myWindowDC; //!< Device Descriptor handle : HDC
915 Aspect_RenderingContext myGContext; //!< Rendering Context handle : HGLRC
916 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
917 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
918 EAGLContext* myGContext; //!< Rendering Context handle
920 NSOpenGLContext* myGContext; //!< Rendering Context handle
923 Aspect_Drawable myWindow; //!< window handle (owner of GL context) : GLXDrawable
924 Aspect_Display myDisplay; //!< connection to the X-server : Display*
925 Aspect_RenderingContext myGContext; //!< X-GLX rendering context : GLXContext
928 private: // context info
930 typedef NCollection_Shared< NCollection_DataMap<TCollection_AsciiString, Standard_Integer> > OpenGl_DelayReleaseMap;
931 typedef NCollection_Shared< NCollection_List<Handle(OpenGl_Resource)> > OpenGl_ResourcesStack;
933 Handle(OpenGl_ResourcesMap) mySharedResources; //!< shared resources with unique identification key
934 Handle(OpenGl_DelayReleaseMap) myDelayed; //!< shared resources for delayed release
935 Handle(OpenGl_ResourcesStack) myUnusedResources; //!< stack of resources for delayed clean up
937 OpenGl_Clipping myClippingState; //!< state of clip planes
939 void* myGlLibHandle; //!< optional handle to GL library
940 NCollection_Handle<OpenGl_GlFunctions>
941 myFuncs; //!< mega structure for all GL functions
942 Standard_Integer myAnisoMax; //!< maximum level of anisotropy texture filter
943 Standard_Integer myTexClamp; //!< either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1)
944 Standard_Integer myMaxTexDim; //!< value for GL_MAX_TEXTURE_SIZE
945 Standard_Integer myMaxTexCombined; //!< value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
946 Standard_Integer myMaxDumpSizeX; //!< maximum FBO width for image dump
947 Standard_Integer myMaxDumpSizeY; //!< maximum FBO height for image dump
948 Standard_Integer myMaxClipPlanes; //!< value for GL_MAX_CLIP_PLANES
949 Standard_Integer myMaxMsaaSamples; //!< value for GL_MAX_SAMPLES
950 Standard_Integer myMaxDrawBuffers; //!< value for GL_MAX_DRAW_BUFFERS
951 Standard_Integer myMaxColorAttachments; //!< value for GL_MAX_COLOR_ATTACHMENTS
952 Standard_Integer myGlVerMajor; //!< cached GL version major number
953 Standard_Integer myGlVerMinor; //!< cached GL version minor number
954 Standard_Boolean myIsInitialized; //!< flag indicates initialization state
955 Standard_Boolean myIsStereoBuffers; //!< context supports stereo buffering
956 Standard_Boolean myIsGlNormalizeEnabled; //!< GL_NORMALIZE flag
957 //!< Used to tell OpenGl that normals should be normalized
958 Graphic3d_TextureUnit mySpriteTexUnit; //!< texture unit for point sprite texture
960 Standard_Boolean myHasRayTracing; //! indicates whether ray tracing mode is supported
961 Standard_Boolean myHasRayTracingTextures; //! indicates whether textures in ray tracing mode are supported
962 Standard_Boolean myHasRayTracingAdaptiveSampling; //! indicates whether adaptive screen sampling in ray tracing mode is supported
963 Standard_Boolean myHasRayTracingAdaptiveSamplingAtomic; //! indicates whether atomic adaptive screen sampling in ray tracing mode is supported
965 Handle(OpenGl_ShaderManager) myShaderManager; //! support object for managing shader programs
967 private: //! @name fields tracking current state
969 Handle(OpenGl_FrameStats) myFrameStats; //!< structure accumulating frame statistics
970 Handle(OpenGl_ShaderProgram) myActiveProgram; //!< currently active GLSL program
971 Handle(OpenGl_TextureSet) myActiveTextures; //!< currently bound textures
972 //!< currently active sampler objects
973 Handle(OpenGl_FrameBuffer) myDefaultFbo; //!< default Frame Buffer Object
974 Handle(OpenGl_LineAttributes) myHatchStyles; //!< resource holding predefined hatch styles patterns
975 Standard_Integer myViewport[4]; //!< current viewport
976 Standard_Integer myViewportVirt[4]; //!< virtual viewport
977 Standard_Integer myPointSpriteOrig; //!< GL_POINT_SPRITE_COORD_ORIGIN state (GL_UPPER_LEFT by default)
978 Standard_Integer myRenderMode; //!< value for active rendering mode
979 Standard_Integer myPolygonMode; //!< currently used polygon rasterization mode (glPolygonMode)
980 Graphic3d_PolygonOffset myPolygonOffset; //!< currently applied polygon offset
981 bool myToCullBackFaces; //!< back face culling mode enabled state (glIsEnabled (GL_CULL_FACE))
982 Standard_Integer myReadBuffer; //!< current read buffer
983 NCollection_Array1<Standard_Integer>
984 myDrawBuffers; //!< current draw buffers
985 unsigned int myDefaultVao; //!< default Vertex Array Object
986 Standard_Boolean myColorMask; //!< flag indicating writing into color buffer is enabled or disabled (glColorMask)
987 Standard_Boolean myAllowAlphaToCov; //!< flag allowing GL_SAMPLE_ALPHA_TO_COVERAGE usage
988 Standard_Boolean myAlphaToCoverage; //!< flag indicating GL_SAMPLE_ALPHA_TO_COVERAGE state
989 Standard_Boolean myIsGlDebugCtx; //!< debug context initialization state
990 TCollection_AsciiString myVendor; //!< Graphics Driver's vendor
991 TColStd_PackedMapOfInteger myFilters[6]; //!< messages suppressing filter (for sources from GL_DEBUG_SOURCE_API_ARB to GL_DEBUG_SOURCE_OTHER_ARB)
992 unsigned int myResolution; //!< Pixels density (PPI), defines scaling factor for parameters like text size
993 Standard_ShortReal myResolutionRatio; //!< scaling factor for parameters like text size
994 //! to be properly displayed on device (screen / printer)
995 Standard_ShortReal myLineWidthScale; //!< scaling factor for line width
996 Standard_ShortReal myLineFeather; //!< line feater width in pixels
997 Standard_ShortReal myRenderScale; //!< scaling factor for rendering resolution
998 Standard_ShortReal myRenderScaleInv; //!< scaling factor for rendering resolution (inverted value)
999 OpenGl_Material myMatFront; //!< current front material state (cached to reduce GL context updates)
1000 OpenGl_Material myMatBack; //!< current back material state
1004 //! Copying allowed only within Handles
1005 OpenGl_Context (const OpenGl_Context& );
1006 OpenGl_Context& operator= (const OpenGl_Context& );
1010 #endif // _OpenGl_Context_H__