diff --git a/src/OpenGl/FILES b/src/OpenGl/FILES index e5b28a4b3c..c15c132dc6 100755 --- a/src/OpenGl/FILES +++ b/src/OpenGl/FILES @@ -84,6 +84,8 @@ OpenGl_ExtGS.hxx OpenGl_GLESExtensions.hxx OpenGl_GlFunctions.cxx OpenGl_GlFunctions.hxx +OpenGl_GlNative.hxx +OpenGl_GlTypes.hxx OpenGl_Flipper.cxx OpenGl_Flipper.hxx OpenGl_GlCore11.hxx diff --git a/src/OpenGl/OpenGl_AspectsSprite.cxx b/src/OpenGl/OpenGl_AspectsSprite.cxx index 81ad63cc78..bf9a21df3e 100644 --- a/src/OpenGl/OpenGl_AspectsSprite.cxx +++ b/src/OpenGl/OpenGl_AspectsSprite.cxx @@ -83,15 +83,14 @@ bool OpenGl_AspectsSprite::HasPointSprite (const Handle(OpenGl_Context)& theCtx, bool OpenGl_AspectsSprite::IsDisplayListSprite (const Handle(OpenGl_Context)& theCtx, const Handle(Graphic3d_Aspects)& theAspects) { -#if !defined(GL_ES_VERSION_2_0) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + return false; + } + const Handle(OpenGl_PointSprite)& aSprite = Sprite (theCtx, theAspects, false); return !aSprite.IsNull() && aSprite->IsDisplayList(); -#else - (void )theCtx; - (void )theAspects; - return false; -#endif } // ======================================================================= @@ -274,7 +273,6 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx, } else if (theCtx->core11ffp != NULL) { - #if !defined(GL_ES_VERSION_2_0) // Creating list with bitmap for using it in compatibility mode GLuint aBitmapList = theCtx->core11ffp->glGenLists (1); aSprite->SetDisplayList (theCtx, aBitmapList); @@ -315,7 +313,7 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx, { if (aFormat.IsValid()) { - aBitmapList = glGenLists (1); + aBitmapList = theCtx->core11ffp->glGenLists (1); aSpriteA->SetDisplayList (theCtx, aBitmapList); } @@ -329,7 +327,6 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx, theCtx->core11ffp->glEndList(); } } - #endif } } // ======================================================================= diff --git a/src/OpenGl/OpenGl_CappingAlgo.cxx b/src/OpenGl/OpenGl_CappingAlgo.cxx index eed90116dd..94bd57c1a3 100755 --- a/src/OpenGl/OpenGl_CappingAlgo.cxx +++ b/src/OpenGl/OpenGl_CappingAlgo.cxx @@ -29,17 +29,18 @@ namespace //! Auxiliary sentry object managing stencil test. struct StencilTestSentry { - StencilTestSentry() : myDepthFuncPrev (0) {} + StencilTestSentry (const Handle(OpenGl_Context)& theCtx) + : myCtx (theCtx.get()), myDepthFuncPrev (0) {} //! Restore previous application state. ~StencilTestSentry() { if (myDepthFuncPrev != 0) { - glClear (GL_STENCIL_BUFFER_BIT); - glDepthFunc (myDepthFuncPrev); - glStencilFunc (GL_ALWAYS, 0, 0xFF); - glDisable (GL_STENCIL_TEST); + myCtx->core11fwd->glClear (GL_STENCIL_BUFFER_BIT); + myCtx->core11fwd->glDepthFunc (myDepthFuncPrev); + myCtx->core11fwd->glStencilFunc (GL_ALWAYS, 0, 0xFF); + myCtx->core11fwd->glDisable (GL_STENCIL_TEST); } } @@ -48,13 +49,14 @@ namespace { if (myDepthFuncPrev == 0) { - glEnable (GL_STENCIL_TEST); - glGetIntegerv (GL_DEPTH_FUNC, &myDepthFuncPrev); - glDepthFunc (GL_LESS); + myCtx->core11fwd->glEnable (GL_STENCIL_TEST); + myCtx->core11fwd->glGetIntegerv (GL_DEPTH_FUNC, &myDepthFuncPrev); + myCtx->core11fwd->glDepthFunc (GL_LESS); } } private: + OpenGl_Context* myCtx; GLint myDepthFuncPrev; }; @@ -120,7 +122,7 @@ namespace aContext->ChangeClipping().DisableAllExcept (theClipChain, theSubPlaneIndex); aContext->ShaderManager()->UpdateClippingState(); - glClear (GL_STENCIL_BUFFER_BIT); + aContext->core11fwd->glClear (GL_STENCIL_BUFFER_BIT); const bool aColorMaskBack = aContext->SetColorMask (false); // override aspects, disable culling @@ -130,14 +132,14 @@ namespace // evaluate number of pair faces if (theWorkspace->UseZBuffer()) { - glDisable (GL_DEPTH_TEST); + aContext->core11fwd->glDisable (GL_DEPTH_TEST); } if (theWorkspace->UseDepthWrite()) { - glDepthMask (GL_FALSE); + aContext->core11fwd->glDepthMask (GL_FALSE); } - glStencilFunc (GL_ALWAYS, 1, 0x01); - glStencilOp (GL_KEEP, GL_INVERT, GL_INVERT); + aContext->core11fwd->glStencilFunc (GL_ALWAYS, 1, 0x01); + aContext->core11fwd->glStencilOp (GL_KEEP, GL_INVERT, GL_INVERT); // render closed primitives if (aRenderPlane->ToUseObjectProperties()) @@ -167,13 +169,13 @@ namespace aContext->SetColorMask (aColorMaskBack); if (theWorkspace->UseDepthWrite()) { - glDepthMask (GL_TRUE); + aContext->core11fwd->glDepthMask (GL_TRUE); } - glStencilFunc (GL_EQUAL, 1, 0x01); - glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP); + aContext->core11fwd->glStencilFunc (GL_EQUAL, 1, 0x01); + aContext->core11fwd->glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP); if (theWorkspace->UseZBuffer()) { - glEnable (GL_DEPTH_TEST); + aContext->core11fwd->glEnable (GL_DEPTH_TEST); } theWorkspace->SetAspects (thePlane->AspectFace()); @@ -212,7 +214,7 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks // only filled primitives should be rendered const Standard_Integer aPrevFilter = theWorkspace->RenderFilter(); theWorkspace->SetRenderFilter (aPrevFilter | OpenGl_RenderFilter_FillModeOnly); - StencilTestSentry aStencilSentry; + StencilTestSentry aStencilSentry (aContext); // generate capping for every clip plane for (OpenGl_ClippingIterator aCappingIt (aContext->Clipping()); aCappingIt.More(); aCappingIt.Next()) diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index f5274a6d46..fbb1caf34d 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -76,6 +76,10 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Context,Standard_Transient) #include #endif +#if defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) + #define OCC_USE_GLES2 +#endif + namespace { static const Handle(OpenGl_Resource) NULL_GL_RESOURCE; @@ -121,7 +125,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps) core20fwd (NULL), caps (!theCaps.IsNull() ? theCaps : new OpenGl_Caps()), hasGetBufferData (Standard_False), -#if defined(GL_ES_VERSION_2_0) +#if defined(OCC_USE_GLES2) hasPackRowLength (Standard_False), hasUnpackRowLength (Standard_False), hasHighp (Standard_False), @@ -139,7 +143,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps) hasFboSRGB (Standard_False), hasSRGBControl (Standard_False), hasFboRenderMipmap (Standard_False), -#if defined(GL_ES_VERSION_2_0) +#if defined(OCC_USE_GLES2) hasFlatShading (OpenGl_FeatureNotAvailable), #else hasFlatShading (OpenGl_FeatureInCore), @@ -185,7 +189,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps) myGlLibHandle (NULL), myFuncs (new OpenGl_GlFunctions()), myGapi ( -#if defined(GL_ES_VERSION_2_0) +#if defined(OCC_USE_GLES2) Aspect_GraphicsLibrary_OpenGLES #else Aspect_GraphicsLibrary_OpenGL @@ -225,17 +229,10 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps) myActiveMockTextures (0), myActiveHatchType (Aspect_HS_SOLID), myHatchIsEnabled (false), -#if !defined(GL_ES_VERSION_2_0) myPointSpriteOrig (GL_UPPER_LEFT), myRenderMode (GL_RENDER), myShadeModel (GL_SMOOTH), myPolygonMode (GL_FILL), -#else - myPointSpriteOrig (0), - myRenderMode (0), - myShadeModel (0), - myPolygonMode (0), -#endif myToCullBackFaces (false), myReadBuffer (0), myDrawBuffers (0, 7), @@ -299,7 +296,6 @@ OpenGl_Context::~OpenGl_Context() // release clean up queue ReleaseDelayed(); -#if !defined(GL_ES_VERSION_2_0) // release default VAO if (myDefaultVao != 0 && IsValid() @@ -308,7 +304,6 @@ OpenGl_Context::~OpenGl_Context() core32->glDeleteVertexArrays (1, &myDefaultVao); } myDefaultVao = 0; -#endif // release mock textures if (!myTextureRgbaBlack.IsNull()) @@ -358,11 +353,13 @@ OpenGl_Context::~OpenGl_Context() && IsValid()) { // reset callback - #if !defined(GL_ES_VERSION_2_0) void* aPtr = NULL; - glGetPointerv (GL_DEBUG_CALLBACK_USER_PARAM, &aPtr); - if (aPtr == this) - #endif + if (myGapi == Aspect_GraphicsLibrary_OpenGL) + { + myFuncs->glGetPointerv (GL_DEBUG_CALLBACK_USER_PARAM, &aPtr); + } + if (aPtr == this + || myGapi != Aspect_GraphicsLibrary_OpenGL) { arbDbg->glDebugMessageCallback (NULL, NULL); } @@ -421,8 +418,7 @@ void OpenGl_Context::ResizeViewport (const Standard_Integer* theRect) } } -#if !defined(GL_ES_VERSION_2_0) -inline Standard_Integer stereoToMonoBuffer (const Standard_Integer theBuffer) +static Standard_Integer stereoToMonoBuffer (const Standard_Integer theBuffer) { switch (theBuffer) { @@ -436,7 +432,6 @@ inline Standard_Integer stereoToMonoBuffer (const Standard_Integer theBuffer) return theBuffer; } } -#endif // ======================================================================= // function : SetReadBuffer @@ -444,17 +439,18 @@ inline Standard_Integer stereoToMonoBuffer (const Standard_Integer theBuffer) // ======================================================================= void OpenGl_Context::SetReadBuffer (const Standard_Integer theReadBuffer) { -#if !defined(GL_ES_VERSION_2_0) + if (myGapi == Aspect_GraphicsLibrary_OpenGLES) + { + return; + } + myReadBuffer = !myIsStereoBuffers ? stereoToMonoBuffer (theReadBuffer) : theReadBuffer; if (myReadBuffer < GL_COLOR_ATTACHMENT0 && arbFBO != NULL) { arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER); } - ::glReadBuffer (myReadBuffer); -#else - (void )theReadBuffer; -#endif + core11fwd->glReadBuffer (myReadBuffer); } // ======================================================================= @@ -463,20 +459,21 @@ void OpenGl_Context::SetReadBuffer (const Standard_Integer theReadBuffer) // ======================================================================= void OpenGl_Context::SetDrawBuffer (const Standard_Integer theDrawBuffer) { -#if !defined(GL_ES_VERSION_2_0) + if (myGapi == Aspect_GraphicsLibrary_OpenGLES) + { + return; + } + const Standard_Integer aDrawBuffer = !myIsStereoBuffers ? stereoToMonoBuffer (theDrawBuffer) : theDrawBuffer; if (aDrawBuffer < GL_COLOR_ATTACHMENT0 && arbFBO != NULL) { arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER); } - ::glDrawBuffer (aDrawBuffer); + core11fwd->glDrawBuffer (aDrawBuffer); myDrawBuffers.Init (GL_NONE); myDrawBuffers.SetValue (0, aDrawBuffer); -#else - (void )theDrawBuffer; -#endif } // ======================================================================= @@ -572,16 +569,20 @@ void OpenGl_Context::SetCullBackFaces (bool theToEnable) // ======================================================================= void OpenGl_Context::FetchState() { -#if !defined(GL_ES_VERSION_2_0) + if (myGapi == Aspect_GraphicsLibrary_OpenGLES) + { + return; + } + // cache feedback mode state if (core11ffp != NULL) { - ::glGetIntegerv (GL_RENDER_MODE, &myRenderMode); - ::glGetIntegerv (GL_SHADE_MODEL, &myShadeModel); + core11fwd->glGetIntegerv (GL_RENDER_MODE, &myRenderMode); + core11fwd->glGetIntegerv (GL_SHADE_MODEL, &myShadeModel); } // cache read buffers state - ::glGetIntegerv (GL_READ_BUFFER, &myReadBuffer); + core11fwd->glGetIntegerv (GL_READ_BUFFER, &myReadBuffer); // cache draw buffers state if (myDrawBuffers.Length() < myMaxDrawBuffers) @@ -593,18 +594,17 @@ void OpenGl_Context::FetchState() Standard_Integer aDrawBuffer = GL_NONE; if (myMaxDrawBuffers == 1) { - ::glGetIntegerv (GL_DRAW_BUFFER, &aDrawBuffer); + core11fwd->glGetIntegerv (GL_DRAW_BUFFER, &aDrawBuffer); myDrawBuffers.SetValue (0, aDrawBuffer); } else { for (Standard_Integer anI = 0; anI < myMaxDrawBuffers; ++anI) { - ::glGetIntegerv (GL_DRAW_BUFFER0 + anI, &aDrawBuffer); + core11fwd->glGetIntegerv (GL_DRAW_BUFFER0 + anI, &aDrawBuffer); myDrawBuffers.SetValue (anI, aDrawBuffer); } } -#endif } // ======================================================================= @@ -755,7 +755,7 @@ void OpenGl_Context::SwapBuffers() if ((HDC )myDisplay != NULL) { ::SwapBuffers ((HDC )myDisplay); - glFlush(); + core11fwd->glFlush(); } #elif defined(HAVE_XLIB) if ((Display* )myDisplay != NULL) @@ -851,14 +851,14 @@ Standard_Boolean OpenGl_Context::CheckExtension (const char* theExtName) const return Standard_False; } -#if !defined(GL_ES_VERSION_2_0) // available since OpenGL 3.0 // and the ONLY way to check extensions with OpenGL 3.1+ core profile - if (IsGlGreaterEqual (3, 0) + if (myGapi == Aspect_GraphicsLibrary_OpenGL + && IsGlGreaterEqual (3, 0) && myFuncs->glGetStringi != NULL) { GLint anExtNb = 0; - ::glGetIntegerv (GL_NUM_EXTENSIONS, &anExtNb); + core11fwd->glGetIntegerv (GL_NUM_EXTENSIONS, &anExtNb); const size_t anExtNameLen = strlen (theExtName); for (GLint anIter = 0; anIter < anExtNb; ++anIter) { @@ -872,10 +872,9 @@ Standard_Boolean OpenGl_Context::CheckExtension (const char* theExtName) const } return Standard_False; } -#endif // use old way with huge string for all extensions - const char* anExtString = (const char* )glGetString (GL_EXTENSIONS); + const char* anExtString = (const char* )core11fwd->glGetString (GL_EXTENSIONS); if (anExtString == NULL) { Messenger()->Send ("TKOpenGL: glGetString (GL_EXTENSIONS) has returned NULL! No GL context?", Message_Warning); @@ -1039,10 +1038,8 @@ TCollection_AsciiString OpenGl_Context::FormatGlError (int theGlError) case GL_INVALID_ENUM: return "GL_INVALID_ENUM"; case GL_INVALID_VALUE: return "GL_INVALID_VALUE"; case GL_INVALID_OPERATION: return "GL_INVALID_OPERATION"; - #ifdef GL_STACK_OVERFLOW case GL_STACK_OVERFLOW: return "GL_STACK_OVERFLOW"; case GL_STACK_UNDERFLOW: return "GL_STACK_UNDERFLOW"; - #endif case GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY"; case GL_INVALID_FRAMEBUFFER_OPERATION: return "GL_INVALID_FRAMEBUFFER_OPERATION"; } @@ -1056,18 +1053,18 @@ TCollection_AsciiString OpenGl_Context::FormatGlError (int theGlError) bool OpenGl_Context::ResetErrors (const bool theToPrintErrors) { int aPrevErr = 0; - int anErr = ::glGetError(); + int anErr = core11fwd->glGetError(); const bool hasError = anErr != GL_NO_ERROR; if (!theToPrintErrors) { - for (; anErr != GL_NO_ERROR && aPrevErr != anErr; aPrevErr = anErr, anErr = ::glGetError()) + for (; anErr != GL_NO_ERROR && aPrevErr != anErr; aPrevErr = anErr, anErr = core11fwd->glGetError()) { // } return hasError; } - for (; anErr != GL_NO_ERROR && aPrevErr != anErr; aPrevErr = anErr, anErr = ::glGetError()) + for (; anErr != GL_NO_ERROR && aPrevErr != anErr; aPrevErr = anErr, anErr = core11fwd->glGetError()) { const TCollection_ExtendedString aMsg = TCollection_ExtendedString ("Unhandled GL error: ") + FormatGlError (anErr); PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_OTHER, 0, GL_DEBUG_SEVERITY_LOW, aMsg); @@ -1075,36 +1072,6 @@ bool OpenGl_Context::ResetErrors (const bool theToPrintErrors) return hasError; } -// ======================================================================= -// function : debugPrintError -// purpose : -// ======================================================================= -bool OpenGl_GlFunctions::debugPrintError (const char* theName) const -{ - const int anErr = ::glGetError(); - if (anErr != GL_NO_ERROR) - { - Message::SendFail() << theName << "(), unhandled GL error: " << OpenGl_Context::FormatGlError (anErr); - // there is no glSetError(), just emulate non-clear state - switch (anErr) - { - case GL_INVALID_VALUE: - { - ::glLineWidth(-1.0f); - ::glLineWidth( 1.0f); - break; - } - default: - case GL_INVALID_ENUM: - { - ::glEnable (0xFFFF); - break; - } - } - } - return anErr != GL_NO_ERROR; -} - // ======================================================================= // function : ReadGlVersion // purpose : @@ -1112,126 +1079,7 @@ bool OpenGl_GlFunctions::debugPrintError (const char* theName) const void OpenGl_Context::ReadGlVersion (Standard_Integer& theGlVerMajor, Standard_Integer& theGlVerMinor) { - // reset values - theGlVerMajor = 0; - theGlVerMinor = 0; - - bool toCheckVer3 = true; -#if defined(__EMSCRIPTEN__) - // WebGL 1.0 prints annoying invalid enumeration warnings to console. - toCheckVer3 = false; - if (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE aWebGlCtx = emscripten_webgl_get_current_context()) - { - EmscriptenWebGLContextAttributes anAttribs = {}; - if (emscripten_webgl_get_context_attributes (aWebGlCtx, &anAttribs) == EMSCRIPTEN_RESULT_SUCCESS) - { - toCheckVer3 = anAttribs.majorVersion >= 2; - } - } -#endif - - // Available since OpenGL 3.0 and OpenGL ES 3.0. - if (toCheckVer3) - { - GLint aMajor = 0, aMinor = 0; - glGetIntegerv (GL_MAJOR_VERSION, &aMajor); - glGetIntegerv (GL_MINOR_VERSION, &aMinor); - // glGetError() sometimes does not report an error here even if - // GL does not know GL_MAJOR_VERSION and GL_MINOR_VERSION constants. - // This happens on some renderers like e.g. Cygwin MESA. - // Thus checking additionally if GL has put anything to - // the output variables. - if (::glGetError() == GL_NO_ERROR && aMajor != 0 && aMinor != 0) - { - theGlVerMajor = aMajor; - theGlVerMinor = aMinor; - return; - } - for (GLenum anErr = ::glGetError(), aPrevErr = GL_NO_ERROR;; aPrevErr = anErr, anErr = ::glGetError()) - { - if (anErr == GL_NO_ERROR - || anErr == aPrevErr) - { - break; - } - } - } - - // Read version string. - // Notice that only first two numbers split by point '2.1 XXXXX' are significant. - // Following trash (after space) is vendor-specific. - // New drivers also returns micro version of GL like '3.3.0' which has no meaning - // and should be considered as vendor-specific too. - const char* aVerStr = (const char* )glGetString (GL_VERSION); - if (aVerStr == NULL || *aVerStr == '\0') - { - // invalid GL context - return; - } - -//#if defined(GL_ES_VERSION_2_0) - // skip "OpenGL ES-** " section - for (; *aVerStr != '\0'; ++aVerStr) - { - if (*aVerStr >= '0' && *aVerStr <= '9') - { - break; - } - } -//#endif - - // parse string for major number - char aMajorStr[32]; - char aMinorStr[32]; - size_t aMajIter = 0; - while (aVerStr[aMajIter] >= '0' && aVerStr[aMajIter] <= '9') - { - ++aMajIter; - } - if (aMajIter == 0 || aMajIter >= sizeof(aMajorStr)) - { - return; - } - memcpy (aMajorStr, aVerStr, aMajIter); - aMajorStr[aMajIter] = '\0'; - - // parse string for minor number - aVerStr += aMajIter + 1; - size_t aMinIter = 0; - while (aVerStr[aMinIter] >= '0' && aVerStr[aMinIter] <= '9') - { - ++aMinIter; - } - if (aMinIter == 0 || aMinIter >= sizeof(aMinorStr)) - { - return; - } - memcpy (aMinorStr, aVerStr, aMinIter); - aMinorStr[aMinIter] = '\0'; - - // read numbers - theGlVerMajor = atoi (aMajorStr); - theGlVerMinor = atoi (aMinorStr); -#if defined(__EMSCRIPTEN__) - if (theGlVerMajor >= 3) - { - if (!toCheckVer3 - || ::strstr (aVerStr, "WebGL 1.0") != NULL) - { - Message::SendWarning() << "Warning! OpenGL context reports version " << theGlVerMajor << "." << theGlVerMinor - << " but WebGL 2.0 was unavailable\n" - << "Fallback to OpenGL ES 2.0 will be used instead of reported version"; - theGlVerMajor = 2; - theGlVerMinor = 0; - } - } -#endif - - if (theGlVerMajor <= 0) - { - theGlVerMajor = 0; - theGlVerMinor = 0; - } + OpenGl_GlFunctions::readGlVersion (theGlVerMajor, theGlVerMinor); } static Standard_CString THE_DBGMSG_UNKNOWN = "UNKNOWN"; @@ -1370,19 +1218,23 @@ void OpenGl_Context::checkWrongVersion (Standard_Integer theGlVerMajor, Standard myGlVerMinor = theGlVerMinor - 1; return; } -#if defined(GL_ES_VERSION_2_0) - switch (theGlVerMajor) + + if (myGapi == Aspect_GraphicsLibrary_OpenGLES) { - case 3: myGlVerMajor = 2; myGlVerMinor = 0; return; + switch (theGlVerMajor) + { + case 3: myGlVerMajor = 2; myGlVerMinor = 0; return; + } } -#else - switch (theGlVerMajor) + else { - case 2: myGlVerMajor = 1; myGlVerMinor = 5; return; - case 3: myGlVerMajor = 2; myGlVerMinor = 1; return; - case 4: myGlVerMajor = 3; myGlVerMinor = 3; return; + switch (theGlVerMajor) + { + case 2: myGlVerMajor = 1; myGlVerMinor = 5; return; + case 3: myGlVerMajor = 2; myGlVerMinor = 1; return; + case 4: myGlVerMajor = 3; myGlVerMinor = 3; return; + } } -#endif } // ======================================================================= @@ -1399,9 +1251,7 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) myMaxDrawBuffers = 1; myMaxColorAttachments = 1; myDefaultVao = 0; - ReadGlVersion (myGlVerMajor, myGlVerMinor); - myVendor = (const char* )::glGetString (GL_VENDOR); - myVendor.LowerCase(); + OpenGl_GlFunctions::readGlVersion (myGlVerMajor, myGlVerMinor); mySupportedFormats->Clear(); if (caps->contextMajorVersionUpper != -1) @@ -1413,19 +1263,22 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) { isLowered = true; myGlVerMajor = caps->contextMajorVersionUpper; - #if defined(GL_ES_VERSION_2_0) - switch (myGlVerMajor) + if (myGapi == Aspect_GraphicsLibrary_OpenGLES) { - case 2: myGlVerMinor = 0; break; + switch (myGlVerMajor) + { + case 2: myGlVerMinor = 0; break; + } } - #else - switch (myGlVerMajor) + else { - case 1: myGlVerMinor = 5; break; - case 2: myGlVerMinor = 1; break; - case 3: myGlVerMinor = 3; break; + switch (myGlVerMajor) + { + case 1: myGlVerMinor = 5; break; + case 2: myGlVerMinor = 1; break; + case 3: myGlVerMinor = 3; break; + } } - #endif } if (caps->contextMinorVersionUpper != -1 && myGlVerMinor > caps->contextMinorVersionUpper) @@ -1441,78 +1294,53 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) } } + myFuncs->load (*this, theIsCoreProfile); + if (!caps->ffpEnable && !IsGlGreaterEqual (2, 0)) { caps->ffpEnable = true; TCollection_ExtendedString aMsg = TCollection_ExtendedString("OpenGL driver is too old! Context info:\n") - + " Vendor: " + (const char* )::glGetString (GL_VENDOR) + "\n" - + " Renderer: " + (const char* )::glGetString (GL_RENDERER) + "\n" - + " Version: " + (const char* )::glGetString (GL_VERSION) + "\n" + + " Vendor: " + (const char* )core11fwd->glGetString (GL_VENDOR) + "\n" + + " Renderer: " + (const char* )core11fwd->glGetString (GL_RENDERER) + "\n" + + " Version: " + (const char* )core11fwd->glGetString (GL_VERSION) + "\n" + " Fallback using deprecated fixed-function pipeline.\n" + " Visualization might work incorrectly.\n" " Consider upgrading the graphics driver."; PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH, aMsg); } -#if defined(GL_ES_VERSION_2_0) - (void )theIsCoreProfile; - const bool isCoreProfile = false; -#else - + myVendor = (const char* )core11fwd->glGetString (GL_VENDOR); + myVendor.LowerCase(); if (myVendor.Search ("nvidia") != -1) { // Buffer detailed info: Buffer object 1 (bound to GL_ARRAY_BUFFER_ARB, usage hint is GL_STATIC_DRAW) // will use VIDEO memory as the source for buffer object operations. ExcludeMessage (GL_DEBUG_SOURCE_API, 131185); } - if (IsGlGreaterEqual (3, 0)) - { - // retrieve auxiliary function in advance - FindProc ("glGetStringi", myFuncs->glGetStringi); - } - - bool isCoreProfile = false; - if (IsGlGreaterEqual (3, 2)) - { - isCoreProfile = (theIsCoreProfile == Standard_True); - - // detect Core profile - if (!isCoreProfile) - { - GLint aProfile = 0; - ::glGetIntegerv (GL_CONTEXT_PROFILE_MASK, &aProfile); - isCoreProfile = (aProfile & GL_CONTEXT_CORE_PROFILE_BIT) != 0; - } - } -#endif - - myFuncs->load (*this, isCoreProfile); // setup shader generator myShaderManager->SetGapiVersion (myGlVerMajor, myGlVerMinor); myShaderManager->SetEmulateDepthClamp (!arbDepthClamp); - bool toReverseDFdxSign = false; -#if defined(GL_ES_VERSION_2_0) // workaround Adreno driver bug computing reversed normal using dFdx/dFdy - toReverseDFdxSign = myVendor.Search("qualcomm") != -1; -#endif + bool toReverseDFdxSign = myGapi == Aspect_GraphicsLibrary_OpenGLES + && myVendor.Search("qualcomm") != -1; myShaderManager->SetFlatShading (hasFlatShading != OpenGl_FeatureNotAvailable, toReverseDFdxSign); -#if defined(GL_ES_VERSION_2_0) - myShaderManager->SetUseRedAlpha (false); -#else - myShaderManager->SetUseRedAlpha (core11ffp == NULL); -#endif + myShaderManager->SetUseRedAlpha (myGapi != Aspect_GraphicsLibrary_OpenGLES + && core11ffp == NULL); #define checkGlslExtensionShort(theName) myShaderManager->EnableGlslExtension (Graphic3d_GlslExtension_ ## theName, CheckExtension (#theName)) -#if defined(GL_ES_VERSION_2_0) - checkGlslExtensionShort(GL_OES_standard_derivatives); - checkGlslExtensionShort(GL_EXT_shader_texture_lod); - checkGlslExtensionShort(GL_EXT_frag_depth); -#else - checkGlslExtensionShort(GL_EXT_gpu_shader4); -#endif + if (myGapi == Aspect_GraphicsLibrary_OpenGLES) + { + checkGlslExtensionShort(GL_OES_standard_derivatives); + checkGlslExtensionShort(GL_EXT_shader_texture_lod); + checkGlslExtensionShort(GL_EXT_frag_depth); + } + else + { + checkGlslExtensionShort(GL_EXT_gpu_shader4); + } // initialize debug context extension if (arbDbg != NULL @@ -1521,51 +1349,49 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) // setup default callback myIsGlDebugCtx = Standard_True; arbDbg->glDebugMessageCallback (debugCallbackWrap, this); - #if defined(GL_ES_VERSION_2_0) - ::glEnable (GL_DEBUG_OUTPUT); - #else - if (core43 != NULL) + if (myGapi == Aspect_GraphicsLibrary_OpenGLES) { - ::glEnable (GL_DEBUG_OUTPUT); + core11fwd->glEnable (GL_DEBUG_OUTPUT); + } + else if (core43 != NULL) + { + core11fwd->glEnable (GL_DEBUG_OUTPUT); } - #endif if (caps->contextSyncDebug) { // note that some broken implementations (e.g. simulators) might generate error message on this call - ::glEnable (GL_DEBUG_OUTPUT_SYNCHRONOUS); + core11fwd->glEnable (GL_DEBUG_OUTPUT_SYNCHRONOUS); } } if (hasDrawBuffers) { - glGetIntegerv (GL_MAX_DRAW_BUFFERS, &myMaxDrawBuffers); - glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &myMaxColorAttachments); + core11fwd->glGetIntegerv (GL_MAX_DRAW_BUFFERS, &myMaxDrawBuffers); + core11fwd->glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &myMaxColorAttachments); if (myDrawBuffers.Length() < myMaxDrawBuffers) { myDrawBuffers.Resize (0, myMaxDrawBuffers - 1, false); } } - glGetIntegerv (GL_MAX_TEXTURE_SIZE, &myMaxTexDim); -#if !defined(GL_ES_VERSION_2_0) + core11fwd->glGetIntegerv (GL_MAX_TEXTURE_SIZE, &myMaxTexDim); if (IsGlGreaterEqual (1, 3) && core11ffp != NULL) { // this is a maximum of texture units for FFP functionality, // usually smaller than combined texture units available for GLSL - glGetIntegerv (GL_MAX_TEXTURE_UNITS, &myMaxTexUnitsFFP); + core11fwd->glGetIntegerv (GL_MAX_TEXTURE_UNITS, &myMaxTexUnitsFFP); myMaxTexCombined = myMaxTexUnitsFFP; } -#endif if (IsGlGreaterEqual (2, 0)) { - glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &myMaxTexCombined); + core11fwd->glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &myMaxTexCombined); } mySpriteTexUnit = myMaxTexCombined >= 2 ? Graphic3d_TextureUnit_PointSprite : Graphic3d_TextureUnit_0; GLint aMaxVPortSize[2] = {0, 0}; - glGetIntegerv (GL_MAX_VIEWPORT_DIMS, aMaxVPortSize); + core11fwd->glGetIntegerv (GL_MAX_VIEWPORT_DIMS, aMaxVPortSize); myMaxDumpSizeX = Min (aMaxVPortSize[0], myMaxTexDim); myMaxDumpSizeY = Min (aMaxVPortSize[1], myMaxTexDim); if (myVendor == "intel") @@ -1576,80 +1402,84 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) if (extAnis) { - glGetIntegerv (GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &myAnisoMax); + core11fwd->glGetIntegerv (GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &myAnisoMax); } myClippingState.Init(); -#if defined(GL_ES_VERSION_2_0) - if (IsGlGreaterEqual (3, 0)) + if (myGapi == Aspect_GraphicsLibrary_OpenGLES) { - // MSAA RenderBuffers have been defined in OpenGL ES 3.0, but MSAA Textures - only in OpenGL ES 3.1+ - myHasMsaaTextures = IsGlGreaterEqual (3, 1) - && myFuncs->glTexStorage2DMultisample != NULL; - ::glGetIntegerv (GL_MAX_SAMPLES, &myMaxMsaaSamples); + if (IsGlGreaterEqual (3, 0)) + { + // MSAA RenderBuffers have been defined in OpenGL ES 3.0, but MSAA Textures - only in OpenGL ES 3.1+ + myHasMsaaTextures = IsGlGreaterEqual (3, 1) + && myFuncs->glTexStorage2DMultisample != NULL; + core11fwd->glGetIntegerv (GL_MAX_SAMPLES, &myMaxMsaaSamples); + } } -#else - if (core30 != NULL) + else if (core30 != NULL) { // MSAA RenderBuffers have been defined in OpenGL 3.0, but MSAA Textures - only in OpenGL 3.2+ if (core32 != NULL) { myHasMsaaTextures = true; - ::glGetIntegerv (GL_MAX_SAMPLES, &myMaxMsaaSamples); + core11fwd->glGetIntegerv (GL_MAX_SAMPLES, &myMaxMsaaSamples); } else if (CheckExtension ("GL_ARB_texture_multisample") && myFuncs->glTexImage2DMultisample != NULL) { myHasMsaaTextures = true; GLint aNbColorSamples = 0, aNbDepthSamples = 0; - ::glGetIntegerv (GL_MAX_COLOR_TEXTURE_SAMPLES, &aNbColorSamples); - ::glGetIntegerv (GL_MAX_DEPTH_TEXTURE_SAMPLES, &aNbDepthSamples); + core11fwd->glGetIntegerv (GL_MAX_COLOR_TEXTURE_SAMPLES, &aNbColorSamples); + core11fwd->glGetIntegerv (GL_MAX_DEPTH_TEXTURE_SAMPLES, &aNbDepthSamples); myMaxMsaaSamples = Min (aNbColorSamples, aNbDepthSamples); } } -#endif if (myMaxMsaaSamples <= 1) { myHasMsaaTextures = false; } -#if !defined(GL_ES_VERSION_2_0) - if (core32 != NULL && isCoreProfile) + if (myGapi != Aspect_GraphicsLibrary_OpenGLES) { - core32->glGenVertexArrays (1, &myDefaultVao); + if (core32 != NULL && core11ffp == NULL) + { + core32->glGenVertexArrays (1, &myDefaultVao); + } + + myTexClamp = IsGlGreaterEqual (1, 2) ? GL_CLAMP_TO_EDGE : GL_CLAMP; + + GLint aStereo = GL_FALSE; + core11fwd->glGetIntegerv (GL_STEREO, &aStereo); + myIsStereoBuffers = aStereo == 1; + + // get number of maximum clipping planes + core11fwd->glGetIntegerv (GL_MAX_CLIP_PLANES, &myMaxClipPlanes); } - myTexClamp = IsGlGreaterEqual (1, 2) ? GL_CLAMP_TO_EDGE : GL_CLAMP; + if (myGapi == Aspect_GraphicsLibrary_OpenGLES) + { + // check whether ray tracing mode is supported + myHasRayTracing = IsGlGreaterEqual (3, 2); + myHasRayTracingTextures = myHasRayTracingAdaptiveSampling = myHasRayTracingAdaptiveSamplingAtomic = false; + } + else + { + // check whether ray tracing mode is supported + myHasRayTracing = IsGlGreaterEqual (3, 1) + && arbTboRGB32 + && arbFBOBlit != NULL; - GLint aStereo = GL_FALSE; - glGetIntegerv (GL_STEREO, &aStereo); - myIsStereoBuffers = aStereo == 1; + // check whether textures in ray tracing mode are supported + myHasRayTracingTextures = myHasRayTracing + && arbTexBindless != NULL; - // get number of maximum clipping planes - glGetIntegerv (GL_MAX_CLIP_PLANES, &myMaxClipPlanes); -#endif - -#if defined(GL_ES_VERSION_2_0) - // check whether ray tracing mode is supported - myHasRayTracing = IsGlGreaterEqual (3, 2); - myHasRayTracingTextures = myHasRayTracingAdaptiveSampling = myHasRayTracingAdaptiveSamplingAtomic = false; -#else - // check whether ray tracing mode is supported - myHasRayTracing = IsGlGreaterEqual (3, 1) - && arbTboRGB32 - && arbFBOBlit != NULL; - - // check whether textures in ray tracing mode are supported - myHasRayTracingTextures = myHasRayTracing - && arbTexBindless != NULL; - - // check whether adaptive screen sampling in ray tracing mode is supported - myHasRayTracingAdaptiveSampling = myHasRayTracing - && core44 != NULL; - myHasRayTracingAdaptiveSamplingAtomic = myHasRayTracingAdaptiveSampling - && CheckExtension ("GL_NV_shader_atomic_float"); -#endif + // check whether adaptive screen sampling in ray tracing mode is supported + myHasRayTracingAdaptiveSampling = myHasRayTracing + && core44 != NULL; + myHasRayTracingAdaptiveSamplingAtomic = myHasRayTracingAdaptiveSampling + && CheckExtension ("GL_NV_shader_atomic_float"); + } if (arbFBO != NULL && hasFboSRGB) @@ -1657,17 +1487,13 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) // Detect if window buffer is considered by OpenGL as sRGB-ready // (linear RGB color written by shader is automatically converted into sRGB) // or not (offscreen FBO should be blit into window buffer with gamma correction). - const GLenum aDefWinBuffer = - #if !defined(GL_ES_VERSION_2_0) - GL_BACK_LEFT; - #else - GL_BACK; - #endif + const GLenum aDefWinBuffer = myGapi == Aspect_GraphicsLibrary_OpenGLES ? GL_BACK : GL_BACK_LEFT; GLint aWinColorEncoding = 0; // GL_LINEAR bool toSkipCheck = false; - #if defined(GL_ES_VERSION_2_0) - toSkipCheck = !IsGlGreaterEqual (3, 0); - #endif + if (myGapi == Aspect_GraphicsLibrary_OpenGLES) + { + toSkipCheck = !IsGlGreaterEqual (3, 0); + } if (!toSkipCheck) { arbFBO->glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER, aDefWinBuffer, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &aWinColorEncoding); @@ -1681,17 +1507,18 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) // NVIDIA drivers, however, always return GL_LINEAR even for sRGB-ready pixel formats on Windows platform, // while AMD and Intel report GL_SRGB as expected. // macOS drivers seems to be also report GL_LINEAR even for [NSColorSpace sRGBColorSpace]. - #if !defined(GL_ES_VERSION_2_0) - #ifdef __APPLE__ - myIsSRgbWindow = true; - #else - if (!myIsSRgbWindow - && myVendor.Search ("nvidia") != -1) + if (myGapi != Aspect_GraphicsLibrary_OpenGLES) { + #ifdef __APPLE__ myIsSRgbWindow = true; + #else + if (!myIsSRgbWindow + && myVendor.Search ("nvidia") != -1) + { + myIsSRgbWindow = true; + } + #endif } - #endif - #endif if (!myIsSRgbWindow) { Message::SendTrace ("OpenGl_Context, warning: window buffer is not sRGB-ready.\n" @@ -1707,10 +1534,11 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) mySupportedFormats->Add (Image_Format_RGBA); if (extBgra) { - #if !defined(GL_ES_VERSION_2_0) - // no BGR on OpenGL ES - only BGRA as extension - mySupportedFormats->Add (Image_Format_BGR); - #endif + if (myGapi != Aspect_GraphicsLibrary_OpenGLES) + { + // no BGR on OpenGL ES - only BGRA as extension + mySupportedFormats->Add (Image_Format_BGR); + } mySupportedFormats->Add (Image_Format_BGR32); mySupportedFormats->Add (Image_Format_BGRA); } @@ -1734,9 +1562,10 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) } if (extBgra) { - #if !defined(GL_ES_VERSION_2_0) - mySupportedFormats->Add (Image_Format_BGRF); - #endif + if (myGapi != Aspect_GraphicsLibrary_OpenGLES) + { + mySupportedFormats->Add (Image_Format_BGRF); + } mySupportedFormats->Add (Image_Format_BGRAF); } } @@ -1781,17 +1610,23 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) #endif // check whether PBR shading model is supported - myHasPBR = arbFBO != NULL - && myMaxTexCombined >= 4 - && arbTexFloat - && (IsGlGreaterEqual (3, 0) - #if defined(GL_ES_VERSION_2_0) - || hasHighp - // || CheckExtension ("GL_EXT_shader_texture_lod") fallback is used when extension is unavailable - #else - || (IsGlGreaterEqual (2, 1) && CheckExtension ("GL_EXT_gpu_shader4")) - #endif - ); + myHasPBR = false; + if (arbFBO != NULL + && myMaxTexCombined >= 4 + && arbTexFloat) + { + if (myGapi == Aspect_GraphicsLibrary_OpenGLES) + { + myHasPBR = IsGlGreaterEqual (3, 0) + || hasHighp; + // || CheckExtension ("GL_EXT_shader_texture_lod") fallback is used when extension is unavailable + } + else + { + myHasPBR = IsGlGreaterEqual (3, 0) + || (IsGlGreaterEqual (2, 1) && CheckExtension ("GL_EXT_gpu_shader4")); + } + } myDepthPeelingDepthTexUnit = static_cast(myMaxTexCombined + Graphic3d_TextureUnit_DepthPeelingDepth); // -6 myDepthPeelingFrontColorTexUnit = static_cast(myMaxTexCombined + Graphic3d_TextureUnit_DepthPeelingFrontColor); // -5 @@ -1813,7 +1648,6 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile) // ======================================================================= Standard_Size OpenGl_Context::AvailableMemory() const { -#if !defined(GL_ES_VERSION_2_0) if (atiMem) { // this is actually information for VBO pool @@ -1821,7 +1655,8 @@ Standard_Size OpenGl_Context::AvailableMemory() const // it can be used for total GPU memory estimations GLint aMemInfo[4]; aMemInfo[0] = 0; - glGetIntegerv (GL_VBO_FREE_MEMORY_ATI, aMemInfo); + + core11fwd->glGetIntegerv (GL_VBO_FREE_MEMORY_ATI, aMemInfo); // returned value is in KiB, however this maybe changed in future return Standard_Size(aMemInfo[0]) * 1024; } @@ -1829,10 +1664,9 @@ Standard_Size OpenGl_Context::AvailableMemory() const { // current available dedicated video memory (in KiB), currently unused GPU memory GLint aMemInfo = 0; - glGetIntegerv (GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &aMemInfo); + core11fwd->glGetIntegerv (GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &aMemInfo); return Standard_Size(aMemInfo) * 1024; } -#endif return 0; } @@ -1863,7 +1697,7 @@ TCollection_AsciiString OpenGl_Context::MemoryInfo() const // ======================================================================= void OpenGl_Context::MemoryInfo (TColStd_IndexedDataMapOfStringString& theDict) const { -#if defined(GL_ES_VERSION_2_0) +#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE (void )theDict; #elif defined(__APPLE__) && !defined(HAVE_XLIB) GLint aGlRendId = 0; @@ -1907,12 +1741,11 @@ void OpenGl_Context::MemoryInfo (TColStd_IndexedDataMapOfStringString& theDict) } #endif -#if !defined(GL_ES_VERSION_2_0) if (atiMem) { GLint aValues[4]; memset (aValues, 0, sizeof(aValues)); - glGetIntegerv (GL_VBO_FREE_MEMORY_ATI, aValues); + core11fwd->glGetIntegerv (GL_VBO_FREE_MEMORY_ATI, aValues); // total memory free in the pool addInfo (theDict, "GPU free memory", TCollection_AsciiString() + (aValues[0] / 1024) + " MiB"); @@ -1932,16 +1765,16 @@ void OpenGl_Context::MemoryInfo (TColStd_IndexedDataMapOfStringString& theDict) { //current available dedicated video memory (in KiB), currently unused GPU memory GLint aValue = 0; - glGetIntegerv (GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &aValue); + core11fwd->glGetIntegerv (GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &aValue); addInfo (theDict, "GPU free memory", TCollection_AsciiString() + (aValue / 1024) + " MiB"); // dedicated video memory, total size (in KiB) of the GPU memory GLint aDedicated = 0; - glGetIntegerv (GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &aDedicated); + core11fwd->glGetIntegerv (GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &aDedicated); addInfo (theDict, "GPU memory", TCollection_AsciiString() + (aDedicated / 1024) + " MiB"); // total available memory, total size (in KiB) of the memory available for allocations - glGetIntegerv (GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &aValue); + core11fwd->glGetIntegerv (GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &aValue); if (aValue != aDedicated) { // different only for special configurations @@ -1963,9 +1796,8 @@ void OpenGl_Context::MemoryInfo (TColStd_IndexedDataMapOfStringString& theDict) } } #endif -#endif -#if !defined(GL_ES_VERSION_2_0) && !defined(__APPLE__) && !defined(_WIN32) +#if defined(HAVE_XLIB) && !defined(__APPLE__) && !defined(_WIN32) // GLX_RENDERER_VENDOR_ID_MESA if (myFuncs->glXQueryCurrentRendererIntegerMESA != NULL) { @@ -2028,24 +1860,24 @@ void OpenGl_Context::DiagnosticInformation (TColStd_IndexedDataMapOfStringString if ((theFlags & Graphic3d_DiagnosticInfo_Device) != 0) { Standard_Integer aDriverVer[2] = {}; - ReadGlVersion (aDriverVer[0], aDriverVer[1]); - addInfo (theDict, "GLvendor", (const char*)::glGetString (GL_VENDOR)); - addInfo (theDict, "GLdevice", (const char*)::glGetString (GL_RENDERER)); + OpenGl_GlFunctions::readGlVersion (aDriverVer[0], aDriverVer[1]); + addInfo (theDict, "GLvendor", (const char*)core11fwd->glGetString (GL_VENDOR)); + addInfo (theDict, "GLdevice", (const char*)core11fwd->glGetString (GL_RENDERER)); #ifdef __EMSCRIPTEN__ if (CheckExtension ("GL_WEBGL_debug_renderer_info")) { - if (const char* aVendor = (const char*)::glGetString (0x9245)) + if (const char* aVendor = (const char*)core11fwd->glGetString (0x9245)) { addInfo (theDict, "GLunmaskedVendor", aVendor); } - if (const char* aDevice = (const char*)::glGetString (0x9246)) + if (const char* aDevice = (const char*)core11fwd->glGetString (0x9246)) { addInfo (theDict, "GLunmaskedDevice", aDevice); } } #endif - addInfo (theDict, "GLversion", (const char*)::glGetString (GL_VERSION)); + addInfo (theDict, "GLversion", (const char*)core11fwd->glGetString (GL_VERSION)); if (myGlVerMajor != aDriverVer[0] || myGlVerMinor != aDriverVer[1]) { @@ -2053,7 +1885,7 @@ void OpenGl_Context::DiagnosticInformation (TColStd_IndexedDataMapOfStringString } if (IsGlGreaterEqual (2, 0)) { - addInfo (theDict, "GLSLversion", (const char*)::glGetString (GL_SHADING_LANGUAGE_VERSION)); + addInfo (theDict, "GLSLversion", (const char*)core11fwd->glGetString (GL_SHADING_LANGUAGE_VERSION)); } if (myIsGlDebugCtx) { @@ -2072,7 +1904,7 @@ void OpenGl_Context::DiagnosticInformation (TColStd_IndexedDataMapOfStringString if ((theFlags & Graphic3d_DiagnosticInfo_FrameBuffer) != 0) { GLint aViewport[4] = {}; - ::glGetIntegerv (GL_VIEWPORT, aViewport); + core11fwd->glGetIntegerv (GL_VIEWPORT, aViewport); addInfo (theDict, "Viewport", TCollection_AsciiString() + aViewport[2] + "x" + aViewport[3]); } @@ -2083,13 +1915,13 @@ void OpenGl_Context::DiagnosticInformation (TColStd_IndexedDataMapOfStringString if ((theFlags & Graphic3d_DiagnosticInfo_Extensions) != 0) { - #if !defined(GL_ES_VERSION_2_0) - if (IsGlGreaterEqual (3, 0) + if (myGapi != Aspect_GraphicsLibrary_OpenGLES + && IsGlGreaterEqual (3, 0) && myFuncs->glGetStringi != NULL) { TCollection_AsciiString anExtList; GLint anExtNb = 0; - ::glGetIntegerv (GL_NUM_EXTENSIONS, &anExtNb); + core11fwd->glGetIntegerv (GL_NUM_EXTENSIONS, &anExtNb); for (GLint anIter = 0; anIter < anExtNb; ++anIter) { const char* anExtension = (const char*)myFuncs->glGetStringi (GL_EXTENSIONS, (GLuint)anIter); @@ -2102,9 +1934,8 @@ void OpenGl_Context::DiagnosticInformation (TColStd_IndexedDataMapOfStringString addInfo(theDict, "GLextensions", anExtList); } else - #endif { - addInfo (theDict, "GLextensions", (const char*)::glGetString (GL_EXTENSIONS)); + addInfo (theDict, "GLextensions", (const char*)core11fwd->glGetString (GL_EXTENSIONS)); } } } @@ -2279,23 +2110,19 @@ Handle(OpenGl_TextureSet) OpenGl_Context::BindTextures (const Handle(OpenGl_Text OpenGl_Sampler::applySamplerParams (aThisCtx, aTextureNew->Sampler()->Parameters(), aTextureNew->Sampler().get(), aTextureNew->GetTarget(), aTextureNew->MaxMipmapLevel()); } } - #if !defined(GL_ES_VERSION_2_0) if (core11ffp != NULL) { OpenGl_Sampler::applyGlobalTextureParams (aThisCtx, *aTextureNew, aTextureNew->Sampler()->Parameters()); } - #endif } else if (aTextureOld != NULL && aTextureOld->IsValid()) { aTextureOld->Unbind (aThisCtx, aTexUnit); - #if !defined(GL_ES_VERSION_2_0) if (core11ffp != NULL) { OpenGl_Sampler::resetGlobalTextureParams (aThisCtx, *aTextureOld, aTextureOld->Sampler()->Parameters()); } - #endif } } myActiveTextures = theTextures; @@ -2362,7 +2189,6 @@ Standard_Boolean OpenGl_Context::BindProgram (const Handle(OpenGl_ShaderProgram) // ======================================================================= void OpenGl_Context::BindDefaultVao() { -#if !defined(GL_ES_VERSION_2_0) if (myDefaultVao == 0 || core32 == NULL) { @@ -2370,7 +2196,6 @@ void OpenGl_Context::BindDefaultVao() } core32->glBindVertexArray (myDefaultVao); -#endif } // ======================================================================= @@ -2390,11 +2215,7 @@ Handle(OpenGl_FrameBuffer) OpenGl_Context::SetDefaultFrameBuffer (const Handle(O // ======================================================================= Standard_Boolean OpenGl_Context::IsRender() const { -#if !defined(GL_ES_VERSION_2_0) return myRenderMode == GL_RENDER; -#else - return Standard_True; -#endif } // ======================================================================= @@ -2403,11 +2224,7 @@ Standard_Boolean OpenGl_Context::IsRender() const // ======================================================================= Standard_Boolean OpenGl_Context::IsFeedback() const { -#if !defined(GL_ES_VERSION_2_0) return myRenderMode == GL_FEEDBACK; -#else - return Standard_False; -#endif } // ======================================================================= @@ -2538,12 +2355,10 @@ void OpenGl_Context::SetColor4fv (const OpenGl_Vec4& theColor) myActiveProgram->SetUniform (this, aLoc, Vec4FromQuantityColor (theColor)); } } -#if !defined(GL_ES_VERSION_2_0) else if (core11ffp != NULL) { core11ffp->glColor4fv (theColor.GetData()); } -#endif } // ======================================================================= @@ -2585,25 +2400,19 @@ void OpenGl_Context::SetLineStipple (const Standard_ShortReal theFactor, return; } -#if !defined(GL_ES_VERSION_2_0) - if (thePattern != 0xFFFF) + if (core11ffp != NULL) { - if (core11ffp != NULL) + if (thePattern != 0xFFFF) { core11fwd->glEnable (GL_LINE_STIPPLE); - core11ffp->glLineStipple (static_cast (theFactor), static_cast (thePattern)); } - } - else - { - if (core11ffp != NULL) + else { core11fwd->glDisable (GL_LINE_STIPPLE); } } -#endif } // ======================================================================= @@ -2612,9 +2421,8 @@ void OpenGl_Context::SetLineStipple (const Standard_ShortReal theFactor, // ======================================================================= void OpenGl_Context::SetLineWidth (const Standard_ShortReal theWidth) { -#if !defined(GL_ES_VERSION_2_0) - if (core11ffp != NULL) -#endif + if (myGapi == Aspect_GraphicsLibrary_OpenGLES + || core11ffp != NULL) { // glLineWidth() is still defined within Core Profile, but has no effect with values != 1.0f core11fwd->glLineWidth (theWidth * myLineWidthScale); @@ -2661,11 +2469,10 @@ void OpenGl_Context::SetTextureMatrix (const Handle(Graphic3d_TextureParams)& th return; } -#if !defined(GL_ES_VERSION_2_0) if (core11ffp != NULL) { GLint aMatrixMode = GL_TEXTURE; - ::glGetIntegerv (GL_MATRIX_MODE, &aMatrixMode); + core11fwd->glGetIntegerv (GL_MATRIX_MODE, &aMatrixMode); core11ffp->glMatrixMode (GL_TEXTURE); OpenGl_Mat4 aTextureMat; @@ -2684,7 +2491,6 @@ void OpenGl_Context::SetTextureMatrix (const Handle(Graphic3d_TextureParams)& th core11ffp->glLoadMatrixf (aTextureMat.GetData()); core11ffp->glMatrixMode (aMatrixMode); } -#endif } // ======================================================================= @@ -2696,20 +2502,19 @@ void OpenGl_Context::SetPointSize (const Standard_ShortReal theSize) if (!myActiveProgram.IsNull()) { myActiveProgram->SetUniform (this, myActiveProgram->GetStateLocation (OpenGl_OCCT_POINT_SIZE), theSize); - #if !defined(GL_ES_VERSION_2_0) - //myContext->core11fwd->glEnable (GL_VERTEX_PROGRAM_POINT_SIZE); - #endif + //if (myGapi == Aspect_GraphicsLibrary_OpenGL) + //core11fwd->glEnable (GL_VERTEX_PROGRAM_POINT_SIZE); } -#if !defined(GL_ES_VERSION_2_0) //else + + if (myGapi != Aspect_GraphicsLibrary_OpenGLES) { core11fwd->glPointSize (theSize); if (core20fwd != NULL) { - //myContext->core11fwd->glDisable (GL_VERTEX_PROGRAM_POINT_SIZE); + //core11fwd->glDisable (GL_VERTEX_PROGRAM_POINT_SIZE); } } -#endif } // ======================================================================= @@ -2718,8 +2523,8 @@ void OpenGl_Context::SetPointSize (const Standard_ShortReal theSize) // ======================================================================= void OpenGl_Context::SetPointSpriteOrigin() { -#if !defined(GL_ES_VERSION_2_0) - if (core15fwd == NULL) + if (myGapi == Aspect_GraphicsLibrary_OpenGLES + || core15fwd == NULL) { return; } @@ -2728,9 +2533,10 @@ void OpenGl_Context::SetPointSpriteOrigin() if (myPointSpriteOrig != aNewState) { myPointSpriteOrig = aNewState; + #if !defined(GL_ES_VERSION_2_0) core15fwd->glPointParameteri (GL_POINT_SPRITE_COORD_ORIGIN, aNewState); + #endif } -#endif } // ======================================================================= @@ -2746,7 +2552,7 @@ Standard_Boolean OpenGl_Context::SetGlNormalizeEnabled (Standard_Boolean isEnabl Standard_Boolean anOldGlNormalize = myIsGlNormalizeEnabled; myIsGlNormalizeEnabled = isEnabled; -#if !defined(GL_ES_VERSION_2_0) + if (core11ffp != NULL) { if (isEnabled) @@ -2758,7 +2564,6 @@ Standard_Boolean OpenGl_Context::SetGlNormalizeEnabled (Standard_Boolean isEnabl core11fwd->glDisable (GL_NORMALIZE); } } -#endif return anOldGlNormalize; } @@ -2769,7 +2574,6 @@ Standard_Boolean OpenGl_Context::SetGlNormalizeEnabled (Standard_Boolean isEnabl // ======================================================================= void OpenGl_Context::SetShadeModel (Graphic3d_TypeOfShadingModel theModel) { -#if !defined(GL_ES_VERSION_2_0) if (core11ffp != NULL) { const Standard_Integer aModel = theModel == Graphic3d_TypeOfShadingModel_PhongFacet @@ -2781,9 +2585,6 @@ void OpenGl_Context::SetShadeModel (Graphic3d_TypeOfShadingModel theModel) myShadeModel = aModel; core11ffp->glShadeModel (aModel); } -#else - (void )theModel; -#endif } // ======================================================================= @@ -2798,13 +2599,11 @@ Standard_Integer OpenGl_Context::SetPolygonMode (const Standard_Integer theMode) } const Standard_Integer anOldPolygonMode = myPolygonMode; - myPolygonMode = theMode; - -#if !defined(GL_ES_VERSION_2_0) - ::glPolygonMode (GL_FRONT_AND_BACK, (GLenum)theMode); -#endif - + if (myGapi != Aspect_GraphicsLibrary_OpenGLES) + { + core11fwd->glPolygonMode (GL_FRONT_AND_BACK, (GLenum)theMode); + } return anOldPolygonMode; } @@ -2824,7 +2623,6 @@ bool OpenGl_Context::SetPolygonHatchEnabled (const bool theIsEnabled) } const bool anOldIsEnabled = myHatchIsEnabled; -#if !defined(GL_ES_VERSION_2_0) if (theIsEnabled && myActiveHatchType != Aspect_HS_SOLID) { @@ -2834,7 +2632,7 @@ bool OpenGl_Context::SetPolygonHatchEnabled (const bool theIsEnabled) { core11fwd->glDisable (GL_POLYGON_STIPPLE); } -#endif + myHatchIsEnabled = theIsEnabled; return anOldIsEnabled; } @@ -2852,7 +2650,6 @@ Standard_Integer OpenGl_Context::SetPolygonHatchStyle (const Handle(Graphic3d_Ha return myActiveHatchType; } -#if !defined(GL_ES_VERSION_2_0) if (aNewStyle == Aspect_HS_SOLID) { if (myHatchIsEnabled) @@ -2879,9 +2676,6 @@ Standard_Integer OpenGl_Context::SetPolygonHatchStyle (const Handle(Graphic3d_Ha core11fwd->glEnable (GL_POLYGON_STIPPLE); } return anOldType; -#else - return myActiveHatchType; -#endif } // ======================================================================= @@ -2904,35 +2698,36 @@ void OpenGl_Context::SetPolygonOffset (const Graphic3d_PolygonOffset& theOffset) } } -#if !defined(GL_ES_VERSION_2_0) - const bool toLineOld = (myPolygonOffset.Mode & Aspect_POM_Line) == Aspect_POM_Line; - const bool toLineNew = (theOffset.Mode & Aspect_POM_Line) == Aspect_POM_Line; - if (toLineNew != toLineOld) + if (myGapi != Aspect_GraphicsLibrary_OpenGLES) { - if (toLineNew) + const bool toLineOld = (myPolygonOffset.Mode & Aspect_POM_Line) == Aspect_POM_Line; + const bool toLineNew = (theOffset.Mode & Aspect_POM_Line) == Aspect_POM_Line; + if (toLineNew != toLineOld) { - core11fwd->glEnable (GL_POLYGON_OFFSET_LINE); + if (toLineNew) + { + core11fwd->glEnable (GL_POLYGON_OFFSET_LINE); + } + else + { + core11fwd->glDisable (GL_POLYGON_OFFSET_LINE); + } } - else - { - core11fwd->glDisable (GL_POLYGON_OFFSET_LINE); - } - } - const bool toPointOld = (myPolygonOffset.Mode & Aspect_POM_Point) == Aspect_POM_Point; - const bool toPointNew = (theOffset.Mode & Aspect_POM_Point) == Aspect_POM_Point; - if (toPointNew != toPointOld) - { - if (toPointNew) + const bool toPointOld = (myPolygonOffset.Mode & Aspect_POM_Point) == Aspect_POM_Point; + const bool toPointNew = (theOffset.Mode & Aspect_POM_Point) == Aspect_POM_Point; + if (toPointNew != toPointOld) { - core11fwd->glEnable (GL_POLYGON_OFFSET_POINT); - } - else - { - core11fwd->glDisable (GL_POLYGON_OFFSET_POINT); + if (toPointNew) + { + core11fwd->glEnable (GL_POLYGON_OFFSET_POINT); + } + else + { + core11fwd->glDisable (GL_POLYGON_OFFSET_POINT); + } } } -#endif if (myPolygonOffset.Factor != theOffset.Factor || myPolygonOffset.Units != theOffset.Units) @@ -3035,7 +2830,6 @@ void OpenGl_Context::DisableFeatures() const core11fwd->glDisable(GL_DEPTH_TEST); core11fwd->glDisable(GL_STENCIL_TEST); -#if !defined(GL_ES_VERSION_2_0) if (core11ffp == NULL) { return; @@ -3049,37 +2843,43 @@ void OpenGl_Context::DisableFeatures() const core11fwd->glDisable(GL_FOG); core11fwd->glDisable(GL_LOGIC_OP); - glPixelTransferi(GL_MAP_COLOR, GL_FALSE); - glPixelTransferi(GL_RED_SCALE, 1); - glPixelTransferi(GL_RED_BIAS, 0); - glPixelTransferi(GL_GREEN_SCALE, 1); - glPixelTransferi(GL_GREEN_BIAS, 0); - glPixelTransferi(GL_BLUE_SCALE, 1); - glPixelTransferi(GL_BLUE_BIAS, 0); - glPixelTransferi(GL_ALPHA_SCALE, 1); - glPixelTransferi(GL_ALPHA_BIAS, 0); + core11ffp->glPixelTransferi (GL_MAP_COLOR, GL_FALSE); + core11ffp->glPixelTransferi (GL_RED_SCALE, 1); + core11ffp->glPixelTransferi (GL_RED_BIAS, 0); + core11ffp->glPixelTransferi (GL_GREEN_SCALE, 1); + core11ffp->glPixelTransferi (GL_GREEN_BIAS, 0); + core11ffp->glPixelTransferi (GL_BLUE_SCALE, 1); + core11ffp->glPixelTransferi (GL_BLUE_BIAS, 0); + core11ffp->glPixelTransferi (GL_ALPHA_SCALE, 1); + core11ffp->glPixelTransferi (GL_ALPHA_BIAS, 0); - if ((myGlVerMajor >= 1) && (myGlVerMinor >= 2)) + if (IsGlGreaterEqual (1, 2)) { if (CheckExtension ("GL_CONVOLUTION_1D_EXT")) + { core11fwd->glDisable(GL_CONVOLUTION_1D_EXT); - + } if (CheckExtension ("GL_CONVOLUTION_2D_EXT")) + { core11fwd->glDisable(GL_CONVOLUTION_2D_EXT); - + } if (CheckExtension ("GL_SEPARABLE_2D_EXT")) + { core11fwd->glDisable(GL_SEPARABLE_2D_EXT); - + } if (CheckExtension ("GL_SEPARABLE_2D_EXT")) + { core11fwd->glDisable(GL_HISTOGRAM_EXT); - + } if (CheckExtension ("GL_MINMAX_EXT")) + { core11fwd->glDisable(GL_MINMAX_EXT); - + } if (CheckExtension ("GL_TEXTURE_3D_EXT")) + { core11fwd->glDisable(GL_TEXTURE_3D_EXT); + } } -#endif } // ======================================================================= @@ -3154,7 +2954,7 @@ bool OpenGl_Context::GetBufferSubData (unsigned int theTarget, intptr_t theOffse Module.ctx.getBufferSubData($0, $1, HEAPU8.subarray($2, $2 + $3)); }, theTarget, theOffset, theData, theSize); return true; -#elif defined(GL_ES_VERSION_2_0) +#elif defined(OCC_USE_GLES2) if (void* aData = core30->glMapBufferRange (theTarget, theOffset, theSize, GL_MAP_READ_BIT)) { memcpy (theData, aData, theSize); @@ -3239,12 +3039,11 @@ void OpenGl_Context::DumpJson (Standard_OStream& theOStream, Standard_Integer th // ======================================================================= void OpenGl_Context::DumpJsonOpenGlState (Standard_OStream& theOStream, Standard_Integer) { - GLboolean isEnableBlend = glIsEnabled (GL_BLEND); - GLboolean isEnableCullFace = glIsEnabled (GL_CULL_FACE); - GLboolean isEnableDepthTest = glIsEnabled (GL_DEPTH_TEST); + GLboolean isEnableBlend = core11fwd->glIsEnabled (GL_BLEND); + GLboolean isEnableCullFace = core11fwd->glIsEnabled (GL_CULL_FACE); + GLboolean isEnableDepthTest = core11fwd->glIsEnabled (GL_DEPTH_TEST); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, isEnableBlend) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, isEnableCullFace) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, isEnableDepthTest) } - diff --git a/src/OpenGl/OpenGl_Context.hxx b/src/OpenGl/OpenGl_Context.hxx index ed3418d3d5..92e456c8e3 100644 --- a/src/OpenGl/OpenGl_Context.hxx +++ b/src/OpenGl/OpenGl_Context.hxx @@ -981,7 +981,7 @@ public: //! @name methods to alter or retrieve current state Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; //! Dumps the content of openGL state into the stream - Standard_EXPORT static void DumpJsonOpenGlState (Standard_OStream& theOStream, Standard_Integer theDepth = -1); + Standard_EXPORT void DumpJsonOpenGlState (Standard_OStream& theOStream, Standard_Integer theDepth = -1); //! Set GL_SHADE_MODEL value. Standard_EXPORT void SetShadeModel (Graphic3d_TypeOfShadingModel theModel); diff --git a/src/OpenGl/OpenGl_Font.cxx b/src/OpenGl/OpenGl_Font.cxx index a5e66273da..384c4754a6 100755 --- a/src/OpenGl/OpenGl_Font.cxx +++ b/src/OpenGl/OpenGl_Font.cxx @@ -203,9 +203,10 @@ bool OpenGl_Font::renderGlyph (const Handle(OpenGl_Context)& theCtx, } aTexture->Bind (theCtx); -#if !defined(GL_ES_VERSION_2_0) - theCtx->core11fwd->glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE); -#endif + if (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES) + { + theCtx->core11fwd->glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE); + } if (theCtx->hasUnpackRowLength) { theCtx->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); diff --git a/src/OpenGl/OpenGl_FrameBuffer.cxx b/src/OpenGl/OpenGl_FrameBuffer.cxx index 6ee169946a..f7a4d95a7d 100644 --- a/src/OpenGl/OpenGl_FrameBuffer.cxx +++ b/src/OpenGl/OpenGl_FrameBuffer.cxx @@ -50,15 +50,14 @@ namespace // while WebGL 1.0 + GL_WEBGL_depth_texture needs GL_DEPTH_STENCIL_ATTACHMENT // and NOT separate GL_DEPTH_ATTACHMENT+GL_STENCIL_ATTACHMENT calls which is different to OpenGL ES 2.0 + extension return theCtx->IsGlGreaterEqual (3, 0) || theCtx->extPDS; - #elif defined(GL_ES_VERSION_2_0) + #else // supported since OpenGL ES 3.0, // while OpenGL ES 2.0 + GL_EXT_packed_depth_stencil needs separate GL_DEPTH_ATTACHMENT+GL_STENCIL_ATTACHMENT calls - return theCtx->IsGlGreaterEqual (3, 0); - #else + // // available on desktop since OpenGL 3.0 // or OpenGL 2.0 + GL_ARB_framebuffer_object (GL_EXT_framebuffer_object is unsupported by OCCT) - (void )theCtx; - return true; + return theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES + || theCtx->IsGlGreaterEqual (3, 0); #endif } } @@ -968,60 +967,104 @@ Standard_Boolean OpenGl_FrameBuffer::BufferDump (const Handle(OpenGl_Context)& t bool toConvRgba2Rgb = false; switch (theImage.Format()) { - #if !defined(GL_ES_VERSION_2_0) case Image_Format_Gray: + { + if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + return false; + } + aFormat = theBufferType == Graphic3d_BT_Depth ? GL_DEPTH_COMPONENT : GL_RED; aType = GL_UNSIGNED_BYTE; break; + } case Image_Format_GrayF: + { + if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + return false; + } + aFormat = theBufferType == Graphic3d_BT_Depth ? GL_DEPTH_COMPONENT : GL_RED; aType = GL_FLOAT; break; + } case Image_Format_RGF: + { + if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + return false; + } + aFormat = GL_RG; aType = GL_FLOAT; break; + } case Image_Format_RGB: - aFormat = GL_RGB; - aType = GL_UNSIGNED_BYTE; + { + if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + aFormat = GL_RGBA; + toConvRgba2Rgb = true; + } + else + { + aFormat = GL_RGB; + } + aType = GL_UNSIGNED_BYTE; break; + } case Image_Format_BGR: - aFormat = GL_BGR; - aType = GL_UNSIGNED_BYTE; + { + if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + aFormat = GL_RGBA; + toConvRgba2Rgb = true; + } + else + { + aFormat = GL_BGR; + } + aType = GL_UNSIGNED_BYTE; break; + } case Image_Format_BGRA: case Image_Format_BGR32: - aFormat = GL_BGRA; - aType = GL_UNSIGNED_BYTE; + { + if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + aFormat = GL_RGBA; + toSwapRgbaBgra = true; + } + else + { + aFormat = GL_BGRA; + } + aType = GL_UNSIGNED_BYTE; break; + } case Image_Format_BGRF: + { + if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + return false; + } + aFormat = GL_BGR; aType = GL_FLOAT; break; + } case Image_Format_BGRAF: + { + if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + return false; + } + aFormat = GL_BGRA; aType = GL_FLOAT; break; - #else - case Image_Format_Gray: - case Image_Format_GrayF: - case Image_Format_BGRF: - case Image_Format_BGRAF: - case Image_Format_RGF: - return Standard_False; - case Image_Format_BGRA: - case Image_Format_BGR32: - aFormat = GL_RGBA; - aType = GL_UNSIGNED_BYTE; - toSwapRgbaBgra = true; - break; - case Image_Format_BGR: - case Image_Format_RGB: - aFormat = GL_RGBA; - aType = GL_UNSIGNED_BYTE; - toConvRgba2Rgb = true; - break; - #endif + } case Image_Format_RGBA: case Image_Format_RGB32: aFormat = GL_RGBA; @@ -1052,30 +1095,25 @@ Standard_Boolean OpenGl_FrameBuffer::BufferDump (const Handle(OpenGl_Context)& t return Standard_False; } -#if !defined(GL_ES_VERSION_2_0) GLint aReadBufferPrev = GL_BACK; - if (theBufferType == Graphic3d_BT_Depth + if (theGlCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES + && theBufferType == Graphic3d_BT_Depth && aFormat != GL_DEPTH_COMPONENT) { return Standard_False; } -#else - (void )theBufferType; -#endif // bind FBO if used if (!theFbo.IsNull() && theFbo->IsValid()) { theFbo->BindBuffer (theGlCtx); } - else + else if (theGlCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES) { - #if !defined(GL_ES_VERSION_2_0) theGlCtx->core11fwd->glGetIntegerv (GL_READ_BUFFER, &aReadBufferPrev); GLint aDrawBufferPrev = GL_BACK; theGlCtx->core11fwd->glGetIntegerv (GL_DRAW_BUFFER, &aDrawBufferPrev); - glReadBuffer (aDrawBufferPrev); - #endif + theGlCtx->core11fwd->glReadBuffer (aDrawBufferPrev); } // setup alignment @@ -1155,11 +1193,9 @@ Standard_Boolean OpenGl_FrameBuffer::BufferDump (const Handle(OpenGl_Context)& t { theFbo->UnbindBuffer (theGlCtx); } - else + else if (theGlCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES) { - #if !defined(GL_ES_VERSION_2_0) - glReadBuffer (aReadBufferPrev); - #endif + theGlCtx->core11fwd->glReadBuffer (aReadBufferPrev); } if (toSwapRgbaBgra) diff --git a/src/OpenGl/OpenGl_FrameStatsPrs.cxx b/src/OpenGl/OpenGl_FrameStatsPrs.cxx index d6891588ef..b57e6ed613 100644 --- a/src/OpenGl/OpenGl_FrameStatsPrs.cxx +++ b/src/OpenGl/OpenGl_FrameStatsPrs.cxx @@ -378,7 +378,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace) if (theWorkspace->UseDepthWrite()) { theWorkspace->UseDepthWrite() = Standard_False; - glDepthMask (GL_FALSE); + aCtx->core11fwd->glDepthMask (GL_FALSE); } const OpenGl_Aspects* aTextAspectBack = theWorkspace->SetAspects (&myTextAspect); @@ -417,8 +417,8 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace) Graphic3d_AlphaMode_Blend, true, false, Handle(OpenGl_ShaderProgram)()); aCtx->SetColor4fv (OpenGl_Vec4 (1.0f, 1.0f, 1.0f, 1.0f)); - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + aCtx->core15fwd->glEnable (GL_BLEND); + aCtx->core15fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); myChartVertices->Bind (aCtx); myChartVertices->bindAttribute (aCtx, Graphic3d_TOA_POS, 3, GL_FLOAT, myChartVertices->GetComponentsNb(), NULL); myChartVertices->bindAttribute (aCtx, Graphic3d_TOA_COLOR, 4, GL_UNSIGNED_BYTE, myChartVertices->GetComponentsNb(), (void* )sizeof(Graphic3d_Vec3)); @@ -429,7 +429,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace) myChartVertices->Unbind (aCtx); myChartVertices->unbindAttribute (aCtx, Graphic3d_TOA_COLOR); myChartVertices->unbindAttribute (aCtx, Graphic3d_TOA_POS); - glDisable (GL_BLEND); + aCtx->core15fwd->glDisable (GL_BLEND); myChartLines->Bind (aCtx); myChartLines->bindAttribute (aCtx, Graphic3d_TOA_POS, 3, GL_FLOAT, myChartLines->GetComponentsNb(), NULL); @@ -453,7 +453,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace) if (theWorkspace->UseDepthWrite() != wasEnabledDepth) { theWorkspace->UseDepthWrite() = wasEnabledDepth; - glDepthMask (wasEnabledDepth ? GL_TRUE : GL_FALSE); + aCtx->core11fwd->glDepthMask (wasEnabledDepth ? GL_TRUE : GL_FALSE); } } diff --git a/src/OpenGl/OpenGl_GlCore11.hxx b/src/OpenGl/OpenGl_GlCore11.hxx index e1495f1cd7..b8858494a5 100644 --- a/src/OpenGl/OpenGl_GlCore11.hxx +++ b/src/OpenGl/OpenGl_GlCore11.hxx @@ -18,6 +18,171 @@ #include +#ifndef GL_COMPILE +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 + +#define GL_RENDER_MODE 0x0C40 +#define GL_RENDER 0x1C00 +#define GL_FEEDBACK 0x1C01 +#define GL_SELECT 0x1C02 + +#define GL_SHADE_MODEL 0x0B54 +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 + +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 + +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_STIPPLE 0x0B42 + +#define GL_MATRIX_MODE 0x0BA0 +#define GL_NORMALIZE 0x0BA1 + +#define GL_TEXTURE_1D 0x0DE0 + +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 + +#define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_POLYGON 0x0009 + +#define GL_LIGHTING 0x0B50 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 + +// LightParameter +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 + +#define GL_EMISSION 0x1600 +#define GL_SHININESS 0x1601 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_COLOR_INDEXES 0x1603 + +// MatrixMode +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 + +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 +#define GL_FOG 0x0B60 + +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_LOGIC_OP GL_INDEX_LOGIC_OP +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_CLEAR 0x1500 +#define GL_AND 0x1501 +#define GL_AND_REVERSE 0x1502 +#define GL_COPY 0x1503 +#define GL_AND_INVERTED 0x1504 +#define GL_NOOP 0x1505 +#define GL_XOR 0x1506 +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_EQUIV 0x1509 +#define GL_INVERT 0x150A +#define GL_OR_REVERSE 0x150B +#define GL_COPY_INVERTED 0x150C +#define GL_OR_INVERTED 0x150D +#define GL_NAND 0x150E +#define GL_SET 0x150F + +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 + +#define GL_PROXY_TEXTURE_1D 0x8063 + +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_FUNC 0x0BC1 +#define GL_ALPHA_TEST_REF 0x0BC2 + +// TextureCoordName +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 + +// TextureEnvMode +#define GL_MODULATE 0x2100 +#define GL_DECAL 0x2101 + +// TextureEnvParameter +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_ENV_COLOR 0x2201 + +// TextureEnvTarget +#define GL_TEXTURE_ENV 0x2300 + +// TextureGenMode +#define GL_EYE_LINEAR 0x2400 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_SPHERE_MAP 0x2402 + +// TextureGenParameter +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_OBJECT_PLANE 0x2501 +#define GL_EYE_PLANE 0x2502 + +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 + +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_RED_SCALE 0x0D14 +#define GL_RED_BIAS 0x0D15 +#define GL_GREEN_SCALE 0x0D18 +#define GL_GREEN_BIAS 0x0D19 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BLUE_BIAS 0x0D1B +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_DEPTH_SCALE 0x0D1E +#define GL_DEPTH_BIAS 0x0D1F + +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#endif + //! OpenGL 1.1 core. //! Notice that all functions within this structure are actually exported by system GL library. //! The main purpose for these hint - to control visibility of functions per GL version @@ -25,272 +190,77 @@ struct OpenGl_GlCore11 : protected OpenGl_GlFunctions { -#if !defined(GL_ES_VERSION_2_0) public: - inline void glTexEnvi (GLenum target, GLenum pname, GLint param) - { - ::glTexEnvi (target, pname, param); - OpenGl_TRACE(glTexEnvi) - } - - inline void glGetTexEnviv (GLenum target, GLenum pname, GLint *params) - { - ::glGetTexEnviv (target, pname, params); - OpenGl_TRACE(glGetTexEnviv) - } - - inline void glLogicOp (GLenum opcode) - { - ::glLogicOp (opcode); - OpenGl_TRACE(glLogicOp) - } + using OpenGl_GlFunctions::glTexEnvi; + using OpenGl_GlFunctions::glGetTexEnviv; public: //! @name Begin/End primitive specification (removed since 3.1) - inline void glColor4fv (const GLfloat* theVec) - { - ::glColor4fv (theVec); - OpenGl_TRACE(glColor4fv) - } + using OpenGl_GlFunctions::glColor4fv; public: //! @name Matrix operations (removed since 3.1) - inline void glMatrixMode (GLenum theMode) - { - ::glMatrixMode (theMode); - OpenGl_TRACE(glMatrixMode) - } - - inline void glLoadIdentity() - { - ::glLoadIdentity(); - OpenGl_TRACE(glLoadIdentity) - } - - inline void glLoadMatrixf (const GLfloat* theMatrix) - { - ::glLoadMatrixf (theMatrix); - OpenGl_TRACE(glLoadMatrixf) - } + using OpenGl_GlFunctions::glMatrixMode; + using OpenGl_GlFunctions::glLoadIdentity; + using OpenGl_GlFunctions::glLoadMatrixf; public: //! @name Line and Polygon stipple (removed since 3.1) - inline void glLineStipple (GLint theFactor, GLushort thePattern) - { - ::glLineStipple (theFactor, thePattern); - OpenGl_TRACE(glLineStipple) - } - - inline void glPolygonStipple (const GLubyte* theMask) - { - ::glPolygonStipple (theMask); - OpenGl_TRACE(glPolygonStipple) - } + using OpenGl_GlFunctions::glLineStipple; + using OpenGl_GlFunctions::glPolygonStipple; public: //! @name Fixed pipeline lighting (removed since 3.1) - inline void glShadeModel (GLenum theMode) - { - ::glShadeModel (theMode); - OpenGl_TRACE(glShadeModel) - } - - inline void glLightf (GLenum theLight, GLenum pname, GLfloat param) - { - ::glLightf (theLight, pname, param); - OpenGl_TRACE(glLightf) - } - - inline void glLightfv (GLenum theLight, GLenum pname, const GLfloat* params) - { - ::glLightfv (theLight, pname, params); - OpenGl_TRACE(glLightfv) - } - - inline void glLightModeli (GLenum pname, GLint param) - { - ::glLightModeli(pname, param); - OpenGl_TRACE(glLightModeli) - } - - inline void glLightModelfv (GLenum pname, const GLfloat* params) - { - ::glLightModelfv(pname, params); - OpenGl_TRACE(glLightModelfv) - } - - inline void glMaterialf (GLenum face, GLenum pname, GLfloat param) - { - ::glMaterialf(face, pname, param); - OpenGl_TRACE(glMaterialf) - } - - inline void glMaterialfv (GLenum face, GLenum pname, const GLfloat* params) - { - ::glMaterialfv(face, pname, params); - OpenGl_TRACE(glMaterialfv) - } - - inline void glColorMaterial (GLenum face, GLenum mode) - { - ::glColorMaterial(face, mode); - OpenGl_TRACE(glColorMaterial) - } + using OpenGl_GlFunctions::glShadeModel; + using OpenGl_GlFunctions::glLightf; + using OpenGl_GlFunctions::glLightfv; + using OpenGl_GlFunctions::glLightModeli; + using OpenGl_GlFunctions::glLightModelfv; + using OpenGl_GlFunctions::glMaterialf; + using OpenGl_GlFunctions::glMaterialfv; + using OpenGl_GlFunctions::glColorMaterial; public: //! @name clipping plane (removed since 3.1) - inline void glClipPlane (GLenum thePlane, const GLdouble* theEquation) - { - ::glClipPlane (thePlane, theEquation); - OpenGl_TRACE(glClipPlane) - } + using OpenGl_GlFunctions::glClipPlane; public: //! @name Display lists (removed since 3.1) - inline void glDeleteLists (GLuint theList, GLsizei theRange) - { - ::glDeleteLists (theList, theRange); - OpenGl_TRACE(glDeleteLists) - } - - inline GLuint glGenLists (GLsizei theRange) - { - const GLuint aRes = ::glGenLists (theRange); - OpenGl_TRACE(glGenLists) - return aRes; - } - - inline void glNewList (GLuint theList, GLenum theMode) - { - ::glNewList (theList, theMode); - OpenGl_TRACE(glNewList) - } - - inline void glEndList() - { - ::glEndList(); - OpenGl_TRACE(glEndList) - } - - inline void glCallList (GLuint theList) - { - ::glCallList (theList); - OpenGl_TRACE(glCallList) - } - - inline void glCallLists (GLsizei theNb, GLenum theType, const GLvoid* theLists) - { - ::glCallLists (theNb, theType, theLists); - OpenGl_TRACE(glCallLists) - } - - inline void glListBase (GLuint theBase) - { - ::glListBase (theBase); - OpenGl_TRACE(glListBase) - } + using OpenGl_GlFunctions::glDeleteLists; + using OpenGl_GlFunctions::glGenLists; + using OpenGl_GlFunctions::glNewList; + using OpenGl_GlFunctions::glEndList; + using OpenGl_GlFunctions::glCallList; + using OpenGl_GlFunctions::glCallLists; + using OpenGl_GlFunctions::glListBase; public: //! @name Current raster position and Rectangles (removed since 3.1) - inline void glRasterPos2i (GLint x, GLint y) - { - ::glRasterPos2i (x, y); - OpenGl_TRACE(glRasterPos2i) - } - - inline void glRasterPos3fv (const GLfloat* theVec) - { - ::glRasterPos3fv (theVec); - OpenGl_TRACE(glRasterPos3fv) - } + using OpenGl_GlFunctions::glRasterPos2i; + using OpenGl_GlFunctions::glRasterPos3fv; public: //! @name Texture mapping (removed since 3.1) - inline void glTexGeni (GLenum coord, GLenum pname, GLint param) - { - ::glTexGeni (coord, pname, param); - OpenGl_TRACE(glTexGeni) - } - - inline void glTexGenfv (GLenum coord, GLenum pname, const GLfloat* params) - { - ::glTexGenfv (coord, pname, params); - OpenGl_TRACE(glTexGenfv) - } + using OpenGl_GlFunctions::glTexGeni; + using OpenGl_GlFunctions::glTexGenfv; public: //! @name Pixel copying (removed since 3.1) - inline void glDrawPixels (GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid* pixels) - { - ::glDrawPixels (width, height, format, type, pixels); - OpenGl_TRACE(glDrawPixels) - } - - inline void glCopyPixels (GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum type) - { - ::glCopyPixels (x, y, width, height, type); - OpenGl_TRACE(glCopyPixels) - } - - inline void glBitmap (GLsizei width, GLsizei height, - GLfloat xorig, GLfloat yorig, - GLfloat xmove, GLfloat ymove, - const GLubyte* bitmap) - { - ::glBitmap (width, height, xorig, yorig, xmove, ymove, bitmap); - OpenGl_TRACE(glBitmap) - } + using OpenGl_GlFunctions::glDrawPixels; + using OpenGl_GlFunctions::glCopyPixels; + using OpenGl_GlFunctions::glBitmap; public: //! @name Edge flags and fixed-function vertex processing (removed since 3.1) - inline void glIndexPointer (GLenum theType, GLsizei theStride, const GLvoid* thePtr) - { - ::glIndexPointer (theType, theStride, thePtr); - OpenGl_TRACE(glIndexPointer) - } - - inline void glVertexPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) - { - ::glVertexPointer (theSize, theType, theStride, thePtr); - OpenGl_TRACE(glVertexPointer) - } - - inline void glNormalPointer (GLenum theType, GLsizei theStride, const GLvoid* thePtr) - { - ::glNormalPointer (theType, theStride, thePtr); - OpenGl_TRACE(glNormalPointer) - } - - inline void glColorPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) - { - ::glColorPointer (theSize, theType, theStride, thePtr); - OpenGl_TRACE(glColorPointer) - } - - inline void glTexCoordPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) - { - ::glTexCoordPointer (theSize, theType, theStride, thePtr); - OpenGl_TRACE(glTexCoordPointer) - } - - inline void glEnableClientState (GLenum theCap) - { - ::glEnableClientState (theCap); - OpenGl_TRACE(glEnableClientState) - } - - inline void glDisableClientState (GLenum theCap) - { - ::glDisableClientState (theCap); - OpenGl_TRACE(glDisableClientState) - } - -#endif + using OpenGl_GlFunctions::glIndexPointer; + using OpenGl_GlFunctions::glVertexPointer; + using OpenGl_GlFunctions::glNormalPointer; + using OpenGl_GlFunctions::glColorPointer; + using OpenGl_GlFunctions::glTexCoordPointer; + using OpenGl_GlFunctions::glEnableClientState; + using OpenGl_GlFunctions::glDisableClientState; + using OpenGl_GlFunctions::glPixelTransferi; }; diff --git a/src/OpenGl/OpenGl_GlCore11Fwd.hxx b/src/OpenGl/OpenGl_GlCore11Fwd.hxx index 07fef6806c..4ac2be42a2 100644 --- a/src/OpenGl/OpenGl_GlCore11Fwd.hxx +++ b/src/OpenGl/OpenGl_GlCore11Fwd.hxx @@ -27,542 +27,96 @@ struct OpenGl_GlCore11Fwd : protected OpenGl_GlFunctions public: //! @name Miscellaneous - inline void glClearColor (GLclampf theRed, GLclampf theGreen, GLclampf theBlue, GLclampf theAlpha) - { - ::glClearColor (theRed, theGreen, theBlue, theAlpha); - OpenGl_TRACE(glClearColor) - } - - inline void glClear (GLbitfield theMask) - { - ::glClear (theMask); - OpenGl_TRACE(glClear) - } - - inline void glColorMask (GLboolean theRed, GLboolean theGreen, GLboolean theBlue, GLboolean theAlpha) - { - ::glColorMask (theRed, theGreen, theBlue, theAlpha); - OpenGl_TRACE(glColorMask) - } - - inline void glBlendFunc (GLenum sfactor, GLenum dfactor) - { - ::glBlendFunc(sfactor, dfactor); - OpenGl_TRACE(glBlendFunc) - } - - inline void glCullFace (GLenum theMode) - { - ::glCullFace (theMode); - OpenGl_TRACE(glCullFace) - } - - inline void glFrontFace (GLenum theMode) - { - ::glFrontFace (theMode); - OpenGl_TRACE(glFrontFace) - } - - inline void glLineWidth (GLfloat theWidth) - { - ::glLineWidth (theWidth); - OpenGl_TRACE(glLineWidth) - } - - inline void glPolygonOffset (GLfloat theFactor, GLfloat theUnits) - { - ::glPolygonOffset (theFactor, theUnits); - OpenGl_TRACE(glPolygonOffset) - } - - inline void glScissor (GLint theX, GLint theY, GLsizei theWidth, GLsizei theHeight) - { - ::glScissor (theX, theY, theWidth, theHeight); - OpenGl_TRACE(glScissor) - } - - inline void glEnable (GLenum theCap) - { - ::glEnable (theCap); - OpenGl_TRACE(glEnable) - } - - inline void glDisable (GLenum theCap) - { - ::glDisable (theCap); - OpenGl_TRACE(glDisable) - } - - inline GLboolean glIsEnabled (GLenum theCap) - { - return ::glIsEnabled (theCap); - } - - inline void glGetBooleanv (GLenum theParamName, GLboolean* theValues) - { - ::glGetBooleanv (theParamName, theValues); - OpenGl_TRACE(glGetBooleanv) - } - - inline void glGetFloatv (GLenum theParamName, GLfloat* theValues) - { - ::glGetFloatv (theParamName, theValues); - OpenGl_TRACE(glGetFloatv) - } - - inline void glGetIntegerv (GLenum theParamName, GLint* theValues) - { - ::glGetIntegerv (theParamName, theValues); - OpenGl_TRACE(glGetIntegerv) - } - - inline GLenum glGetError() - { - return ::glGetError(); - } - - inline const GLubyte* glGetString (GLenum theName) - { - const GLubyte* aRes = ::glGetString (theName); - OpenGl_TRACE(glGetString) - return aRes; - } - - inline void glFinish() - { - ::glFinish(); - OpenGl_TRACE(glFinish) - } - - inline void glFlush() - { - ::glFlush(); - OpenGl_TRACE(glFlush) - } - - inline void glHint (GLenum theTarget, GLenum theMode) - { - ::glHint (theTarget, theMode); - OpenGl_TRACE(glHint) - } + using OpenGl_GlFunctions::glClearColor; + using OpenGl_GlFunctions::glClear; + using OpenGl_GlFunctions::glColorMask; + using OpenGl_GlFunctions::glBlendFunc; + using OpenGl_GlFunctions::glCullFace; + using OpenGl_GlFunctions::glFrontFace; + using OpenGl_GlFunctions::glLineWidth; + using OpenGl_GlFunctions::glPolygonOffset; + using OpenGl_GlFunctions::glScissor; + using OpenGl_GlFunctions::glEnable; + using OpenGl_GlFunctions::glDisable; + using OpenGl_GlFunctions::glIsEnabled; + using OpenGl_GlFunctions::glGetBooleanv; + using OpenGl_GlFunctions::glGetFloatv; + using OpenGl_GlFunctions::glGetIntegerv; + using OpenGl_GlFunctions::glGetError; + using OpenGl_GlFunctions::glGetString; + using OpenGl_GlFunctions::glFinish; + using OpenGl_GlFunctions::glFlush; + using OpenGl_GlFunctions::glHint; public: //! @name Depth Buffer - inline void glClearDepth (GLclampd theDepth) - { - #if defined(GL_ES_VERSION_2_0) - ::glClearDepthf ((GLfloat )theDepth); - #else - ::glClearDepth (theDepth); - #endif - OpenGl_TRACE(glClearDepth) - } - - inline void glClearDepthf (GLfloat theDepth) - { - #if defined(GL_ES_VERSION_2_0) - ::glClearDepthf (theDepth); - #else - ::glClearDepth ((GLclampd )theDepth); - #endif - OpenGl_TRACE(glClearDepthf) - } - - inline void glDepthFunc (GLenum theFunc) - { - ::glDepthFunc (theFunc); - OpenGl_TRACE(glDepthFunc) - } - - inline void glDepthMask (GLboolean theFlag) - { - ::glDepthMask (theFlag); - OpenGl_TRACE(glDepthMask) - } - - inline void glDepthRange (GLclampd theNearValue, - GLclampd theFarValue) - { - #if defined(GL_ES_VERSION_2_0) - ::glDepthRangef ((GLfloat )theNearValue, (GLfloat )theFarValue); - #else - ::glDepthRange (theNearValue, theFarValue); - #endif - OpenGl_TRACE(glDepthRange) - } - - inline void glDepthRangef (GLfloat theNearValue, - GLfloat theFarValue) - { - #if defined(GL_ES_VERSION_2_0) - ::glDepthRangef (theNearValue, theFarValue); - #else - ::glDepthRange ((GLclampd )theNearValue, (GLclampd )theFarValue); - #endif - OpenGl_TRACE(glDepthRangef) - } + using OpenGl_GlFunctions::glClearDepth; + using OpenGl_GlFunctions::glClearDepthf; + using OpenGl_GlFunctions::glDepthFunc; + using OpenGl_GlFunctions::glDepthMask; + using OpenGl_GlFunctions::glDepthRange; + using OpenGl_GlFunctions::glDepthRangef; public: //! @name Transformation - inline void glViewport (GLint theX, GLint theY, GLsizei theWidth, GLsizei theHeight) - { - ::glViewport (theX, theY, theWidth, theHeight); - OpenGl_TRACE(glViewport) - } + using OpenGl_GlFunctions::glViewport; public: //! @name Vertex Arrays - inline void glDrawArrays (GLenum theMode, GLint theFirst, GLsizei theCount) - { - ::glDrawArrays (theMode, theFirst, theCount); - OpenGl_TRACE(glDrawArrays) - } - - inline void glDrawElements (GLenum theMode, GLsizei theCount, GLenum theType, const GLvoid* theIndices) - { - ::glDrawElements (theMode, theCount, theType, theIndices); - OpenGl_TRACE(glDrawElements) - } + using OpenGl_GlFunctions::glDrawArrays; + using OpenGl_GlFunctions::glDrawElements; public: //! @name Raster functions - inline void glPixelStorei (GLenum theParamName, GLint theParam) - { - ::glPixelStorei (theParamName, theParam); - OpenGl_TRACE(glPixelStorei) - } - - inline void glReadPixels (GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLvoid* pixels) - { - ::glReadPixels (x, y, width, height, format, type, pixels); - OpenGl_TRACE(glReadPixels) - } + using OpenGl_GlFunctions::glPixelStorei; + using OpenGl_GlFunctions::glReadPixels; public: //! @name Stenciling - inline void glStencilFunc (GLenum func, GLint ref, GLuint mask) - { - ::glStencilFunc (func, ref, mask); - OpenGl_TRACE(glStencilFunc) - } - - inline void glStencilMask (GLuint mask) - { - ::glStencilMask (mask); - OpenGl_TRACE(glStencilMask) - } - - inline void glStencilOp (GLenum fail, GLenum zfail, GLenum zpass) - { - ::glStencilOp (fail, zfail, zpass); - OpenGl_TRACE(glStencilOp) - } - - inline void glClearStencil (GLint s) - { - ::glClearStencil (s); - OpenGl_TRACE(glClearStencil) - } + using OpenGl_GlFunctions::glStencilFunc; + using OpenGl_GlFunctions::glStencilMask; + using OpenGl_GlFunctions::glStencilOp; + using OpenGl_GlFunctions::glClearStencil; public: //! @name Texture mapping - inline void glTexParameterf (GLenum target, GLenum pname, GLfloat param) - { - ::glTexParameterf (target, pname, param); - OpenGl_TRACE(glTexParameterf) - } + using OpenGl_GlFunctions::glTexParameterf; + using OpenGl_GlFunctions::glTexParameteri; + using OpenGl_GlFunctions::glTexParameterfv; + using OpenGl_GlFunctions::glTexParameteriv; + using OpenGl_GlFunctions::glGetTexParameterfv; + using OpenGl_GlFunctions::glGetTexParameteriv; + using OpenGl_GlFunctions::glTexImage2D; + using OpenGl_GlFunctions::glGenTextures; + using OpenGl_GlFunctions::glDeleteTextures; + using OpenGl_GlFunctions::glBindTexture; + using OpenGl_GlFunctions::glIsTexture; + using OpenGl_GlFunctions::glTexSubImage2D; + using OpenGl_GlFunctions::glCopyTexImage2D; + using OpenGl_GlFunctions::glCopyTexSubImage2D; - inline void glTexParameteri (GLenum target, GLenum pname, GLint param) - { - ::glTexParameteri (target, pname, param); - OpenGl_TRACE(glTexParameteri) - } +public: //! @name desktop extensions - not supported in OpenGL ES 2..0 - inline void glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params) - { - ::glTexParameterfv (target, pname, params); - OpenGl_TRACE(glTexParameterfv) - } + using OpenGl_GlFunctions::glTexImage1D; + using OpenGl_GlFunctions::glTexSubImage1D; + using OpenGl_GlFunctions::glCopyTexImage1D; + using OpenGl_GlFunctions::glCopyTexSubImage1D; + using OpenGl_GlFunctions::glGetTexImage; + using OpenGl_GlFunctions::glAlphaFunc; + using OpenGl_GlFunctions::glPointSize; - inline void glTexParameteriv (GLenum target, GLenum pname, const GLint* params) - { - ::glTexParameteriv (target, pname, params); - OpenGl_TRACE(glTexParameteriv) - } + // added to OpenGL ES 3.0 + using OpenGl_GlFunctions::glReadBuffer; + using OpenGl_GlFunctions::glDrawBuffer; - inline void glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params) - { - ::glGetTexParameterfv (target, pname, params); - OpenGl_TRACE(glGetTexParameterfv) - } + // added to OpenGL ES 3.1 + using OpenGl_GlFunctions::glGetTexLevelParameteriv; - inline void glGetTexParameteriv (GLenum target, GLenum pname, GLint* params) - { - ::glGetTexParameteriv (target, pname, params); - OpenGl_TRACE(glGetTexParameteriv) - } + // added to OpenGL ES 3.2 + using OpenGl_GlFunctions::glGetPointerv; - inline void glTexImage2D (GLenum target, GLint level, - GLint internalFormat, - GLsizei width, GLsizei height, - GLint border, GLenum format, GLenum type, - const GLvoid* pixels) - { - ::glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels); - OpenGl_TRACE(glTexImage2D) - } - - inline void glGenTextures (GLsizei n, GLuint* textures) - { - ::glGenTextures(n, textures); - OpenGl_TRACE(glGenTextures) - } - - inline void glDeleteTextures (GLsizei n, const GLuint* textures) - { - ::glDeleteTextures(n, textures); - OpenGl_TRACE(glDeleteTextures) - } - - inline void glBindTexture (GLenum target, GLuint texture) - { - ::glBindTexture(target, texture); - OpenGl_TRACE(glBindTexture) - } - - inline GLboolean glIsTexture (GLuint texture) - { - const GLboolean aRes = ::glIsTexture (texture); - OpenGl_TRACE(glIsTexture) - return aRes; - } - - inline void glTexSubImage2D (GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid* pixels) - { - ::glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); - OpenGl_TRACE(glTexSubImage2D) - } - - inline void glCopyTexImage2D (GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLint border) - { - ::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); - OpenGl_TRACE(glCopyTexImage2D) - } - - inline void glCopyTexSubImage2D (GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, GLsizei height) - { - ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); - OpenGl_TRACE(glCopyTexSubImage2D) - } - -#if !defined(GL_ES_VERSION_2_0) - inline void glTexImage1D (GLenum target, GLint level, - GLint internalFormat, - GLsizei width, GLint border, - GLenum format, GLenum type, - const GLvoid* pixels) - { - ::glTexImage1D(target, level, internalFormat, width, border, format, type, pixels); - OpenGl_TRACE(glTexImage1D) - } - - inline void glTexSubImage1D (GLenum target, GLint level, - GLint xoffset, - GLsizei width, GLenum format, - GLenum type, const GLvoid* pixels) - { - ::glTexSubImage1D(target, level, xoffset, width, format, type, pixels); - OpenGl_TRACE(glTexSubImage1D) - } - - inline void glCopyTexImage1D (GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, - GLsizei width, GLint border) - { - ::glCopyTexImage1D(target, level, internalformat, x, y, width, border); - OpenGl_TRACE(glCopyTexImage1D) - } - - inline void glCopyTexSubImage1D (GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, - GLsizei width) - { - ::glCopyTexSubImage1D(target, level, xoffset, x, y, width); - OpenGl_TRACE(glCopyTexSubImage1D) - } - - inline void glGetTexImage (GLenum target, GLint level, - GLenum format, GLenum type, - GLvoid* pixels) - { - ::glGetTexImage (target, level, format, type, pixels); - OpenGl_TRACE(glGetTexImage) - } -#endif - -#if !defined(GL_ES_VERSION_2_0) - - inline void glAlphaFunc (GLenum theFunc, GLclampf theRef) - { - ::glAlphaFunc (theFunc, theRef); - OpenGl_TRACE(glAlphaFunc) - } - - inline void glPointSize (GLfloat theSize) - { - ::glPointSize (theSize); - OpenGl_TRACE(glPointSize) - } - -#endif - -/*#if !defined(GL_ES_VERSION_2_0) - - inline void glTexEnvf (GLenum target, GLenum pname, GLfloat param) - { - ::glTexEnvf (target, pname, param); - } - - inline void glTexEnvi (GLenum target, GLenum pname, GLint param) - { - ::glTexEnvi (target, pname, param); - } - - inline void glTexEnvfv (GLenum target, GLenum pname, const GLfloat* params) - { - ::glTexEnvfv (target, pname, params); - } - - inline void glTexEnviv (GLenum target, GLenum pname, const GLint* params) - { - ::glTexEnviv (target, pname, params); - } - - inline void glGetTexEnvfv (GLenum target, GLenum pname, GLfloat* params) - { - ::glGetTexEnvfv (target, pname, params); - } - - inline void glGetTexEnviv (GLenum target, GLenum pname, GLint* params) - { - ::glGetTexEnviv (target, pname, params); - } - - inline void glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat* params) - { - ::glGetTexLevelParameterfv (target, level, pname, params); - } - - inline void glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint* params) - { - ::glGetTexLevelParameteriv (target, level, pname, params); - } - - inline void glClearIndex (GLfloat c) - { - ::glClearIndex(c); - } - - inline void glIndexMask (GLuint theMask) - { - ::glIndexMask (theMask); - } - - inline void glLogicOp (GLenum opcode) - { - ::glLogicOp(opcode); - } - - inline void glPolygonMode (GLenum theFace, GLenum theMode) - { - ::glPolygonMode (theFace, theMode); - } - - inline void glDrawBuffer (GLenum theMode) - { - ::glDrawBuffer (theMode); - } - - inline void glReadBuffer (GLenum theMode) - { - ::glReadBuffer (theMode); - } - - inline void glGetDoublev (GLenum theParamName, GLdouble* theValues) - { - ::glGetDoublev (theParamName, theValues); - } - - inline GLint glRenderMode (GLenum theMode) - { - return ::glRenderMode (theMode); - } - - inline void glArrayElement (GLint i) - { - ::glArrayElement (i); - } - - inline void glPixelStoref (GLenum theParamName, GLfloat theParam) - { - ::glPixelStoref (theParamName, theParam); - } - - inline void glPixelTransferf (GLenum theParamName, GLfloat theParam) - { - ::glPixelTransferf (theParamName, theParam); - } - - inline void glPixelTransferi (GLenum theParamName, GLint theParam) - { - ::glPixelTransferi (theParamName, theParam); - } - - inline void glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat* values) - { - ::glPixelMapfv (map, mapsize, values); - } - - inline void glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint* values) - { - ::glPixelMapuiv (map, mapsize, values); - } - - inline void glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort* values) - { - ::glPixelMapusv (map, mapsize, values); - } - - inline void glGetPixelMapfv (GLenum map, GLfloat* values) - { - ::glGetPixelMapfv (map, values); - } - - inline void glGetPixelMapuiv (GLenum map, GLuint* values) - { - ::glGetPixelMapuiv (map, values); - } - - inline void glGetPixelMapusv (GLenum map, GLushort* values) - { - ::glGetPixelMapusv (map, values); - } -#endif*/ + using OpenGl_GlFunctions::glPolygonMode; + using OpenGl_GlFunctions::glLogicOp; }; diff --git a/src/OpenGl/OpenGl_GlCore32.hxx b/src/OpenGl/OpenGl_GlCore32.hxx index 1a42ee80a0..b225fb569b 100644 --- a/src/OpenGl/OpenGl_GlCore32.hxx +++ b/src/OpenGl/OpenGl_GlCore32.hxx @@ -24,8 +24,6 @@ struct OpenGl_GlCore32 : public OpenGl_GlCore31 private: typedef OpenGl_GlCore31 theBaseClass_t; -#if !defined(GL_ES_VERSION_2_0) - public: //! @name GL_ARB_draw_elements_base_vertex (added to OpenGL 3.2 core) using theBaseClass_t::glDrawElementsBaseVertex; @@ -60,8 +58,6 @@ public: //! @name OpenGL 3.2 additives to 3.1 using theBaseClass_t::glGetBufferParameteri64v; using theBaseClass_t::glFramebufferTexture; -#endif - }; #endif // _OpenGl_GlCore32_Header diff --git a/src/OpenGl/OpenGl_GlCore33.hxx b/src/OpenGl/OpenGl_GlCore33.hxx index a2e95f4a3c..263a8c52fa 100644 --- a/src/OpenGl/OpenGl_GlCore33.hxx +++ b/src/OpenGl/OpenGl_GlCore33.hxx @@ -24,8 +24,6 @@ struct OpenGl_GlCore33 : public OpenGl_GlCore32 private: typedef OpenGl_GlCore32 theBaseClass_t; -#if !defined(GL_ES_VERSION_2_0) - public: //! @name GL_ARB_blend_func_extended (added to OpenGL 3.3 core) using theBaseClass_t::glBindFragDataLocationIndexed; @@ -69,8 +67,6 @@ public: //! @name OpenGL 3.3 additives to 3.2 using theBaseClass_t::glVertexAttribDivisor; -#endif - }; #endif // _OpenGl_GlCore33_Header diff --git a/src/OpenGl/OpenGl_GlCore40.hxx b/src/OpenGl/OpenGl_GlCore40.hxx index 1f69f80c6d..dc6b835502 100644 --- a/src/OpenGl/OpenGl_GlCore40.hxx +++ b/src/OpenGl/OpenGl_GlCore40.hxx @@ -24,8 +24,6 @@ struct OpenGl_GlCore40 : public OpenGl_GlCore33 private: typedef OpenGl_GlCore33 theBaseClass_t; -#if !defined(GL_ES_VERSION_2_0) - public: //! @name GL_ARB_draw_indirect (added to OpenGL 4.0 core) using theBaseClass_t::glDrawArraysIndirect; @@ -93,8 +91,6 @@ public: //! @name OpenGL 4.0 additives to 3.3 using theBaseClass_t::glBlendFunci; using theBaseClass_t::glBlendFuncSeparatei; -#endif - }; #endif // _OpenGl_GlCore40_Header diff --git a/src/OpenGl/OpenGl_GlCore41.hxx b/src/OpenGl/OpenGl_GlCore41.hxx index cdf82b403c..2b69a2518b 100644 --- a/src/OpenGl/OpenGl_GlCore41.hxx +++ b/src/OpenGl/OpenGl_GlCore41.hxx @@ -24,8 +24,6 @@ struct OpenGl_GlCore41 : public OpenGl_GlCore40 private: typedef OpenGl_GlCore40 theBaseClass_t; -#if !defined(GL_ES_VERSION_2_0) - public: //! @name GL_ARB_ES2_compatibility (added to OpenGL 4.1 core) using theBaseClass_t::glReleaseShaderCompiler; @@ -129,8 +127,6 @@ public: //! @name GL_ARB_viewport_array (added to OpenGL 4.1 core) using theBaseClass_t::glGetFloati_v; using theBaseClass_t::glGetDoublei_v; -#endif - }; #endif // _OpenGl_GlCore41_Header diff --git a/src/OpenGl/OpenGl_GlCore42.hxx b/src/OpenGl/OpenGl_GlCore42.hxx index 7746b2f738..20514c0f19 100644 --- a/src/OpenGl/OpenGl_GlCore42.hxx +++ b/src/OpenGl/OpenGl_GlCore42.hxx @@ -24,8 +24,6 @@ struct OpenGl_GlCore42 : public OpenGl_GlCore41 private: typedef OpenGl_GlCore41 theBaseClass_t; -#if !defined(GL_ES_VERSION_2_0) - public: //! @name GL_ARB_base_instance (added to OpenGL 4.2 core) using theBaseClass_t::glDrawArraysInstancedBaseInstance; @@ -56,8 +54,6 @@ public: //! @name GL_ARB_texture_storage (added to OpenGL 4.2 core) using theBaseClass_t::glTexStorage2D; using theBaseClass_t::glTexStorage3D; -#endif - }; #endif // _OpenGl_GlCore42_Header diff --git a/src/OpenGl/OpenGl_GlCore43.hxx b/src/OpenGl/OpenGl_GlCore43.hxx index 9971877c9f..9f95c856ba 100644 --- a/src/OpenGl/OpenGl_GlCore43.hxx +++ b/src/OpenGl/OpenGl_GlCore43.hxx @@ -26,8 +26,6 @@ private: public: //! @name OpenGL 4.3 additives to 4.2 -#if !defined(GL_ES_VERSION_2_0) - using theBaseClass_t::glClearBufferData; using theBaseClass_t::glClearBufferSubData; using theBaseClass_t::glDispatchCompute; @@ -72,8 +70,6 @@ public: //! @name OpenGL 4.3 additives to 4.2 using theBaseClass_t::glObjectPtrLabel; using theBaseClass_t::glGetObjectPtrLabel; -#endif - }; #endif // _OpenGl_GlCore43_Header diff --git a/src/OpenGl/OpenGl_GlCore44.hxx b/src/OpenGl/OpenGl_GlCore44.hxx index e8c8e5997a..5405899165 100644 --- a/src/OpenGl/OpenGl_GlCore44.hxx +++ b/src/OpenGl/OpenGl_GlCore44.hxx @@ -26,8 +26,6 @@ private: public: //! @name OpenGL 4.4 additives to 4.3 -#if !defined(GL_ES_VERSION_2_0) - using theBaseClass_t::glBufferStorage; using theBaseClass_t::glClearTexImage; using theBaseClass_t::glClearTexSubImage; @@ -38,8 +36,6 @@ public: //! @name OpenGL 4.4 additives to 4.3 using theBaseClass_t::glBindImageTextures; using theBaseClass_t::glBindVertexBuffers; -#endif - }; #endif // _OpenGl_GlCore44_Header diff --git a/src/OpenGl/OpenGl_GlCore45.hxx b/src/OpenGl/OpenGl_GlCore45.hxx index 804dde35f1..86f2aa4bf1 100644 --- a/src/OpenGl/OpenGl_GlCore45.hxx +++ b/src/OpenGl/OpenGl_GlCore45.hxx @@ -24,7 +24,6 @@ private: public: //! @name OpenGL 4.5 additives to 4.4 -#if !defined(GL_ES_VERSION_2_0) using theBaseClass_t::glClipControl; using theBaseClass_t::glCreateTransformFeedbacks; using theBaseClass_t::glTransformFeedbackBufferBase; @@ -135,7 +134,6 @@ public: //! @name OpenGL 4.5 additives to 4.4 using theBaseClass_t::glGetnUniformuiv; using theBaseClass_t::glReadnPixels; using theBaseClass_t::glTextureBarrier; -#endif }; diff --git a/src/OpenGl/OpenGl_GlCore46.hxx b/src/OpenGl/OpenGl_GlCore46.hxx index 333d1947cb..6a47a8c6fb 100644 --- a/src/OpenGl/OpenGl_GlCore46.hxx +++ b/src/OpenGl/OpenGl_GlCore46.hxx @@ -24,12 +24,10 @@ private: public: //! @name OpenGL 4.6 additives to 4.5 -#if !defined(GL_ES_VERSION_2_0) using theBaseClass_t::glSpecializeShader; using theBaseClass_t::glMultiDrawArraysIndirectCount; using theBaseClass_t::glMultiDrawElementsIndirectCount; using theBaseClass_t::glPolygonOffsetClamp; -#endif }; diff --git a/src/OpenGl/OpenGl_GlFunctions.cxx b/src/OpenGl/OpenGl_GlFunctions.cxx index 67688584bb..3eda7a2cb4 100644 --- a/src/OpenGl/OpenGl_GlFunctions.cxx +++ b/src/OpenGl/OpenGl_GlFunctions.cxx @@ -11,9 +11,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#if defined(_WIN32) - #include -#endif +#include #include @@ -26,22 +24,1658 @@ #include #include +#include + #if !defined(HAVE_EGL) && defined(HAVE_XLIB) #include #endif +#ifdef __EMSCRIPTEN__ + #include + #include +#endif + +// This debug macros can be enabled to help debugging OpenGL implementations +// without solid / working debugging capabilities. +//#define TO_TRACE + +#define WrapProxyProc(theFunc) this->theFunc=opencascade::theFunc +#define WrapProxyProc5(theFunc1,theFunc2,theFunc3,theFunc4,theFunc5) \ + WrapProxyProc(theFunc1);WrapProxyProc(theFunc2);WrapProxyProc(theFunc3);WrapProxyProc(theFunc4);WrapProxyProc(theFunc5) + +#ifdef TO_TRACE + #define OpenGl_TRACE(theName) {OpenGl_GlFunctions::debugPrintError(#theName);} + #define WrapProxyDef(theFunc) this->theFunc=opencascade::theFunc +#else + #define OpenGl_TRACE(theName) + // skip wrapper and set pointer to global function + #define WrapProxyDef(theFunc) this->theFunc=opencascade::theFunc;this->theFunc=::theFunc; +#endif + +#define WrapProxyDef5(theFunc1,theFunc2,theFunc3,theFunc4,theFunc5) \ + WrapProxyDef(theFunc1);WrapProxyDef(theFunc2);WrapProxyDef(theFunc3);WrapProxyDef(theFunc4);WrapProxyDef(theFunc5) + +namespace opencascade +{ + static void APIENTRY glReadBuffer (GLenum mode) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); // added to OpenGL ES 3.0 + (void )mode; + #else + ::glReadBuffer (mode); + #endif + OpenGl_TRACE(glReadBuffer) + } + + static void APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); // added to OpenGL ES 3.1 + (void )target; (void )level; (void )pname; (void )params; + #else + ::glGetTexLevelParameteriv (target, level, pname, params); + #endif + OpenGl_TRACE(glGetTexLevelParameteriv) + } + + static void APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); // added to OpenGL ES 3.1 + (void )target; (void )level; (void )pname; (void )params; + #else + ::glGetTexLevelParameterfv (target, level, pname, params); + #endif + OpenGl_TRACE(glGetTexLevelParameterfv) + } + + static void APIENTRY glGetPointerv (GLenum name, GLvoid* *params) + { + #if defined(GL_ES_VERSION_2_0) + *params = NULL; + ::glEnable (0xFFFF); // added to OpenGL ES 3.2 + (void )name; + #else + ::glGetPointerv (name, params); + #endif + OpenGl_TRACE(glGetPointerv) + } + + static void APIENTRY glDrawBuffer (GLenum mode) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); + (void )mode; + #else + ::glDrawBuffer (mode); + #endif + OpenGl_TRACE(glDrawBuffer) + } + + // Miscellaneous + + static void APIENTRY glClearColor (GLclampf theRed, GLclampf theGreen, GLclampf theBlue, GLclampf theAlpha) + { + ::glClearColor (theRed, theGreen, theBlue, theAlpha); + OpenGl_TRACE(glClearColor) + } + + static void APIENTRY glClear (GLbitfield theMask) + { + ::glClear (theMask); + OpenGl_TRACE(glClear) + } + + static void APIENTRY glColorMask (GLboolean theRed, GLboolean theGreen, GLboolean theBlue, GLboolean theAlpha) + { + ::glColorMask (theRed, theGreen, theBlue, theAlpha); + OpenGl_TRACE(glColorMask) + } + + static void APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor) + { + ::glBlendFunc(sfactor, dfactor); + OpenGl_TRACE(glBlendFunc) + } + + static void APIENTRY glCullFace (GLenum theMode) + { + ::glCullFace (theMode); + OpenGl_TRACE(glCullFace) + } + + static void APIENTRY glFrontFace (GLenum theMode) + { + ::glFrontFace (theMode); + OpenGl_TRACE(glFrontFace) + } + + static void APIENTRY glLineWidth (GLfloat theWidth) + { + ::glLineWidth (theWidth); + OpenGl_TRACE(glLineWidth) + } + + static void APIENTRY glPolygonOffset (GLfloat theFactor, GLfloat theUnits) + { + ::glPolygonOffset (theFactor, theUnits); + OpenGl_TRACE(glPolygonOffset) + } + + static void APIENTRY glScissor (GLint theX, GLint theY, GLsizei theWidth, GLsizei theHeight) + { + ::glScissor (theX, theY, theWidth, theHeight); + OpenGl_TRACE(glScissor) + } + + static void APIENTRY glEnable (GLenum theCap) + { + ::glEnable (theCap); + OpenGl_TRACE(glEnable) + } + + static void APIENTRY glDisable (GLenum theCap) + { + ::glDisable (theCap); + OpenGl_TRACE(glDisable) + } + + static GLboolean APIENTRY glIsEnabled (GLenum theCap) + { + return ::glIsEnabled (theCap); + } + + static void APIENTRY glGetBooleanv (GLenum theParamName, GLboolean* theValues) + { + ::glGetBooleanv (theParamName, theValues); + OpenGl_TRACE(glGetBooleanv) + } + + static void APIENTRY glGetFloatv (GLenum theParamName, GLfloat* theValues) + { + ::glGetFloatv (theParamName, theValues); + OpenGl_TRACE(glGetFloatv) + } + + static void APIENTRY glGetIntegerv (GLenum theParamName, GLint* theValues) + { + ::glGetIntegerv (theParamName, theValues); + OpenGl_TRACE(glGetIntegerv) + } + + static GLenum APIENTRY glGetError() + { + return ::glGetError(); + } + + static const GLubyte* APIENTRY glGetString (GLenum theName) + { + const GLubyte* aRes = ::glGetString (theName); + OpenGl_TRACE(glGetString) + return aRes; + } + + static void APIENTRY glFinish() + { + ::glFinish(); + OpenGl_TRACE(glFinish) + } + + static void APIENTRY glFlush() + { + ::glFlush(); + OpenGl_TRACE(glFlush) + } + + static void APIENTRY glHint (GLenum theTarget, GLenum theMode) + { + ::glHint (theTarget, theMode); + OpenGl_TRACE(glHint) + } + + // Depth Buffer + + static void APIENTRY glClearDepth (GLclampd theDepth) + { + #if defined(GL_ES_VERSION_2_0) + ::glClearDepthf ((GLfloat )theDepth); + #else + ::glClearDepth (theDepth); + #endif + OpenGl_TRACE(glClearDepth) + } + + static void APIENTRY glClearDepthf (GLfloat theDepth) + { + #if defined(GL_ES_VERSION_2_0) + ::glClearDepthf (theDepth); + #else + ::glClearDepth (theDepth); + #endif + OpenGl_TRACE(glClearDepthf) + } + + static void APIENTRY glDepthFunc (GLenum theFunc) + { + ::glDepthFunc (theFunc); + OpenGl_TRACE(glDepthFunc) + } + + static void APIENTRY glDepthMask (GLboolean theFlag) + { + ::glDepthMask (theFlag); + OpenGl_TRACE(glDepthMask) + } + + static void APIENTRY glDepthRange (GLclampd theNearValue, + GLclampd theFarValue) + { + #if defined(GL_ES_VERSION_2_0) + ::glDepthRangef ((GLfloat )theNearValue, (GLfloat )theFarValue); + #else + ::glDepthRange (theNearValue, theFarValue); + #endif + OpenGl_TRACE(glDepthRange) + } + + static void APIENTRY glDepthRangef (GLfloat theNearValue, + GLfloat theFarValue) + { + #if defined(GL_ES_VERSION_2_0) + ::glDepthRangef (theNearValue, theFarValue); + #else + ::glDepthRange (theNearValue, theFarValue); + #endif + OpenGl_TRACE(glDepthRangef) + } + + // Transformation + + static void APIENTRY glViewport (GLint theX, GLint theY, GLsizei theWidth, GLsizei theHeight) + { + ::glViewport (theX, theY, theWidth, theHeight); + OpenGl_TRACE(glViewport) + } + + // Vertex Arrays + + static void APIENTRY glDrawArrays (GLenum theMode, GLint theFirst, GLsizei theCount) + { + ::glDrawArrays (theMode, theFirst, theCount); + OpenGl_TRACE(glDrawArrays) + } + + static void APIENTRY glDrawElements (GLenum theMode, GLsizei theCount, GLenum theType, const GLvoid* theIndices) + { + ::glDrawElements (theMode, theCount, theType, theIndices); + OpenGl_TRACE(glDrawElements) + } + + // Raster functions + + static void APIENTRY glPixelStorei (GLenum theParamName, GLint theParam) + { + ::glPixelStorei (theParamName, theParam); + OpenGl_TRACE(glPixelStorei) + } + + static void APIENTRY glReadPixels (GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLvoid* pixels) + { + ::glReadPixels (x, y, width, height, format, type, pixels); + OpenGl_TRACE(glReadPixels) + } + + // Stenciling + + static void APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask) + { + ::glStencilFunc (func, ref, mask); + OpenGl_TRACE(glStencilFunc) + } + + static void APIENTRY glStencilMask (GLuint mask) + { + ::glStencilMask (mask); + OpenGl_TRACE(glStencilMask) + } + + static void APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass) + { + ::glStencilOp (fail, zfail, zpass); + OpenGl_TRACE(glStencilOp) + } + + static void APIENTRY glClearStencil (GLint s) + { + ::glClearStencil (s); + OpenGl_TRACE(glClearStencil) + } + + // Texture mapping + + static void APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param) + { + ::glTexParameterf (target, pname, param); + OpenGl_TRACE(glTexParameterf) + } + + static void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param) + { + ::glTexParameteri (target, pname, param); + OpenGl_TRACE(glTexParameteri) + } + + static void APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params) + { + ::glTexParameterfv (target, pname, params); + OpenGl_TRACE(glTexParameterfv) + } + + static void APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params) + { + ::glTexParameteriv (target, pname, params); + OpenGl_TRACE(glTexParameteriv) + } + + static void APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params) + { + ::glGetTexParameterfv (target, pname, params); + OpenGl_TRACE(glGetTexParameterfv) + } + + static void APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params) + { + ::glGetTexParameteriv (target, pname, params); + OpenGl_TRACE(glGetTexParameteriv) + } + + static void APIENTRY glTexImage2D (GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid* pixels) + { + ::glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels); + OpenGl_TRACE(glTexImage2D) + } + + static void APIENTRY glGenTextures (GLsizei n, GLuint* textures) + { + ::glGenTextures(n, textures); + OpenGl_TRACE(glGenTextures) + } + + static void APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures) + { + ::glDeleteTextures(n, textures); + OpenGl_TRACE(glDeleteTextures) + } + + static void APIENTRY glBindTexture (GLenum target, GLuint texture) + { + ::glBindTexture(target, texture); + OpenGl_TRACE(glBindTexture) + } + + static GLboolean APIENTRY glIsTexture (GLuint texture) + { + const GLboolean aRes = ::glIsTexture (texture); + OpenGl_TRACE(glIsTexture) + return aRes; + } + + static void APIENTRY glTexSubImage2D (GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid* pixels) + { + ::glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + OpenGl_TRACE(glTexSubImage2D) + } + + static void APIENTRY glCopyTexImage2D (GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLint border) + { + ::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); + OpenGl_TRACE(glCopyTexImage2D) + } + + static void APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height) + { + ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); + OpenGl_TRACE(glCopyTexSubImage2D) + } + + // desktop extensions - not supported in OpenGL ES 2.0 + + static void APIENTRY glTexImage1D (GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLint border, + GLenum format, GLenum type, + const GLvoid* pixels) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); + (void )target; (void )level; (void )internalFormat; (void )width; (void )border; (void )format; (void )type; (void )pixels; + #else + ::glTexImage1D(target, level, internalFormat, width, border, format, type, pixels); + #endif + OpenGl_TRACE(glTexImage1D) + } + + static void APIENTRY glTexSubImage1D (GLenum target, GLint level, + GLint xoffset, + GLsizei width, GLenum format, + GLenum type, const GLvoid* pixels) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); + (void )target; (void )level; (void )xoffset; (void )width; (void )format; (void )type; (void )pixels; + #else + ::glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + #endif + OpenGl_TRACE(glTexSubImage1D) + } + + static void APIENTRY glCopyTexImage1D (GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); + (void )target; (void )level; (void )internalformat; (void )x; (void )y; (void )width; (void )border; + #else + ::glCopyTexImage1D(target, level, internalformat, x, y, width, border); + #endif + OpenGl_TRACE(glCopyTexImage1D) + } + + static void APIENTRY glCopyTexSubImage1D (GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); + (void )target; (void )level; (void )xoffset; (void )x; (void )y; (void )width; + #else + ::glCopyTexSubImage1D(target, level, xoffset, x, y, width); + #endif + OpenGl_TRACE(glCopyTexSubImage1D) + } + + static void APIENTRY glGetTexImage (GLenum target, GLint level, + GLenum format, GLenum type, + GLvoid* pixels) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); + (void )target; (void )level; (void )format; (void )type; (void )pixels; + #else + ::glGetTexImage (target, level, format, type, pixels); + #endif + OpenGl_TRACE(glGetTexImage) + } + + static void APIENTRY glAlphaFunc (GLenum theFunc, GLclampf theRef) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); + (void )theFunc; (void )theRef; + #else + ::glAlphaFunc (theFunc, theRef); + #endif + OpenGl_TRACE(glAlphaFunc) + } + + static void APIENTRY glPointSize (GLfloat theSize) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); + (void )theSize; + #else + ::glPointSize (theSize); + #endif + OpenGl_TRACE(glPointSize) + } + + static void APIENTRY glPolygonMode (GLenum face, GLenum mode) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); + (void )face; (void )mode; + #else + ::glPolygonMode (face, mode); + #endif + OpenGl_TRACE(glPolygonMode); + } + + static void APIENTRY glLogicOp (GLenum opcode) + { + #if defined(GL_ES_VERSION_2_0) + ::glEnable (0xFFFF); + (void )opcode; + #else + ::glLogicOp (opcode); + #endif + OpenGl_TRACE(glLogicOp) + } + + static void APIENTRY glMultiDrawElements (GLenum theMode, const GLsizei* theCount, GLenum theType, const void* const* theIndices, GLsizei theDrawCount) + { + if (theCount == NULL + || theIndices == NULL) + { + return; + } + + for (GLsizei aBatchIter = 0; aBatchIter < theDrawCount; ++aBatchIter) + { + ::glDrawElements (theMode, theCount[aBatchIter], theType, theIndices[aBatchIter]); + } + OpenGl_TRACE(glMultiDrawElements) + } + +#if defined(GL_ES_VERSION_2_0) + +// OpenGL ES 1.1 + + static void APIENTRY glActiveTexture (GLenum texture) + { + ::glActiveTexture (texture); + OpenGl_TRACE(glActiveTexture) + } + + static void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) + { + ::glCompressedTexImage2D (target, level, internalformat, width, height, border, imageSize, data); + OpenGl_TRACE(glCompressedTexImage2D) + } + + static void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) + { + ::glCompressedTexSubImage2D (target, level, xoffset, yoffset, width, height, format, imageSize, data); + OpenGl_TRACE(glCompressedTexSubImage2D) + } + + static void APIENTRY glBindBuffer (GLenum target, GLuint buffer) + { + ::glBindBuffer (target, buffer); + OpenGl_TRACE(glBindBuffer) + } + + static void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void* data, GLenum usage) + { + ::glBufferData (target, size, data, usage); + OpenGl_TRACE(glBufferData) + } + + static void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void* data) + { + ::glBufferSubData (target, offset, size, data); + OpenGl_TRACE(glBufferSubData) + } + + static void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers) + { + ::glDeleteBuffers (n, buffers); + OpenGl_TRACE(glDeleteBuffers) + } + + static void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers) + { + ::glGenBuffers (n, buffers); + OpenGl_TRACE(glGenBuffers) + } + + static void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params) + { + ::glGetBufferParameteriv (target, pname, params); + OpenGl_TRACE(glGetBufferParameteriv) + } + + static GLboolean APIENTRY glIsBuffer (GLuint buffer) + { + return ::glIsBuffer (buffer); + } + + static void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert) + { + ::glSampleCoverage (value, invert); + OpenGl_TRACE(glSampleCoverage) + } + + // OpenGL ES 2.0 + + static void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) + { + ::glBlendColor (red, green, blue, alpha); + OpenGl_TRACE(glBlendColor) + } + + static void APIENTRY glBlendEquation (GLenum mode) + { + ::glBlendEquation (mode); + OpenGl_TRACE(glBlendEquation) + } + + static void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) + { + ::glBlendFuncSeparate (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); + OpenGl_TRACE(glBlendFuncSeparate) + } + + static void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha) + { + ::glBlendEquationSeparate (modeRGB, modeAlpha); + OpenGl_TRACE(glBlendEquationSeparate) + } + + static void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) + { + ::glStencilOpSeparate (face, sfail, dpfail, dppass); + OpenGl_TRACE(glStencilOpSeparate) + } + + static void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask) + { + ::glStencilFuncSeparate (face, func, ref, mask); + OpenGl_TRACE(glStencilFuncSeparate) + } + + static void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask) + { + ::glStencilMaskSeparate (face, mask); + OpenGl_TRACE(glStencilMaskSeparate) + } + + static void APIENTRY glAttachShader (GLuint program, GLuint shader) + { + ::glAttachShader (program, shader); + OpenGl_TRACE(glAttachShader) + } + + static void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name) + { + ::glBindAttribLocation (program, index, name); + OpenGl_TRACE(glBindAttribLocation) + } + + static void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer) + { + ::glBindFramebuffer (target, framebuffer); + OpenGl_TRACE(glBindFramebuffer) + } + + static void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer) + { + ::glBindRenderbuffer (target, renderbuffer); + OpenGl_TRACE(glBindRenderbuffer) + } + + static GLenum APIENTRY glCheckFramebufferStatus (GLenum target) + { + return ::glCheckFramebufferStatus (target); + } + + static void APIENTRY glCompileShader (GLuint shader) + { + ::glCompileShader (shader); + OpenGl_TRACE(glCompileShader) + } + + static GLuint APIENTRY glCreateProgram() + { + return ::glCreateProgram(); + } + + static GLuint APIENTRY glCreateShader (GLenum type) + { + return ::glCreateShader (type); + } + + static void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers) + { + ::glDeleteFramebuffers (n, framebuffers); + OpenGl_TRACE(glDeleteFramebuffers) + } + + static void APIENTRY glDeleteProgram (GLuint program) + { + ::glDeleteProgram (program); + OpenGl_TRACE(glDeleteProgram) + } + + static void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers) + { + ::glDeleteRenderbuffers (n, renderbuffers); + OpenGl_TRACE(glDeleteRenderbuffers) + } + + static void APIENTRY glDeleteShader (GLuint shader) + { + ::glDeleteShader (shader); + OpenGl_TRACE(glDeleteShader) + } + + static void APIENTRY glDetachShader (GLuint program, GLuint shader) + { + ::glDetachShader (program, shader); + OpenGl_TRACE(glDetachShader) + } + + static void APIENTRY glDisableVertexAttribArray (GLuint index) + { + ::glDisableVertexAttribArray (index); + OpenGl_TRACE(glDisableVertexAttribArray) + } + + static void APIENTRY glEnableVertexAttribArray (GLuint index) + { + ::glEnableVertexAttribArray (index); + OpenGl_TRACE(glEnableVertexAttribArray) + } + + static void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) + { + ::glFramebufferRenderbuffer (target, attachment, renderbuffertarget, renderbuffer); + OpenGl_TRACE(glFramebufferRenderbuffer) + } + + static void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) + { + ::glFramebufferTexture2D (target, attachment, textarget, texture, level); + OpenGl_TRACE(glFramebufferTexture2D) + } + + static void APIENTRY glGenerateMipmap (GLenum target) + { + ::glGenerateMipmap (target); + OpenGl_TRACE(glGenerateMipmap) + } + + static void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers) + { + ::glGenFramebuffers (n, framebuffers); + OpenGl_TRACE(glGenFramebuffers) + } + + static void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers) + { + ::glGenRenderbuffers (n, renderbuffers); + OpenGl_TRACE(glGenRenderbuffers) + } + + static void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint* size, GLenum *type, GLchar *name) + { + ::glGetActiveAttrib (program, index, bufSize, length, size, type, name); + OpenGl_TRACE(glGetActiveAttrib) + } + + static void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint* size, GLenum *type, GLchar *name) + { + ::glGetActiveUniform (program, index, bufSize, length, size, type, name); + OpenGl_TRACE(glGetActiveUniform) + } + + static void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders) + { + ::glGetAttachedShaders (program, maxCount, count, shaders); + OpenGl_TRACE(glGetAttachedShaders) + } + + static GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name) + { + const GLint aRes = ::glGetAttribLocation (program, name); + OpenGl_TRACE(glGetAttribLocation) + return aRes; + } + + static void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params) + { + ::glGetFramebufferAttachmentParameteriv (target, attachment, pname, params); + OpenGl_TRACE(glGetFramebufferAttachmentParameteriv) + } + + static void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params) + { + ::glGetProgramiv (program, pname, params); + OpenGl_TRACE(glGetProgramiv) + } + + static void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) + { + ::glGetProgramInfoLog (program, bufSize, length, infoLog); + OpenGl_TRACE(glGetProgramInfoLog) + } + + static void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params) + { + ::glGetRenderbufferParameteriv (target, pname, params); + OpenGl_TRACE(glGetRenderbufferParameteriv) + } + + static void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params) + { + ::glGetShaderiv (shader, pname, params); + OpenGl_TRACE(glGetShaderiv) + } + + static void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) + { + ::glGetShaderInfoLog (shader, bufSize, length, infoLog); + OpenGl_TRACE(glGetShaderInfoLog) + } + + static void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) + { + ::glGetShaderPrecisionFormat (shadertype, precisiontype, range, precision); + OpenGl_TRACE(glGetShaderPrecisionFormat) + } + + static void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) + { + ::glGetShaderSource (shader, bufSize, length, source); + OpenGl_TRACE(glGetShaderSource) + } + + static void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params) + { + ::glGetUniformfv (program, location, params); + OpenGl_TRACE(glGetUniformfv) + } + + static void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params) + { + ::glGetUniformiv (program, location, params); + OpenGl_TRACE(glGetUniformiv) + } + + static GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name) + { + const GLint aRes = ::glGetUniformLocation (program, name); + OpenGl_TRACE(glGetUniformLocation) + return aRes; + } + + static void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params) + { + ::glGetVertexAttribfv (index, pname, params); + OpenGl_TRACE(glGetVertexAttribfv) + } + + static void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params) + { + ::glGetVertexAttribiv (index, pname, params); + OpenGl_TRACE(glGetVertexAttribiv) + } + + static void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void* *pointer) + { + ::glGetVertexAttribPointerv (index, pname, pointer); + OpenGl_TRACE(glGetVertexAttribPointerv) + } + + static GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer) + { + return ::glIsFramebuffer (framebuffer); + } + + static GLboolean APIENTRY glIsProgram (GLuint program) + { + return ::glIsProgram (program); + } + + static GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer) + { + return ::glIsRenderbuffer (renderbuffer); + } + + static GLboolean APIENTRY glIsShader (GLuint shader) + { + return ::glIsShader (shader); + } + + static void APIENTRY glLinkProgram (GLuint program) + { + ::glLinkProgram (program); + OpenGl_TRACE(glLinkProgram) + } + + static void APIENTRY glReleaseShaderCompiler() + { + ::glReleaseShaderCompiler(); + OpenGl_TRACE(glReleaseShaderCompiler) + } + + static void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) + { + ::glRenderbufferStorage (target, internalformat, width, height); + OpenGl_TRACE(glRenderbufferStorage) + } + + static void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void* binary, GLsizei length) + { + ::glShaderBinary (count, shaders, binaryformat, binary, length); + OpenGl_TRACE(glShaderBinary) + } + + static void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint* length) + { + ::glShaderSource (shader, count, string, length); + OpenGl_TRACE(glShaderSource) + } + + static void APIENTRY glUniform1f (GLint location, GLfloat v0) + { + ::glUniform1f (location, v0); + OpenGl_TRACE(glUniform1f) + } + + static void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* value) + { + ::glUniform1fv (location, count, value); + OpenGl_TRACE(glUniform1fv) + } + + static void APIENTRY glUniform1i (GLint location, GLint v0) + { + ::glUniform1i (location, v0); + OpenGl_TRACE(glUniform1i) + } + + static void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* value) + { + ::glUniform1iv (location, count, value); + OpenGl_TRACE(glUniform1iv) + } + + static void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1) + { + ::glUniform2f (location, v0, v1); + OpenGl_TRACE(glUniform2f) + } + + static void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* value) + { + ::glUniform2fv (location, count, value); + OpenGl_TRACE(glUniform2fv) + } + + static void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1) + { + ::glUniform2i (location, v0, v1); + OpenGl_TRACE(glUniform2i) + } + + static void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* value) + { + ::glUniform2iv (location, count, value); + OpenGl_TRACE(glUniform2iv) + } + + static void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2) + { + ::glUniform3f (location, v0, v1, v2); + OpenGl_TRACE(glUniform3f) + } + + static void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* value) + { + ::glUniform3fv (location, count, value); + OpenGl_TRACE(glUniform3fv) + } + + static void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2) + { + ::glUniform3i (location, v0, v1, v2); + OpenGl_TRACE(glUniform3i) + } + + static void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* value) + { + ::glUniform3iv (location, count, value); + OpenGl_TRACE(glUniform3iv) + } + + static void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) + { + ::glUniform4f (location, v0, v1, v2, v3); + OpenGl_TRACE(glUniform4f) + } + + static void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* value) + { + ::glUniform4fv (location, count, value); + OpenGl_TRACE(glUniform4fv) + } + + static void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3) + { + ::glUniform4i (location, v0, v1, v2, v3); + OpenGl_TRACE(glUniform4i) + } + + static void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* value) + { + ::glUniform4iv (location, count, value); + OpenGl_TRACE(glUniform4iv) + } + + static void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + ::glUniformMatrix2fv (location, count, transpose, value); + OpenGl_TRACE(glUniformMatrix2fv) + } + + static void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + ::glUniformMatrix3fv (location, count, transpose, value); + OpenGl_TRACE(glUniformMatrix3fv) + } + + static void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + ::glUniformMatrix4fv (location, count, transpose, value); + OpenGl_TRACE(glUniformMatrix4fv) + } + + static void APIENTRY glUseProgram (GLuint program) + { + ::glUseProgram (program); + OpenGl_TRACE(glUseProgram) + } + + static void APIENTRY glValidateProgram (GLuint program) + { + ::glValidateProgram (program); + OpenGl_TRACE(glValidateProgram) + } + + static void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x) + { + ::glVertexAttrib1f (index, x); + OpenGl_TRACE(glVertexAttrib1f) + } + + static void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat* v) + { + ::glVertexAttrib1fv (index, v); + OpenGl_TRACE(glVertexAttrib1fv) + } + + static void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y) + { + ::glVertexAttrib2f (index, x, y); + OpenGl_TRACE(glVertexAttrib2f) + } + + static void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat* v) + { + ::glVertexAttrib2fv (index, v); + OpenGl_TRACE(glVertexAttrib2fv) + } + + static void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z) + { + ::glVertexAttrib3f (index, x, y, z); + OpenGl_TRACE(glVertexAttrib3f) + } + + static void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat* v) + { + ::glVertexAttrib3fv (index, v); + OpenGl_TRACE(glVertexAttrib3fv) + } + + static void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) + { + ::glVertexAttrib4f (index, x, y, z, w); + OpenGl_TRACE(glVertexAttrib4f) + } + + static void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat* v) + { + ::glVertexAttrib4fv (index, v); + OpenGl_TRACE(glVertexAttrib4fv) + } + + static void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer) + { + ::glVertexAttribPointer (index, size, type, normalized, stride, pointer); + OpenGl_TRACE(glVertexAttribPointer) + } + +#else + // legacy OpenGL 1.1 FFP + + static void APIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param) + { + ::glTexEnvi (target, pname, param); + OpenGl_TRACE(glTexEnvi) + } + + static void APIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params) + { + ::glGetTexEnviv (target, pname, params); + OpenGl_TRACE(glGetTexEnviv) + } + + // Begin/End primitive specification (removed since 3.1) + + static void APIENTRY glColor4fv (const GLfloat* theVec) + { + ::glColor4fv (theVec); + OpenGl_TRACE(glColor4fv) + } + + // Matrix operations (removed since 3.1) + + static void APIENTRY glMatrixMode (GLenum theMode) + { + ::glMatrixMode (theMode); + OpenGl_TRACE(glMatrixMode) + } + + static void APIENTRY glLoadIdentity() + { + ::glLoadIdentity(); + OpenGl_TRACE(glLoadIdentity) + } + + static void APIENTRY glLoadMatrixf (const GLfloat* theMatrix) + { + ::glLoadMatrixf (theMatrix); + OpenGl_TRACE(glLoadMatrixf) + } + + // Line and Polygon stipple (removed since 3.1) + + static void APIENTRY glLineStipple (GLint theFactor, GLushort thePattern) + { + ::glLineStipple (theFactor, thePattern); + OpenGl_TRACE(glLineStipple) + } + + static void APIENTRY glPolygonStipple (const GLubyte* theMask) + { + ::glPolygonStipple (theMask); + OpenGl_TRACE(glPolygonStipple) + } + + // Fixed pipeline lighting (removed since 3.1) + + static void APIENTRY glShadeModel (GLenum theMode) + { + ::glShadeModel (theMode); + OpenGl_TRACE(glShadeModel) + } + + static void APIENTRY glLightf (GLenum theLight, GLenum pname, GLfloat param) + { + ::glLightf (theLight, pname, param); + OpenGl_TRACE(glLightf) + } + + static void APIENTRY glLightfv (GLenum theLight, GLenum pname, const GLfloat* params) + { + ::glLightfv (theLight, pname, params); + OpenGl_TRACE(glLightfv) + } + + static void APIENTRY glLightModeli (GLenum pname, GLint param) + { + ::glLightModeli(pname, param); + OpenGl_TRACE(glLightModeli) + } + + static void APIENTRY glLightModelfv (GLenum pname, const GLfloat* params) + { + ::glLightModelfv(pname, params); + OpenGl_TRACE(glLightModelfv) + } + + static void APIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param) + { + ::glMaterialf(face, pname, param); + OpenGl_TRACE(glMaterialf) + } + + static void APIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat* params) + { + ::glMaterialfv(face, pname, params); + OpenGl_TRACE(glMaterialfv) + } + + static void APIENTRY glColorMaterial (GLenum face, GLenum mode) + { + ::glColorMaterial(face, mode); + OpenGl_TRACE(glColorMaterial) + } + + // clipping plane (removed since 3.1) + + static void APIENTRY glClipPlane (GLenum thePlane, const GLdouble* theEquation) + { + ::glClipPlane (thePlane, theEquation); + OpenGl_TRACE(glClipPlane) + } + + // Display lists (removed since 3.1) + + static void APIENTRY glDeleteLists (GLuint theList, GLsizei theRange) + { + ::glDeleteLists (theList, theRange); + OpenGl_TRACE(glDeleteLists) + } + + static GLuint APIENTRY glGenLists (GLsizei theRange) + { + const GLuint aRes = ::glGenLists (theRange); + OpenGl_TRACE(glGenLists) + return aRes; + } + + static void APIENTRY glNewList (GLuint theList, GLenum theMode) + { + ::glNewList (theList, theMode); + OpenGl_TRACE(glNewList) + } + + static void APIENTRY glEndList() + { + ::glEndList(); + OpenGl_TRACE(glEndList) + } + + static void APIENTRY glCallList (GLuint theList) + { + ::glCallList (theList); + OpenGl_TRACE(glCallList) + } + + static void APIENTRY glCallLists (GLsizei theNb, GLenum theType, const GLvoid* theLists) + { + ::glCallLists (theNb, theType, theLists); + OpenGl_TRACE(glCallLists) + } + + static void APIENTRY glListBase (GLuint theBase) + { + ::glListBase (theBase); + OpenGl_TRACE(glListBase) + } + + // Current raster position and Rectangles (removed since 3.1) + + static void APIENTRY glRasterPos2i (GLint x, GLint y) + { + ::glRasterPos2i (x, y); + OpenGl_TRACE(glRasterPos2i) + } + + static void APIENTRY glRasterPos3fv (const GLfloat* theVec) + { + ::glRasterPos3fv (theVec); + OpenGl_TRACE(glRasterPos3fv) + } + + // Texture mapping (removed since 3.1) + + static void APIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param) + { + ::glTexGeni (coord, pname, param); + OpenGl_TRACE(glTexGeni) + } + + static void APIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat* params) + { + ::glTexGenfv (coord, pname, params); + OpenGl_TRACE(glTexGenfv) + } + + // Pixel copying (removed since 3.1) + + static void APIENTRY glDrawPixels (GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid* pixels) + { + ::glDrawPixels (width, height, format, type, pixels); + OpenGl_TRACE(glDrawPixels) + } + + static void APIENTRY glCopyPixels (GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type) + { + ::glCopyPixels (x, y, width, height, type); + OpenGl_TRACE(glCopyPixels) + } + + static void APIENTRY glBitmap (GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const GLubyte* bitmap) + { + ::glBitmap (width, height, xorig, yorig, xmove, ymove, bitmap); + OpenGl_TRACE(glBitmap) + } + + // Edge flags and fixed-function vertex processing (removed since 3.1) + + static void APIENTRY glIndexPointer (GLenum theType, GLsizei theStride, const GLvoid* thePtr) + { + ::glIndexPointer (theType, theStride, thePtr); + OpenGl_TRACE(glIndexPointer) + } + + static void APIENTRY glVertexPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) + { + ::glVertexPointer (theSize, theType, theStride, thePtr); + OpenGl_TRACE(glVertexPointer) + } + + static void APIENTRY glNormalPointer (GLenum theType, GLsizei theStride, const GLvoid* thePtr) + { + ::glNormalPointer (theType, theStride, thePtr); + OpenGl_TRACE(glNormalPointer) + } + + static void APIENTRY glColorPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) + { + ::glColorPointer (theSize, theType, theStride, thePtr); + OpenGl_TRACE(glColorPointer) + } + + static void APIENTRY glTexCoordPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) + { + ::glTexCoordPointer (theSize, theType, theStride, thePtr); + OpenGl_TRACE(glTexCoordPointer) + } + + static void APIENTRY glEnableClientState (GLenum theCap) + { + ::glEnableClientState (theCap); + OpenGl_TRACE(glEnableClientState) + } + + static void APIENTRY glDisableClientState (GLenum theCap) + { + ::glDisableClientState (theCap); + OpenGl_TRACE(glDisableClientState) + } + + static void APIENTRY glPixelTransferi (GLenum pname, GLint param) + { + ::glPixelTransferi (pname, param); + OpenGl_TRACE(glPixelTransferi) + } +#endif +} + // ======================================================================= -// function : init +// function : debugPrintError +// purpose : +// ======================================================================= +bool OpenGl_GlFunctions::debugPrintError (const char* theName) +{ + const int anErr = ::glGetError(); + if (anErr != GL_NO_ERROR) + { + Message::SendFail() << theName << "(), unhandled GL error: " << OpenGl_Context::FormatGlError (anErr); + // there is no glSetError(), just emulate non-clear state + switch (anErr) + { + case GL_INVALID_VALUE: + { + ::glLineWidth(-1.0f); + ::glLineWidth( 1.0f); + break; + } + default: + case GL_INVALID_ENUM: + { + ::glEnable (0xFFFF); + break; + } + } + } + return anErr != GL_NO_ERROR; +} + +// ======================================================================= +// function : readGlVersion +// purpose : +// ======================================================================= +void OpenGl_GlFunctions::readGlVersion (Standard_Integer& theGlVerMajor, + Standard_Integer& theGlVerMinor) +{ + // reset values + theGlVerMajor = 0; + theGlVerMinor = 0; + + bool toCheckVer3 = true; +#if defined(__EMSCRIPTEN__) + // WebGL 1.0 prints annoying invalid enumeration warnings to console. + toCheckVer3 = false; + if (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE aWebGlCtx = emscripten_webgl_get_current_context()) + { + EmscriptenWebGLContextAttributes anAttribs = {}; + if (emscripten_webgl_get_context_attributes (aWebGlCtx, &anAttribs) == EMSCRIPTEN_RESULT_SUCCESS) + { + toCheckVer3 = anAttribs.majorVersion >= 2; + } + } +#endif + + // Available since OpenGL 3.0 and OpenGL ES 3.0. + if (toCheckVer3) + { + GLint aMajor = 0, aMinor = 0; + ::glGetIntegerv (GL_MAJOR_VERSION, &aMajor); + ::glGetIntegerv (GL_MINOR_VERSION, &aMinor); + // glGetError() sometimes does not report an error here even if + // GL does not know GL_MAJOR_VERSION and GL_MINOR_VERSION constants. + // This happens on some renderers like e.g. Cygwin MESA. + // Thus checking additionally if GL has put anything to + // the output variables. + if (::glGetError() == GL_NO_ERROR && aMajor != 0 && aMinor != 0) + { + theGlVerMajor = aMajor; + theGlVerMinor = aMinor; + return; + } + for (GLenum anErr = ::glGetError(), aPrevErr = GL_NO_ERROR;; aPrevErr = anErr, anErr = ::glGetError()) + { + if (anErr == GL_NO_ERROR + || anErr == aPrevErr) + { + break; + } + } + } + + // Read version string. + // Notice that only first two numbers split by point '2.1 XXXXX' are significant. + // Following trash (after space) is vendor-specific. + // New drivers also returns micro version of GL like '3.3.0' which has no meaning + // and should be considered as vendor-specific too. + const char* aVerStr = (const char* )::glGetString (GL_VERSION); + if (aVerStr == NULL || *aVerStr == '\0') + { + // invalid GL context + return; + } + +//#if defined(GL_ES_VERSION_2_0) + // skip "OpenGL ES-** " section + for (; *aVerStr != '\0'; ++aVerStr) + { + if (*aVerStr >= '0' && *aVerStr <= '9') + { + break; + } + } +//#endif + + // parse string for major number + char aMajorStr[32]; + char aMinorStr[32]; + size_t aMajIter = 0; + while (aVerStr[aMajIter] >= '0' && aVerStr[aMajIter] <= '9') + { + ++aMajIter; + } + if (aMajIter == 0 || aMajIter >= sizeof(aMajorStr)) + { + return; + } + memcpy (aMajorStr, aVerStr, aMajIter); + aMajorStr[aMajIter] = '\0'; + + // parse string for minor number + aVerStr += aMajIter + 1; + size_t aMinIter = 0; + while (aVerStr[aMinIter] >= '0' && aVerStr[aMinIter] <= '9') + { + ++aMinIter; + } + if (aMinIter == 0 || aMinIter >= sizeof(aMinorStr)) + { + return; + } + memcpy (aMinorStr, aVerStr, aMinIter); + aMinorStr[aMinIter] = '\0'; + + // read numbers + theGlVerMajor = atoi (aMajorStr); + theGlVerMinor = atoi (aMinorStr); +#if defined(__EMSCRIPTEN__) + if (theGlVerMajor >= 3) + { + if (!toCheckVer3 + || ::strstr (aVerStr, "WebGL 1.0") != NULL) + { + Message::SendWarning() << "Warning! OpenGL context reports version " << theGlVerMajor << "." << theGlVerMinor + << " but WebGL 2.0 was unavailable\n" + << "Fallback to OpenGL ES 2.0 will be used instead of reported version"; + theGlVerMajor = 2; + theGlVerMinor = 0; + } + } +#endif + + if (theGlVerMajor <= 0) + { + theGlVerMajor = 0; + theGlVerMinor = 0; + } +} + +// ======================================================================= +// function : load // purpose : // ======================================================================= void OpenGl_GlFunctions::load (OpenGl_Context& theCtx, Standard_Boolean theIsCoreProfile) { -#if defined(GL_ES_VERSION_2_0) +#if !defined(GL_ES_VERSION_2_0) + bool isCoreProfile = false; + if (theCtx.GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGL + && theCtx.IsGlGreaterEqual (3, 2)) + { + isCoreProfile = (theIsCoreProfile == true); + + // detect Core profile + if (!isCoreProfile) + { + GLint aProfile = 0; + ::glGetIntegerv (GL_CONTEXT_PROFILE_MASK, &aProfile); + isCoreProfile = (aProfile & GL_CONTEXT_CORE_PROFILE_BIT) != 0; + } + } +#else (void )theIsCoreProfile; +#endif + + // set built-in functions + WrapProxyDef5 (glGetIntegerv, glClearColor, glClear, glColorMask, glBlendFunc); + WrapProxyDef5 (glCullFace, glFrontFace, glLineWidth, glPolygonOffset, glScissor); + WrapProxyDef5 (glEnable, glDisable, glIsEnabled, glGetBooleanv, glGetFloatv); + WrapProxyDef5 (glGetIntegerv, glGetError, glGetString, glFinish, glFlush); + WrapProxyDef5 (glHint, glDepthFunc, glDepthMask, glPixelStorei, glClearStencil); + WrapProxyDef5 (glReadPixels, glStencilFunc, glStencilMask, glStencilOp, glTexParameterf); + WrapProxyDef5 (glTexParameterf, glTexParameteri, glTexParameterfv, glTexParameteriv, glGetTexParameterfv); + WrapProxyDef5 (glGetTexParameteriv, glTexImage2D, glGenTextures, glDeleteTextures, glBindTexture); + WrapProxyDef5 (glIsTexture, glTexSubImage2D, glCopyTexImage2D, glCopyTexSubImage2D, glViewport); + WrapProxyProc5 (glDrawArrays, glDrawElements, glMultiDrawElements, glClearDepth, glClearDepthf); + WrapProxyProc5 (glReadBuffer, glDrawBuffer, glGetPointerv, glDepthRange, glDepthRangef); + WrapProxyProc5 (glTexImage1D, glTexSubImage1D, glCopyTexImage1D, glCopyTexSubImage1D, glGetTexImage); + +#if defined(GL_ES_VERSION_2_0) + WrapProxyDef5 (glActiveTexture, glCompressedTexImage2D, glCompressedTexSubImage2D, glBindBuffer, glBufferData); + WrapProxyDef5 (glBufferSubData, glDeleteBuffers, glDepthRangef, glGenBuffers, glGetBufferParameteriv); + WrapProxyDef5 (glIsBuffer, glSampleCoverage, glBlendColor, glBlendEquation, glBlendFuncSeparate); + WrapProxyDef5 (glBlendEquationSeparate, glStencilOpSeparate, glStencilFuncSeparate, glStencilMaskSeparate, glAttachShader); + WrapProxyDef5 (glBindAttribLocation, glBindFramebuffer, glBindRenderbuffer, glCheckFramebufferStatus, glCompileShader); + WrapProxyDef5 (glCreateProgram, glCreateShader, glDeleteFramebuffers, glDeleteProgram, glDeleteRenderbuffers); + WrapProxyDef5 (glDeleteShader, glDetachShader, glDisableVertexAttribArray, glEnableVertexAttribArray, glFramebufferRenderbuffer); + WrapProxyDef5 (glFramebufferTexture2D, glGenerateMipmap, glGenFramebuffers, glGenRenderbuffers, glGetActiveAttrib); + WrapProxyDef5 (glGetActiveUniform, glGetAttachedShaders, glGetAttribLocation, glGetFramebufferAttachmentParameteriv, glGetProgramiv); + WrapProxyDef5 (glGetProgramInfoLog, glGetRenderbufferParameteriv, glGetShaderiv, glGetShaderInfoLog, glGetShaderPrecisionFormat); + WrapProxyDef5 (glGetShaderSource, glGetUniformfv, glGetUniformiv, glGetUniformLocation, glGetVertexAttribfv); + WrapProxyDef5 (glGetVertexAttribiv, glGetVertexAttribPointerv, glIsFramebuffer, glIsProgram, glIsRenderbuffer); + WrapProxyDef5 (glIsShader, glLinkProgram, glReleaseShaderCompiler, glRenderbufferStorage, glShaderBinary); + WrapProxyDef5 (glShaderSource, glUniform1f, glUniform1fv, glUniform1i, glUniform1iv); + WrapProxyDef5 (glUniform2f, glUniform2fv, glUniform2i, glUniform2iv, glUniform3f); + WrapProxyDef5 (glUniform3fv, glUniform3i, glUniform3iv, glUniform4f, glUniform4fv); + WrapProxyDef5 (glUniform4i, glUniform4iv, glUniformMatrix2fv, glUniformMatrix3fv, glUniformMatrix4fv); + WrapProxyDef5 (glUseProgram, glValidateProgram, glVertexAttrib1f, glVertexAttrib1fv, glVertexAttrib2f); + WrapProxyDef5 (glVertexAttrib2fv, glVertexAttrib3f, glVertexAttrib3fv, glVertexAttrib4f, glVertexAttrib4fv); + WrapProxyDef (glVertexAttribPointer); + // empty fallbacks + WrapProxyProc5 (glAlphaFunc, glPointSize, glLogicOp, glPolygonMode, glGetTexLevelParameteriv); + WrapProxyProc (glGetTexLevelParameterfv); +#else + WrapProxyDef5 (glAlphaFunc, glPointSize, glLogicOp, glPolygonMode, glGetTexLevelParameteriv); + WrapProxyDef (glGetTexLevelParameterfv); + if (!isCoreProfile) + { + WrapProxyDef5 (glTexEnvi, glGetTexEnviv, glColor4fv, glMatrixMode, glLoadIdentity); + WrapProxyDef5 (glLoadMatrixf, glLineStipple, glPolygonStipple, glShadeModel, glLightf); + WrapProxyDef5 (glLightfv, glLightModeli, glLightModelfv, glMaterialf, glMaterialfv); + WrapProxyDef5 (glColorMaterial, glClipPlane, glDeleteLists, glGenLists, glNewList); + WrapProxyDef5 (glEndList, glCallList, glCallLists, glListBase, glRasterPos2i); + WrapProxyDef5 (glRasterPos3fv, glTexGeni, glTexGenfv, glDrawPixels, glCopyPixels); + WrapProxyDef5 (glBitmap, glIndexPointer, glVertexPointer, glNormalPointer, glColorPointer); + WrapProxyDef (glTexCoordPointer); + WrapProxyDef (glEnableClientState); + WrapProxyDef (glDisableClientState); + WrapProxyDef (glPixelTransferi); + } +#endif + + if (theCtx.IsGlGreaterEqual (3, 0)) + { + // retrieve auxiliary function in advance + theCtx.FindProc ("glGetStringi", theCtx.myFuncs->glGetStringi); + } + +#if defined(GL_ES_VERSION_2_0) theCtx.core11ffp = NULL; #else - theCtx.core11ffp = !theIsCoreProfile ? (OpenGl_GlCore11* )this : NULL; + theCtx.core11ffp = !isCoreProfile ? (OpenGl_GlCore11* )this : NULL; #endif theCtx.core11fwd = (OpenGl_GlCore11Fwd* )this; theCtx.core15 = NULL; diff --git a/src/OpenGl/OpenGl_GlFunctions.hxx b/src/OpenGl/OpenGl_GlFunctions.hxx index 3e2f6b64d2..351fe717a3 100644 --- a/src/OpenGl/OpenGl_GlFunctions.hxx +++ b/src/OpenGl/OpenGl_GlFunctions.hxx @@ -16,54 +16,12 @@ #ifndef OpenGl_GlFunctions_HeaderFile #define OpenGl_GlFunctions_HeaderFile -// required for correct APIENTRY definition -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) - #define WIN32_LEAN_AND_MEAN - #include -#endif +#include #include #include -#ifndef APIENTRY - #define APIENTRY -#endif -#ifndef APIENTRYP - #define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI - #define GLAPI extern -#endif - -// exclude modern definitions and system-provided glext.h, should be defined before gl.h inclusion -#ifndef GL_GLEXT_LEGACY - #define GL_GLEXT_LEGACY -#endif -#ifndef GLX_GLXEXT_LEGACY - #define GLX_GLXEXT_LEGACY -#endif - -// include main OpenGL header provided with system -#if defined(__APPLE__) - #import - // macOS 10.4 deprecated OpenGL framework - suppress useless warnings - #define GL_SILENCE_DEPRECATION - #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE - #include - #else - #include - #endif - #define __X_GL_H // prevent chaotic gl.h inclusions to avoid compile errors -#elif defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) - #if defined(_WIN32) - // Angle OpenGL ES headers do not define function prototypes even for core functions, - // however OCCT is expected to be linked against libGLESv2 - #define GL_GLEXT_PROTOTYPES - #endif - #include -#else - #include -#endif +#include #if !defined(HAVE_EGL) #if defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(HAVE_GLES2) || defined(OCCT_UWP) @@ -74,10 +32,8 @@ #endif struct Aspect_XDisplay; -#if defined(GL_ES_VERSION_2_0) - #include -#else - // GL version can be defined by system gl.h header +// GL version can be defined by system gl.h header +#ifdef GL_VERSION_1_2 #undef GL_VERSION_1_2 #undef GL_VERSION_1_3 #undef GL_VERSION_1_4 @@ -94,10 +50,15 @@ struct Aspect_XDisplay; #undef GL_VERSION_4_3 #undef GL_VERSION_4_4 #undef GL_VERSION_4_5 - - // include glext.h provided by Khronos group - #include #endif +#ifdef GL_COPY_READ_BUFFER_BINDING + // suppress iOS SDK -Wmacro-redefined warnings + #undef GL_DRAW_FRAMEBUFFER_BINDING + #undef GL_COPY_READ_BUFFER_BINDING + #undef GL_COPY_WRITE_BUFFER_BINDING +#endif +// include glext.h provided by Khronos group +#include class OpenGl_Context; @@ -107,864 +68,398 @@ struct OpenGl_GlFunctions //! Check glGetError(); defined for debugging purposes. //! @return TRUE on error - Standard_EXPORT bool debugPrintError (const char* theName) const; + Standard_EXPORT static bool debugPrintError (const char* theName); + + //! Read OpenGL version. + Standard_EXPORT static void readGlVersion (Standard_Integer& theGlVerMajor, + Standard_Integer& theGlVerMinor); //! Load functions. Standard_EXPORT void load (OpenGl_Context& theCtx, Standard_Boolean theIsCoreProfile); - // This debug macros can be enabled to help debugging OpenGL implementations - // without solid / working debugging capabilities. - //#define OpenGl_TRACE(theName) {OpenGl_GlFunctions::debugPrintError(#theName);} - #define OpenGl_TRACE(theName) - -public: //! @name OpenGL ES 1.1 - -#if defined(GL_ES_VERSION_2_0) - - inline void glActiveTexture (GLenum texture) const - { - ::glActiveTexture (texture); - OpenGl_TRACE(glActiveTexture) - } - - inline void glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) const - { - ::glCompressedTexImage2D (target, level, internalformat, width, height, border, imageSize, data); - OpenGl_TRACE(glCompressedTexImage2D) - } - - inline void glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) const - { - ::glCompressedTexSubImage2D (target, level, xoffset, yoffset, width, height, format, imageSize, data); - OpenGl_TRACE(glCompressedTexSubImage2D) - } - - inline void glBindBuffer (GLenum target, GLuint buffer) const - { - ::glBindBuffer (target, buffer); - OpenGl_TRACE(glBindBuffer) - } - - inline void glBufferData (GLenum target, GLsizeiptr size, const void* data, GLenum usage) const - { - ::glBufferData (target, size, data, usage); - OpenGl_TRACE(glBufferData) - } - - inline void glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void* data) const - { - ::glBufferSubData (target, offset, size, data); - OpenGl_TRACE(glBufferSubData) - } - - inline void glDeleteBuffers (GLsizei n, const GLuint *buffers) const - { - ::glDeleteBuffers (n, buffers); - OpenGl_TRACE(glDeleteBuffers) - } - - inline void glDeleteTextures (GLsizei n, const GLuint *textures) const - { - ::glDeleteTextures (n, textures); - OpenGl_TRACE(glDeleteTextures) - } - - inline void glDepthFunc (GLenum func) const - { - ::glDepthFunc (func); - OpenGl_TRACE(glDepthFunc) - } - - inline void glDepthMask (GLboolean flag) const - { - ::glDepthMask (flag); - OpenGl_TRACE(glDepthMask) - } - - inline void glDepthRangef (GLfloat n, GLfloat f) const - { - ::glDepthRangef (n, f); - OpenGl_TRACE(glDepthRangef) - } - - inline void glGenBuffers (GLsizei n, GLuint *buffers) const - { - ::glGenBuffers (n, buffers); - OpenGl_TRACE(glGenBuffers) - } - - inline void glGenTextures (GLsizei n, GLuint *textures) const - { - ::glGenTextures (n, textures); - OpenGl_TRACE(glGenTextures) - } - - inline void glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params) const - { - ::glGetBufferParameteriv (target, pname, params); - OpenGl_TRACE(glGetBufferParameteriv) - } - - inline GLboolean glIsBuffer (GLuint buffer) const - { - return ::glIsBuffer (buffer); - } - - inline void glSampleCoverage (GLfloat value, GLboolean invert) const - { - ::glSampleCoverage (value, invert); - OpenGl_TRACE(glSampleCoverage) - } - - inline void glMultiDrawElements (GLenum theMode, const GLsizei* theCount, GLenum theType, const void* const* theIndices, GLsizei theDrawCount) const - { - if (theCount == NULL - || theIndices == NULL) - { - return; - } - - for (GLsizei aBatchIter = 0; aBatchIter < theDrawCount; ++aBatchIter) - { - ::glDrawElements (theMode, theCount[aBatchIter], theType, theIndices[aBatchIter]); - } - OpenGl_TRACE(glMultiDrawElements) - } - -#endif - -public: //! @name OpenGL ES 2.0 - -#if defined(GL_ES_VERSION_2_0) - inline void glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) const - { - ::glBlendColor (red, green, blue, alpha); - OpenGl_TRACE(glBlendColor) - } - - inline void glBlendEquation (GLenum mode) const - { - ::glBlendEquation (mode); - OpenGl_TRACE(glBlendEquation) - } - - inline void glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) const - { - ::glBlendFuncSeparate (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); - OpenGl_TRACE(glBlendFuncSeparate) - } - - inline void glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha) const - { - ::glBlendEquationSeparate (modeRGB, modeAlpha); - OpenGl_TRACE(glBlendEquationSeparate) - } - - inline void glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) const - { - ::glStencilOpSeparate (face, sfail, dpfail, dppass); - OpenGl_TRACE(glStencilOpSeparate) - } - - inline void glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask) const - { - ::glStencilFuncSeparate (face, func, ref, mask); - OpenGl_TRACE(glStencilFuncSeparate) - } - - inline void glStencilMaskSeparate (GLenum face, GLuint mask) const - { - ::glStencilMaskSeparate (face, mask); - OpenGl_TRACE(glStencilMaskSeparate) - } - - inline void glAttachShader (GLuint program, GLuint shader) const - { - ::glAttachShader (program, shader); - OpenGl_TRACE(glAttachShader) - } - - inline void glBindAttribLocation (GLuint program, GLuint index, const GLchar *name) const - { - ::glBindAttribLocation (program, index, name); - OpenGl_TRACE(glBindAttribLocation) - } - - inline void glBindFramebuffer (GLenum target, GLuint framebuffer) const - { - ::glBindFramebuffer (target, framebuffer); - OpenGl_TRACE(glBindFramebuffer) - } - - inline void glBindRenderbuffer (GLenum target, GLuint renderbuffer) const - { - ::glBindRenderbuffer (target, renderbuffer); - OpenGl_TRACE(glBindRenderbuffer) - } - - inline GLenum glCheckFramebufferStatus (GLenum target) const - { - return ::glCheckFramebufferStatus (target); - } - - inline void glCompileShader (GLuint shader) const - { - ::glCompileShader (shader); - OpenGl_TRACE(glCompileShader) - } - - inline GLuint glCreateProgram() const - { - return ::glCreateProgram(); - } - - inline GLuint glCreateShader (GLenum type) const - { - return ::glCreateShader (type); - } - - inline void glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers) const - { - ::glDeleteFramebuffers (n, framebuffers); - OpenGl_TRACE(glDeleteFramebuffers) - } - - inline void glDeleteProgram (GLuint program) const - { - ::glDeleteProgram (program); - OpenGl_TRACE(glDeleteProgram) - } - - inline void glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers) const - { - ::glDeleteRenderbuffers (n, renderbuffers); - OpenGl_TRACE(glDeleteRenderbuffers) - } - - inline void glDeleteShader (GLuint shader) const - { - ::glDeleteShader (shader); - OpenGl_TRACE(glDeleteShader) - } - - inline void glDetachShader (GLuint program, GLuint shader) const - { - ::glDetachShader (program, shader); - OpenGl_TRACE(glDetachShader) - } - - inline void glDisableVertexAttribArray (GLuint index) const - { - ::glDisableVertexAttribArray (index); - OpenGl_TRACE(glDisableVertexAttribArray) - } - - inline void glEnableVertexAttribArray (GLuint index) const - { - ::glEnableVertexAttribArray (index); - OpenGl_TRACE(glEnableVertexAttribArray) - } - - inline void glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) const - { - ::glFramebufferRenderbuffer (target, attachment, renderbuffertarget, renderbuffer); - OpenGl_TRACE(glFramebufferRenderbuffer) - } - - inline void glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) const - { - ::glFramebufferTexture2D (target, attachment, textarget, texture, level); - OpenGl_TRACE(glFramebufferTexture2D) - } - - inline void glGenerateMipmap (GLenum target) const - { - ::glGenerateMipmap (target); - OpenGl_TRACE(glGenerateMipmap) - } - - inline void glGenFramebuffers (GLsizei n, GLuint *framebuffers) const - { - ::glGenFramebuffers (n, framebuffers); - OpenGl_TRACE(glGenFramebuffers) - } - - inline void glGenRenderbuffers (GLsizei n, GLuint *renderbuffers) const - { - ::glGenRenderbuffers (n, renderbuffers); - OpenGl_TRACE(glGenRenderbuffers) - } - - inline void glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint* size, GLenum *type, GLchar *name) const - { - ::glGetActiveAttrib (program, index, bufSize, length, size, type, name); - OpenGl_TRACE(glGetActiveAttrib) - } - - inline void glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint* size, GLenum *type, GLchar *name) const - { - ::glGetActiveUniform (program, index, bufSize, length, size, type, name); - OpenGl_TRACE(glGetActiveUniform) - } - - inline void glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders) const - { - ::glGetAttachedShaders (program, maxCount, count, shaders); - OpenGl_TRACE(glGetAttachedShaders) - } - - inline GLint glGetAttribLocation (GLuint program, const GLchar *name) const - { - const GLint aRes = ::glGetAttribLocation (program, name); - OpenGl_TRACE(glGetAttribLocation) - return aRes; - } - - inline void glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params) const - { - ::glGetFramebufferAttachmentParameteriv (target, attachment, pname, params); - OpenGl_TRACE(glGetFramebufferAttachmentParameteriv) - } - - inline void glGetProgramiv (GLuint program, GLenum pname, GLint* params) const - { - ::glGetProgramiv (program, pname, params); - OpenGl_TRACE(glGetProgramiv) - } - - inline void glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) const - { - ::glGetProgramInfoLog (program, bufSize, length, infoLog); - OpenGl_TRACE(glGetProgramInfoLog) - } - - inline void glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params) const - { - ::glGetRenderbufferParameteriv (target, pname, params); - OpenGl_TRACE(glGetRenderbufferParameteriv) - } - - inline void glGetShaderiv (GLuint shader, GLenum pname, GLint* params) const - { - ::glGetShaderiv (shader, pname, params); - OpenGl_TRACE(glGetShaderiv) - } - - inline void glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) const - { - ::glGetShaderInfoLog (shader, bufSize, length, infoLog); - OpenGl_TRACE(glGetShaderInfoLog) - } - - inline void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) const - { - ::glGetShaderPrecisionFormat (shadertype, precisiontype, range, precision); - OpenGl_TRACE(glGetShaderPrecisionFormat) - } - - inline void glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) const - { - ::glGetShaderSource (shader, bufSize, length, source); - OpenGl_TRACE(glGetShaderSource) - } - - inline void glGetUniformfv (GLuint program, GLint location, GLfloat* params) const - { - ::glGetUniformfv (program, location, params); - OpenGl_TRACE(glGetUniformfv) - } - - inline void glGetUniformiv (GLuint program, GLint location, GLint* params) const - { - ::glGetUniformiv (program, location, params); - OpenGl_TRACE(glGetUniformiv) - } - - GLint glGetUniformLocation (GLuint program, const GLchar *name) const - { - const GLint aRes = ::glGetUniformLocation (program, name); - OpenGl_TRACE(glGetUniformLocation) - return aRes; - } - - inline void glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params) const - { - ::glGetVertexAttribfv (index, pname, params); - OpenGl_TRACE(glGetVertexAttribfv) - } - - inline void glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params) const - { - ::glGetVertexAttribiv (index, pname, params); - OpenGl_TRACE(glGetVertexAttribiv) - } - - inline void glGetVertexAttribPointerv (GLuint index, GLenum pname, void* *pointer) const - { - ::glGetVertexAttribPointerv (index, pname, pointer); - OpenGl_TRACE(glGetVertexAttribPointerv) - } - - inline GLboolean glIsFramebuffer (GLuint framebuffer) const - { - return ::glIsFramebuffer (framebuffer); - } - - inline GLboolean glIsProgram (GLuint program) const - { - return ::glIsProgram (program); - } - - inline GLboolean glIsRenderbuffer (GLuint renderbuffer) const - { - return ::glIsRenderbuffer (renderbuffer); - } - - inline GLboolean glIsShader (GLuint shader) const - { - return ::glIsShader (shader); - } - - inline void glLinkProgram (GLuint program) const - { - ::glLinkProgram (program); - OpenGl_TRACE(glLinkProgram) - } - - inline void glReleaseShaderCompiler() const - { - ::glReleaseShaderCompiler(); - OpenGl_TRACE(glReleaseShaderCompiler) - } - - inline void glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) const - { - ::glRenderbufferStorage (target, internalformat, width, height); - OpenGl_TRACE(glRenderbufferStorage) - } - - inline void glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void* binary, GLsizei length) const - { - ::glShaderBinary (count, shaders, binaryformat, binary, length); - OpenGl_TRACE(glShaderBinary) - } - - inline void glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length) const - { - ::glShaderSource (shader, count, string, length); - OpenGl_TRACE(glShaderSource) - } - - inline void glUniform1f (GLint location, GLfloat v0) const - { - ::glUniform1f (location, v0); - OpenGl_TRACE(glUniform1f) - } - - inline void glUniform1fv (GLint location, GLsizei count, const GLfloat* value) const - { - ::glUniform1fv (location, count, value); - OpenGl_TRACE(glUniform1fv) - } - - inline void glUniform1i (GLint location, GLint v0) const - { - ::glUniform1i (location, v0); - OpenGl_TRACE(glUniform1i) - } - - inline void glUniform1iv (GLint location, GLsizei count, const GLint* value) const - { - ::glUniform1iv (location, count, value); - OpenGl_TRACE(glUniform1iv) - } - - inline void glUniform2f (GLint location, GLfloat v0, GLfloat v1) const - { - ::glUniform2f (location, v0, v1); - OpenGl_TRACE(glUniform2f) - } - - inline void glUniform2fv (GLint location, GLsizei count, const GLfloat* value) const - { - ::glUniform2fv (location, count, value); - OpenGl_TRACE(glUniform2fv) - } - - inline void glUniform2i (GLint location, GLint v0, GLint v1) const - { - ::glUniform2i (location, v0, v1); - OpenGl_TRACE(glUniform2i) - } - - inline void glUniform2iv (GLint location, GLsizei count, const GLint* value) const - { - ::glUniform2iv (location, count, value); - OpenGl_TRACE(glUniform2iv) - } - - inline void glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2) const - { - ::glUniform3f (location, v0, v1, v2); - OpenGl_TRACE(glUniform3f) - } - - inline void glUniform3fv (GLint location, GLsizei count, const GLfloat* value) const - { - ::glUniform3fv (location, count, value); - OpenGl_TRACE(glUniform3fv) - } - - inline void glUniform3i (GLint location, GLint v0, GLint v1, GLint v2) const - { - ::glUniform3i (location, v0, v1, v2); - OpenGl_TRACE(glUniform3i) - } - - inline void glUniform3iv (GLint location, GLsizei count, const GLint* value) const - { - ::glUniform3iv (location, count, value); - OpenGl_TRACE(glUniform3iv) - } - - inline void glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) const - { - ::glUniform4f (location, v0, v1, v2, v3); - OpenGl_TRACE(glUniform4f) - } - - inline void glUniform4fv (GLint location, GLsizei count, const GLfloat* value) const - { - ::glUniform4fv (location, count, value); - OpenGl_TRACE(glUniform4fv) - } - - inline void glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3) const - { - ::glUniform4i (location, v0, v1, v2, v3); - OpenGl_TRACE(glUniform4i) - } - - inline void glUniform4iv (GLint location, GLsizei count, const GLint* value) const - { - ::glUniform4iv (location, count, value); - OpenGl_TRACE(glUniform4iv) - } - - inline void glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) const - { - ::glUniformMatrix2fv (location, count, transpose, value); - OpenGl_TRACE(glUniformMatrix2fv) - } - - inline void glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) const - { - ::glUniformMatrix3fv (location, count, transpose, value); - OpenGl_TRACE(glUniformMatrix3fv) - } - - inline void glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) const - { - ::glUniformMatrix4fv (location, count, transpose, value); - OpenGl_TRACE(glUniformMatrix4fv) - } - - inline void glUseProgram (GLuint program) const - { - ::glUseProgram (program); - OpenGl_TRACE(glUseProgram) - } - - inline void glValidateProgram (GLuint program) const - { - ::glValidateProgram (program); - OpenGl_TRACE(glValidateProgram) - } - - inline void glVertexAttrib1f (GLuint index, GLfloat x) const - { - ::glVertexAttrib1f (index, x); - OpenGl_TRACE(glVertexAttrib1f) - } - - inline void glVertexAttrib1fv (GLuint index, const GLfloat* v) const - { - ::glVertexAttrib1fv (index, v); - OpenGl_TRACE(glVertexAttrib1fv) - } - - inline void glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y) const - { - ::glVertexAttrib2f (index, x, y); - OpenGl_TRACE(glVertexAttrib2f) - } - - inline void glVertexAttrib2fv (GLuint index, const GLfloat* v) const - { - ::glVertexAttrib2fv (index, v); - OpenGl_TRACE(glVertexAttrib2fv) - } - - inline void glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z) const - { - ::glVertexAttrib3f (index, x, y, z); - OpenGl_TRACE(glVertexAttrib3f) - } - - inline void glVertexAttrib3fv (GLuint index, const GLfloat* v) const - { - ::glVertexAttrib3fv (index, v); - OpenGl_TRACE(glVertexAttrib3fv) - } - - inline void glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) const - { - ::glVertexAttrib4f (index, x, y, z, w); - OpenGl_TRACE(glVertexAttrib4f) - } - - inline void glVertexAttrib4fv (GLuint index, const GLfloat* v) const - { - ::glVertexAttrib4fv (index, v); - OpenGl_TRACE(glVertexAttrib4fv) - } - - inline void glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer) const - { - ::glVertexAttribPointer (index, size, type, normalized, stride, pointer); - OpenGl_TRACE(glVertexAttribPointer) - } - -public: //! @name OpenGL ES 3.0 - - opencascade::PFNGLREADBUFFERPROC glReadBuffer; - opencascade::PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements; - opencascade::PFNGLTEXIMAGE3DPROC glTexImage3D; - opencascade::PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D; - opencascade::PFNGLCOPYTEXSUBIMAGE3DPROC glCopyTexSubImage3D; - opencascade::PFNGLCOMPRESSEDTEXIMAGE3DPROC glCompressedTexImage3D; - opencascade::PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D; - opencascade::PFNGLGENQUERIESPROC glGenQueries; - opencascade::PFNGLDELETEQUERIESPROC glDeleteQueries; - opencascade::PFNGLISQUERYPROC glIsQuery; - opencascade::PFNGLBEGINQUERYPROC glBeginQuery; - opencascade::PFNGLENDQUERYPROC glEndQuery; - opencascade::PFNGLGETQUERYIVPROC glGetQueryiv; - opencascade::PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv; - opencascade::PFNGLUNMAPBUFFERPROC glUnmapBuffer; - opencascade::PFNGLGETBUFFERPOINTERVPROC glGetBufferPointerv; - opencascade::PFNGLDRAWBUFFERSPROC glDrawBuffers; - opencascade::PFNGLUNIFORMMATRIX2X3FVPROC glUniformMatrix2x3fv; - opencascade::PFNGLUNIFORMMATRIX3X2FVPROC glUniformMatrix3x2fv; - opencascade::PFNGLUNIFORMMATRIX2X4FVPROC glUniformMatrix2x4fv; - opencascade::PFNGLUNIFORMMATRIX4X2FVPROC glUniformMatrix4x2fv; - opencascade::PFNGLUNIFORMMATRIX3X4FVPROC glUniformMatrix3x4fv; - opencascade::PFNGLUNIFORMMATRIX4X3FVPROC glUniformMatrix4x3fv; - opencascade::PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; - opencascade::PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample; - opencascade::PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; - opencascade::PFNGLMAPBUFFERRANGEPROC glMapBufferRange; - opencascade::PFNGLFLUSHMAPPEDBUFFERRANGEPROC glFlushMappedBufferRange; - opencascade::PFNGLBINDVERTEXARRAYPROC glBindVertexArray; - opencascade::PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; - opencascade::PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; - opencascade::PFNGLISVERTEXARRAYPROC glIsVertexArray; - opencascade::PFNGLGETINTEGERI_VPROC glGetIntegeri_v; - opencascade::PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback; - opencascade::PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback; - opencascade::PFNGLBINDBUFFERRANGEPROC glBindBufferRange; - opencascade::PFNGLBINDBUFFERBASEPROC glBindBufferBase; - opencascade::PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings; - opencascade::PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glGetTransformFeedbackVarying; - opencascade::PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; - opencascade::PFNGLGETVERTEXATTRIBIIVPROC glGetVertexAttribIiv; - opencascade::PFNGLGETVERTEXATTRIBIUIVPROC glGetVertexAttribIuiv; - opencascade::PFNGLVERTEXATTRIBI4IPROC glVertexAttribI4i; - opencascade::PFNGLVERTEXATTRIBI4UIPROC glVertexAttribI4ui; - opencascade::PFNGLVERTEXATTRIBI4IVPROC glVertexAttribI4iv; - opencascade::PFNGLVERTEXATTRIBI4UIVPROC glVertexAttribI4uiv; - opencascade::PFNGLGETUNIFORMUIVPROC glGetUniformuiv; - opencascade::PFNGLGETFRAGDATALOCATIONPROC glGetFragDataLocation; - opencascade::PFNGLUNIFORM1UIPROC glUniform1ui; - opencascade::PFNGLUNIFORM2UIPROC glUniform2ui; - opencascade::PFNGLUNIFORM3UIPROC glUniform3ui; - opencascade::PFNGLUNIFORM4UIPROC glUniform4ui; - opencascade::PFNGLUNIFORM1UIVPROC glUniform1uiv; - opencascade::PFNGLUNIFORM2UIVPROC glUniform2uiv; - opencascade::PFNGLUNIFORM3UIVPROC glUniform3uiv; - opencascade::PFNGLUNIFORM4UIVPROC glUniform4uiv; - opencascade::PFNGLCLEARBUFFERIVPROC glClearBufferiv; - opencascade::PFNGLCLEARBUFFERUIVPROC glClearBufferuiv; - opencascade::PFNGLCLEARBUFFERFVPROC glClearBufferfv; - opencascade::PFNGLCLEARBUFFERFIPROC glClearBufferfi; - opencascade::PFNGLGETSTRINGIPROC glGetStringi; - opencascade::PFNGLCOPYBUFFERSUBDATAPROC glCopyBufferSubData; - opencascade::PFNGLGETUNIFORMINDICESPROC glGetUniformIndices; - opencascade::PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv; - opencascade::PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex; - opencascade::PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv; - opencascade::PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName; - opencascade::PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding; - opencascade::PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; - opencascade::PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced; - opencascade::PFNGLFENCESYNCPROC glFenceSync; - opencascade::PFNGLISSYNCPROC glIsSync; - opencascade::PFNGLDELETESYNCPROC glDeleteSync; - opencascade::PFNGLCLIENTWAITSYNCPROC glClientWaitSync; - opencascade::PFNGLWAITSYNCPROC glWaitSync; - opencascade::PFNGLGETINTEGER64VPROC glGetInteger64v; - opencascade::PFNGLGETSYNCIVPROC glGetSynciv; - opencascade::PFNGLGETINTEGER64I_VPROC glGetInteger64i_v; - opencascade::PFNGLGETBUFFERPARAMETERI64VPROC glGetBufferParameteri64v; - opencascade::PFNGLGENSAMPLERSPROC glGenSamplers; - opencascade::PFNGLDELETESAMPLERSPROC glDeleteSamplers; - opencascade::PFNGLISSAMPLERPROC glIsSampler; - opencascade::PFNGLBINDSAMPLERPROC glBindSampler; - opencascade::PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri; - opencascade::PFNGLSAMPLERPARAMETERIVPROC glSamplerParameteriv; - opencascade::PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf; - opencascade::PFNGLSAMPLERPARAMETERFVPROC glSamplerParameterfv; - opencascade::PFNGLGETSAMPLERPARAMETERIVPROC glGetSamplerParameteriv; - opencascade::PFNGLGETSAMPLERPARAMETERFVPROC glGetSamplerParameterfv; - opencascade::PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; - opencascade::PFNGLBINDTRANSFORMFEEDBACKPROC glBindTransformFeedback; - opencascade::PFNGLDELETETRANSFORMFEEDBACKSPROC glDeleteTransformFeedbacks; - opencascade::PFNGLGENTRANSFORMFEEDBACKSPROC glGenTransformFeedbacks; - opencascade::PFNGLISTRANSFORMFEEDBACKPROC glIsTransformFeedback; - opencascade::PFNGLPAUSETRANSFORMFEEDBACKPROC glPauseTransformFeedback; - opencascade::PFNGLRESUMETRANSFORMFEEDBACKPROC glResumeTransformFeedback; - opencascade::PFNGLGETPROGRAMBINARYPROC glGetProgramBinary; - opencascade::PFNGLPROGRAMBINARYPROC glProgramBinary; - opencascade::PFNGLPROGRAMPARAMETERIPROC glProgramParameteri; - opencascade::PFNGLINVALIDATEFRAMEBUFFERPROC glInvalidateFramebuffer; - opencascade::PFNGLINVALIDATESUBFRAMEBUFFERPROC glInvalidateSubFramebuffer; - opencascade::PFNGLTEXSTORAGE2DPROC glTexStorage2D; - opencascade::PFNGLTEXSTORAGE3DPROC glTexStorage3D; - opencascade::PFNGLGETINTERNALFORMATIVPROC glGetInternalformativ; - -public: //! @name OpenGL ES 3.1 - - opencascade::PFNGLDISPATCHCOMPUTEPROC glDispatchCompute; - opencascade::PFNGLDISPATCHCOMPUTEINDIRECTPROC glDispatchComputeIndirect; - opencascade::PFNGLDRAWARRAYSINDIRECTPROC glDrawArraysIndirect; - opencascade::PFNGLDRAWELEMENTSINDIRECTPROC glDrawElementsIndirect; - opencascade::PFNGLFRAMEBUFFERPARAMETERIPROC glFramebufferParameteri; - opencascade::PFNGLGETFRAMEBUFFERPARAMETERIVPROC glGetFramebufferParameteriv; - opencascade::PFNGLGETPROGRAMINTERFACEIVPROC glGetProgramInterfaceiv; - opencascade::PFNGLGETPROGRAMRESOURCEINDEXPROC glGetProgramResourceIndex; - opencascade::PFNGLGETPROGRAMRESOURCENAMEPROC glGetProgramResourceName; - opencascade::PFNGLGETPROGRAMRESOURCEIVPROC glGetProgramResourceiv; - opencascade::PFNGLGETPROGRAMRESOURCELOCATIONPROC glGetProgramResourceLocation; - opencascade::PFNGLUSEPROGRAMSTAGESPROC glUseProgramStages; - opencascade::PFNGLACTIVESHADERPROGRAMPROC glActiveShaderProgram; - opencascade::PFNGLCREATESHADERPROGRAMVPROC glCreateShaderProgramv; - opencascade::PFNGLBINDPROGRAMPIPELINEPROC glBindProgramPipeline; - opencascade::PFNGLDELETEPROGRAMPIPELINESPROC glDeleteProgramPipelines; - opencascade::PFNGLGENPROGRAMPIPELINESPROC glGenProgramPipelines; - opencascade::PFNGLISPROGRAMPIPELINEPROC glIsProgramPipeline; - opencascade::PFNGLGETPROGRAMPIPELINEIVPROC glGetProgramPipelineiv; - opencascade::PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i; - opencascade::PFNGLPROGRAMUNIFORM2IPROC glProgramUniform2i; - opencascade::PFNGLPROGRAMUNIFORM3IPROC glProgramUniform3i; - opencascade::PFNGLPROGRAMUNIFORM4IPROC glProgramUniform4i; - opencascade::PFNGLPROGRAMUNIFORM1UIPROC glProgramUniform1ui; - opencascade::PFNGLPROGRAMUNIFORM2UIPROC glProgramUniform2ui; - opencascade::PFNGLPROGRAMUNIFORM3UIPROC glProgramUniform3ui; - opencascade::PFNGLPROGRAMUNIFORM4UIPROC glProgramUniform4ui; - opencascade::PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f; - opencascade::PFNGLPROGRAMUNIFORM2FPROC glProgramUniform2f; - opencascade::PFNGLPROGRAMUNIFORM3FPROC glProgramUniform3f; - opencascade::PFNGLPROGRAMUNIFORM4FPROC glProgramUniform4f; - opencascade::PFNGLPROGRAMUNIFORM1IVPROC glProgramUniform1iv; - opencascade::PFNGLPROGRAMUNIFORM2IVPROC glProgramUniform2iv; - opencascade::PFNGLPROGRAMUNIFORM3IVPROC glProgramUniform3iv; - opencascade::PFNGLPROGRAMUNIFORM4IVPROC glProgramUniform4iv; - opencascade::PFNGLPROGRAMUNIFORM1UIVPROC glProgramUniform1uiv; - opencascade::PFNGLPROGRAMUNIFORM2UIVPROC glProgramUniform2uiv; - opencascade::PFNGLPROGRAMUNIFORM3UIVPROC glProgramUniform3uiv; - opencascade::PFNGLPROGRAMUNIFORM4UIVPROC glProgramUniform4uiv; - opencascade::PFNGLPROGRAMUNIFORM1FVPROC glProgramUniform1fv; - opencascade::PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv; - opencascade::PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv; - opencascade::PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv; - opencascade::PFNGLPROGRAMUNIFORMMATRIX2FVPROC glProgramUniformMatrix2fv; - opencascade::PFNGLPROGRAMUNIFORMMATRIX3FVPROC glProgramUniformMatrix3fv; - opencascade::PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv; - opencascade::PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC glProgramUniformMatrix2x3fv; - opencascade::PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC glProgramUniformMatrix3x2fv; - opencascade::PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC glProgramUniformMatrix2x4fv; - opencascade::PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC glProgramUniformMatrix4x2fv; - opencascade::PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC glProgramUniformMatrix3x4fv; - opencascade::PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC glProgramUniformMatrix4x3fv; - opencascade::PFNGLVALIDATEPROGRAMPIPELINEPROC glValidateProgramPipeline; - opencascade::PFNGLGETPROGRAMPIPELINEINFOLOGPROC glGetProgramPipelineInfoLog; - opencascade::PFNGLBINDIMAGETEXTUREPROC glBindImageTexture; - opencascade::PFNGLGETBOOLEANI_VPROC glGetBooleani_v; - opencascade::PFNGLMEMORYBARRIERPROC glMemoryBarrier; - opencascade::PFNGLMEMORYBARRIERBYREGIONPROC glMemoryBarrierByRegion; - opencascade::PFNGLTEXSTORAGE2DMULTISAMPLEPROC glTexStorage2DMultisample; - opencascade::PFNGLGETMULTISAMPLEFVPROC glGetMultisamplefv; - opencascade::PFNGLSAMPLEMASKIPROC glSampleMaski; - opencascade::PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv; - opencascade::PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv; - opencascade::PFNGLBINDVERTEXBUFFERPROC glBindVertexBuffer; - opencascade::PFNGLVERTEXATTRIBFORMATPROC glVertexAttribFormat; - opencascade::PFNGLVERTEXATTRIBIFORMATPROC glVertexAttribIFormat; - opencascade::PFNGLVERTEXATTRIBBINDINGPROC glVertexAttribBinding; - opencascade::PFNGLVERTEXBINDINGDIVISORPROC glVertexBindingDivisor; +public: //! @name OpenGL 1.1 + + typedef void (APIENTRYP glClearColor_t)(GLclampf theRed, GLclampf theGreen, GLclampf theBlue, GLclampf theAlpha); + glClearColor_t glClearColor; + + typedef void (APIENTRYP glClear_t)(GLbitfield theMask); + glClear_t glClear; + + typedef void (APIENTRYP glColorMask_t)(GLboolean theRed, GLboolean theGreen, GLboolean theBlue, GLboolean theAlpha); + glColorMask_t glColorMask; + + typedef void (APIENTRYP glBlendFunc_t)(GLenum sfactor, GLenum dfactor); + glBlendFunc_t glBlendFunc; + + typedef void (APIENTRYP glCullFace_t)(GLenum theMode); + glCullFace_t glCullFace; + + typedef void (APIENTRYP glFrontFace_t)(GLenum theMode); + glFrontFace_t glFrontFace; + + typedef void (APIENTRYP glLineWidth_t)(GLfloat theWidth); + glLineWidth_t glLineWidth; + + typedef void (APIENTRYP glPolygonOffset_t)(GLfloat theFactor, GLfloat theUnits); + glPolygonOffset_t glPolygonOffset; + + typedef void (APIENTRYP glScissor_t)(GLint theX, GLint theY, GLsizei theWidth, GLsizei theHeight); + glScissor_t glScissor; + + typedef void (APIENTRYP glEnable_t)(GLenum theCap); + glEnable_t glEnable; + + typedef void (APIENTRYP glDisable_t)(GLenum theCap); + glDisable_t glDisable; + + typedef GLboolean (APIENTRYP glIsEnabled_t)(GLenum theCap); + glIsEnabled_t glIsEnabled; + + typedef void (APIENTRYP glGetBooleanv_t)(GLenum theParamName, GLboolean* theValues); + glGetBooleanv_t glGetBooleanv; + + typedef void (APIENTRYP glGetFloatv_t)(GLenum theParamName, GLfloat* theValues); + glGetFloatv_t glGetFloatv; + + typedef void (APIENTRYP glGetIntegerv_t)(GLenum theParamName, GLint* theValues); + glGetIntegerv_t glGetIntegerv; + + typedef GLenum (APIENTRYP glGetError_t)(); + glGetError_t glGetError; + + typedef const GLubyte* (APIENTRYP glGetString_t)(GLenum theName); + glGetString_t glGetString; + + typedef void (APIENTRYP glFinish_t)(); + glFinish_t glFinish; + + typedef void (APIENTRYP glFlush_t)(); + glFlush_t glFlush; + + typedef void (APIENTRYP glHint_t)(GLenum theTarget, GLenum theMode); + glHint_t glHint; + + typedef void (APIENTRYP glGetPointerv_t)(GLenum pname, GLvoid* *params); + glGetPointerv_t glGetPointerv; + + typedef void (APIENTRYP glReadBuffer_t)(GLenum src); // added to OpenGL ES 3.0 + glReadBuffer_t glReadBuffer; + + typedef void (APIENTRYP glDrawBuffer_t)(GLenum mode); // added to OpenGL ES 3.0 + glDrawBuffer_t glDrawBuffer; + + typedef void (APIENTRYP glPixelTransferi_t)(GLenum pname, GLint param); + glPixelTransferi_t glPixelTransferi; + +public: //! @name Depth Buffer + + typedef void (APIENTRYP glClearDepth_t)(GLclampd theDepth); + glClearDepth_t glClearDepth; + + typedef void (APIENTRYP glDepthFunc_t)(GLenum theFunc); + glDepthFunc_t glDepthFunc; + + typedef void (APIENTRYP glDepthMask_t)(GLboolean theFlag); + glDepthMask_t glDepthMask; + + typedef void (APIENTRYP glDepthRange_t)(GLclampd theNearValue, GLclampd theFarValue); + glDepthRange_t glDepthRange; + +public: //! @name Transformation + + typedef void (APIENTRYP glViewport_t)(GLint theX, GLint theY, GLsizei theWidth, GLsizei theHeight); + glViewport_t glViewport; + +public: //! @name Vertex Arrays + + typedef void (APIENTRYP glDrawArrays_t)(GLenum theMode, GLint theFirst, GLsizei theCount); + glDrawArrays_t glDrawArrays; + + typedef void (APIENTRYP glDrawElements_t)(GLenum theMode, GLsizei theCount, GLenum theType, const GLvoid* theIndices); + glDrawElements_t glDrawElements; + +public: //! @name Raster functions + + typedef void (APIENTRYP glPixelStorei_t)(GLenum theParamName, GLint theParam); + glPixelStorei_t glPixelStorei; + + typedef void (APIENTRYP glReadPixels_t)(GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLvoid* pixels); + glReadPixels_t glReadPixels; + +public: //! @name Stenciling + + typedef void (APIENTRYP glStencilFunc_t)(GLenum func, GLint ref, GLuint mask); + glStencilFunc_t glStencilFunc; + + typedef void (APIENTRYP glStencilMask_t)(GLuint mask); + glStencilMask_t glStencilMask; + + typedef void (APIENTRYP glStencilOp_t)(GLenum fail, GLenum zfail, GLenum zpass); + glStencilOp_t glStencilOp; + + typedef void (APIENTRYP glClearStencil_t)(GLint s); + glClearStencil_t glClearStencil; + +public: //! @name Texture mapping + + typedef void (APIENTRYP glTexParameterf_t)(GLenum target, GLenum pname, GLfloat param); + glTexParameterf_t glTexParameterf; + + typedef void (APIENTRYP glTexParameteri_t)(GLenum target, GLenum pname, GLint param); + glTexParameteri_t glTexParameteri; + + typedef void (APIENTRYP glTexParameterfv_t)(GLenum target, GLenum pname, const GLfloat* params); + glTexParameterfv_t glTexParameterfv; + + typedef void (APIENTRYP glTexParameteriv_t)(GLenum target, GLenum pname, const GLint* params); + glTexParameteriv_t glTexParameteriv; + + typedef void (APIENTRYP glGetTexParameterfv_t)(GLenum target, GLenum pname, GLfloat* params); + glGetTexParameterfv_t glGetTexParameterfv; + + typedef void (APIENTRYP glGetTexParameteriv_t)(GLenum target, GLenum pname, GLint* params); + glGetTexParameteriv_t glGetTexParameteriv; + + typedef void (APIENTRYP glTexImage2D_t)(GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid* pixels); + glTexImage2D_t glTexImage2D; + + typedef void (APIENTRYP glGenTextures_t)(GLsizei n, GLuint* textures); + glGenTextures_t glGenTextures; + + typedef void (APIENTRYP glDeleteTextures_t)(GLsizei n, const GLuint* textures); + glDeleteTextures_t glDeleteTextures; + + typedef void (APIENTRYP glBindTexture_t)(GLenum target, GLuint texture); + glBindTexture_t glBindTexture; + + typedef GLboolean (APIENTRYP glIsTexture_t)(GLuint texture); + glIsTexture_t glIsTexture; + + typedef void (APIENTRYP glTexSubImage2D_t)(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid* pixels); + glTexSubImage2D_t glTexSubImage2D; + + typedef void (APIENTRYP glCopyTexImage2D_t)(GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLint border); + glCopyTexImage2D_t glCopyTexImage2D; + + typedef void (APIENTRYP glCopyTexSubImage2D_t)(GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height); + glCopyTexSubImage2D_t glCopyTexSubImage2D; + +public: // not part of OpenGL ES 2.0 + typedef void (APIENTRYP glTexImage1D_t)(GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLint border, + GLenum format, GLenum type, + const GLvoid* pixels); + glTexImage1D_t glTexImage1D; + + typedef void (APIENTRYP glTexSubImage1D_t)(GLenum target, GLint level, + GLint xoffset, + GLsizei width, GLenum format, + GLenum type, const GLvoid* pixels); + glTexSubImage1D_t glTexSubImage1D; + + typedef void (APIENTRYP glCopyTexImage1D_t)(GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border); + glCopyTexImage1D_t glCopyTexImage1D; + + typedef void (APIENTRYP glCopyTexSubImage1D_t)(GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width); + glCopyTexSubImage1D_t glCopyTexSubImage1D; + + typedef void (APIENTRYP glGetTexImage_t)(GLenum target, GLint level, + GLenum format, GLenum type, + GLvoid* pixels); + glGetTexImage_t glGetTexImage; + + typedef void (APIENTRYP glAlphaFunc_t)(GLenum theFunc, GLclampf theRef); + glAlphaFunc_t glAlphaFunc; + + typedef void (APIENTRYP glPointSize_t)(GLfloat theSize); + glPointSize_t glPointSize; + +public: //! @name OpenGL 1.1 FFP (obsolete, removed since 3.1) + + typedef void (APIENTRYP glTexEnvi_t)(GLenum target, GLenum pname, GLint param); + glTexEnvi_t glTexEnvi; + + typedef void (APIENTRYP glGetTexEnviv_t)(GLenum target, GLenum pname, GLint *params); + glGetTexEnviv_t glGetTexEnviv; + + typedef void (APIENTRYP glLogicOp_t)(GLenum opcode); + glLogicOp_t glLogicOp; + +public: //! @name Begin/End primitive specification (removed since 3.1) + + typedef void (APIENTRYP glColor4fv_t)(const GLfloat* theVec); + glColor4fv_t glColor4fv; + +public: //! @name Matrix operations (removed since 3.1) + + typedef void (APIENTRYP glMatrixMode_t)(GLenum theMode); + glMatrixMode_t glMatrixMode; + + typedef void (APIENTRYP glLoadIdentity_t)(); + glLoadIdentity_t glLoadIdentity; + + typedef void (APIENTRYP glLoadMatrixf_t)(const GLfloat* theMatrix); + glLoadMatrixf_t glLoadMatrixf; + +public: //! @name Line and Polygon stipple (removed since 3.1) + + typedef void (APIENTRYP glLineStipple_t)(GLint theFactor, GLushort thePattern); + glLineStipple_t glLineStipple; + + typedef void (APIENTRYP glPolygonStipple_t)(const GLubyte* theMask); + glPolygonStipple_t glPolygonStipple; + +public: //! @name Fixed pipeline lighting (removed since 3.1) + + typedef void (APIENTRYP glShadeModel_t)(GLenum theMode); + glShadeModel_t glShadeModel; + + typedef void (APIENTRYP glLightf_t)(GLenum theLight, GLenum pname, GLfloat param); + glLightf_t glLightf; + + typedef void (APIENTRYP glLightfv_t)(GLenum theLight, GLenum pname, const GLfloat* params); + glLightfv_t glLightfv; + + typedef void (APIENTRYP glLightModeli_t)(GLenum pname, GLint param); + glLightModeli_t glLightModeli; + + typedef void (APIENTRYP glLightModelfv_t)(GLenum pname, const GLfloat* params); + glLightModelfv_t glLightModelfv; + + typedef void (APIENTRYP glMaterialf_t)(GLenum face, GLenum pname, GLfloat param); + glMaterialf_t glMaterialf; + + typedef void (APIENTRYP glMaterialfv_t)(GLenum face, GLenum pname, const GLfloat* params); + glMaterialfv_t glMaterialfv; + + typedef void (APIENTRYP glColorMaterial_t)(GLenum face, GLenum mode); + glColorMaterial_t glColorMaterial; + +public: //! @name clipping plane (removed since 3.1) + + typedef void (APIENTRYP glClipPlane_t)(GLenum thePlane, const GLdouble* theEquation); + glClipPlane_t glClipPlane; + +public: //! @name Display lists (removed since 3.1) + + typedef void (APIENTRYP glDeleteLists_t)(GLuint theList, GLsizei theRange); + glDeleteLists_t glDeleteLists; + + typedef GLuint (APIENTRYP glGenLists_t)(GLsizei theRange); + glGenLists_t glGenLists; + + typedef void (APIENTRYP glNewList_t)(GLuint theList, GLenum theMode); + glNewList_t glNewList; + + typedef void (APIENTRYP glEndList_t)(); + glEndList_t glEndList; + + typedef void (APIENTRYP glCallList_t)(GLuint theList); + glCallList_t glCallList; + + typedef void (APIENTRYP glCallLists_t)(GLsizei theNb, GLenum theType, const GLvoid* theLists); + glCallLists_t glCallLists; + + typedef void (APIENTRYP glListBase_t)(GLuint theBase); + glListBase_t glListBase; + +public: //! @name Current raster position and Rectangles (removed since 3.1) + + typedef void (APIENTRYP glRasterPos2i_t)(GLint x, GLint y); + glRasterPos2i_t glRasterPos2i; + + typedef void (APIENTRYP glRasterPos3fv_t)(const GLfloat* theVec); + glRasterPos3fv_t glRasterPos3fv; + +public: //! @name Texture mapping (removed since 3.1) + + typedef void (APIENTRYP glTexGeni_t)(GLenum coord, GLenum pname, GLint param); + glTexGeni_t glTexGeni; + + typedef void (APIENTRYP glTexGenfv_t)(GLenum coord, GLenum pname, const GLfloat* params); + glTexGenfv_t glTexGenfv; + +public: //! @name Pixel copying (removed since 3.1) + + typedef void (APIENTRYP glDrawPixels_t)(GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid* pixels); + glDrawPixels_t glDrawPixels; + + typedef void (APIENTRYP glCopyPixels_t)(GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type); + glCopyPixels_t glCopyPixels; + + typedef void (APIENTRYP glBitmap_t)(GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const GLubyte* bitmap); + glBitmap_t glBitmap; + +public: //! @name Edge flags and fixed-function vertex processing (removed since 3.1) + + typedef void (APIENTRYP glIndexPointer_t)(GLenum theType, GLsizei theStride, const GLvoid* thePtr); + glIndexPointer_t glIndexPointer; + + typedef void (APIENTRYP glVertexPointer_t)(GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr); + glVertexPointer_t glVertexPointer; + + typedef void (APIENTRYP glNormalPointer_t)(GLenum theType, GLsizei theStride, const GLvoid* thePtr); + glNormalPointer_t glNormalPointer; + + typedef void (APIENTRYP glColorPointer_t)(GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr); + glColorPointer_t glColorPointer; + + typedef void (APIENTRYP glTexCoordPointer_t)(GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr); + glTexCoordPointer_t glTexCoordPointer; + + typedef void (APIENTRYP glEnableClientState_t)(GLenum theCap); + glEnableClientState_t glEnableClientState; + + typedef void (APIENTRYP glDisableClientState_t)(GLenum theCap); + glDisableClientState_t glDisableClientState; + + typedef void (APIENTRYP glGetTexLevelParameterfv_t)(GLenum target, GLint level, GLenum pname, GLfloat *params); + glGetTexLevelParameterfv_t glGetTexLevelParameterfv; + + typedef void (APIENTRYP glGetTexLevelParameteriv_t)(GLenum target, GLint level, GLenum pname, GLint *params); + glGetTexLevelParameteriv_t glGetTexLevelParameteriv; + + typedef void (APIENTRYP glPolygonMode_t)(GLenum face, GLenum mode); + glPolygonMode_t glPolygonMode; public: //! @name OpenGL ES 3.2 + typedef void (APIENTRYP glBlendBarrier_t) (void); + glBlendBarrier_t glBlendBarrier; - opencascade::PFNGLBLENDBARRIERPROC glBlendBarrier; - opencascade::PFNGLCOPYIMAGESUBDATAPROC glCopyImageSubData; - opencascade::PFNGLPUSHDEBUGGROUPPROC glPushDebugGroup; - opencascade::PFNGLPOPDEBUGGROUPPROC glPopDebugGroup; - opencascade::PFNGLOBJECTLABELPROC glObjectLabel; - opencascade::PFNGLGETOBJECTLABELPROC glGetObjectLabel; - opencascade::PFNGLOBJECTPTRLABELPROC glObjectPtrLabel; - opencascade::PFNGLGETOBJECTPTRLABELPROC glGetObjectPtrLabel; - opencascade::PFNGLGETPOINTERVPROC glGetPointerv; - opencascade::PFNGLENABLEIPROC glEnablei; - opencascade::PFNGLDISABLEIPROC glDisablei; - opencascade::PFNGLBLENDEQUATIONIPROC glBlendEquationi; - opencascade::PFNGLBLENDEQUATIONSEPARATEIPROC glBlendEquationSeparatei; - opencascade::PFNGLBLENDFUNCIPROC glBlendFunci; - opencascade::PFNGLBLENDFUNCSEPARATEIPROC glBlendFuncSeparatei; - opencascade::PFNGLCOLORMASKIPROC glColorMaski; - opencascade::PFNGLISENABLEDIPROC glIsEnabledi; - opencascade::PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex; - opencascade::PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glDrawRangeElementsBaseVertex; - opencascade::PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glDrawElementsInstancedBaseVertex; - opencascade::PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture; - opencascade::PFNGLPRIMITIVEBOUNDINGBOXPROC glPrimitiveBoundingBox; - opencascade::PFNGLGETGRAPHICSRESETSTATUSPROC glGetGraphicsResetStatus; - opencascade::PFNGLREADNPIXELSPROC glReadnPixels; - opencascade::PFNGLGETNUNIFORMFVPROC glGetnUniformfv; - opencascade::PFNGLGETNUNIFORMIVPROC glGetnUniformiv; - opencascade::PFNGLGETNUNIFORMUIVPROC glGetnUniformuiv; - opencascade::PFNGLMINSAMPLESHADINGPROC glMinSampleShading; - opencascade::PFNGLPATCHPARAMETERIPROC glPatchParameteri; - opencascade::PFNGLTEXPARAMETERIIVPROC glTexParameterIiv; - opencascade::PFNGLTEXPARAMETERIUIVPROC glTexParameterIuiv; - opencascade::PFNGLGETTEXPARAMETERIIVPROC glGetTexParameterIiv; - opencascade::PFNGLGETTEXPARAMETERIUIVPROC glGetTexParameterIuiv; - opencascade::PFNGLSAMPLERPARAMETERIIVPROC glSamplerParameterIiv; - opencascade::PFNGLSAMPLERPARAMETERIUIVPROC glSamplerParameterIuiv; - opencascade::PFNGLGETSAMPLERPARAMETERIIVPROC glGetSamplerParameterIiv; - opencascade::PFNGLGETSAMPLERPARAMETERIUIVPROC glGetSamplerParameterIuiv; - opencascade::PFNGLTEXBUFFERPROC glTexBuffer; - opencascade::PFNGLTEXBUFFERRANGEPROC glTexBufferRange; - opencascade::PFNGLTEXSTORAGE3DMULTISAMPLEPROC glTexStorage3DMultisample; - -public: //! @name GL_KHR_debug (optional) or OpenGL ES 3.2+ - - opencascade::PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl; - opencascade::PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert; - opencascade::PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback; - opencascade::PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog; - -#else // OpenGL ES vs. desktop + typedef void (APIENTRYP glPrimitiveBoundingBox_t) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); + glPrimitiveBoundingBox_t glPrimitiveBoundingBox; public: //! @name OpenGL 1.2 @@ -1942,8 +1437,6 @@ public: //! @name glX extensions glXQueryCurrentRendererStringMESA_t glXQueryCurrentRendererStringMESA; #endif -#endif // OpenGL ES vs. desktop - }; #endif // _OpenGl_GlFunctions_Header diff --git a/src/OpenGl/OpenGl_GlNative.hxx b/src/OpenGl/OpenGl_GlNative.hxx new file mode 100644 index 0000000000..f65e33eb0a --- /dev/null +++ b/src/OpenGl/OpenGl_GlNative.hxx @@ -0,0 +1,67 @@ +// Copyright (c) 2021 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef OpenGl_GlNative_HeaderFile +#define OpenGl_GlNative_HeaderFile + +// required for correct APIENTRY definition +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) + #define WIN32_LEAN_AND_MEAN + #include +#endif + +#ifndef APIENTRY + #define APIENTRY +#endif +#ifndef APIENTRYP + #define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI + #define GLAPI extern +#endif + +#ifndef GL_APICALL + #define GL_APICALL GLAPI +#endif + +// exclude modern definitions and system-provided glext.h, should be defined before gl.h inclusion +#ifndef GL_GLEXT_LEGACY + #define GL_GLEXT_LEGACY +#endif +#ifndef GLX_GLXEXT_LEGACY + #define GLX_GLXEXT_LEGACY +#endif + +// include main OpenGL header provided with system +#if defined(__APPLE__) + #import + // macOS 10.4 deprecated OpenGL framework - suppress useless warnings + #define GL_SILENCE_DEPRECATION + #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE + #include + #else + #include + #endif + #define __X_GL_H // prevent chaotic gl.h inclusions to avoid compile errors +#elif defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) + #if defined(_WIN32) + // Angle OpenGL ES headers do not define function prototypes even for core functions, + // however OCCT is expected to be linked against libGLESv2 + #define GL_GLEXT_PROTOTYPES + #endif + #include +#else + #include +#endif + +#endif // OpenGl_GlNative_HeaderFile diff --git a/src/OpenGl/OpenGl_GlTypes.hxx b/src/OpenGl/OpenGl_GlTypes.hxx new file mode 100644 index 0000000000..1de86a6131 --- /dev/null +++ b/src/OpenGl/OpenGl_GlTypes.hxx @@ -0,0 +1,345 @@ +// Copyright (c) 2021 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef OpenGl_GlTypes_HeaderFile +#define OpenGl_GlTypes_HeaderFile + +#include + +typedef khronos_int8_t GLbyte; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef short GLshort; +typedef unsigned short GLushort; +typedef void GLvoid; +typedef struct __GLsync *GLsync; +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef unsigned int GLenum; +typedef unsigned int GLuint; +typedef char GLchar; +typedef khronos_float_t GLfloat; +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; +typedef unsigned int GLbitfield; +typedef int GLint; +typedef unsigned char GLboolean; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; + +typedef double GLdouble; +typedef double GLclampd; + +#define GL_NONE 0 + +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 + +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +#define GL_FRONT_AND_BACK 0x0408 + +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 + +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 + +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 + +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 + +#define GL_UNPACK_LSB_FIRST 0x0CF1 // only desktop +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_LSB_FIRST 0x0D01 // only desktop +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_ALIGNMENT 0x0D05 + +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A + +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE 0x1702 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLAMP 0x2900 +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 + +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_RED 0x1903 +#define GL_RGB8 0x8051 +#define GL_RGBA8 0x8058 + +// in core since OpenGL ES 3.0, extension GL_OES_rgb8_rgba8 +#define GL_LUMINANCE8 0x8040 +// GL_EXT_texture_format_BGRA8888 +#define GL_BGRA_EXT 0x80E1 // same as GL_BGRA on desktop + +#define GL_R16 0x822A +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_ALPHA8 0x803C +#define GL_ALPHA16 0x803E +#define GL_RG16 0x822C + +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B + +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 + +#define GL_DRAW_BUFFER 0x0C01 +#define GL_READ_BUFFER 0x0C02 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 + +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 + +// OpenGL ES 3.0+ or OES_texture_half_float +#define GL_HALF_FLOAT_OES 0x8D61 + +#endif // OpenGl_GlTypes_HeaderFile diff --git a/src/OpenGl/OpenGl_GraphicDriver.cxx b/src/OpenGl/OpenGl_GraphicDriver.cxx index b98795d318..448f53642b 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver.cxx @@ -14,7 +14,7 @@ // commercial license or contractual agreement. #if defined(_WIN32) - #include + #include // for UWP #endif #include @@ -59,6 +59,10 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraphicDriver,Graphic3d_GraphicDriver) #endif #endif +#if defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) + #define OpenGl_USE_GLES2 +#endif + namespace { static const Handle(OpenGl_Context) TheNullGlCtx; @@ -75,7 +79,7 @@ namespace EGL_ALPHA_SIZE, 0, EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8, - #if defined(GL_ES_VERSION_2_0) + #if defined(OpenGl_USE_GLES2) EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, #else EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, @@ -87,7 +91,7 @@ namespace EGLint aNbConfigs = 0; for (Standard_Integer aGlesVer = 3; aGlesVer >= 2; --aGlesVer) { - #if defined(GL_ES_VERSION_2_0) + #if defined(OpenGl_USE_GLES2) aConfigAttribs[6 * 2 + 1] = aGlesVer == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT; #else if (aGlesVer == 2) @@ -317,7 +321,7 @@ Standard_Boolean OpenGl_GraphicDriver::InitContext() return Standard_False; } -#if defined(GL_ES_VERSION_2_0) +#if defined(OpenGl_USE_GLES2) 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) diff --git a/src/OpenGl/OpenGl_LayerList.cxx b/src/OpenGl/OpenGl_LayerList.cxx index d12e38ea5f..efa7434541 100644 --- a/src/OpenGl/OpenGl_LayerList.cxx +++ b/src/OpenGl/OpenGl_LayerList.cxx @@ -573,11 +573,11 @@ void OpenGl_LayerList::renderLayer (const Handle(OpenGl_Workspace)& theWorkspace if (aLayerSettings.ToEnableDepthTest()) { // assuming depth test is enabled by default - glDepthFunc (theDefaultSettings.DepthFunc); + aCtx->core11fwd->glDepthFunc (theDefaultSettings.DepthFunc); } else { - glDepthFunc (GL_ALWAYS); + aCtx->core11fwd->glDepthFunc (GL_ALWAYS); } // save environment texture @@ -592,7 +592,7 @@ void OpenGl_LayerList::renderLayer (const Handle(OpenGl_Workspace)& theWorkspace // handle depth write theWorkspace->UseDepthWrite() = aLayerSettings.ToEnableDepthWrite() && theDefaultSettings.DepthMask == GL_TRUE; - glDepthMask (theWorkspace->UseDepthWrite() ? GL_TRUE : GL_FALSE); + aCtx->core11fwd->glDepthMask (theWorkspace->UseDepthWrite() ? GL_TRUE : GL_FALSE); const Standard_Boolean hasLocalCS = !aLayerSettings.OriginTransformation().IsNull(); const Handle(OpenGl_ShaderManager)& aManager = aCtx->ShaderManager(); @@ -863,8 +863,8 @@ void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace)& theWorkspace, if (aClearDepthLayer > aClearDepthLayerPrev) { aClearDepthLayerPrev = aClearDepthLayer; - glDepthMask (GL_TRUE); - glClear (GL_DEPTH_BUFFER_BIT); + aCtx->core11fwd->glDepthMask (GL_TRUE); + aCtx->core11fwd->glClear (GL_DEPTH_BUFFER_BIT); } } diff --git a/src/OpenGl/OpenGl_LineAttributes.cxx b/src/OpenGl/OpenGl_LineAttributes.cxx index aa53850aee..4ea3843aba 100644 --- a/src/OpenGl/OpenGl_LineAttributes.cxx +++ b/src/OpenGl/OpenGl_LineAttributes.cxx @@ -44,7 +44,6 @@ OpenGl_LineAttributes::~OpenGl_LineAttributes() // ======================================================================= void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx) { -#if !defined(GL_ES_VERSION_2_0) if (theGlCtx != NULL && theGlCtx->IsValid()) { @@ -53,9 +52,6 @@ void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx) theGlCtx->core11ffp->glDeleteLists ((GLuint)anIter.Value(), 1); } } -#else - (void )theGlCtx; -#endif myStyles.Clear(); } @@ -66,17 +62,11 @@ void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx) unsigned int OpenGl_LineAttributes::init (const OpenGl_Context* theGlCtx, const Handle(Graphic3d_HatchStyle)& theStyle) { -#if !defined(GL_ES_VERSION_2_0) const unsigned int aListId = theGlCtx->core11ffp->glGenLists(1); theGlCtx->core11ffp->glNewList ((GLuint)aListId, GL_COMPILE); theGlCtx->core11ffp->glPolygonStipple ((const GLubyte*)theStyle->Pattern()); theGlCtx->core11ffp->glEndList(); return aListId; -#else - (void )theGlCtx; - (void )theStyle; - return 0; -#endif } // ======================================================================= @@ -100,8 +90,6 @@ bool OpenGl_LineAttributes::SetTypeOfHatch (const OpenGl_Context* myStyles.Bind (theStyle, aGpuListId); } -#if !defined(GL_ES_VERSION_2_0) theGlCtx->core11ffp->glCallList ((GLuint)aGpuListId); -#endif return true; } diff --git a/src/OpenGl/OpenGl_PBREnvironment.cxx b/src/OpenGl/OpenGl_PBREnvironment.cxx index b6e83efd9c..80da3218dd 100644 --- a/src/OpenGl/OpenGl_PBREnvironment.cxx +++ b/src/OpenGl/OpenGl_PBREnvironment.cxx @@ -468,12 +468,11 @@ bool OpenGl_PBREnvironment::processSpecIBLMap (const Handle(OpenGl_Context)& the const bool canRenderMipmaps = theCtx->hasFboRenderMipmap; const OpenGl_TextureFormat aTexFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, myIBLMaps[OpenGl_TypeOfIBLMap_Specular].SizedFormat()); -#if !defined(GL_ES_VERSION_2_0) - const GLint anIntFormat = aTexFormat.InternalFormat(); -#else // ES 2.0 does not support sized formats and format conversions - them detected from data type - const GLint anIntFormat = theCtx->IsGlGreaterEqual (3, 0) ? aTexFormat.InternalFormat() : aTexFormat.PixelFormat(); -#endif + const GLint anIntFormat = (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES + || theCtx->IsGlGreaterEqual (3, 0)) + ? aTexFormat.InternalFormat() + : aTexFormat.PixelFormat(); for (int aLevelIter = mySpecMapLevelsNumber - 1;; --aLevelIter) { diff --git a/src/OpenGl/OpenGl_PointSprite.cxx b/src/OpenGl/OpenGl_PointSprite.cxx index acbe7d1f20..e188f6d8d2 100755 --- a/src/OpenGl/OpenGl_PointSprite.cxx +++ b/src/OpenGl/OpenGl_PointSprite.cxx @@ -59,9 +59,7 @@ void OpenGl_PointSprite::Release (OpenGl_Context* theGlCtx) if (theGlCtx->IsValid()) { - #if !defined(GL_ES_VERSION_2_0) - glDeleteLists (myBitmapList, 1); - #endif + theGlCtx->core11ffp->glDeleteLists (myBitmapList, 1); } myBitmapList = 0; } @@ -84,12 +82,10 @@ void OpenGl_PointSprite::SetDisplayList (const Handle(OpenGl_Context)& theCtx, // function : DrawBitmap // purpose : // ======================================================================= -void OpenGl_PointSprite::DrawBitmap (const Handle(OpenGl_Context)& ) const +void OpenGl_PointSprite::DrawBitmap (const Handle(OpenGl_Context)& theCtx) const { if (myBitmapList != 0) { - #if !defined(GL_ES_VERSION_2_0) - glCallList (myBitmapList); - #endif + theCtx->core11ffp->glCallList (myBitmapList); } } diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index b9f12d0992..fa37741aaf 100644 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -416,20 +416,19 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp const Graphic3d_Vec4* theFaceColors, const Standard_Boolean theHasVertColor) const { + const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext(); if (myVboAttribs.IsNull()) { - #if !defined(GL_ES_VERSION_2_0) - if (myDrawMode == GL_POINTS) + if (myDrawMode == GL_POINTS + && aGlContext->core11ffp != NULL) { // extreme compatibility mode - without sprites but with markers drawMarkers (theWorkspace); } - #endif return; } - const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext(); - const bool toHilight = theWorkspace->ToHighlight(); + const bool toHilight = theWorkspace->ToHighlight(); const GLenum aDrawMode = !aGlContext->ActiveProgram().IsNull() && aGlContext->ActiveProgram()->HasTessellationStage() ? GL_PATCHES @@ -452,14 +451,14 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp { const GLint aNbElemsInGroup = myBounds->Bounds[aGroupIter]; if (theFaceColors != NULL) aGlContext->SetColor4fv (theFaceColors[aGroupIter]); - glDrawElements (aDrawMode, aNbElemsInGroup, myVboIndices->GetDataType(), anOffset); + aGlContext->core11fwd->glDrawElements (aDrawMode, aNbElemsInGroup, myVboIndices->GetDataType(), anOffset); anOffset += aStride * aNbElemsInGroup; } } else { // draw one (or sequential) primitive by the indices - glDrawElements (aDrawMode, myVboIndices->GetElemsNb(), myVboIndices->GetDataType(), anOffset); + aGlContext->core11fwd->glDrawElements (aDrawMode, myVboIndices->GetElemsNb(), myVboIndices->GetDataType(), anOffset); } myVboIndices->Unbind (aGlContext); } @@ -470,7 +469,7 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp { const GLint aNbElemsInGroup = myBounds->Bounds[aGroupIter]; if (theFaceColors != NULL) aGlContext->SetColor4fv (theFaceColors[aGroupIter]); - glDrawArrays (aDrawMode, aFirstElem, aNbElemsInGroup); + aGlContext->core11fwd->glDrawArrays (aDrawMode, aFirstElem, aNbElemsInGroup); aFirstElem += aNbElemsInGroup; } } @@ -482,7 +481,7 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp } else { - glDrawArrays (aDrawMode, 0, myVboAttribs->GetElemsNb()); + aGlContext->core11fwd->glDrawArrays (aDrawMode, 0, myVboAttribs->GetElemsNb()); } } @@ -503,9 +502,7 @@ void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorksp } const OpenGl_Aspects* anAspect = theWorkspace->Aspects(); -#if !defined(GL_ES_VERSION_2_0) const Standard_Integer aPolyModeOld = aGlContext->SetPolygonMode (GL_LINE); -#endif if (aGlContext->core20fwd != NULL) { @@ -518,13 +515,11 @@ void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorksp && aGlContext->ActiveProgram()->HasTessellationStage() ? GL_PATCHES : myDrawMode; -#if !defined(GL_ES_VERSION_2_0) if (aGlContext->ActiveProgram().IsNull() && aGlContext->core11ffp != NULL) { aGlContext->core11fwd->glDisable (GL_LIGHTING); } -#endif /// OCC22236 NOTE: draw edges for all situations: /// 1) draw elements with GL_LINE style as edges from myPArray->bufferVBO[VBOEdges] indices array @@ -580,9 +575,7 @@ void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorksp myVboAttribs->UnbindAttribute (aGlContext, Graphic3d_TOA_POS); // restore line context -#if !defined(GL_ES_VERSION_2_0) aGlContext->SetPolygonMode (aPolyModeOld); -#endif } // ======================================================================= @@ -605,13 +598,12 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork return; } -#if !defined(GL_ES_VERSION_2_0) if (aCtx->core11ffp != NULL) { aCtx->core11fwd->glEnable (GL_ALPHA_TEST); aCtx->core11fwd->glAlphaFunc (GL_GEQUAL, 0.1f); } -#endif + aCtx->core11fwd->glEnable (GL_BLEND); aCtx->core11fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -625,7 +617,6 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork aCtx->SetPointSize (1.0f); } -#if !defined(GL_ES_VERSION_2_0) // Textured markers will be drawn with the glBitmap else if (const Handle(OpenGl_PointSprite)& aSprite = anAspectMarker->SpriteRes (aCtx, theWorkspace->ToHighlight())) { @@ -635,10 +626,8 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork aSprite->DrawBitmap (theWorkspace->GetGlContext()); } } -#endif aCtx->core11fwd->glDisable (GL_BLEND); -#if !defined(GL_ES_VERSION_2_0) if (aCtx->core11ffp != NULL) { if (aCtx->ShaderManager()->MaterialState().AlphaCutoff() >= ShortRealLast()) @@ -650,7 +639,6 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork aCtx->core11fwd->glAlphaFunc (GL_GEQUAL, aCtx->ShaderManager()->MaterialState().AlphaCutoff()); } } -#endif } // ======================================================================= @@ -696,13 +684,12 @@ OpenGl_PrimitiveArray::OpenGl_PrimitiveArray (const OpenGl_GraphicDriver* if (theDriver != NULL) { myUID = theDriver->GetNextPrimitiveArrayUID(); - #if defined (GL_ES_VERSION_2_0) const Handle(OpenGl_Context)& aCtx = theDriver->GetSharedContext(); - if (!aCtx.IsNull()) + if (!aCtx.IsNull() + && aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) { processIndices (aCtx); } - #endif } setDrawMode (theType); @@ -838,7 +825,6 @@ void OpenGl_PrimitiveArray::UpdateDrawStats (Graphic3d_FrameStatsDataTmp& theSta theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices - 4 * aNbBounds; break; } - #if !defined(GL_ES_VERSION_2_0) case GL_QUADS: { theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices / 2; @@ -849,7 +835,6 @@ void OpenGl_PrimitiveArray::UpdateDrawStats (Graphic3d_FrameStatsDataTmp& theSta theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += (aNbIndices / 2 - aNbBounds) * 2; break; } - #endif } } @@ -876,10 +861,10 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace { toDrawInteriorEdges = 1; toDrawArray = true; - #if !defined(GL_ES_VERSION_2_0) - if (anAspectFace->Aspect()->EdgeLineType() != Aspect_TOL_SOLID - || aCtx->hasGeometryStage == OpenGl_FeatureNotAvailable - || aCtx->caps->usePolygonMode) + if (aCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES + && (anAspectFace->Aspect()->EdgeLineType() != Aspect_TOL_SOLID + || aCtx->hasGeometryStage == OpenGl_FeatureNotAvailable + || aCtx->caps->usePolygonMode)) { toDrawInteriorEdges = 2; if (anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_EMPTY) @@ -894,7 +879,6 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace } } } - #endif } } else @@ -921,9 +905,10 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace // compatibility - keep data to draw markers using display lists Standard_Boolean toKeepData = myDrawMode == GL_POINTS && anAspectFace->IsDisplayListSprite (aCtx); - #if defined (GL_ES_VERSION_2_0) - processIndices (aCtx); - #endif + if (aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + processIndices (aCtx); + } buildVBO (aCtx, toKeepData); myIsVboInit = Standard_True; } @@ -984,14 +969,10 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace { aCtx->ShaderManager()->PushInteriorState (aCtx->ActiveProgram(), anAspectFace->Aspect()); } - #if !defined (GL_ES_VERSION_2_0) else if (toSetLinePolygMode) { aCtx->SetPolygonMode (GL_LINE); } - #else - (void )toSetLinePolygMode; - #endif break; } } @@ -1067,7 +1048,6 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace } } -#if !defined(GL_ES_VERSION_2_0) // draw triangulation edges using Polygon Mode if (toDrawInteriorEdges == 2) { @@ -1081,7 +1061,6 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace drawEdges (theWorkspace); } } -#endif } // ======================================================================= @@ -1141,7 +1120,6 @@ void OpenGl_PrimitiveArray::setDrawMode (const Graphic3d_TypeOfPrimitiveArray th myIsFillType = true; break; // - #if !defined(GL_ES_VERSION_2_0) case Graphic3d_TOPA_QUADRANGLES: myDrawMode = GL_QUADS; myIsFillType = true; @@ -1154,11 +1132,6 @@ void OpenGl_PrimitiveArray::setDrawMode (const Graphic3d_TypeOfPrimitiveArray th myDrawMode = GL_POLYGON; myIsFillType = true; break; - #else - case Graphic3d_TOPA_QUADRANGLES: - case Graphic3d_TOPA_QUADRANGLESTRIPS: - case Graphic3d_TOPA_POLYGONS: - #endif case Graphic3d_TOPA_UNDEFINED: myDrawMode = DRAW_MODE_NONE; myIsFillType = false; @@ -1218,9 +1191,11 @@ void OpenGl_PrimitiveArray::InitBuffers (const Handle(OpenGl_Context)& th myIndices = theIndices; myAttribs = theAttribs; myBounds = theBounds; -#if defined(GL_ES_VERSION_2_0) - processIndices (theContext); -#endif + if (!theContext.IsNull() + && theContext->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + processIndices (theContext); + } setDrawMode (theType); } diff --git a/src/OpenGl/OpenGl_Sampler.cxx b/src/OpenGl/OpenGl_Sampler.cxx index a793dda89d..45fe965044 100644 --- a/src/OpenGl/OpenGl_Sampler.cxx +++ b/src/OpenGl/OpenGl_Sampler.cxx @@ -217,12 +217,11 @@ void OpenGl_Sampler::applySamplerParams (const Handle(OpenGl_Context)& theCtx, // setup texture wrapping const GLenum aWrapMode = theParams->IsRepeat() ? GL_REPEAT : theCtx->TextureWrapClamp(); setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_WRAP_S, aWrapMode); -#if !defined(GL_ES_VERSION_2_0) if (theTarget == GL_TEXTURE_1D) { return; } -#endif + setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_WRAP_T, aWrapMode); if (theTarget == GL_TEXTURE_3D || theTarget == GL_TEXTURE_CUBE_MAP) @@ -284,11 +283,6 @@ void OpenGl_Sampler::applyGlobalTextureParams (const Handle(OpenGl_Context)& the const OpenGl_Texture& theTexture, const Handle(Graphic3d_TextureParams)& theParams) { -#if defined(GL_ES_VERSION_2_0) - (void )theCtx; - (void )theTexture; - (void )theParams; -#else if (theCtx->core11ffp == NULL || theParams->TextureUnit() >= theCtx->MaxTextureUnitsFFP()) { @@ -386,7 +380,6 @@ void OpenGl_Sampler::applyGlobalTextureParams (const Handle(OpenGl_Context)& the } default: break; } -#endif } // ======================================================================= @@ -397,11 +390,6 @@ void OpenGl_Sampler::resetGlobalTextureParams (const Handle(OpenGl_Context)& the const OpenGl_Texture& theTexture, const Handle(Graphic3d_TextureParams)& theParams) { -#if defined(GL_ES_VERSION_2_0) - (void )theCtx; - (void )theTexture; - (void )theParams; -#else if (theCtx->core11ffp == NULL) { return; @@ -442,5 +430,4 @@ void OpenGl_Sampler::resetGlobalTextureParams (const Handle(OpenGl_Context)& the } default: break; } -#endif } diff --git a/src/OpenGl/OpenGl_ShaderManager.cxx b/src/OpenGl/OpenGl_ShaderManager.cxx index 04efdf9a1e..892cc020a5 100644 --- a/src/OpenGl/OpenGl_ShaderManager.cxx +++ b/src/OpenGl/OpenGl_ShaderManager.cxx @@ -30,8 +30,6 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_ShaderManager, Graphic3d_ShaderManager) namespace { -#if !defined(GL_ES_VERSION_2_0) - static const GLfloat THE_DEFAULT_AMBIENT[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; static const GLfloat THE_DEFAULT_SPOT_DIR[3] = { 0.0f, 0.0f, -1.0f }; static const GLfloat THE_DEFAULT_SPOT_EXPONENT = 0.0f; @@ -112,9 +110,8 @@ namespace theCtx->core11ffp->glLoadMatrixf (theModelView.GetData()); } - glEnable (theLightGlId); + theCtx->core11fwd->glEnable (theLightGlId); } -#endif } // ======================================================================= @@ -122,11 +119,7 @@ namespace // purpose : Creates new empty shader manager // ======================================================================= OpenGl_ShaderManager::OpenGl_ShaderManager (OpenGl_Context* theContext) -#if defined(GL_ES_VERSION_2_0) -: Graphic3d_ShaderManager (Aspect_GraphicsLibrary_OpenGLES), -#else -: Graphic3d_ShaderManager (Aspect_GraphicsLibrary_OpenGL), -#endif +: Graphic3d_ShaderManager (theContext->GraphicsLibrary()), myFfpProgram (new OpenGl_ShaderProgramFFP()), myShadingModel (Graphic3d_TypeOfShadingModel_Gouraud), myUnlitPrograms (new OpenGl_SetOfPrograms()), @@ -366,7 +359,6 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr theProgram->UpdateState (OpenGl_LIGHT_SOURCES_STATE, myLightSourceState.Index()); if (theProgram == myFfpProgram) { - #if !defined(GL_ES_VERSION_2_0) if (myContext->core11ffp == NULL) { return; @@ -409,7 +401,6 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr { myContext->core11fwd->glDisable (aLightGlId); } - #endif return; } @@ -596,13 +587,11 @@ void OpenGl_ShaderManager::pushProjectionState (const Handle(OpenGl_ShaderProgra theProgram->UpdateState (OpenGl_PROJECTION_STATE, myProjectionState.Index()); if (theProgram == myFfpProgram) { - #if !defined(GL_ES_VERSION_2_0) if (myContext->core11ffp != NULL) { myContext->core11ffp->glMatrixMode (GL_PROJECTION); myContext->core11ffp->glLoadMatrixf (myProjectionState.ProjectionMatrix().GetData()); } - #endif return; } @@ -636,7 +625,6 @@ void OpenGl_ShaderManager::pushModelWorldState (const Handle(OpenGl_ShaderProgra theProgram->UpdateState (OpenGl_MODEL_WORLD_STATE, myModelWorldState.Index()); if (theProgram == myFfpProgram) { - #if !defined(GL_ES_VERSION_2_0) if (myContext->core11ffp != NULL) { const OpenGl_Mat4 aModelView = myWorldViewState.WorldViewMatrix() * myModelWorldState.ModelWorldMatrix(); @@ -644,7 +632,6 @@ void OpenGl_ShaderManager::pushModelWorldState (const Handle(OpenGl_ShaderProgra myContext->core11ffp->glLoadMatrixf (aModelView.GetData()); theProgram->UpdateState (OpenGl_WORLD_VIEW_STATE, myWorldViewState.Index()); } - #endif return; } @@ -683,7 +670,6 @@ void OpenGl_ShaderManager::pushWorldViewState (const Handle(OpenGl_ShaderProgram theProgram->UpdateState (OpenGl_WORLD_VIEW_STATE, myWorldViewState.Index()); if (theProgram == myFfpProgram) { - #if !defined(GL_ES_VERSION_2_0) if (myContext->core11ffp != NULL) { const OpenGl_Mat4 aModelView = myWorldViewState.WorldViewMatrix() * myModelWorldState.ModelWorldMatrix(); @@ -691,7 +677,6 @@ void OpenGl_ShaderManager::pushWorldViewState (const Handle(OpenGl_ShaderProgram myContext->core11ffp->glLoadMatrixf (aModelView.GetData()); theProgram->UpdateState (OpenGl_MODEL_WORLD_STATE, myModelWorldState.Index()); } - #endif return; } @@ -743,7 +728,6 @@ void OpenGl_ShaderManager::pushClippingState (const Handle(OpenGl_ShaderProgram) theProgram->UpdateState (OpenGl_CLIP_PLANES_STATE, myClippingState.Index()); if (theProgram == myFfpProgram) { - #if !defined(GL_ES_VERSION_2_0) if (myContext->core11ffp == NULL) { return; @@ -814,7 +798,6 @@ void OpenGl_ShaderManager::pushClippingState (const Handle(OpenGl_ShaderProgram) const OpenGl_Mat4 aModelView = myWorldViewState.WorldViewMatrix() * myModelWorldState.ModelWorldMatrix(); myContext->core11ffp->glLoadMatrixf (aModelView.GetData()); } - #endif return; } @@ -917,7 +900,6 @@ void OpenGl_ShaderManager::pushMaterialState (const Handle(OpenGl_ShaderProgram) theProgram->UpdateState (OpenGl_MATERIAL_STATE, myMaterialState.Index()); if (theProgram == myFfpProgram) { - #if !defined(GL_ES_VERSION_2_0) if (myContext->core11ffp == NULL) { return; @@ -951,7 +933,6 @@ void OpenGl_ShaderManager::pushMaterialState (const Handle(OpenGl_ShaderProgram) myContext->core11ffp->glMaterialfv(GL_BACK, GL_EMISSION, aBackMat.Emission.GetData()); myContext->core11ffp->glMaterialf (GL_BACK, GL_SHININESS, aBackMat.Shine()); } - #endif return; } @@ -1050,7 +1031,6 @@ void OpenGl_ShaderManager::PushState (const Handle(OpenGl_ShaderProgram)& thePro (float )myContext->Viewport()[2], (float )myContext->Viewport()[3])); } } -#if !defined(GL_ES_VERSION_2_0) else if (myContext->core11ffp != NULL) { // manage FFP lighting @@ -1064,9 +1044,6 @@ void OpenGl_ShaderManager::PushState (const Handle(OpenGl_ShaderProgram)& thePro myContext->core11fwd->glEnable (GL_LIGHTING); } } -#else - (void )theShadingModel; -#endif } // ======================================================================= diff --git a/src/OpenGl/OpenGl_ShaderProgram.cxx b/src/OpenGl/OpenGl_ShaderProgram.cxx index 55971d5e09..51143e1bd2 100755 --- a/src/OpenGl/OpenGl_ShaderProgram.cxx +++ b/src/OpenGl/OpenGl_ShaderProgram.cxx @@ -217,102 +217,105 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)& } // detect the minimum GLSL version required for defined Shader Objects -#if defined(GL_ES_VERSION_2_0) - if (myHasTessShader) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) { - if (!theCtx->IsGlGreaterEqual (3, 2)) + if (myHasTessShader) { - theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, - "Error! Tessellation shader requires OpenGL ES 3.2+"); - return false; - } - else if (aHeaderVer.IsEmpty()) - { - aHeaderVer = "#version 320 es"; - } - } - else if ((aShaderMask & Graphic3d_TOS_GEOMETRY) != 0) - { - switch (theCtx->hasGeometryStage) - { - case OpenGl_FeatureNotAvailable: + if (!theCtx->IsGlGreaterEqual (3, 2)) { theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, - "Error! Geometry shader requires OpenGL ES 3.2+ or GL_EXT_geometry_shader"); + "Error! Tessellation shader requires OpenGL ES 3.2+"); return false; } - case OpenGl_FeatureInExtensions: + else if (aHeaderVer.IsEmpty()) { - if (aHeaderVer.IsEmpty()) - { - aHeaderVer = "#version 310 es"; - } - break; + aHeaderVer = "#version 320 es"; } - case OpenGl_FeatureInCore: + } + else if ((aShaderMask & Graphic3d_TOS_GEOMETRY) != 0) + { + switch (theCtx->hasGeometryStage) { - if (aHeaderVer.IsEmpty()) + case OpenGl_FeatureNotAvailable: { - aHeaderVer = "#version 320 es"; + theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, + "Error! Geometry shader requires OpenGL ES 3.2+ or GL_EXT_geometry_shader"); + return false; } - break; + case OpenGl_FeatureInExtensions: + { + if (aHeaderVer.IsEmpty()) + { + aHeaderVer = "#version 310 es"; + } + break; + } + case OpenGl_FeatureInCore: + { + if (aHeaderVer.IsEmpty()) + { + aHeaderVer = "#version 320 es"; + } + break; + } + } + } + else if ((aShaderMask & Graphic3d_TOS_COMPUTE) != 0) + { + if (!theCtx->IsGlGreaterEqual (3, 1)) + { + theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, + "Error! Compute shaders require OpenGL ES 3.1+"); + return false; + } + else if (aHeaderVer.IsEmpty()) + { + aHeaderVer = "#version 310 es"; } } } - else if ((aShaderMask & Graphic3d_TOS_COMPUTE) != 0) + else { - if (!theCtx->IsGlGreaterEqual (3, 1)) + if ((aShaderMask & Graphic3d_TOS_COMPUTE) != 0) { - theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, - "Error! Compute shaders require OpenGL ES 3.1+"); - return false; + if (!theCtx->IsGlGreaterEqual (4, 3)) + { + theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, + "Error! Compute shaders require OpenGL 4.3+"); + return 0; + } + else if (aHeaderVer.IsEmpty()) + { + aHeaderVer = "#version 430"; + } } - else if (aHeaderVer.IsEmpty()) + else if (myHasTessShader) { - aHeaderVer = "#version 310 es"; + if (!theCtx->IsGlGreaterEqual (4, 0)) + { + theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, + "Error! Tessellation shaders require OpenGL 4.0+"); + return 0; + } + else if (aHeaderVer.IsEmpty()) + { + aHeaderVer = "#version 400"; + } + } + else if ((aShaderMask & Graphic3d_TOS_GEOMETRY) != 0) + { + if (!theCtx->IsGlGreaterEqual (3, 2)) + { + theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, + "Error! Geometry shaders require OpenGL 3.2+"); + return 0; + } + else if (aHeaderVer.IsEmpty()) + { + aHeaderVer = "#version 150"; + } } } -#else - if ((aShaderMask & Graphic3d_TOS_COMPUTE) != 0) - { - if (!theCtx->IsGlGreaterEqual (4, 3)) - { - theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, - "Error! Compute shaders require OpenGL 4.3+"); - return 0; - } - else if (aHeaderVer.IsEmpty()) - { - aHeaderVer = "#version 430"; - } - } - else if (myHasTessShader) - { - if (!theCtx->IsGlGreaterEqual (4, 0)) - { - theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, - "Error! Tessellation shaders require OpenGL 4.0+"); - return 0; - } - else if (aHeaderVer.IsEmpty()) - { - aHeaderVer = "#version 400"; - } - } - else if ((aShaderMask & Graphic3d_TOS_GEOMETRY) != 0) - { - if (!theCtx->IsGlGreaterEqual (3, 2)) - { - theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, - "Error! Geometry shaders require OpenGL 3.2+"); - return 0; - } - else if (aHeaderVer.IsEmpty()) - { - aHeaderVer = "#version 150"; - } - } -#endif for (Graphic3d_ShaderObjectList::Iterator anIter (theShaders); anIter.More(); anIter.Next()) { @@ -380,36 +383,34 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)& if (theCtx->hasSampleVariables == OpenGl_FeatureInExtensions) { -#if defined(GL_ES_VERSION_2_0) - if (theCtx->oesSampleVariables) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + && theCtx->oesSampleVariables) { anExtensions += "#extension GL_OES_sample_variables : enable\n"; } -#else - if (theCtx->arbSampleShading) + else if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGL + && theCtx->arbSampleShading) { anExtensions += "#extension GL_ARB_sample_shading : enable\n"; } -#endif } -#if defined(GL_ES_VERSION_2_0) - if (theCtx->hasGeometryStage == OpenGl_FeatureInExtensions) + + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + && theCtx->hasGeometryStage == OpenGl_FeatureInExtensions) { anExtensions += "#extension GL_EXT_geometry_shader : enable\n" "#extension GL_EXT_shader_io_blocks : enable\n"; } -#endif TCollection_AsciiString aPrecisionHeader; - if (anIter.Value()->Type() == Graphic3d_TOS_FRAGMENT) + if (anIter.Value()->Type() == Graphic3d_TOS_FRAGMENT + && theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) { - #if defined(GL_ES_VERSION_2_0) aPrecisionHeader = theCtx->hasHighp ? "precision highp float;\n" "precision highp int;\n" : "precision mediump float;\n" "precision mediump int;\n"; - #endif } TCollection_AsciiString aHeaderType; @@ -999,19 +1000,23 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& return false; } -#if !defined(GL_ES_VERSION_2_0) - if (theCtx->core32 != NULL) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) { - theCtx->core32->glUniform2uiv (theLocation, 1, theValue.GetData()); - return true; + if (theCtx->core30 != NULL) + { + theCtx->core30->glUniform2uiv (theLocation, 1, theValue.GetData()); + return true; + } } -#else - if (theCtx->core30 != NULL) + else { - theCtx->core30->glUniform2uiv (theLocation, 1, theValue.GetData()); - return true; + if (theCtx->core32 != NULL) + { + theCtx->core32->glUniform2uiv (theLocation, 1, theValue.GetData()); + return true; + } } -#endif + return false; } @@ -1041,19 +1046,22 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)& return false; } -#if !defined(GL_ES_VERSION_2_0) - if (theCtx->core32 != NULL) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) { - theCtx->core32->glUniform2uiv (theLocation, theCount, theValue->GetData()); - return true; + if (theCtx->core30 != NULL) + { + theCtx->core30->glUniform2uiv (theLocation, theCount, theValue->GetData()); + return true; + } } -#else - if (theCtx->core30 != NULL) + else { - theCtx->core30->glUniform2uiv (theLocation, theCount, theValue->GetData()); - return true; + if (theCtx->core32 != NULL) + { + theCtx->core32->glUniform2uiv (theLocation, theCount, theValue->GetData()); + return true; + } } -#endif return false; } diff --git a/src/OpenGl/OpenGl_StencilTest.cxx b/src/OpenGl/OpenGl_StencilTest.cxx index 12af1e30a4..ea3b0c92dd 100755 --- a/src/OpenGl/OpenGl_StencilTest.cxx +++ b/src/OpenGl/OpenGl_StencilTest.cxx @@ -15,6 +15,8 @@ #include #include +#include +#include #include OpenGl_StencilTest::OpenGl_StencilTest() @@ -26,16 +28,17 @@ OpenGl_StencilTest::OpenGl_StencilTest() // function : Render // purpose : // ======================================================================= -void OpenGl_StencilTest::Render (const Handle(OpenGl_Workspace)&) const +void OpenGl_StencilTest::Render (const Handle(OpenGl_Workspace)& theWorkspace) const { + const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext(); if (myIsEnabled) { - glEnable (GL_STENCIL_TEST); - glStencilFunc (GL_NOTEQUAL, 1, 0xFF); + aCtx->core11fwd->glEnable (GL_STENCIL_TEST); + aCtx->core11fwd->glStencilFunc (GL_NOTEQUAL, 1, 0xFF); } else { - glDisable (GL_STENCIL_TEST); + aCtx->core11fwd->glDisable (GL_STENCIL_TEST); } } diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index 722df45c7d..9e4c4bfa98 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -59,7 +59,6 @@ void OpenGl_Structure::renderBoundingBox (const Handle(OpenGl_Workspace)& theWor aCtx->core20fwd->glDrawArrays (GL_LINES, 0, aBoundBoxVertBuffer->GetElemsNb()); aBoundBoxVertBuffer->UnbindAttribute(aCtx, Graphic3d_TOA_POS); } -#if !defined(GL_ES_VERSION_2_0) else if (aCtx->core11ffp != NULL) { const Graphic3d_Vec3d aMind = myBndBox.CornerMin() + aMoveVec; @@ -94,7 +93,6 @@ void OpenGl_Structure::renderBoundingBox (const Handle(OpenGl_Workspace)& theWor aCtx->core11fwd->glDrawArrays (GL_LINE_STRIP, 0, 16); aCtx->core11ffp->glDisableClientState (GL_VERTEX_ARRAY); } -#endif aCtx->BindTextures (aPrevTexture, Handle(OpenGl_ShaderProgram)()); } @@ -444,7 +442,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con aModelWorld = myRenderTrsf; const Standard_Boolean anOldGlNormalize = aCtx->IsGlNormalizeEnabled(); -#if !defined(GL_ES_VERSION_2_0) + // detect scale transform if (aCtx->core11ffp != NULL && !myTrsf.IsNull()) @@ -455,7 +453,6 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con aCtx->SetGlNormalizeEnabled (Standard_True); } } -#endif bool anOldCastShadows = false; #ifdef GL_DEPTH_CLAMP @@ -703,7 +700,6 @@ void OpenGl_Structure::applyPersistence (const Handle(OpenGl_Context)& theCtx, theCtx->VirtualViewport()[2], theCtx->VirtualViewport()[3]); } -#if !defined(GL_ES_VERSION_2_0) if (!theCtx->IsGlNormalizeEnabled() && theCtx->core11ffp != NULL) { @@ -713,7 +709,6 @@ void OpenGl_Structure::applyPersistence (const Handle(OpenGl_Context)& theCtx, theCtx->SetGlNormalizeEnabled (true); } } -#endif } // ======================================================================= diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index f27d9d6c7e..9f439522d1 100644 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -375,10 +375,8 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx, unsigned int theResolution, Font_Hinting theFontHinting) const { -#if !defined(GL_ES_VERSION_2_0) const Standard_Integer aPrevPolygonMode = theCtx->SetPolygonMode (GL_FILL); const bool aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false); -#endif render (theCtx, theTextAspect, theTextAspect.Aspect()->ColorRGBA(), @@ -386,10 +384,8 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx, theResolution, theFontHinting); -#if !defined(GL_ES_VERSION_2_0) theCtx->SetPolygonMode (aPrevPolygonMode); theCtx->SetPolygonHatchEnabled (aPrevHatchingMode); -#endif } // ======================================================================= @@ -645,13 +641,12 @@ void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx, Graphic3d_AlphaMode_Opaque, Standard_False, Standard_False, Handle(OpenGl_ShaderProgram)()); -#if !defined(GL_ES_VERSION_2_0) if (theCtx->core11ffp != NULL && theCtx->ActiveProgram().IsNull()) { theCtx->core11fwd->glBindTexture (GL_TEXTURE_2D, 0); } -#endif + theCtx->SetColor4fv (theColorSubs); setupMatrix (theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f)); myBndVertsVbo->BindAttribute (theCtx, Graphic3d_TOA_POS); @@ -759,13 +754,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, } } -#if !defined(GL_ES_VERSION_2_0) if (theCtx->core11ffp != NULL && theCtx->caps->ffpEnable) { theCtx->core11fwd->glDisable (GL_LIGHTING); } -#endif // setup depth test const bool hasDepthTest = !myIs2d @@ -779,14 +772,13 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, { theCtx->core15fwd->glActiveTexture (GL_TEXTURE0); } -#if !defined(GL_ES_VERSION_2_0) + // activate texture unit if (theCtx->core11ffp != NULL && theCtx->ActiveProgram().IsNull()) { const Handle(OpenGl_Texture)& aTexture = myFont->Texture(); OpenGl_Sampler::applyGlobalTextureParams (theCtx, *aTexture, aTexture->Sampler()->Parameters()); } -#endif // setup blending if (theTextAspect.Aspect()->AlphaMode() == Graphic3d_AlphaMode_MaskBlend) @@ -803,10 +795,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, { case Aspect_TODT_BLEND: { - #if !defined(GL_ES_VERSION_2_0) - theCtx->core11fwd->glEnable (GL_COLOR_LOGIC_OP); - theCtx->core11ffp->glLogicOp (GL_XOR); - #endif + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGL) + { + theCtx->core11fwd->glEnable (GL_COLOR_LOGIC_OP); + theCtx->core11fwd->glLogicOp (GL_XOR); + } break; } case Aspect_TODT_SUBTITLE: @@ -855,13 +848,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, theCtx->ApplyProjectionMatrix(); } -#if !defined(GL_ES_VERSION_2_0) if (theCtx->core11ffp != NULL && theCtx->ActiveProgram().IsNull()) { const Handle(OpenGl_Texture)& aTexture = myFont->Texture(); OpenGl_Sampler::resetGlobalTextureParams (theCtx, *aTexture, aTexture->Sampler()->Parameters()); } -#endif if (theTextAspect.Aspect()->TextDisplayType() == Aspect_TODT_DIMENSION) { @@ -873,12 +864,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, { theCtx->core11fwd->glDisable (GL_DEPTH_TEST); } - #if !defined(GL_ES_VERSION_2_0) if (theCtx->core11ffp != NULL) { theCtx->core11fwd->glDisable (GL_TEXTURE_2D); } - #endif + const bool aColorMaskBack = theCtx->SetColorMask (false); theCtx->core11fwd->glClear (GL_STENCIL_BUFFER_BIT); @@ -899,9 +889,10 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, theCtx->core11fwd->glDisable (GL_BLEND); } theCtx->core11fwd->glDisable (GL_STENCIL_TEST); -#if !defined(GL_ES_VERSION_2_0) - theCtx->core11fwd->glDisable (GL_COLOR_LOGIC_OP); -#endif + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGL) + { + theCtx->core11fwd->glDisable (GL_COLOR_LOGIC_OP); + } // model view matrix was modified theCtx->WorldViewState.Pop(); diff --git a/src/OpenGl/OpenGl_Texture.cxx b/src/OpenGl/OpenGl_Texture.cxx index 1d1933ff23..655e02001a 100644 --- a/src/OpenGl/OpenGl_Texture.cxx +++ b/src/OpenGl/OpenGl_Texture.cxx @@ -244,13 +244,10 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, return false; } -#if !defined(GL_ES_VERSION_2_0) - const GLenum aTarget = theType == Graphic3d_TOT_1D + const GLenum aTarget = (theType == Graphic3d_TOT_1D + && theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES) ? GL_TEXTURE_1D : GL_TEXTURE_2D; -#else - const GLenum aTarget = GL_TEXTURE_2D; -#endif const bool toPatchExisting = IsValid() && myTextFormat == theFormat.PixelFormat() && myTarget == aTarget @@ -280,12 +277,12 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, myTextFormat = theFormat.PixelFormat(); mySizedFormat = theFormat.InternalFormat(); myNbSamples = 1; -#if !defined(GL_ES_VERSION_2_0) - const GLint anIntFormat = theFormat.InternalFormat(); -#else + // ES 2.0 does not support sized formats and format conversions - them detected from data type - const GLint anIntFormat = theCtx->IsGlGreaterEqual (3, 0) ? theFormat.InternalFormat() : theFormat.PixelFormat(); -#endif + const GLint anIntFormat = (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES + || theCtx->IsGlGreaterEqual (3, 0)) + ? theFormat.InternalFormat() + : theFormat.PixelFormat(); if (theFormat.DataType() == GL_FLOAT && !theCtx->arbTexFloat) @@ -307,8 +304,9 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, Release (theCtx.get()); return false; } -#if !defined(GL_ES_VERSION_2_0) - else if (!theCtx->IsGlGreaterEqual (3, 0) && !theCtx->arbNPTW) + else if (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGL + && !theCtx->IsGlGreaterEqual (3, 0) + && !theCtx->arbNPTW) { // Notice that formally general NPOT textures are required by OpenGL 2.0 specifications // however some hardware (NV30 - GeForce FX, RadeOn 9xxx and Xxxx) supports GLSL but not NPOT! @@ -326,8 +324,9 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, return false; } } -#else - else if (!theCtx->IsGlGreaterEqual (3, 0) && theType == Graphic3d_TOT_2D_MIPMAP) + else if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + && !theCtx->IsGlGreaterEqual (3, 0) + && theType == Graphic3d_TOT_2D_MIPMAP) { // Mipmap NPOT textures are not supported by OpenGL ES 2.0. const GLsizei aWidthP2 = OpenGl_Context::GetPowerOfTwo (theSizeXY.x(), aMaxSize); @@ -341,11 +340,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, myMaxMipLevel = 0; } } -#endif -#if !defined(GL_ES_VERSION_2_0) GLint aTestWidth = 0, aTestHeight = 0; -#endif GLvoid* aDataPtr = (theImage != NULL) ? (GLvoid* )theImage->Data() : NULL; // setup the alignment @@ -376,7 +372,14 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, { case Graphic3d_TOT_1D: { - #if !defined(GL_ES_VERSION_2_0) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, + TCollection_AsciiString ( "Error: 1D textures are not supported by hardware [") + myResourceId +"]"); + Release (theCtx.get()); + return false; + } + Bind (theCtx); applyDefaultSamplerParams (theCtx); if (toPatchExisting) @@ -391,8 +394,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, theCtx->core11fwd->glTexImage1D (GL_PROXY_TEXTURE_1D, 0, anIntFormat, theSizeXY.x(), 0, theFormat.PixelFormat(), theFormat.DataType(), NULL); - glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &aTestWidth); - glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat); + theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &aTestWidth); + theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat); if (aTestWidth == 0) { // no memory or broken input parameters @@ -416,12 +419,6 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, Unbind (theCtx); return true; - #else - theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, - TCollection_AsciiString ( "Error: 1D textures are not supported by hardware [") + myResourceId +"]"); - Release (theCtx.get()); - return false; - #endif } case Graphic3d_TOT_2D: case Graphic3d_TOT_2D_MIPMAP: @@ -449,22 +446,23 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, return true; } - #if !defined(GL_ES_VERSION_2_0) - // use proxy to check texture could be created or not - theCtx->core11fwd->glTexImage2D (GL_PROXY_TEXTURE_2D, 0, anIntFormat, - theSizeXY.x(), theSizeXY.y(), 0, - theFormat.PixelFormat(), theFormat.DataType(), NULL); - glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestWidth); - glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &aTestHeight); - glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat); - if (aTestWidth == 0 || aTestHeight == 0) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGL) { - // no memory or broken input parameters - Unbind (theCtx); - Release (theCtx.get()); - return false; + // use proxy to check texture could be created or not + theCtx->core11fwd->glTexImage2D (GL_PROXY_TEXTURE_2D, 0, anIntFormat, + theSizeXY.x(), theSizeXY.y(), 0, + theFormat.PixelFormat(), theFormat.DataType(), NULL); + theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestWidth); + theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &aTestHeight); + theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat); + if (aTestWidth == 0 || aTestHeight == 0) + { + // no memory or broken input parameters + Unbind (theCtx); + Release (theCtx.get()); + return false; + } } - #endif theCtx->core11fwd->glTexImage2D (GL_TEXTURE_2D, 0, anIntFormat, theSizeXY.x(), theSizeXY.y(), 0, @@ -496,16 +494,15 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, if (anErr != GL_NO_ERROR) { myMaxMipLevel = 0; - #if defined(GL_ES_VERSION_2_0) - if (theFormat.InternalFormat() == GL_RGB8 - || theFormat.InternalFormat() == GL_SRGB8) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + && (theFormat.InternalFormat() == GL_RGB8 + || theFormat.InternalFormat() == GL_SRGB8)) { theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH, TCollection_AsciiString ("Warning: generating mipmaps requires color-renderable format, while giving ") + OpenGl_TextureFormat::FormatFormat (anIntFormat) + " [" + myResourceId +"]"); } else - #endif { theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH, TCollection_AsciiString ("Warning: generating mipmaps has failed [") + myResourceId +"]"); @@ -737,17 +734,15 @@ bool OpenGl_Texture::Init2DMultisample (const Handle(OpenGl_Context)& theCtx, //myTextFormat = theTextFormat; mySizedFormat = theTextFormat; if (theCtx->HasTextureMultisampling() - && theCtx->Functions()->glTexStorage2DMultisample != NULL) + && theCtx->Functions()->glTexStorage2DMultisample != NULL) // OpenGL 4.3 { theCtx->Functions()->glTexStorage2DMultisample (myTarget, myNbSamples, theTextFormat, theSizeX, theSizeY, GL_FALSE); } -#if !defined(GL_ES_VERSION_2_0) else if (theCtx->HasTextureMultisampling() - && theCtx->Functions()->glTexImage2DMultisample != NULL) + && theCtx->Functions()->glTexImage2DMultisample != NULL) // OpenGL 3.2 { theCtx->Functions()->glTexImage2DMultisample (myTarget, myNbSamples, theTextFormat, theSizeX, theSizeY, GL_FALSE); } -#endif else { theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, @@ -783,12 +778,13 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx, const Standard_Integer theSizeY, const OpenGl_TextureFormat& theFormat) { - if (!Create (theCtx) || !theCtx->IsGlGreaterEqual (3, 0)) + if (!theCtx->IsGlGreaterEqual (3, 0) + || !Create (theCtx) + || theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) { return false; } -#if !defined(GL_ES_VERSION_2_0) myTarget = GL_TEXTURE_RECTANGLE; myNbSamples = 1; myMaxMipLevel = 0; @@ -810,9 +806,9 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx, myTextFormat, GL_FLOAT, NULL); GLint aTestSizeX = 0, aTestSizeY = 0; - glGetTexLevelParameteriv (GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_WIDTH, &aTestSizeX); - glGetTexLevelParameteriv (GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_HEIGHT, &aTestSizeY); - glGetTexLevelParameteriv (GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat); + theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_WIDTH, &aTestSizeX); + theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_HEIGHT, &aTestSizeY); + theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat); if (aTestSizeX == 0 || aTestSizeY == 0) { Unbind (theCtx); @@ -832,12 +828,6 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx, mySizeY = aSizeY; Unbind (theCtx); return true; -#else - (void )theSizeX; - (void )theSizeY; - (void )theFormat; - return false; -#endif } // ======================================================================= @@ -891,23 +881,24 @@ bool OpenGl_Texture::Init3D (const Handle(OpenGl_Context)& theCtx, // setup the alignment OpenGl_UnpackAlignmentSentry::Reset (*theCtx); -#if !defined (GL_ES_VERSION_2_0) - theCtx->core15fwd->glTexImage3D (GL_PROXY_TEXTURE_3D, 0, mySizedFormat, - aSizeXYZ.x(), aSizeXYZ.y(), aSizeXYZ.z(), 0, - theFormat.PixelFormat(), theFormat.DataType(), NULL); - - NCollection_Vec3 aTestSizeXYZ; - glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &aTestSizeXYZ.x()); - glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_HEIGHT, &aTestSizeXYZ.y()); - glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_DEPTH, &aTestSizeXYZ.z()); - glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat); - if (aTestSizeXYZ.x() == 0 || aTestSizeXYZ.y() == 0 || aTestSizeXYZ.z() == 0) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGL) { - Unbind (theCtx); - Release (theCtx.get()); - return false; + theCtx->Functions()->glTexImage3D (GL_PROXY_TEXTURE_3D, 0, mySizedFormat, + aSizeXYZ.x(), aSizeXYZ.y(), aSizeXYZ.z(), 0, + theFormat.PixelFormat(), theFormat.DataType(), NULL); + + NCollection_Vec3 aTestSizeXYZ; + theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &aTestSizeXYZ.x()); + theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_HEIGHT, &aTestSizeXYZ.y()); + theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_DEPTH, &aTestSizeXYZ.z()); + theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat); + if (aTestSizeXYZ.x() == 0 || aTestSizeXYZ.y() == 0 || aTestSizeXYZ.z() == 0) + { + Unbind (theCtx); + Release (theCtx.get()); + return false; + } } -#endif applyDefaultSamplerParams (theCtx); theCtx->Functions()->glTexImage3D (myTarget, 0, mySizedFormat, @@ -1030,8 +1021,8 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx, return false; } -#if defined(GL_ES_VERSION_2_0) if (theToGenMipmap + && theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES && !theCtx->IsGlGreaterEqual (3, 0) && (aFormat.PixelFormat() == GL_SRGB_EXT || aFormat.PixelFormat() == GL_SRGB_ALPHA_EXT)) @@ -1042,7 +1033,6 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx, aFormat.SetPixelFormat (aFormat.PixelFormat() == GL_SRGB_EXT ? GL_RGB : GL_RGBA); aFormat.SetInternalFormat(aFormat.PixelFormat() == GL_SRGB_EXT ? GL_RGB8 : GL_RGBA8); } -#endif myTarget = GL_TEXTURE_CUBE_MAP; myNbSamples = 1; @@ -1050,12 +1040,12 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx, mySizeY = (GLsizei )theSize; myTextFormat = aFormat.Format(); mySizedFormat = aFormat.Internal(); -#if !defined(GL_ES_VERSION_2_0) - const GLint anIntFormat = aFormat.InternalFormat(); -#else + // ES 2.0 does not support sized formats and format conversions - them detected from data type - const GLint anIntFormat = theCtx->IsGlGreaterEqual (3, 0) ? aFormat.InternalFormat() : aFormat.PixelFormat(); -#endif + const GLint anIntFormat = (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES + || theCtx->IsGlGreaterEqual (3, 0)) + ? aFormat.InternalFormat() + : aFormat.PixelFormat(); Bind (theCtx); applyDefaultSamplerParams (theCtx); @@ -1290,10 +1280,10 @@ bool OpenGl_Texture::ImageDump (Image_PixMap& theImage, Standard_Integer theLevel, Standard_Integer theCubeSide) const { -#if !defined(GL_ES_VERSION_2_0) const OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, mySizedFormat); if (theCtx.IsNull() || !IsValid() + || theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES // glGetTexImage() is unavailable in OpenGL ES || theLevel < 0 || !aFormat.IsValid() || aFormat.ImageFormat() == Image_Format_UNKNOWN @@ -1341,13 +1331,4 @@ bool OpenGl_Texture::ImageDump (Image_PixMap& theImage, const bool hasErrors = theCtx->ResetErrors (true); theCtx->core11fwd->glPixelStorei (GL_PACK_ALIGNMENT, 1); return !hasErrors; -#else - // glGetTexImage() is unavailable in OpenGL ES - (void )theImage; - (void )theCtx; - (void )theTexUnit; - (void )theLevel; - (void )theCubeSide; - return false; -#endif } diff --git a/src/OpenGl/OpenGl_TextureFormat.cxx b/src/OpenGl/OpenGl_TextureFormat.cxx index 14a89723a4..5fcc450efd 100644 --- a/src/OpenGl/OpenGl_TextureFormat.cxx +++ b/src/OpenGl/OpenGl_TextureFormat.cxx @@ -125,11 +125,8 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte { OpenGl_TextureFormat aFormat; aFormat.SetImageFormat (theFormat); -#if defined(GL_ES_VERSION_2_0) - const bool useRedRedAlpha = false; -#else - const bool useRedRedAlpha = (theCtx->core11ffp == NULL); -#endif + const bool useRedRedAlpha = theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES + && theCtx->core11ffp == NULL; switch (theFormat) { case Image_Format_GrayF: @@ -142,11 +139,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte } else { - #if !defined(GL_ES_VERSION_2_0) - aFormat.SetInternalFormat (GL_LUMINANCE8); - #else - aFormat.SetInternalFormat (GL_LUMINANCE); - #endif + aFormat.SetInternalFormat (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + ? GL_LUMINANCE + : GL_LUMINANCE8); aFormat.SetPixelFormat (GL_LUMINANCE); } aFormat.SetDataType (GL_FLOAT); @@ -162,11 +157,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte } else { - #if !defined(GL_ES_VERSION_2_0) - aFormat.SetInternalFormat (GL_ALPHA8); - #else - aFormat.SetInternalFormat (GL_ALPHA); - #endif + aFormat.SetInternalFormat (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + ? GL_ALPHA + : GL_ALPHA8); aFormat.SetPixelFormat (GL_ALPHA); } aFormat.SetDataType (GL_FLOAT); @@ -214,15 +207,16 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte } case Image_Format_BGRF: { - #if !defined(GL_ES_VERSION_2_0) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + return OpenGl_TextureFormat(); + } + aFormat.SetNbComponents (3); aFormat.SetInternalFormat (theCtx->arbTexFloat ? GL_RGB32F : GL_RGB8); aFormat.SetPixelFormat (GL_BGR); // equals to GL_BGR_EXT aFormat.SetDataType (GL_FLOAT); return aFormat; - #else - return OpenGl_TextureFormat(); - #endif } case Image_Format_RGF_half: { @@ -230,11 +224,10 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte aFormat.SetInternalFormat (GL_RG16F); aFormat.SetPixelFormat (GL_RG); aFormat.SetDataType (GL_HALF_FLOAT); - if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions) + if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions + && theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) { - #if defined(GL_ES_VERSION_2_0) aFormat.SetDataType (GL_HALF_FLOAT_OES); - #endif } return aFormat; } @@ -244,11 +237,10 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte aFormat.SetInternalFormat (GL_RGBA16F); aFormat.SetPixelFormat (GL_RGBA); aFormat.SetDataType (GL_HALF_FLOAT); - if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions) + if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions + && theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) { - #if defined(GL_ES_VERSION_2_0) aFormat.SetDataType (GL_HALF_FLOAT_OES); - #endif } return aFormat; } @@ -261,106 +253,114 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte if (theIsColorMap && theCtx->ToRenderSRGB()) { - #if defined(GL_ES_VERSION_2_0) - if (!theCtx->IsGlGreaterEqual (3, 0)) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + && !theCtx->IsGlGreaterEqual (3, 0)) { aFormat.SetPixelFormat (GL_SRGB_ALPHA_EXT); } - #endif aFormat.SetInternalFormat (GL_SRGB8_ALPHA8); } return aFormat; } case Image_Format_BGRA: { - #if !defined(GL_ES_VERSION_2_0) - if (!theCtx->IsGlGreaterEqual (1, 2) - && !theCtx->extBgra) + if (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES) { - return OpenGl_TextureFormat(); + if (!theCtx->IsGlGreaterEqual (1, 2) + && !theCtx->extBgra) + { + return OpenGl_TextureFormat(); + } + aFormat.SetNbComponents (4); + aFormat.SetInternalFormat (GL_RGBA8); + if (theIsColorMap + && theCtx->ToRenderSRGB()) + { + aFormat.SetInternalFormat (GL_SRGB8_ALPHA8); + } } - aFormat.SetNbComponents (4); - aFormat.SetInternalFormat (GL_RGBA8); - if (theIsColorMap - && theCtx->ToRenderSRGB()) + else { - aFormat.SetInternalFormat (GL_SRGB8_ALPHA8); + if (theIsColorMap + && theCtx->ToRenderSRGB()) + { + // GL_SRGB8_ALPHA8 with texture swizzling would be better + } + if (!theCtx->extBgra) + { + return OpenGl_TextureFormat(); + } + aFormat.SetNbComponents (4); + aFormat.SetInternalFormat (GL_BGRA_EXT); } - #else - if (theIsColorMap - && theCtx->ToRenderSRGB()) - { - // GL_SRGB8_ALPHA8 with texture swizzling would be better - } - if (!theCtx->extBgra) - { - return OpenGl_TextureFormat(); - } - aFormat.SetNbComponents (4); - aFormat.SetInternalFormat (GL_BGRA_EXT); - #endif aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA aFormat.SetDataType (GL_UNSIGNED_BYTE); return aFormat; } case Image_Format_RGB32: { - #if !defined(GL_ES_VERSION_2_0) - // ask driver to convert data to RGB8 to save memory - aFormat.SetNbComponents (3); - aFormat.SetInternalFormat (GL_RGB8); - aFormat.SetPixelFormat (GL_RGBA); - aFormat.SetDataType (GL_UNSIGNED_BYTE); - if (theIsColorMap - && theCtx->ToRenderSRGB()) + if (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES) { - aFormat.SetInternalFormat (GL_SRGB8); - } - #else - // conversion is not supported - aFormat.SetNbComponents (4); - aFormat.SetInternalFormat (GL_RGBA8); - aFormat.SetPixelFormat (GL_RGBA); - aFormat.SetDataType (GL_UNSIGNED_BYTE); - if (theIsColorMap - && theCtx->ToRenderSRGB()) - { - if (!theCtx->IsGlGreaterEqual (3, 0)) + // ask driver to convert data to RGB8 to save memory + aFormat.SetNbComponents (3); + aFormat.SetInternalFormat (GL_RGB8); + aFormat.SetPixelFormat (GL_RGBA); + aFormat.SetDataType (GL_UNSIGNED_BYTE); + if (theIsColorMap + && theCtx->ToRenderSRGB()) { - aFormat.SetPixelFormat (GL_SRGB_ALPHA_EXT); + aFormat.SetInternalFormat (GL_SRGB8); + } + } + else + { + // conversion is not supported + aFormat.SetNbComponents (4); + aFormat.SetInternalFormat (GL_RGBA8); + aFormat.SetPixelFormat (GL_RGBA); + aFormat.SetDataType (GL_UNSIGNED_BYTE); + if (theIsColorMap + && theCtx->ToRenderSRGB()) + { + if (!theCtx->IsGlGreaterEqual (3, 0)) + { + aFormat.SetPixelFormat (GL_SRGB_ALPHA_EXT); + } + aFormat.SetInternalFormat (GL_SRGB8_ALPHA8); } - aFormat.SetInternalFormat (GL_SRGB8_ALPHA8); } - #endif return aFormat; } case Image_Format_BGR32: { - #if !defined(GL_ES_VERSION_2_0) - if (!theCtx->IsGlGreaterEqual(1, 2) && !theCtx->extBgra) + if (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES) { - return OpenGl_TextureFormat(); + if (!theCtx->IsGlGreaterEqual(1, 2) && !theCtx->extBgra) + { + return OpenGl_TextureFormat(); + } + aFormat.SetNbComponents (3); + aFormat.SetInternalFormat (GL_RGB8); + if (theIsColorMap + && theCtx->ToRenderSRGB()) + { + aFormat.SetInternalFormat (GL_SRGB8); + } } - aFormat.SetNbComponents (3); - aFormat.SetInternalFormat (GL_RGB8); - if (theIsColorMap - && theCtx->ToRenderSRGB()) + else { - aFormat.SetInternalFormat (GL_SRGB8); + if (theIsColorMap + && theCtx->ToRenderSRGB()) + { + // GL_SRGB8_ALPHA8 with texture swizzling would be better + } + if (!theCtx->extBgra) + { + return OpenGl_TextureFormat(); + } + aFormat.SetNbComponents (4); + aFormat.SetInternalFormat (GL_BGRA_EXT); } - #else - if (theIsColorMap - && theCtx->ToRenderSRGB()) - { - // GL_SRGB8_ALPHA8 with texture swizzling would be better - } - if (!theCtx->extBgra) - { - return OpenGl_TextureFormat(); - } - aFormat.SetNbComponents (4); - aFormat.SetInternalFormat (GL_BGRA_EXT); - #endif aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA aFormat.SetDataType (GL_UNSIGNED_BYTE); return aFormat; @@ -374,19 +374,22 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte if (theIsColorMap && theCtx->ToRenderSRGB()) { - #if defined(GL_ES_VERSION_2_0) - if (!theCtx->IsGlGreaterEqual (3, 0)) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + && !theCtx->IsGlGreaterEqual (3, 0)) { aFormat.SetPixelFormat (GL_SRGB_EXT); } - #endif aFormat.SetInternalFormat (GL_SRGB8); } return aFormat; } case Image_Format_BGR: { - #if !defined(GL_ES_VERSION_2_0) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + return OpenGl_TextureFormat(); + } + if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra) { @@ -401,7 +404,6 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte { aFormat.SetInternalFormat (GL_SRGB8); } - #endif return aFormat; } case Image_Format_Gray: @@ -414,11 +416,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte } else { - #if !defined(GL_ES_VERSION_2_0) - aFormat.SetInternalFormat (GL_LUMINANCE8); - #else - aFormat.SetInternalFormat (GL_LUMINANCE); - #endif + aFormat.SetInternalFormat (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + ? GL_LUMINANCE + : GL_LUMINANCE8); aFormat.SetPixelFormat (GL_LUMINANCE); } aFormat.SetDataType (GL_UNSIGNED_BYTE); @@ -434,11 +434,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte } else { - #if !defined(GL_ES_VERSION_2_0) - aFormat.SetInternalFormat (GL_ALPHA8); - #else - aFormat.SetInternalFormat (GL_ALPHA); - #endif + aFormat.SetInternalFormat (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + ? GL_ALPHA + : GL_ALPHA8); aFormat.SetPixelFormat (GL_ALPHA); } aFormat.SetDataType (GL_UNSIGNED_BYTE); @@ -498,11 +496,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_ aFormat.SetImageFormat (Image_Format_RGBAF_half); if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions) { - #if defined(GL_ES_VERSION_2_0) - aFormat.SetDataType (GL_HALF_FLOAT_OES); - #else - aFormat.SetDataType (GL_FLOAT); - #endif + aFormat.SetDataType (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + ? GL_HALF_FLOAT_OES + : GL_FLOAT); } return aFormat; } @@ -515,11 +511,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_ aFormat.SetImageFormat (Image_Format_GrayF); if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions) { - #if defined(GL_ES_VERSION_2_0) - aFormat.SetDataType (GL_HALF_FLOAT_OES); - #else - aFormat.SetDataType (GL_FLOAT); - #endif + aFormat.SetDataType (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + ? GL_HALF_FLOAT_OES + : GL_FLOAT); } return aFormat; } @@ -532,11 +526,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_ aFormat.SetImageFormat (Image_Format_RGF_half); if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions) { - #if defined(GL_ES_VERSION_2_0) - aFormat.SetDataType (GL_HALF_FLOAT_OES); - #else - aFormat.SetDataType (GL_FLOAT); - #endif + aFormat.SetDataType (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + ? GL_HALF_FLOAT_OES + : GL_FLOAT); } return aFormat; } @@ -554,12 +546,11 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_ { if (theCtx->ToRenderSRGB()) { - #if defined(GL_ES_VERSION_2_0) - if (!theCtx->IsGlGreaterEqual (3, 0)) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + && !theCtx->IsGlGreaterEqual (3, 0)) { aFormat.SetPixelFormat (GL_SRGB_ALPHA_EXT); } - #endif } else { @@ -582,12 +573,11 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_ { if (theCtx->ToRenderSRGB()) { - #if defined(GL_ES_VERSION_2_0) - if (!theCtx->IsGlGreaterEqual (3, 0)) + if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + && !theCtx->IsGlGreaterEqual (3, 0)) { aFormat.SetPixelFormat (GL_SRGB_EXT); } - #endif } else { diff --git a/src/OpenGl/OpenGl_TileSampler.cxx b/src/OpenGl/OpenGl_TileSampler.cxx index 1f28b4671f..3d988e4d1f 100644 --- a/src/OpenGl/OpenGl_TileSampler.cxx +++ b/src/OpenGl/OpenGl_TileSampler.cxx @@ -47,7 +47,7 @@ void OpenGl_TileSampler::GrabVarianceMap (const Handle(OpenGl_Context)& theConte } myVarianceRaw.Init (0); -#if !defined(GL_ES_VERSION_2_0) + theTexture->Bind (theContext); theContext->core11fwd->glPixelStorei (GL_PACK_ALIGNMENT, 1); theContext->core11fwd->glPixelStorei (GL_PACK_ROW_LENGTH, 0); @@ -60,10 +60,6 @@ void OpenGl_TileSampler::GrabVarianceMap (const Handle(OpenGl_Context)& theConte TCollection_AsciiString ("Error! Failed to fetch visual error map from the GPU ") + OpenGl_Context::FormatGlError (anErr)); return; } -#else - // glGetTexImage() is unavailable on OpenGL ES, FBO + glReadPixels() can be used instead - (void )theContext; -#endif const float aFactor = 1.0f / myScaleFactor; for (Standard_Size aColIter = 0; aColIter < myVarianceMap.SizeX; ++aColIter) @@ -274,9 +270,10 @@ bool OpenGl_TileSampler::upload (const Handle(OpenGl_Context)& theContext, { theSamplesTexture->Bind (theContext); theContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1); - #if !defined(GL_ES_VERSION_2_0) - theContext->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); - #endif + if (theContext->hasUnpackRowLength) + { + theContext->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); + } if (theSamplesTexture->SizeX() == (int )myTileSamples.SizeX && theSamplesTexture->SizeY() == (int )myTileSamples.SizeY) { @@ -314,9 +311,10 @@ bool OpenGl_TileSampler::upload (const Handle(OpenGl_Context)& theContext, { theOffsetsTexture->Bind (theContext); theContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1); - #if !defined(GL_ES_VERSION_2_0) - theContext->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); - #endif + if (theContext->hasUnpackRowLength) + { + theContext->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); + } theContext->core11fwd->glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, (int )anOffsets.SizeX, (int )anOffsets.SizeY, GL_RG_INTEGER, GL_INT, anOffsets.Data()); if (theContext->core11fwd->glGetError() != GL_NO_ERROR) { diff --git a/src/OpenGl/OpenGl_VertexBuffer.cxx b/src/OpenGl/OpenGl_VertexBuffer.cxx index da052caaa4..a13a70c034 100644 --- a/src/OpenGl/OpenGl_VertexBuffer.cxx +++ b/src/OpenGl/OpenGl_VertexBuffer.cxx @@ -136,13 +136,11 @@ void OpenGl_VertexBuffer::bindAttribute (const Handle(OpenGl_Context)& theCtx, { if (theCtx->ActiveProgram().IsNull()) { - #if !defined(GL_ES_VERSION_2_0) if (theCtx->core11ffp != NULL) { bindFixed (theCtx, theAttribute, theNbComp, theDataType, theStride, theOffset); } else - #endif { // OpenGL handles vertex attribute setup independently from active GLSL program, // but OCCT historically requires program to be bound beforehand (this check could be removed in future). @@ -164,19 +162,16 @@ void OpenGl_VertexBuffer::unbindAttribute (const Handle(OpenGl_Context)& theCt { if (theCtx->ActiveProgram().IsNull()) { - #if !defined(GL_ES_VERSION_2_0) if (theCtx->core11ffp != NULL) { unbindFixed (theCtx, theAttribute); } - #endif return; } theCtx->core20fwd->glDisableVertexAttribArray (theAttribute); } -#if !defined(GL_ES_VERSION_2_0) // ======================================================================= // function : bindFixed // purpose : @@ -255,4 +250,3 @@ void OpenGl_VertexBuffer::unbindFixedColor (const Handle(OpenGl_Context)& theCtx // invalidate FFP material state after GL_COLOR_MATERIAL has modified it (took values from the vertex color) theCtx->ShaderManager()->UpdateMaterialState(); } -#endif diff --git a/src/OpenGl/OpenGl_VertexBuffer.hxx b/src/OpenGl/OpenGl_VertexBuffer.hxx index e423d05988..fc59435972 100644 --- a/src/OpenGl/OpenGl_VertexBuffer.hxx +++ b/src/OpenGl/OpenGl_VertexBuffer.hxx @@ -84,7 +84,7 @@ public: //! @name advanced methods const Graphic3d_TypeOfAttribute theMode); private: -#if !defined(GL_ES_VERSION_2_0) + //! Setup FFP array pointer. Standard_EXPORT static void bindFixed (const Handle(OpenGl_Context)& theGlCtx, const Graphic3d_TypeOfAttribute theMode, @@ -100,7 +100,6 @@ private: //! Disable FFP color array pointer. Standard_EXPORT static void unbindFixedColor (const Handle(OpenGl_Context)& theCtx); -#endif public: //! @name methods for interleaved attributes array //! @return true if buffer contains per-vertex color attribute diff --git a/src/OpenGl/OpenGl_View.cxx b/src/OpenGl/OpenGl_View.cxx index c636f9252b..ec410fc6f8 100644 --- a/src/OpenGl/OpenGl_View.cxx +++ b/src/OpenGl/OpenGl_View.cxx @@ -464,6 +464,7 @@ void OpenGl_View::GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, c // ======================================================================= Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3d_BufferType& theBufferType) { + const Handle(OpenGl_Context)& aCtx = myWorkspace->GetGlContext(); if (theBufferType != Graphic3d_BT_RGB_RayTraceHdrLeft) { return myWorkspace->BufferDump(myFBO, theImage, theBufferType); @@ -474,9 +475,10 @@ Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3 return myWorkspace->BufferDump(myAccumFrames % 2 ? myRaytraceFBO2[0] : myRaytraceFBO1[0], theImage, theBufferType); } -#if defined(GL_ES_VERSION_2_0) - return false; -#else + if (aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + return false; + } if (theImage.Format() != Image_Format_RGBF) { return false; @@ -499,9 +501,9 @@ Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3 return false; } - glBindTexture (GL_TEXTURE_RECTANGLE, myRaytraceOutputTexture[0]->TextureId()); - glGetTexImage (GL_TEXTURE_RECTANGLE, 0, OpenGl_TextureFormat::Create().Format(), GL_FLOAT, &aValues[0]); - glBindTexture (GL_TEXTURE_RECTANGLE, 0); + aCtx->core11fwd->glBindTexture (GL_TEXTURE_RECTANGLE, myRaytraceOutputTexture[0]->TextureId()); + aCtx->core11fwd->glGetTexImage (GL_TEXTURE_RECTANGLE, 0, OpenGl_TextureFormat::Create().Format(), GL_FLOAT, &aValues[0]); + aCtx->core11fwd->glBindTexture (GL_TEXTURE_RECTANGLE, 0); for (unsigned int aRow = 0; aRow < aH; aRow += 2) { for (unsigned int aCol = 0; aCol < aW; aCol += 3) @@ -515,7 +517,6 @@ Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3 } return true; -#endif } // ======================================================================= @@ -989,7 +990,7 @@ void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace, } #ifdef GL_DEPTH_CLAMP - const bool wasDepthClamped = aCtx->arbDepthClamp && glIsEnabled (GL_DEPTH_CLAMP); + const bool wasDepthClamped = aCtx->arbDepthClamp && aCtx->core11fwd->glIsEnabled (GL_DEPTH_CLAMP); if (aCtx->arbDepthClamp && !wasDepthClamped) { // make sure background is always drawn (workaround skybox rendering on some hardware) @@ -1280,14 +1281,18 @@ bool OpenGl_View::prepareFrameBuffers (Graphic3d_Camera::Projection& theProj) if (!aCtx->GetResource (THE_SHARED_ENV_LUT_KEY, anEnvLUT)) { bool toConvertHalfFloat = false; - #if defined(GL_ES_VERSION_2_0) + // GL_RG32F is not texture-filterable format in OpenGL ES without OES_texture_float_linear extension. // GL_RG16F is texture-filterable since OpenGL ES 3.0 or OpenGL ES 2.0 + OES_texture_half_float_linear. // OpenGL ES 3.0 allows initialization of GL_RG16F from 32-bit float data, but OpenGL ES 2.0 + OES_texture_half_float does not. // Note that it is expected that GL_RG16F has enough precision for this table, so that it can be used also on desktop OpenGL. - const bool hasHalfFloat = aCtx->IsGlGreaterEqual (3, 0) || aCtx->CheckExtension ("GL_OES_texture_half_float_linear"); - toConvertHalfFloat = !aCtx->IsGlGreaterEqual (3, 0) && hasHalfFloat; - #endif + const bool hasHalfFloat = aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + && (aCtx->IsGlGreaterEqual (3, 0) || aCtx->CheckExtension ("GL_OES_texture_half_float_linear")); + if (aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) + { + toConvertHalfFloat = !aCtx->IsGlGreaterEqual (3, 0) && hasHalfFloat; + } + Image_Format anImgFormat = Image_Format_UNKNOWN; if (aCtx->arbTexRG) { @@ -1330,13 +1335,12 @@ bool OpenGl_View::prepareFrameBuffers (Graphic3d_Camera::Projection& theProj) } OpenGl_TextureFormat aTexFormat = OpenGl_TextureFormat::FindFormat (aCtx, aPixMap->Format(), false); - #if defined(GL_ES_VERSION_2_0) - if (aTexFormat.IsValid() + if (aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + && aTexFormat.IsValid() && hasHalfFloat) { aTexFormat.SetInternalFormat (aCtx->arbTexRG ? GL_RG16F : GL_RGBA16F); } - #endif Handle(Graphic3d_TextureParams) aParams = new Graphic3d_TextureParams(); aParams->SetFilter (Graphic3d_TOTF_BILINEAR); @@ -1677,18 +1681,14 @@ void OpenGl_View::Redraw() anImmFbosOit[1] = NULL; } - #if !defined(GL_ES_VERSION_2_0) aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_LEFT : GL_BACK); - #endif aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), aMainFbos[0] != NULL ? myRenderParams.RenderResolutionScale : 1.0f); redraw (Graphic3d_Camera::Projection_MonoLeftEye, aMainFbos[0], aMainFbosOit[0]); myBackBufferRestored = Standard_True; myIsImmediateDrawn = Standard_False; - #if !defined(GL_ES_VERSION_2_0) aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_LEFT : GL_BACK); - #endif aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), anImmFbos[0] != NULL ? myRenderParams.RenderResolutionScale : 1.0f); if (!redrawImmediate (Graphic3d_Camera::Projection_MonoLeftEye, aMainFbos[0], anImmFbos[0], anImmFbosOit[0])) @@ -1708,18 +1708,15 @@ void OpenGl_View::Redraw() { blitBuffers (aMainFbos[0], anXRFbo); // resize or resolve MSAA samples } - #if !defined(GL_ES_VERSION_2_0) - const Aspect_GraphicsLibrary aGraphicsLib = Aspect_GraphicsLibrary_OpenGL; - #else - const Aspect_GraphicsLibrary aGraphicsLib = Aspect_GraphicsLibrary_OpenGLES; - #endif + const Aspect_GraphicsLibrary aGraphicsLib = aCtx->GraphicsLibrary(); myXRSession->SubmitEye ((void* )(size_t )anXRFbo->ColorTexture()->TextureId(), aGraphicsLib, Aspect_ColorSpace_sRGB, Aspect_Eye_Left); } - #if !defined(GL_ES_VERSION_2_0) - aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_RIGHT : GL_BACK); - #endif + if (aCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES) + { + aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_RIGHT : GL_BACK); + } aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), aMainFbos[1] != NULL ? myRenderParams.RenderResolutionScale : 1.0f); @@ -1741,11 +1738,8 @@ void OpenGl_View::Redraw() { blitBuffers (aMainFbos[1], anXRFbo); // resize or resolve MSAA samples } - #if !defined(GL_ES_VERSION_2_0) - const Aspect_GraphicsLibrary aGraphicsLib = Aspect_GraphicsLibrary_OpenGL; - #else - const Aspect_GraphicsLibrary aGraphicsLib = Aspect_GraphicsLibrary_OpenGLES; - #endif + + const Aspect_GraphicsLibrary aGraphicsLib = aCtx->GraphicsLibrary(); myXRSession->SubmitEye ((void* )(size_t )anXRFbo->ColorTexture()->TextureId(), aGraphicsLib, Aspect_ColorSpace_sRGB, Aspect_Eye_Right); aCtx->core11fwd->glFinish(); @@ -1778,12 +1772,10 @@ void OpenGl_View::Redraw() anImmFboOit = myImmediateSceneFbosOit[0]->IsValid() ? myImmediateSceneFbosOit[0].operator->() : NULL; } - #if !defined(GL_ES_VERSION_2_0) if (aMainFbo == NULL) { aCtx->SetReadDrawBuffer (GL_BACK); } - #endif aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), aMainFbo != aFrameBuffer ? myRenderParams.RenderResolutionScale : 1.0f); @@ -1920,12 +1912,10 @@ void OpenGl_View::RedrawImmediate() { aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER); } - #if !defined(GL_ES_VERSION_2_0) if (anImmFbos[0] == NULL) { aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_LEFT : GL_BACK); } - #endif aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), anImmFbos[0] != NULL ? myRenderParams.RenderResolutionScale : 1.0f); @@ -1946,12 +1936,10 @@ void OpenGl_View::RedrawImmediate() { aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER); } - #if !defined(GL_ES_VERSION_2_0) if (anImmFbos[1] == NULL) { aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_RIGHT : GL_BACK); } - #endif aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), anImmFbos[1] != NULL ? myRenderParams.RenderResolutionScale : 1.0f); toSwap = redrawImmediate (Graphic3d_Camera::Projection_MonoRightEye, @@ -1974,12 +1962,10 @@ void OpenGl_View::RedrawImmediate() anImmFbo = myImmediateSceneFbos[0].operator->(); anImmFboOit = myImmediateSceneFbosOit[0]->IsValid() ? myImmediateSceneFbosOit[0].operator->() : NULL; } - #if !defined(GL_ES_VERSION_2_0) if (aMainFbo == NULL) { aCtx->SetReadDrawBuffer (GL_BACK); } - #endif aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), anImmFbo != aFrameBuffer ? myRenderParams.RenderResolutionScale : 1.0f); toSwap = redrawImmediate (aProjectType, @@ -2090,9 +2076,10 @@ bool OpenGl_View::redrawImmediate (const Graphic3d_Camera::Projection theProject } else if (theDrawFbo == NULL) { - #if !defined(GL_ES_VERSION_2_0) - aCtx->core11fwd->glGetBooleanv (GL_DOUBLEBUFFER, &toCopyBackToFront); - #endif + if (aCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES) + { + aCtx->core11fwd->glGetBooleanv (GL_DOUBLEBUFFER, &toCopyBackToFront); + } if (toCopyBackToFront && myTransientDrawToFront) { @@ -2204,7 +2191,6 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection, && theOutputFBO != NULL && theOutputFBO->NbSamples() != 0); -#if !defined(GL_ES_VERSION_2_0) // Disable current clipping planes if (aContext->core11ffp != NULL) { @@ -2214,7 +2200,6 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection, aContext->core11fwd->glDisable (aClipPlaneId); } } -#endif // update states of OpenGl_BVHTreeSelector (frustum culling algorithm); // note that we pass here window dimensions ignoring Graphic3d_RenderingParams::RenderResolutionScale @@ -2262,20 +2247,17 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection, drawBackground (myWorkspace, theProjection); } -#if !defined(GL_ES_VERSION_2_0) // Switch off lighting by default if (aContext->core11ffp != NULL && aContext->caps->ffpEnable) { aContext->core11fwd->glDisable (GL_LIGHTING); } -#endif // ================================= // Step 3: Redraw main plane // ================================= -#if !defined(GL_ES_VERSION_2_0) // if the view is scaled normal vectors are scaled to unit // length for correct displaying of shaded objects const gp_Pnt anAxialScale = aContext->Camera()->AxialScale(); @@ -2289,7 +2271,6 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection, { aContext->SetGlNormalizeEnabled (Standard_False); } -#endif aManager->SetShadingModel (OpenGl_ShaderManager::PBRShadingModelFallback (myRenderParams.ShadingModel, checkPBRAvailability())); @@ -2558,14 +2539,15 @@ void OpenGl_View::bindDefaultFbo (OpenGl_FrameBuffer* theCustomFbo) } else { - #if !defined(GL_ES_VERSION_2_0) - aCtx->SetReadDrawBuffer (GL_BACK); - #else - if (aCtx->arbFBO != NULL) + if (aCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES) + { + aCtx->SetReadDrawBuffer (GL_BACK); + } + else if (aCtx->arbFBO != NULL) { aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER); } - #endif + const Standard_Integer aViewport[4] = { 0, 0, myWindow->Width(), myWindow->Height() }; aCtx->ResizeViewport (aViewport); } @@ -2744,13 +2726,12 @@ bool OpenGl_View::blitBuffers (OpenGl_FrameBuffer* theReadFbo, aCtx->core20fwd->glDepthFunc (GL_ALWAYS); aCtx->core20fwd->glDepthMask (GL_TRUE); aCtx->core20fwd->glEnable (GL_DEPTH_TEST); - #if defined(GL_ES_VERSION_2_0) - if (!aCtx->IsGlGreaterEqual (3, 0) - && !aCtx->extFragDepth) + if (aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + && !aCtx->IsGlGreaterEqual (3, 0) + && !aCtx->extFragDepth) { aCtx->core20fwd->glDisable (GL_DEPTH_TEST); } - #endif aCtx->BindTextures (Handle(OpenGl_TextureSet)(), Handle(OpenGl_ShaderProgram)()); @@ -2995,7 +2976,6 @@ void OpenGl_View::drawStereoPair (OpenGl_FrameBuffer* theDrawFbo) bool OpenGl_View::copyBackToFront() { myIsImmediateDrawn = Standard_False; -#if !defined(GL_ES_VERSION_2_0) const Handle(OpenGl_Context)& aCtx = myWorkspace->GetGlContext(); if (aCtx->core11ffp == NULL) { @@ -3056,9 +3036,6 @@ bool OpenGl_View::copyBackToFront() // read/write from front buffer now aCtx->SetReadBuffer (aCtx->DrawBuffer()); return true; -#else - return false; -#endif } // ======================================================================= diff --git a/src/OpenGl/OpenGl_View_Raytrace.cxx b/src/OpenGl/OpenGl_View_Raytrace.cxx index 7b3b171877..91894ef2ff 100644 --- a/src/OpenGl/OpenGl_View_Raytrace.cxx +++ b/src/OpenGl/OpenGl_View_Raytrace.cxx @@ -600,11 +600,7 @@ Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const OpenGl_ const Handle(Graphic3d_Buffer)& anAttribs = theArray->Attributes(); if (theArray->DrawMode() < GL_TRIANGLES - #ifndef GL_ES_VERSION_2_0 || theArray->DrawMode() > GL_POLYGON - #else - || theArray->DrawMode() > GL_TRIANGLE_FAN - #endif || anAttribs.IsNull()) { return Handle(OpenGl_TriangleSet)(); @@ -755,11 +751,9 @@ Standard_Boolean OpenGl_View::addRaytraceVertexIndices (OpenGl_TriangleSet& case GL_TRIANGLES: return addRaytraceTriangleArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); case GL_TRIANGLE_FAN: return addRaytraceTriangleFanArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); case GL_TRIANGLE_STRIP: return addRaytraceTriangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); - #if !defined(GL_ES_VERSION_2_0) case GL_QUAD_STRIP: return addRaytraceQuadrangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); case GL_QUADS: return addRaytraceQuadrangleArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); case GL_POLYGON: return addRaytracePolygonArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); - #endif } return Standard_False; @@ -1031,16 +1025,14 @@ const TCollection_AsciiString OpenGl_View::ShaderSource::EMPTY_PREFIX; TCollection_AsciiString OpenGl_View::ShaderSource::Source (const Handle(OpenGl_Context)& theCtx, const GLenum theType) const { - TCollection_AsciiString aVersion = - #if defined(GL_ES_VERSION_2_0) - "#version 320 es\n"; - #else - "#version 140\n"; - #endif + TCollection_AsciiString aVersion = theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES + ? "#version 320 es\n" + : "#version 140\n"; + TCollection_AsciiString aPrecisionHeader; - if (theType == GL_FRAGMENT_SHADER) + if (theType == GL_FRAGMENT_SHADER + && theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) { - #if defined(GL_ES_VERSION_2_0) aPrecisionHeader = theCtx->hasHighp ? "precision highp float;\n" "precision highp int;\n" @@ -1050,9 +1042,6 @@ TCollection_AsciiString OpenGl_View::ShaderSource::Source (const Handle(OpenGl_C "precision mediump int;\n" "precision mediump samplerBuffer;\n" "precision mediump isamplerBuffer;\n"; - #else - (void )theCtx; - #endif } if (myPrefix.IsEmpty()) { @@ -1480,25 +1469,28 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Standard_Integer theS { myAccumFrames = 0; // accumulation should be restarted - #if defined(GL_ES_VERSION_2_0) - if (!theGlContext->IsGlGreaterEqual (3, 2)) + if (theGlContext->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) { - return safeFailBack ("Ray-tracing requires OpenGL ES 3.2 and higher", theGlContext); + if (!theGlContext->IsGlGreaterEqual (3, 2)) + { + return safeFailBack ("Ray-tracing requires OpenGL ES 3.2 and higher", theGlContext); + } } - #else - if (!theGlContext->IsGlGreaterEqual (3, 1)) + else { - return safeFailBack ("Ray-tracing requires OpenGL 3.1 and higher", theGlContext); + if (!theGlContext->IsGlGreaterEqual (3, 1)) + { + return safeFailBack ("Ray-tracing requires OpenGL 3.1 and higher", theGlContext); + } + else if (!theGlContext->arbTboRGB32) + { + return safeFailBack ("Ray-tracing requires OpenGL 4.0+ or GL_ARB_texture_buffer_object_rgb32 extension", theGlContext); + } + else if (!theGlContext->arbFBOBlit) + { + return safeFailBack ("Ray-tracing requires EXT_framebuffer_blit extension", theGlContext); + } } - else if (!theGlContext->arbTboRGB32) - { - return safeFailBack ("Ray-tracing requires OpenGL 4.0+ or GL_ARB_texture_buffer_object_rgb32 extension", theGlContext); - } - else if (!theGlContext->arbFBOBlit) - { - return safeFailBack ("Ray-tracing requires EXT_framebuffer_blit extension", theGlContext); - } - #endif myRaytraceParameters.NbBounces = myRenderParams.RaytracingDepth; @@ -2119,19 +2111,22 @@ void OpenGl_View::updatePerspCameraPT (const OpenGl_Mat4& theOrientati // ======================================================================= Standard_Boolean OpenGl_View::uploadRaytraceData (const Handle(OpenGl_Context)& theGlContext) { -#if defined(GL_ES_VERSION_2_0) - if (!theGlContext->IsGlGreaterEqual (3, 2)) + if (theGlContext->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES) { - Message::SendFail() << "Error: OpenGL ES version is less than 3.2"; - return Standard_False; + if (!theGlContext->IsGlGreaterEqual (3, 2)) + { + Message::SendFail() << "Error: OpenGL ES version is less than 3.2"; + return Standard_False; + } } -#else - if (!theGlContext->IsGlGreaterEqual (3, 1)) + else { - Message::SendFail() << "Error: OpenGL version is less than 3.1"; - return Standard_False; + if (!theGlContext->IsGlGreaterEqual (3, 1)) + { + Message::SendFail() << "Error: OpenGL version is less than 3.1"; + return Standard_False; + } } -#endif myAccumFrames = 0; // accumulation should be restarted @@ -2748,7 +2743,6 @@ void OpenGl_View::bindRaytraceTextures (const Handle(OpenGl_Context)& theGlConte if (myRaytraceParameters.AdaptiveScreenSampling && myRaytraceParameters.GlobalIllumination) { - #if !defined(GL_ES_VERSION_2_0) theGlContext->core42->glBindImageTexture (OpenGl_RT_OutputImage, myRaytraceOutputTexture[theStereoView]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32F); theGlContext->core42->glBindImageTexture (OpenGl_RT_VisualErrorImage, @@ -2763,9 +2757,6 @@ void OpenGl_View::bindRaytraceTextures (const Handle(OpenGl_Context)& theGlConte theGlContext->core42->glBindImageTexture (OpenGl_RT_TileSamplesImage, myRaytraceTileSamplesTexture[theStereoView]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32I); } - #else - (void )theStereoView; - #endif } const Handle(OpenGl_TextureSet)& anEnvTextureSet = myRaytraceParameters.CubemapForBack @@ -2996,15 +2987,11 @@ Standard_Boolean OpenGl_View::runPathtrace (const Standard_Integer myTileSampler.UploadSamples (theGlContext, myRaytraceTileSamplesTexture[aFBOIdx], false); } - #if !defined(GL_ES_VERSION_2_0) theGlContext->core44->glClearTexImage (myRaytraceOutputTexture[aFBOIdx]->TextureId(), 0, GL_RED, GL_FLOAT, NULL); - #endif } // Clear adaptive screen sampling images - #if !defined(GL_ES_VERSION_2_0) theGlContext->core44->glClearTexImage (myRaytraceVisualErrorTexture[aFBOIdx]->TextureId(), 0, GL_RED_INTEGER, GL_INT, NULL); - #endif } bindRaytraceTextures (theGlContext, aFBOIdx); @@ -3065,9 +3052,7 @@ Standard_Boolean OpenGl_View::runPathtrace (const Standard_Integer theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6); if (myRaytraceParameters.AdaptiveScreenSampling) { - #if !defined(GL_ES_VERSION_2_0) theGlContext->core44->glMemoryBarrier (GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); - #endif } } aRenderImageFramebuffer->UnbindBuffer (theGlContext); diff --git a/src/OpenGl/OpenGl_Window.cxx b/src/OpenGl/OpenGl_Window.cxx index 89140cdea7..711fa1a243 100644 --- a/src/OpenGl/OpenGl_Window.cxx +++ b/src/OpenGl/OpenGl_Window.cxx @@ -804,17 +804,15 @@ void OpenGl_Window::Init() // #endif - glDisable (GL_DITHER); - glDisable (GL_SCISSOR_TEST); + myGlContext->core11fwd->glDisable (GL_DITHER); + myGlContext->core11fwd->glDisable (GL_SCISSOR_TEST); const Standard_Integer aViewport[4] = { 0, 0, myWidth, myHeight }; myGlContext->ResizeViewport (aViewport); -#if !defined(GL_ES_VERSION_2_0) myGlContext->SetDrawBuffer (GL_BACK); if (myGlContext->core11ffp != NULL) { - glMatrixMode (GL_MODELVIEW); + myGlContext->core11ffp->glMatrixMode (GL_MODELVIEW); } -#endif } // ======================================================================= diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index 8b927eb652..9ff9e1ba81 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -124,7 +124,6 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1); // General initialization of the context - #if !defined(GL_ES_VERSION_2_0) if (myGlContext->core11ffp != NULL) { // enable two-side lighting by default @@ -136,15 +135,17 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi } } - myGlContext->core11fwd->glHint (GL_LINE_SMOOTH_HINT, GL_FASTEST); - myGlContext->core11fwd->glHint (GL_POLYGON_SMOOTH_HINT, GL_FASTEST); + if (myGlContext->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES) + { + myGlContext->core11fwd->glHint (GL_LINE_SMOOTH_HINT, GL_FASTEST); + myGlContext->core11fwd->glHint (GL_POLYGON_SMOOTH_HINT, GL_FASTEST); + } if (myGlContext->Vendor() == "microsoft corporation" && !myGlContext->IsGlGreaterEqual (1, 2)) { // this software implementation causes too slow rendering into GL_FRONT on modern Windows theView->SetImmediateModeDrawToFront (false); } - #endif } myNoneCulling .Aspect()->SetFaceCulling (Graphic3d_TypeOfBackfacingModel_DoubleSided); @@ -171,11 +172,9 @@ Standard_Boolean OpenGl_Workspace::Activate() { if (myGlContext->caps->ffpEnable) { - #if defined(GL_ES_VERSION_2_0) - Message::SendWarning ("Warning: FFP is unsupported by OpenGL ES"); - #else - Message::SendWarning ("Warning: FFP is unsupported by OpenGL Core Profile"); - #endif + Message::SendWarning (myGlContext->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES + ? "Warning: FFP is unsupported by OpenGL ES" + : "Warning: FFP is unsupported by OpenGL Core Profile"); myGlContext->caps->ffpEnable = false; } } @@ -187,12 +186,10 @@ Standard_Boolean OpenGl_Workspace::Activate() myGlContext->caps->useZeroToOneDepth = false; } myView->Camera()->SetZeroToOneDepth (myGlContext->caps->useZeroToOneDepth); -#if !defined(GL_ES_VERSION_2_0) if (myGlContext->arbClipControl) { myGlContext->Functions()->glClipControl (GL_LOWER_LEFT, myGlContext->caps->useZeroToOneDepth ? GL_ZERO_TO_ONE : GL_NEGATIVE_ONE_TO_ONE); } -#endif ResetAppliedAspect(); @@ -305,18 +302,14 @@ const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects (bool theToBindTextures) if (myAspectsApplied.IsNull() || myAspectsApplied->InteriorStyle() != anIntstyle) { - #if !defined(GL_ES_VERSION_2_0) myGlContext->SetPolygonMode (anIntstyle == Aspect_IS_POINT ? GL_POINT : GL_FILL); myGlContext->SetPolygonHatchEnabled (anIntstyle == Aspect_IS_HATCH); - #endif } -#if !defined(GL_ES_VERSION_2_0) if (anIntstyle == Aspect_IS_HATCH) { myGlContext->SetPolygonHatchStyle (myAspectsSet->Aspect()->HatchStyle()); } -#endif // Case of hidden line if (anIntstyle == Aspect_IS_HIDDENLINE) diff --git a/src/OpenGlTest/OpenGlTest_Commands.cxx b/src/OpenGlTest/OpenGlTest_Commands.cxx index 792ee68113..be6785cf38 100644 --- a/src/OpenGlTest/OpenGlTest_Commands.cxx +++ b/src/OpenGlTest/OpenGlTest_Commands.cxx @@ -199,7 +199,7 @@ void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const // Finally draw something to make sure UserDraw really works aVertBuffer->BindAttribute (aCtx, Graphic3d_TOA_POS); - glDrawArrays(GL_LINE_LOOP, 0, aVertBuffer->GetElemsNb()); + aCtx->core11fwd->glDrawArrays (GL_LINE_LOOP, 0, aVertBuffer->GetElemsNb()); aVertBuffer->UnbindAttribute(aCtx, Graphic3d_TOA_POS); aVertBuffer->Release (aCtx.get()); } @@ -350,10 +350,15 @@ static int VGlDebug (Draw_Interpretor& theDI, const char** theArgVec) { Handle(OpenGl_GraphicDriver) aDriver; + Handle(OpenGl_Context) aGlCtx; Handle(V3d_View) aView = ViewerTest::CurrentView(); if (!aView.IsNull()) { aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver()); + if (!aDriver.IsNull()) + { + aGlCtx = aDriver->GetSharedContext(); + } } OpenGl_Caps* aDefCaps = getDefaultCaps().get(); OpenGl_Caps* aCaps = !aDriver.IsNull() ? &aDriver->ChangeOptions() : NULL; @@ -365,15 +370,15 @@ static int VGlDebug (Draw_Interpretor& theDI, { aCaps = aDefCaps; } - else + else if (!aGlCtx.IsNull()) { - Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )::glGetString (GL_EXTENSIONS), + Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )aGlCtx->core11fwd->glGetString (GL_EXTENSIONS), "GL_ARB_debug_output"); aDebActive = isActive ? " (active)" : " (inactive)"; if (isActive) { // GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB - aSyncActive = ::glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)"; + aSyncActive = aGlCtx->core11fwd->glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)"; } }