#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
#include <EGL/egl.h>
+ #ifndef EGL_OPENGL_ES3_BIT
+ #define EGL_OPENGL_ES3_BIT 0x00000040
+ #endif
#endif
namespace
EGLConfig aCfg = NULL;
EGLint aNbConfigs = 0;
- if (eglChooseConfig (theDisplay, aConfigAttribs, &aCfg, 1, &aNbConfigs) == EGL_TRUE
- || aCfg != NULL)
+ for (Standard_Integer aGlesVer = 3; aGlesVer >= 2; --aGlesVer)
{
- return aCfg;
- }
+ #if defined(GL_ES_VERSION_2_0)
+ aConfigAttribs[6 * 2 + 1] = aGlesVer == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT;
+ #else
+ if (aGlesVer == 2)
+ {
+ break;
+ }
+ #endif
- eglGetError();
- aConfigAttribs[4 * 2 + 1] = 16; // try config with smaller depth buffer
- if (eglChooseConfig (theDisplay, aConfigAttribs, &aCfg, 1, &aNbConfigs) != EGL_TRUE
- || aCfg == NULL)
- {
+ if (eglChooseConfig (theDisplay, aConfigAttribs, &aCfg, 1, &aNbConfigs) == EGL_TRUE
+ && aCfg != NULL)
+ {
+ return aCfg;
+ }
+ eglGetError();
+
+ aConfigAttribs[4 * 2 + 1] = 16; // try config with smaller depth buffer
+ if (eglChooseConfig (theDisplay, aConfigAttribs, &aCfg, 1, &aNbConfigs) == EGL_TRUE
+ && aCfg != NULL)
+ {
+ return aCfg;
+ }
eglGetError();
}
return aCfg;
{
throw Aspect_GraphicDeviceDefinitionError("OpenGl_GraphicDriver: default context can not be initialized!");
}
-
- // default layers are always presented in display layer sequence it can not be removed
- {
- Graphic3d_ZLayerSettings aSettings;
- aSettings.SetImmediate (Standard_False);
- aSettings.SetEnvironmentTexture (Standard_False);
- aSettings.SetEnableDepthTest (Standard_False);
- aSettings.SetEnableDepthWrite (Standard_False);
- aSettings.SetClearDepth (Standard_False);
- aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
- myLayerIds.Add (Graphic3d_ZLayerId_BotOSD);
- myLayerSeq.Append (Graphic3d_ZLayerId_BotOSD);
- myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_BotOSD, aSettings);
- }
-
- {
- Graphic3d_ZLayerSettings aSettings;
- aSettings.SetImmediate (Standard_False);
- aSettings.SetEnvironmentTexture (Standard_True);
- aSettings.SetEnableDepthTest (Standard_True);
- aSettings.SetEnableDepthWrite (Standard_True);
- aSettings.SetClearDepth (Standard_False);
- aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
- myLayerIds.Add (Graphic3d_ZLayerId_Default);
- myLayerSeq.Append (Graphic3d_ZLayerId_Default);
- myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Default, aSettings);
- }
-
- {
- Graphic3d_ZLayerSettings aSettings;
- aSettings.SetImmediate (Standard_True);
- aSettings.SetEnvironmentTexture (Standard_True);
- aSettings.SetEnableDepthTest (Standard_True);
- aSettings.SetEnableDepthWrite (Standard_True);
- aSettings.SetClearDepth (Standard_False);
- aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
- myLayerIds.Add (Graphic3d_ZLayerId_Top);
- myLayerSeq.Append (Graphic3d_ZLayerId_Top);
- myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Top, aSettings);
- }
-
- {
- Graphic3d_ZLayerSettings aSettings;
- aSettings.SetImmediate (Standard_True);
- aSettings.SetEnvironmentTexture (Standard_True);
- aSettings.SetEnableDepthTest (Standard_True);
- aSettings.SetEnableDepthWrite (Standard_True);
- aSettings.SetClearDepth (Standard_True);
- aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
- myLayerIds.Add (Graphic3d_ZLayerId_Topmost);
- myLayerSeq.Append (Graphic3d_ZLayerId_Topmost);
- myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_Topmost, aSettings);
- }
-
- {
- Graphic3d_ZLayerSettings aSettings;
- aSettings.SetImmediate (Standard_True);
- aSettings.SetEnvironmentTexture (Standard_False);
- aSettings.SetEnableDepthTest (Standard_False);
- aSettings.SetEnableDepthWrite (Standard_False);
- aSettings.SetClearDepth (Standard_False);
- aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
- myLayerIds.Add (Graphic3d_ZLayerId_TopOSD);
- myLayerSeq.Append (Graphic3d_ZLayerId_TopOSD);
- myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_TopOSD, aSettings);
- }
}
// =======================================================================
}
#if defined(GL_ES_VERSION_2_0)
- EGLint anEglCtxAttribs[] =
- {
- EGL_CONTEXT_CLIENT_VERSION, 2,
- EGL_NONE
- };
+ EGLint anEglCtxAttribs3[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE, EGL_NONE };
+ EGLint anEglCtxAttribs2[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
if (eglBindAPI (EGL_OPENGL_ES_API) != EGL_TRUE)
{
::Message::DefaultMessenger()->Send ("Error: EGL does not provide OpenGL ES client!", Message_Fail);
return Standard_False;
}
+ myEglContext = (Aspect_RenderingContext )eglCreateContext ((EGLDisplay )myEglDisplay, myEglConfig, EGL_NO_CONTEXT, anEglCtxAttribs3);
+ if ((EGLContext )myEglContext == EGL_NO_CONTEXT)
+ {
+ myEglContext = (Aspect_RenderingContext )eglCreateContext ((EGLDisplay )myEglDisplay, myEglConfig, EGL_NO_CONTEXT, anEglCtxAttribs2);
+ }
#else
EGLint* anEglCtxAttribs = NULL;
if (eglBindAPI (EGL_OPENGL_API) != EGL_TRUE)
::Message::DefaultMessenger()->Send ("Error: EGL does not provide OpenGL client!", Message_Fail);
return Standard_False;
}
+ myEglContext = (Aspect_RenderingContext )eglCreateContext ((EGLDisplay )myEglDisplay, myEglConfig, EGL_NO_CONTEXT, anEglCtxAttribs);
#endif
- myEglContext = (Aspect_RenderingContext )eglCreateContext ((EGLDisplay )myEglDisplay, myEglConfig, EGL_NO_CONTEXT, anEglCtxAttribs);
if ((EGLContext )myEglContext == EGL_NO_CONTEXT)
{
::Message::DefaultMessenger()->Send ("Error: EGL is unable to create OpenGL context!", Message_Fail);
return (!aCtx.IsNull() && aCtx->HasRayTracingTextures()) ? 1 : 0;
case Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSampling:
return (!aCtx.IsNull() && aCtx->HasRayTracingAdaptiveSampling()) ? 1 : 0;
+ case Graphic3d_TypeOfLimit_HasRayTracingAdaptiveSamplingAtomic:
+ return (!aCtx.IsNull() && aCtx->HasRayTracingAdaptiveSamplingAtomic()) ? 1 : 0;
case Graphic3d_TypeOfLimit_HasBlendedOit:
return (!aCtx.IsNull()
&& aCtx->hasDrawBuffers != OpenGl_FeatureNotAvailable
return !aCtx.IsNull() && aCtx->hasFlatShading != OpenGl_FeatureNotAvailable ? 1 : 0;
case Graphic3d_TypeOfLimit_IsWorkaroundFBO:
return !aCtx.IsNull() && aCtx->MaxTextureSize() != aCtx->MaxDumpSizeX() ? 1 : 0;
+ case Graphic3d_TypeOfLimit_HasMeshEdges:
+ return !aCtx.IsNull() && aCtx->hasGeometryStage != OpenGl_FeatureNotAvailable ? 1 : 0;
case Graphic3d_TypeOfLimit_NB:
return 0;
}
// function : GetSharedContext
// purpose :
// =======================================================================
-const Handle(OpenGl_Context)& OpenGl_GraphicDriver::GetSharedContext() const
+const Handle(OpenGl_Context)& OpenGl_GraphicDriver::GetSharedContext (bool theBound) const
{
if (myMapOfView.IsEmpty())
{
return TheNullGlCtx;
}
- NCollection_Map<Handle(OpenGl_View)>::Iterator anIter (myMapOfView);
- for (; anIter.More(); anIter.Next())
+ for (NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIter (myMapOfView); aViewIter.More(); aViewIter.Next())
{
- Handle(OpenGl_Window) aWindow = anIter.Value()->GlWindow();
- if (aWindow.IsNull())
+ if (const Handle(OpenGl_Window)& aWindow = aViewIter.Value()->GlWindow())
{
- continue;
+ if (!theBound)
+ {
+ return aWindow->GetGlContext();
+ }
+ else if (aWindow->GetGlContext()->IsCurrent())
+ {
+ return aWindow->GetGlContext();
+ }
}
-
- return aWindow->GetGlContext();
}
return TheNullGlCtx;
const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight;
OpenGl_TextParam aTextParam;
aTextParam.Height = (int )aHeight;
- OpenGl_AspectText aTextAspect;
- aTextAspect.Aspect()->SetSpace (0.3);
+ OpenGl_Aspects aTextAspect;
TCollection_ExtendedString anExtText = theText;
NCollection_String aText (anExtText.ToExtString());
OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aTextParam, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);
}
-//=======================================================================
-//function : addZLayerIndex
-//purpose :
-//=======================================================================
-void OpenGl_GraphicDriver::addZLayerIndex (const Graphic3d_ZLayerId theLayerId)
-{
- // remove index
- for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
- {
- if (aLayerIt.Value() == theLayerId)
- {
- myLayerSeq.Remove (aLayerIt);
- break;
- }
- }
-
- if (myMapOfZLayerSettings.Find (theLayerId).IsImmediate())
- {
- myLayerSeq.Append (theLayerId);
- return;
- }
-
- for (TColStd_SequenceOfInteger::Iterator aLayerIt (myLayerSeq); aLayerIt.More(); aLayerIt.Next())
- {
- const Graphic3d_ZLayerSettings& aSettings = myMapOfZLayerSettings.Find (aLayerIt.Value());
- if (aSettings.IsImmediate())
- {
- aLayerIt.Previous();
- if (aLayerIt.More())
- {
- myLayerSeq.InsertAfter (aLayerIt, theLayerId);
- return;
- }
-
- // first non-immediate layer
- myLayerSeq.Prepend (theLayerId);
- return;
- }
- }
-
- // no immediate layers
- myLayerSeq.Append (theLayerId);
-}
-
//=======================================================================
//function : AddZLayer
//purpose :
myLayerIds.Remove (theLayerId);
}
-//=======================================================================
-//function : ZLayers
-//purpose :
-//=======================================================================
-void OpenGl_GraphicDriver::ZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
-{
- theLayerSeq.Assign (myLayerSeq);
-}
-
//=======================================================================
//function : SetZLayerSettings
//purpose :
void OpenGl_GraphicDriver::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
const Graphic3d_ZLayerSettings& theSettings)
{
- Graphic3d_ZLayerSettings* aSettings = myMapOfZLayerSettings.ChangeSeek (theLayerId);
- if (aSettings != NULL)
- {
- const bool isChanged = (aSettings->IsImmediate() != theSettings.IsImmediate());
- *aSettings = theSettings;
- if (isChanged)
- {
- addZLayerIndex (theLayerId);
- }
- }
- else
- {
- // abnormal case
- myMapOfZLayerSettings.Bind (theLayerId, theSettings);
- addZLayerIndex (theLayerId);
- }
+ base_type::SetZLayerSettings (theLayerId, theSettings);
// Change Z layer settings in all managed views
for (NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIt (myMapOfView); aViewIt.More(); aViewIt.Next())
}
}
-//=======================================================================
-//function : ZLayerSettings
-//purpose :
-//=======================================================================
-const Graphic3d_ZLayerSettings& OpenGl_GraphicDriver::ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const
-{
- Standard_ASSERT_RAISE (myLayerIds.Contains (theLayerId),
- "OpenGl_GraphicDriver::ZLayerSettings, "
- "Layer with theLayerId does not exist");
-
- return myMapOfZLayerSettings.Find (theLayerId);
-}
-
// =======================================================================
// function : Structure
// purpose :