From ca3c13d1e8415e0b7a6d9ec2955b4807a813f290 Mon Sep 17 00:00:00 2001 From: kgv Date: Wed, 24 Sep 2014 09:53:22 +0300 Subject: [PATCH] 0025219: Visualization, TKOpenGl - disable code paths unavailable on OpenGL ES 2.0 --- src/OpenGl/OpenGl_ArbDbg.hxx | 4 +- src/OpenGl/OpenGl_ArbFBO.hxx | 9 +- src/OpenGl/OpenGl_ArbIns.hxx | 4 +- src/OpenGl/OpenGl_ArbTBO.hxx | 4 +- src/OpenGl/OpenGl_AspectMarker.cxx | 2 + src/OpenGl/OpenGl_CappingAlgo.cxx | 20 +- src/OpenGl/OpenGl_Clipping.cxx | 25 +- src/OpenGl/OpenGl_Context.cxx | 98 +++- src/OpenGl/OpenGl_Context.hxx | 42 +- src/OpenGl/OpenGl_ExtGS.hxx | 2 + src/OpenGl/OpenGl_Flipper.cxx | 3 + src/OpenGl/OpenGl_Font.cxx | 8 +- src/OpenGl/OpenGl_FrameBuffer.cxx | 7 + src/OpenGl/OpenGl_GlCore11.hxx | 83 ++- src/OpenGl/OpenGl_GlCore11Fwd.hxx | 357 ++++++------ src/OpenGl/OpenGl_GlCore12.hxx | 3 + src/OpenGl/OpenGl_GlCore13.hxx | 26 +- src/OpenGl/OpenGl_GlCore14.hxx | 5 +- src/OpenGl/OpenGl_GlCore15.hxx | 12 +- src/OpenGl/OpenGl_GlCore20.hxx | 43 +- src/OpenGl/OpenGl_GlCore21.hxx | 4 + src/OpenGl/OpenGl_GlCore30.hxx | 4 + src/OpenGl/OpenGl_GlCore31.hxx | 4 + src/OpenGl/OpenGl_GlCore32.hxx | 4 + src/OpenGl/OpenGl_GlCore33.hxx | 4 + src/OpenGl/OpenGl_GlCore40.hxx | 4 + src/OpenGl/OpenGl_GlCore41.hxx | 4 + src/OpenGl/OpenGl_GlCore42.hxx | 4 + src/OpenGl/OpenGl_GlCore43.hxx | 4 + src/OpenGl/OpenGl_GlCore44.hxx | 4 + src/OpenGl/OpenGl_GlFunctions.hxx | 647 +++++++++++++++++++++- src/OpenGl/OpenGl_GraduatedTrihedron.cxx | 8 + src/OpenGl/OpenGl_GraphicDriver_7.cxx | 70 ++- src/OpenGl/OpenGl_GraphicDriver_Layer.cxx | 37 +- src/OpenGl/OpenGl_LineAttributes.cxx | 10 + src/OpenGl/OpenGl_PointSprite.cxx | 4 + src/OpenGl/OpenGl_PrimitiveArray.cxx | 58 +- src/OpenGl/OpenGl_PrinterContext.cxx | 4 +- src/OpenGl/OpenGl_Structure.cxx | 9 +- src/OpenGl/OpenGl_Text.cxx | 27 +- src/OpenGl/OpenGl_Texture.cxx | 55 +- src/OpenGl/OpenGl_TextureBufferArb.cxx | 8 + src/OpenGl/OpenGl_Trihedron.cxx | 6 + src/OpenGl/OpenGl_VertexBuffer.hxx | 8 +- src/OpenGl/OpenGl_VertexBuffer.lxx | 8 + src/OpenGl/OpenGl_View.cxx | 11 +- src/OpenGl/OpenGl_View_2.cxx | 41 +- src/OpenGl/OpenGl_Window.cxx | 26 +- src/OpenGl/OpenGl_Workspace.cxx | 30 +- src/OpenGl/OpenGl_Workspace_5.cxx | 21 +- src/OpenGl/OpenGl_Workspace_Raytrace.cxx | 20 +- 51 files changed, 1524 insertions(+), 381 deletions(-) diff --git a/src/OpenGl/OpenGl_ArbDbg.hxx b/src/OpenGl/OpenGl_ArbDbg.hxx index d73c7a5a11..934551b4e7 100755 --- a/src/OpenGl/OpenGl_ArbDbg.hxx +++ b/src/OpenGl/OpenGl_ArbDbg.hxx @@ -21,12 +21,12 @@ //! Debug context routines struct OpenGl_ArbDbg : protected OpenGl_GlFunctions { - +#if !defined(GL_ES_VERSION_2_0) using OpenGl_GlFunctions::glDebugMessageControlARB; using OpenGl_GlFunctions::glDebugMessageInsertARB; using OpenGl_GlFunctions::glDebugMessageCallbackARB; using OpenGl_GlFunctions::glGetDebugMessageLogARB; - +#endif }; #endif // _OpenGl_ArbDbg_H__ diff --git a/src/OpenGl/OpenGl_ArbFBO.hxx b/src/OpenGl/OpenGl_ArbFBO.hxx index 638d0c2794..8e67351e93 100644 --- a/src/OpenGl/OpenGl_ArbFBO.hxx +++ b/src/OpenGl/OpenGl_ArbFBO.hxx @@ -33,15 +33,18 @@ struct OpenGl_ArbFBO : protected OpenGl_GlFunctions using OpenGl_GlFunctions::glDeleteFramebuffers; using OpenGl_GlFunctions::glGenFramebuffers; using OpenGl_GlFunctions::glCheckFramebufferStatus; - using OpenGl_GlFunctions::glFramebufferTexture1D; using OpenGl_GlFunctions::glFramebufferTexture2D; - using OpenGl_GlFunctions::glFramebufferTexture3D; using OpenGl_GlFunctions::glFramebufferRenderbuffer; using OpenGl_GlFunctions::glGetFramebufferAttachmentParameteriv; using OpenGl_GlFunctions::glGenerateMipmap; + +#if !defined(GL_ES_VERSION_2_0) using OpenGl_GlFunctions::glBlitFramebuffer; - using OpenGl_GlFunctions::glRenderbufferStorageMultisample; + using OpenGl_GlFunctions::glFramebufferTexture1D; + using OpenGl_GlFunctions::glFramebufferTexture3D; using OpenGl_GlFunctions::glFramebufferTextureLayer; + using OpenGl_GlFunctions::glRenderbufferStorageMultisample; +#endif }; diff --git a/src/OpenGl/OpenGl_ArbIns.hxx b/src/OpenGl/OpenGl_ArbIns.hxx index 39863a6d64..db86f6fadc 100644 --- a/src/OpenGl/OpenGl_ArbIns.hxx +++ b/src/OpenGl/OpenGl_ArbIns.hxx @@ -21,10 +21,10 @@ //! Instancing is available on OpenGL 3.0+ hardware struct OpenGl_ArbIns : protected OpenGl_GlFunctions { - +#if !defined(GL_ES_VERSION_2_0) using OpenGl_GlFunctions::glDrawArraysInstanced; using OpenGl_GlFunctions::glDrawElementsInstanced; - +#endif }; #endif // _OpenGl_ArbIns_H__ diff --git a/src/OpenGl/OpenGl_ArbTBO.hxx b/src/OpenGl/OpenGl_ArbTBO.hxx index 34ef3c2c04..4790d5e2b2 100644 --- a/src/OpenGl/OpenGl_ArbTBO.hxx +++ b/src/OpenGl/OpenGl_ArbTBO.hxx @@ -21,9 +21,9 @@ //! TBO is available on OpenGL 3.0+ hardware struct OpenGl_ArbTBO : protected OpenGl_GlFunctions { - +#if !defined(GL_ES_VERSION_2_0) using OpenGl_GlFunctions::glTexBuffer; - +#endif }; #endif // _OpenGl_ArbTBO_H__ diff --git a/src/OpenGl/OpenGl_AspectMarker.cxx b/src/OpenGl/OpenGl_AspectMarker.cxx index ae2a74d264..a29e430f9f 100644 --- a/src/OpenGl/OpenGl_AspectMarker.cxx +++ b/src/OpenGl/OpenGl_AspectMarker.cxx @@ -1773,6 +1773,7 @@ void OpenGl_AspectMarker::Resources::BuildSprites (const Handle(OpenGl_Workspace } else { + #if !defined(GL_ES_VERSION_2_0) // Creating list with bitmap for using it in compatibility mode GLuint aBitmapList = glGenLists (1); Sprite->SetDisplayList (aContext, aBitmapList); @@ -1881,6 +1882,7 @@ void OpenGl_AspectMarker::Resources::BuildSprites (const Handle(OpenGl_Workspace } glEndList(); } + #endif } } diff --git a/src/OpenGl/OpenGl_CappingAlgo.cxx b/src/OpenGl/OpenGl_CappingAlgo.cxx index d0bdb57c10..c0ffa5450d 100755 --- a/src/OpenGl/OpenGl_CappingAlgo.cxx +++ b/src/OpenGl/OpenGl_CappingAlgo.cxx @@ -31,6 +31,15 @@ Standard_Boolean OpenGl_CappingAlgo::myIsInit = Standard_False; namespace { + +#if !defined(GL_ES_VERSION_2_0) + static const GLint THE_FILLPRIM_FROM = GL_TRIANGLES; + static const GLint THE_FILLPRIM_TO = GL_POLYGON; +#else + static const GLint THE_FILLPRIM_FROM = GL_TRIANGLES; + static const GLint THE_FILLPRIM_TO = GL_TRIANGLE_FAN; +#endif + static const OpenGl_Vec4 THE_CAPPING_PLN_VERTS[12] = { OpenGl_Vec4 ( 0.0f, 0.0f, 0.0f, 1.0f), OpenGl_Vec4 ( 1.0f, 0.0f, 0.0f, 0.0f), @@ -45,7 +54,7 @@ namespace OpenGl_Vec4 ( 0.0f, 0.0f,-1.0f, 0.0f), OpenGl_Vec4 ( 1.0f, 0.0f, 0.0f, 0.0f) }; - static const OpenGl_Vec4 THE_CAPPING_PLN_TCOORD[12] = + static const OpenGl_Vec4 THE_CAPPING_PLN_TCOORD[12] = { OpenGl_Vec4 ( 0.0f, 0.0f, 0.0f, 1.0f), OpenGl_Vec4 ( 1.0f, 0.0f, 0.0f, 0.0f), OpenGl_Vec4 ( 0.0f, 1.0f, 0.0f, 0.0f), @@ -58,7 +67,7 @@ namespace OpenGl_Vec4 ( 0.0f, 0.0f, 0.0f, 1.0f), OpenGl_Vec4 ( 0.0f,-1.0f, 0.0f, 0.0f), OpenGl_Vec4 ( 1.0f, 0.0f, 0.0f, 0.0f) }; -}; +} // ======================================================================= // function : RenderCapping @@ -222,7 +231,7 @@ void OpenGl_CappingAlgo::RenderPlane (const Handle(OpenGl_Workspace)& theWorkspa // set identity model matrix const OpenGl_Matrix* aModelMatrix = theWorkspace->SetStructureMatrix (&OpenGl_IdentityMatrix); - +#if !defined(GL_ES_VERSION_2_0) glMultMatrixf ((const GLfloat*)aPlaneRes->Orientation()); glNormal3f (0.0f, 1.0f, 0.0f); glEnableClientState (GL_VERTEX_ARRAY); @@ -232,6 +241,7 @@ void OpenGl_CappingAlgo::RenderPlane (const Handle(OpenGl_Workspace)& theWorkspa glDrawArrays (GL_TRIANGLES, 0, 12); glDisableClientState (GL_VERTEX_ARRAY); glDisableClientState (GL_TEXTURE_COORD_ARRAY); +#endif theWorkspace->SetStructureMatrix (aModelMatrix, true); theWorkspace->SetAspectFace (aFaceAspect); @@ -268,6 +278,6 @@ Standard_Boolean OpenGl_CappingAlgoFilter::CanRender (const OpenGl_Element* theE { const OpenGl_PrimitiveArray* aPArray = dynamic_cast (theElement); return aPArray != NULL - && aPArray->DrawMode() >= GL_TRIANGLES - && aPArray->DrawMode() <= GL_POLYGON; + && aPArray->DrawMode() >= THE_FILLPRIM_FROM + && aPArray->DrawMode() <= THE_FILLPRIM_TO; } diff --git a/src/OpenGl/OpenGl_Clipping.cxx b/src/OpenGl/OpenGl_Clipping.cxx index fd954d0af6..220d170527 100755 --- a/src/OpenGl/OpenGl_Clipping.cxx +++ b/src/OpenGl/OpenGl_Clipping.cxx @@ -17,12 +17,17 @@ #include #include +#if defined(GL_ES_VERSION_2_0) + // id does not matter for GLSL-based clipping, just for consistency + #define GL_CLIP_PLANE0 0x3000 +#endif + // ======================================================================= // function : OpenGl_ClippingState // purpose : // ======================================================================= OpenGl_Clipping::OpenGl_Clipping () -: myEmptyPlaneIds (new Aspect_GenId (GL_CLIP_PLANE0, GL_CLIP_PLANE5)), +: myEmptyPlaneIds (new Aspect_GenId (GL_CLIP_PLANE0, GL_CLIP_PLANE0 + 5)), myNbClipping (0), myNbCapping (0) {} @@ -50,6 +55,7 @@ void OpenGl_Clipping::Add (Graphic3d_SequenceOfHClipPlane& thePlanes, const EquationCoords& theCoordSpace, const Handle(OpenGl_Workspace)& theWS) { +#if !defined(GL_ES_VERSION_2_0) GLint aMatrixMode; glGetIntegerv (GL_MATRIX_MODE, &aMatrixMode); @@ -77,6 +83,9 @@ void OpenGl_Clipping::Add (Graphic3d_SequenceOfHClipPlane& thePlanes, { glMatrixMode (aMatrixMode); } +#else + Add (thePlanes, theCoordSpace); +#endif } // ======================================================================= @@ -99,8 +108,10 @@ void OpenGl_Clipping::Add (Graphic3d_SequenceOfHClipPlane& thePlanes, const Equa myPlanes.Append (aPlane); myPlaneStates.Bind (aPlane, PlaneProps (theCoordSpace, anID, Standard_True)); - glEnable ((GLenum)anID); - glClipPlane ((GLenum)anID, aPlane->GetEquation()); + #if !defined(GL_ES_VERSION_2_0) + ::glEnable ((GLenum)anID); + ::glClipPlane ((GLenum)anID, aPlane->GetEquation()); + #endif if (aPlane->IsCapping()) { ++myNbCapping; @@ -141,7 +152,9 @@ void OpenGl_Clipping::Remove (const Graphic3d_SequenceOfHClipPlane& thePlanes) PlaneProps& aProps = myPlaneStates.ChangeFind (aPlane); if (aProps.IsEnabled) { + #if !defined(GL_ES_VERSION_2_0) glDisable ((GLenum)anID); + #endif if (aPlane->IsCapping()) { --myNbCapping; @@ -190,10 +203,14 @@ void OpenGl_Clipping::SetEnabled (const Handle(Graphic3d_ClipPlane)& thePlane, return; } +#if !defined(GL_ES_VERSION_2_0) GLenum anID = (GLenum)aProps.ContextID; +#endif if (theIsEnabled) { + #if !defined(GL_ES_VERSION_2_0) glEnable (anID); + #endif if (thePlane->IsCapping()) { ++myNbCapping; @@ -205,7 +222,9 @@ void OpenGl_Clipping::SetEnabled (const Handle(Graphic3d_ClipPlane)& thePlane, } else { + #if !defined(GL_ES_VERSION_2_0) glDisable (anID); + #endif if (thePlane->IsCapping()) { --myNbCapping; diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index 000304beaa..31c803b79f 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -88,6 +88,13 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps) core44 (NULL), core44back (NULL), caps (!theCaps.IsNull() ? theCaps : new OpenGl_Caps()), +#if defined(GL_ES_VERSION_2_0) + hasHighp (Standard_False), + hasTexRGBA8(Standard_False), +#else + hasHighp (Standard_True), + hasTexRGBA8(Standard_True), +#endif arbNPTW(Standard_False), arbTBO (NULL), arbIns (NULL), @@ -106,13 +113,18 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps) myGlLibHandle (NULL), myFuncs (new OpenGl_GlFunctions()), myAnisoMax (1), + myTexClamp (GL_CLAMP_TO_EDGE), myMaxTexDim (1024), myMaxClipPlanes (6), myGlVerMajor (0), myGlVerMinor (0), myIsInitialized (Standard_False), myIsStereoBuffers (Standard_False), +#if !defined(GL_ES_VERSION_2_0) myRenderMode (GL_RENDER), +#else + myRenderMode (0), +#endif myDrawBuffer (0) { #if defined(MAC_OS_X_VERSION_10_3) && !defined(MACOSX_USE_GLX) @@ -157,6 +169,7 @@ OpenGl_Context::~OpenGl_Context() mySharedResources.Nullify(); myDelayed.Nullify(); +#if !defined(GL_ES_VERSION_2_0) if (arbDbg != NULL && caps->contextDebug && IsValid()) @@ -169,6 +182,7 @@ OpenGl_Context::~OpenGl_Context() arbDbg->glDebugMessageCallbackARB (NULL, NULL); } } +#endif } // ======================================================================= @@ -204,6 +218,7 @@ Standard_Integer OpenGl_Context::MaxClipPlanes() const // ======================================================================= void OpenGl_Context::SetDrawBufferLeft() { +#if !defined(GL_ES_VERSION_2_0) switch (myDrawBuffer) { case GL_BACK_RIGHT : @@ -224,6 +239,7 @@ void OpenGl_Context::SetDrawBufferLeft() myDrawBuffer = GL_LEFT; break; } +#endif } // ======================================================================= @@ -232,6 +248,7 @@ void OpenGl_Context::SetDrawBufferLeft() // ======================================================================= void OpenGl_Context::SetDrawBufferRight() { +#if !defined(GL_ES_VERSION_2_0) switch (myDrawBuffer) { case GL_BACK_LEFT : @@ -252,6 +269,7 @@ void OpenGl_Context::SetDrawBufferRight() myDrawBuffer = GL_RIGHT; break; } +#endif } // ======================================================================= @@ -260,6 +278,7 @@ void OpenGl_Context::SetDrawBufferRight() // ======================================================================= void OpenGl_Context::SetDrawBufferMono() { +#if !defined(GL_ES_VERSION_2_0) switch (myDrawBuffer) { case GL_BACK_LEFT : @@ -280,6 +299,7 @@ void OpenGl_Context::SetDrawBufferMono() myDrawBuffer = GL_FRONT_AND_BACK; break; } +#endif } // ======================================================================= @@ -288,11 +308,13 @@ void OpenGl_Context::SetDrawBufferMono() // ======================================================================= void OpenGl_Context::FetchState() { +#if !defined(GL_ES_VERSION_2_0) // cache feedback mode state glGetIntegerv (GL_RENDER_MODE, &myRenderMode); // cache draw buffer state glGetIntegerv (GL_DRAW_BUFFER, &myDrawBuffer); +#endif } // ======================================================================= @@ -640,13 +662,14 @@ void OpenGl_Context::readGlVersion() myGlVerMajor = 0; myGlVerMinor = 0; - // available since OpenGL 3.0 +#ifdef GL_MAJOR_VERSION + // available since OpenGL 3.0 and OpenGL 3.0 ES 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 rendereres like e.g. Cygwin MESA. + // 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) @@ -656,9 +679,10 @@ void OpenGl_Context::readGlVersion() return; } ResetErrors(); +#endif // Read version string. - // Notice that only first two numbers splitted by point '2.1 XXXXX' are significant. + // 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. @@ -669,6 +693,17 @@ void OpenGl_Context::readGlVersion() 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]; @@ -734,6 +769,7 @@ static Standard_CString THE_DBGMSG_SEV_HIGH = "High"; // GL_DEBUG_SEVERITY_H static Standard_CString THE_DBGMSG_SEV_MEDIUM = "Medium"; // GL_DEBUG_SEVERITY_MEDIUM_ARB static Standard_CString THE_DBGMSG_SEV_LOW = "Low"; // GL_DEBUG_SEVERITY_LOW_ARB +#if !defined(GL_ES_VERSION_2_0) //! Callback for GL_ARB_debug_output extension static void APIENTRY debugCallbackWrap(unsigned int theSource, unsigned int theType, @@ -746,6 +782,7 @@ static void APIENTRY debugCallbackWrap(unsigned int theSource, OpenGl_Context* aCtx = (OpenGl_Context* )theUserParam; aCtx->PushMessage (theSource, theType, theId, theSeverity, theMessage); } +#endif // ======================================================================= // function : PushMessage @@ -784,7 +821,6 @@ void OpenGl_Context::PushMessage (const unsigned int theSource, aMsg += " | Severity: "; aMsg += aSev; aMsg += " | Message:\n "; aMsg += theMessage; - Messenger()->Send (aMsg, aGrav); } @@ -819,6 +855,41 @@ void OpenGl_Context::init() arbFBO = NULL; extGS = NULL; +#if defined(GL_ES_VERSION_2_0) + + hasTexRGBA8 = IsGlGreaterEqual (3, 0) + || CheckExtension ("GL_OES_rgb8_rgba8"); + arbNPTW = IsGlGreaterEqual (3, 0) + || CheckExtension ("GL_OES_texture_npot"); + arbTexRG = IsGlGreaterEqual (3, 0) + || CheckExtension ("GL_EXT_texture_rg"); + extBgra = CheckExtension ("GL_EXT_texture_format_BGRA8888"); + extAnis = CheckExtension ("GL_EXT_texture_filter_anisotropic"); + extPDS = CheckExtension ("GL_OES_packed_depth_stencil"); + + core11fwd = (OpenGl_GlCore11Fwd* )(&(*myFuncs)); + if (IsGlGreaterEqual (2, 0)) + { + // enable compatible functions + core20 = (OpenGl_GlCore20* )(&(*myFuncs)); + core20fwd = (OpenGl_GlCore20Fwd* )(&(*myFuncs)); + core15fwd = (OpenGl_GlCore15Fwd* )(&(*myFuncs)); + arbFBO = (OpenGl_ArbFBO* )(&(*myFuncs)); + } + + hasHighp = CheckExtension ("OES_fragment_precision_high"); + GLint aRange[2] = {0, 0}; + GLint aPrec [2] = {0, 0}; + ::glGetShaderPrecisionFormat (GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, aRange, aPrec); + if (aPrec[1] != 0) + { + hasHighp = Standard_True; + } +#else + + myTexClamp = IsGlGreaterEqual (1, 2) ? GL_CLAMP_TO_EDGE : GL_CLAMP; + + hasTexRGBA8 = Standard_True; arbNPTW = CheckExtension ("GL_ARB_texture_non_power_of_two"); extBgra = CheckExtension ("GL_EXT_bgra"); extAnis = CheckExtension ("GL_EXT_texture_filter_anisotropic"); @@ -826,14 +897,16 @@ void OpenGl_Context::init() atiMem = CheckExtension ("GL_ATI_meminfo"); nvxMem = CheckExtension ("GL_NVX_gpu_memory_info"); - // get number of maximum clipping planes - glGetIntegerv (GL_MAX_CLIP_PLANES, &myMaxClipPlanes); - glGetIntegerv (GL_MAX_TEXTURE_SIZE, &myMaxTexDim); - - GLint aStereo; + GLint aStereo = GL_FALSE; glGetIntegerv (GL_STEREO, &aStereo); myIsStereoBuffers = aStereo == 1; + // get number of maximum clipping planes + glGetIntegerv (GL_MAX_CLIP_PLANES, &myMaxClipPlanes); +#endif + + glGetIntegerv (GL_MAX_TEXTURE_SIZE, &myMaxTexDim); + if (extAnis) { glGetIntegerv (GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &myAnisoMax); @@ -841,6 +914,8 @@ void OpenGl_Context::init() myClippingState.Init (myMaxClipPlanes); +#if !defined(GL_ES_VERSION_2_0) + bool has12 = false; bool has13 = false; bool has14 = false; @@ -1787,6 +1862,7 @@ void OpenGl_Context::init() } core44 = (OpenGl_GlCore44* )(&(*myFuncs)); core44back = (OpenGl_GlCore44Back* )(&(*myFuncs)); +#endif } // ======================================================================= @@ -1795,6 +1871,7 @@ void OpenGl_Context::init() // ======================================================================= Standard_Size OpenGl_Context::AvailableMemory() const { +#if !defined(GL_ES_VERSION_2_0) if (atiMem) { // this is actually information for VBO pool @@ -1813,6 +1890,7 @@ Standard_Size OpenGl_Context::AvailableMemory() const glGetIntegerv (GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &aMemInfo); return Standard_Size(aMemInfo) * 1024; } +#endif return 0; } @@ -1823,6 +1901,7 @@ Standard_Size OpenGl_Context::AvailableMemory() const TCollection_AsciiString OpenGl_Context::MemoryInfo() const { TCollection_AsciiString anInfo; +#if !defined(GL_ES_VERSION_2_0) if (atiMem) { GLint aValues[4]; @@ -1860,6 +1939,7 @@ TCollection_AsciiString OpenGl_Context::MemoryInfo() const anInfo += TCollection_AsciiString (" Total memory: ") + (aValue / 1024) + " MiB\n"; } } +#endif return anInfo; } diff --git a/src/OpenGl/OpenGl_Context.hxx b/src/OpenGl/OpenGl_Context.hxx index 5d8e292e1d..ae5d28eae8 100644 --- a/src/OpenGl/OpenGl_Context.hxx +++ b/src/OpenGl/OpenGl_Context.hxx @@ -260,13 +260,21 @@ public: //! Return true if active mode is GL_RENDER (cached state) Standard_Boolean IsRender() const { + #if !defined(GL_ES_VERSION_2_0) return myRenderMode == GL_RENDER; + #else + return Standard_True; + #endif } //! Return true if active mode is GL_FEEDBACK (cached state) Standard_Boolean IsFeedback() const { + #if !defined(GL_ES_VERSION_2_0) return myRenderMode == GL_FEEDBACK; + #else + return Standard_False; + #endif } //! This function retrieves information from GL about free GPU memory that is: @@ -341,6 +349,9 @@ public: public: + //! Either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1). + Standard_Integer TextureWrapClamp() const { return myTexClamp; } + //! @return maximum degree of anisotropy texture filter Standard_EXPORT Standard_Integer MaxDegreeOfAnisotropy() const; @@ -386,7 +397,11 @@ public: //! right rendering buffers. Standard_Boolean HasStereoBuffers() const { + #if !defined(GL_ES_VERSION_2_0) return myIsStereoBuffers; + #else + return Standard_False; + #endif } public: //! @name methods to alter or retrieve current state @@ -456,18 +471,20 @@ public: //! @name core profiles public: //! @name extensions - Standard_Boolean arbNPTW; //!< GL_ARB_texture_non_power_of_two - Standard_Boolean arbTexRG;//!< GL_ARB_texture_rg - OpenGl_ArbTBO* arbTBO; //!< GL_ARB_texture_buffer_object - OpenGl_ArbIns* arbIns; //!< GL_ARB_draw_instanced - OpenGl_ArbDbg* arbDbg; //!< GL_ARB_debug_output - OpenGl_ArbFBO* arbFBO; //!< GL_ARB_framebuffer_object - OpenGl_ExtGS* extGS; //!< GL_EXT_geometry_shader4 - Standard_Boolean extBgra; //!< GL_EXT_bgra - Standard_Boolean extAnis; //!< GL_EXT_texture_filter_anisotropic - Standard_Boolean extPDS; //!< GL_EXT_packed_depth_stencil - Standard_Boolean atiMem; //!< GL_ATI_meminfo - Standard_Boolean nvxMem; //!< GL_NVX_gpu_memory_info + Standard_Boolean hasHighp; //!< highp in GLSL ES fragment shader is supported + Standard_Boolean hasTexRGBA8; //!< always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_rgb8_rgba8 + Standard_Boolean arbNPTW; //!< GL_ARB_texture_non_power_of_two + Standard_Boolean arbTexRG; //!< GL_ARB_texture_rg + OpenGl_ArbTBO* arbTBO; //!< GL_ARB_texture_buffer_object + OpenGl_ArbIns* arbIns; //!< GL_ARB_draw_instanced + OpenGl_ArbDbg* arbDbg; //!< GL_ARB_debug_output + OpenGl_ArbFBO* arbFBO; //!< GL_ARB_framebuffer_object + OpenGl_ExtGS* extGS; //!< GL_EXT_geometry_shader4 + Standard_Boolean extBgra; //!< GL_EXT_bgra or GL_EXT_texture_format_BGRA8888 on OpenGL ES + Standard_Boolean extAnis; //!< GL_EXT_texture_filter_anisotropic + Standard_Boolean extPDS; //!< GL_EXT_packed_depth_stencil + Standard_Boolean atiMem; //!< GL_ATI_meminfo + Standard_Boolean nvxMem; //!< GL_NVX_gpu_memory_info private: // system-dependent fields @@ -506,6 +523,7 @@ private: // context info NCollection_Handle myFuncs; //!< mega structure for all GL functions Standard_Integer myAnisoMax; //!< maximum level of anisotropy texture filter + Standard_Integer myTexClamp; //!< either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1) Standard_Integer myMaxTexDim; //!< value for GL_MAX_TEXTURE_SIZE Standard_Integer myMaxClipPlanes; //!< value for GL_MAX_CLIP_PLANES Standard_Integer myGlVerMajor; //!< cached GL version major number diff --git a/src/OpenGl/OpenGl_ExtGS.hxx b/src/OpenGl/OpenGl_ExtGS.hxx index dd7f146bd4..5c8c2f6037 100644 --- a/src/OpenGl/OpenGl_ExtGS.hxx +++ b/src/OpenGl/OpenGl_ExtGS.hxx @@ -21,7 +21,9 @@ //! Geometry shader as extension is available on OpenGL 2.0+ struct OpenGl_ExtGS : protected OpenGl_GlFunctions { +#if !defined(GL_ES_VERSION_2_0) using OpenGl_GlFunctions::glProgramParameteriEXT; +#endif }; #endif // _OpenGl_ExtGS_H__ diff --git a/src/OpenGl/OpenGl_Flipper.cxx b/src/OpenGl/OpenGl_Flipper.cxx index 242143b2cd..14776ac8fb 100755 --- a/src/OpenGl/OpenGl_Flipper.cxx +++ b/src/OpenGl/OpenGl_Flipper.cxx @@ -67,6 +67,8 @@ void OpenGl_Flipper::Render (const Handle(OpenGl_Workspace)& theWorkspace) const // Check if rendering is to be in immediate mode const Standard_Boolean isImmediate = (theWorkspace->NamedStatus & OPENGL_NS_IMMEDIATE) != 0; const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext(); + +#if !defined(GL_ES_VERSION_2_0) GLint aCurrMode = GL_MODELVIEW; glGetIntegerv (GL_MATRIX_MODE, &aCurrMode); @@ -198,4 +200,5 @@ void OpenGl_Flipper::Render (const Handle(OpenGl_Workspace)& theWorkspace) const { glMatrixMode (aCurrMode); } +#endif } diff --git a/src/OpenGl/OpenGl_Font.cxx b/src/OpenGl/OpenGl_Font.cxx index c8d11edfac..2b888b69da 100755 --- a/src/OpenGl/OpenGl_Font.cxx +++ b/src/OpenGl/OpenGl_Font.cxx @@ -36,7 +36,7 @@ OpenGl_Font::OpenGl_Font (const Handle(Font_FTFont)& theFont, myTileSizeX (0), myTileSizeY (0), myLastTileId (-1), - myTextureFormat (GL_ALPHA8) + myTextureFormat (GL_ALPHA) { memset (&myLastTilePx, 0, sizeof(myLastTilePx)); } @@ -131,8 +131,8 @@ bool OpenGl_Font::createTexture (const Handle(OpenGl_Context)& theCtx) } aTexture->Bind (theCtx); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, theCtx->TextureWrapClamp()); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, theCtx->TextureWrapClamp()); aTexture->Unbind (theCtx); return true; } @@ -173,8 +173,10 @@ bool OpenGl_Font::renderGlyph (const Handle(OpenGl_Context)& theCtx, } aTexture->Bind (theCtx); +#if !defined(GL_ES_VERSION_2_0) glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE); glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); +#endif glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glTexSubImage2D (GL_TEXTURE_2D, 0, diff --git a/src/OpenGl/OpenGl_FrameBuffer.cxx b/src/OpenGl/OpenGl_FrameBuffer.cxx index 244bdf68e2..4d45461cd0 100644 --- a/src/OpenGl/OpenGl_FrameBuffer.cxx +++ b/src/OpenGl/OpenGl_FrameBuffer.cxx @@ -92,8 +92,15 @@ Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlCo theGlContext->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, myGlFBufferId); theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, myColorTexture->TextureId(), 0); +#ifdef GL_DEPTH_STENCIL_ATTACHMENT theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, myDepthStencilTexture->TextureId(), 0); +#else + theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, + GL_TEXTURE_2D, myDepthStencilTexture->TextureId(), 0); + theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, + GL_TEXTURE_2D, myDepthStencilTexture->TextureId(), 0); +#endif if (theGlContext->arbFBO->glCheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { Release (theGlContext.operator->()); diff --git a/src/OpenGl/OpenGl_GlCore11.hxx b/src/OpenGl/OpenGl_GlCore11.hxx index cd2611dca6..e4eadd4de0 100644 --- a/src/OpenGl/OpenGl_GlCore11.hxx +++ b/src/OpenGl/OpenGl_GlCore11.hxx @@ -25,6 +25,23 @@ struct OpenGl_GlCore11 : protected OpenGl_GlFunctions { +#if !defined(GL_ES_VERSION_2_0) + inline void glRotated (GLdouble theAngleDegrees, + GLdouble theX, GLdouble theY, GLdouble theZ) + { + ::glRotated (theAngleDegrees, theX, theY, theZ); + } + + inline void glScaled (GLdouble theX, GLdouble theY, GLdouble theZ) + { + ::glScaled (theX, theY, theZ); + } + + inline void glTranslated (GLdouble theX, GLdouble theY, GLdouble theZ) + { + ::glTranslated (theX, theY, theZ); + } + public: //! @name Begin/End primitive specification (removed since 3.1) inline void glBegin (GLenum theMode) @@ -633,38 +650,6 @@ public: //! @name Matrix operations (removed since 3.1) ::glMultMatrixf (theMatrix); } - inline void glRotated (GLdouble theAngleDegrees, - GLdouble theX, GLdouble theY, GLdouble theZ) - { - ::glRotated (theAngleDegrees, theX, theY, theZ); - } - - inline void glRotatef (GLfloat theAngleDegrees, - GLfloat theX, GLfloat theY, GLfloat theZ) - { - ::glRotatef (theAngleDegrees, theX, theY, theZ); - } - - inline void glScaled (GLdouble theX, GLdouble theY, GLdouble theZ) - { - ::glScaled (theX, theY, theZ); - } - - inline void glScalef (GLfloat theX, GLfloat theY, GLfloat theZ) - { - ::glScalef (theX, theY, theZ); - } - - inline void glTranslated (GLdouble theX, GLdouble theY, GLdouble theZ) - { - ::glTranslated (theX, theY, theZ); - } - - inline void glTranslatef (GLfloat theX, GLfloat theY, GLfloat theZ) - { - ::glTranslatef (theX, theY, theZ); - } - public: //! @name Line and Polygon stripple (removed since 3.1) //void glLineWidth (GLfloat theWidth) { ::glLineWidth (theWidth); } @@ -1313,44 +1298,44 @@ public: //! @name Edge flags and fixed-function vertex processing (removed since ::glEdgeFlagv (theFlag); } - inline void glVertexPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) + inline void glIndexPointer (GLenum theType, GLsizei theStride, const GLvoid* thePtr) { - ::glVertexPointer (theSize, theType, theStride, thePtr); + ::glIndexPointer (theType, theStride, thePtr); } - inline void glNormalPointer (GLenum theType, GLsizei theStride, const GLvoid* thePtr) + inline void glEdgeFlagPointer (GLsizei theStride, const GLvoid* thePtr) { - ::glNormalPointer (theType, theStride, thePtr); + ::glEdgeFlagPointer (theStride, thePtr); } - inline void glColorPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) + inline void glGetPointerv (GLenum pname, GLvoid** params) { - ::glColorPointer (theSize, theType, theStride, thePtr); + ::glGetPointerv(pname, params); } - inline void glIndexPointer (GLenum theType, GLsizei theStride, const GLvoid* thePtr) + inline void glInterleavedArrays (GLenum theFormat, GLsizei theStride, const GLvoid* thePointer) { - ::glIndexPointer (theType, theStride, thePtr); + ::glInterleavedArrays (theFormat, theStride, thePointer); } - inline void glTexCoordPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) + inline void glVertexPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) { - ::glTexCoordPointer (theSize, theType, theStride, thePtr); + ::glVertexPointer (theSize, theType, theStride, thePtr); } - inline void glEdgeFlagPointer (GLsizei theStride, const GLvoid* thePtr) + inline void glNormalPointer (GLenum theType, GLsizei theStride, const GLvoid* thePtr) { - ::glEdgeFlagPointer (theStride, thePtr); + ::glNormalPointer (theType, theStride, thePtr); } - inline void glGetPointerv (GLenum pname, GLvoid** params) + inline void glColorPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) { - ::glGetPointerv(pname, params); + ::glColorPointer (theSize, theType, theStride, thePtr); } - inline void glInterleavedArrays (GLenum theFormat, GLsizei theStride, const GLvoid* thePointer) + inline void glTexCoordPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) { - ::glInterleavedArrays (theFormat, theStride, thePointer); + ::glTexCoordPointer (theSize, theType, theStride, thePtr); } inline void glEnableClientState (GLenum theCap) @@ -1363,6 +1348,8 @@ public: //! @name Edge flags and fixed-function vertex processing (removed since ::glDisableClientState (theCap); } +#endif + }; #endif // _OpenGl_GlCore11_Header diff --git a/src/OpenGl/OpenGl_GlCore11Fwd.hxx b/src/OpenGl/OpenGl_GlCore11Fwd.hxx index 6cc0e21a09..358e8333ef 100644 --- a/src/OpenGl/OpenGl_GlCore11Fwd.hxx +++ b/src/OpenGl/OpenGl_GlCore11Fwd.hxx @@ -27,11 +27,6 @@ struct OpenGl_GlCore11Fwd : protected OpenGl_GlFunctions public: //! @name Miscellaneous - inline void glClearIndex (GLfloat c) - { - ::glClearIndex(c); - } - inline void glClearColor (GLclampf theRed, GLclampf theGreen, GLclampf theBlue, GLclampf theAlpha) { ::glClearColor (theRed, theGreen, theBlue, theAlpha); @@ -42,31 +37,16 @@ public: //! @name Miscellaneous ::glClear (theMask); } - inline void glIndexMask (GLuint theMask) - { - ::glIndexMask (theMask); - } - inline void glColorMask (GLboolean theRed, GLboolean theGreen, GLboolean theBlue, GLboolean theAlpha) { ::glColorMask (theRed, theGreen, theBlue, theAlpha); } - inline void glAlphaFunc (GLenum theFunc, GLclampf theRef) - { - ::glAlphaFunc (theFunc, theRef); - } - inline void glBlendFunc (GLenum sfactor, GLenum dfactor) { ::glBlendFunc(sfactor, dfactor); } - inline void glLogicOp (GLenum opcode) - { - ::glLogicOp(opcode); - } - inline void glCullFace (GLenum theMode) { ::glCullFace (theMode); @@ -77,21 +57,11 @@ public: //! @name Miscellaneous ::glFrontFace (theMode); } - inline void glPointSize (GLfloat theSize) - { - ::glPointSize (theSize); - } - inline void glLineWidth (GLfloat theWidth) { ::glLineWidth (theWidth); } - inline void glPolygonMode (GLenum theFace, GLenum theMode) - { - ::glPolygonMode (theFace, theMode); - } - inline void glPolygonOffset (GLfloat theFactor, GLfloat theUnits) { ::glPolygonOffset (theFactor, theUnits); @@ -102,16 +72,6 @@ public: //! @name Miscellaneous ::glScissor (theX, theY, theWidth, theHeight); } - inline void glDrawBuffer (GLenum theMode) - { - ::glDrawBuffer (theMode); - } - - inline void glReadBuffer (GLenum theMode) - { - ::glReadBuffer (theMode); - } - inline void glEnable (GLenum theCap) { ::glEnable (theCap); @@ -132,11 +92,6 @@ public: //! @name Miscellaneous ::glGetBooleanv (theParamName, theValues); } - inline void glGetDoublev (GLenum theParamName, GLdouble* theValues) - { - ::glGetDoublev (theParamName, theValues); - } - inline void glGetFloatv (GLenum theParamName, GLfloat* theValues) { ::glGetFloatv (theParamName, theValues); @@ -147,11 +102,6 @@ public: //! @name Miscellaneous ::glGetIntegerv (theParamName, theValues); } - inline GLint glRenderMode (GLenum theMode) - { - return ::glRenderMode (theMode); - } - inline GLenum glGetError() { return ::glGetError(); @@ -181,7 +131,20 @@ public: //! @name Depth Buffer inline void glClearDepth (GLclampd theDepth) { + #if defined(GL_ES_VERSION_2_0) + ::glClearDepthf ((GLfloat )theDepth); + #else ::glClearDepth (theDepth); + #endif + } + + inline void glClearDepthf (GLfloat theDepth) + { + #if defined(GL_ES_VERSION_2_0) + ::glClearDepthf (theDepth); + #else + ::glClearDepth ((GLclampd )theDepth); + #endif } inline void glDepthFunc (GLenum theFunc) @@ -194,9 +157,24 @@ public: //! @name Depth Buffer ::glDepthMask (theFlag); } - inline void glDepthRange (GLclampd theNearValue, GLclampd theFarValue) + inline void glDepthRange (GLclampd theNearValue, + GLclampd theFarValue) { + #if defined(GL_ES_VERSION_2_0) + ::glDepthRangef ((GLfloat )theNearValue, (GLfloat )theFarValue); + #else ::glDepthRange (theNearValue, theFarValue); + #endif + } + + inline void glDepthRangef (GLfloat theNearValue, + GLfloat theFarValue) + { + #if defined(GL_ES_VERSION_2_0) + ::glDepthRangef (theNearValue, theFarValue); + #else + ::glDepthRange ((GLclampd )theNearValue, (GLclampd )theFarValue); + #endif } public: //! @name Transformation @@ -208,11 +186,6 @@ public: //! @name Transformation public: //! @name Vertex Arrays - inline void glArrayElement (GLint i) - { - ::glArrayElement (i); - } - inline void glDrawArrays (GLenum theMode, GLint theFirst, GLsizei theCount) { ::glDrawArrays (theMode, theFirst, theCount); @@ -225,87 +198,177 @@ public: //! @name Vertex Arrays public: //! @name Raster functions - inline void glPixelStoref (GLenum theParamName, GLfloat theParam) + inline void glPixelStorei (GLenum theParamName, GLint theParam) { - ::glPixelStoref (theParamName, theParam); + ::glPixelStorei (theParamName, theParam); } - inline void glPixelStorei (GLenum theParamName, GLint theParam) + inline void glReadPixels (GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLvoid* pixels) { - ::glPixelStorei (theParamName, theParam); + ::glReadPixels (x, y, width, height, format, type, pixels); } - inline void glPixelTransferf (GLenum theParamName, GLfloat theParam) +public: //! @name Stenciling + + inline void glStencilFunc (GLenum func, GLint ref, GLuint mask) { - ::glPixelTransferf (theParamName, theParam); + ::glStencilFunc (func, ref, mask); } - inline void glPixelTransferi (GLenum theParamName, GLint theParam) + inline void glStencilMask (GLuint mask) { - ::glPixelTransferi (theParamName, theParam); + ::glStencilMask (mask); } - inline void glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat* values) + inline void glStencilOp (GLenum fail, GLenum zfail, GLenum zpass) { - ::glPixelMapfv (map, mapsize, values); + ::glStencilOp (fail, zfail, zpass); } - inline void glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint* values) + inline void glClearStencil (GLint s) { - ::glPixelMapuiv (map, mapsize, values); + ::glClearStencil (s); } - inline void glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort* values) +public: //! @name Texture mapping + + inline void glTexParameterf (GLenum target, GLenum pname, GLfloat param) { - ::glPixelMapusv (map, mapsize, values); + ::glTexParameterf (target, pname, param); } - inline void glGetPixelMapfv (GLenum map, GLfloat* values) + inline void glTexParameteri (GLenum target, GLenum pname, GLint param) { - ::glGetPixelMapfv (map, values); + ::glTexParameteri (target, pname, param); } - inline void glGetPixelMapuiv (GLenum map, GLuint* values) + inline void glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params) { - ::glGetPixelMapuiv (map, values); + ::glTexParameterfv (target, pname, params); } - inline void glGetPixelMapusv (GLenum map, GLushort* values) + inline void glTexParameteriv (GLenum target, GLenum pname, const GLint* params) { - ::glGetPixelMapusv (map, values); + ::glTexParameteriv (target, pname, params); } - inline void glReadPixels (GLint x, GLint y, + inline void glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params) + { + ::glGetTexParameterfv (target, pname, params); + } + + inline void glGetTexParameteriv (GLenum target, GLenum pname, GLint* params) + { + ::glGetTexParameteriv (target, pname, params); + } + + 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); + } + + inline void glGenTextures (GLsizei n, GLuint* textures) + { + ::glGenTextures(n, textures); + } + + inline void glDeleteTextures (GLsizei n, const GLuint* textures) + { + ::glDeleteTextures(n, textures); + } + + inline void glBindTexture (GLenum target, GLuint texture) + { + ::glBindTexture(target, texture); + } + + inline GLboolean glIsTexture (GLuint texture) + { + return ::glIsTexture (texture); + } + + 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); + } + + 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); + } + + 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); + } + +#if !defined(GL_ES_VERSION_2_0) + inline void glTexImage1D (GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLint border, GLenum format, GLenum type, - GLvoid* pixels) + const GLvoid* pixels) { - ::glReadPixels (x, y, width, height, format, type, pixels); + ::glTexImage1D(target, level, internalFormat, width, border, format, type, pixels); } -public: //! @name Stenciling + 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); + } - inline void glStencilFunc (GLenum func, GLint ref, GLuint mask) + inline void glCopyTexImage1D (GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border) { - ::glStencilFunc (func, ref, mask); + ::glCopyTexImage1D(target, level, internalformat, x, y, width, border); } - inline void glStencilMask (GLuint mask) + inline void glCopyTexSubImage1D (GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width) { - ::glStencilMask (mask); + ::glCopyTexSubImage1D(target, level, xoffset, x, y, width); } +#endif - inline void glStencilOp (GLenum fail, GLenum zfail, GLenum zpass) +#if !defined(GL_ES_VERSION_2_0) + + inline void glAlphaFunc (GLenum theFunc, GLclampf theRef) { - ::glStencilOp (fail, zfail, zpass); + ::glAlphaFunc (theFunc, theRef); } - inline void glClearStencil (GLint s) + inline void glPointSize (GLfloat theSize) { - ::glClearStencil (s); + ::glPointSize (theSize); } -public: //! @name Texture mapping +#endif + +/*#if !defined(GL_ES_VERSION_2_0) inline void glTexEnvf (GLenum target, GLenum pname, GLfloat param) { @@ -337,139 +400,113 @@ public: //! @name Texture mapping ::glGetTexEnviv (target, pname, params); } - inline void glTexParameterf (GLenum target, GLenum pname, GLfloat param) + inline void glGetTexImage (GLenum target, GLint level, + GLenum format, GLenum type, + GLvoid* pixels) { - ::glTexParameterf (target, pname, param); + ::glGetTexImage(target, level, format, type, pixels); } - inline void glTexParameteri (GLenum target, GLenum pname, GLint param) + inline void glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat* params) { - ::glTexParameteri (target, pname, param); + ::glGetTexLevelParameterfv (target, level, pname, params); } - inline void glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params) + inline void glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint* params) { - ::glTexParameterfv (target, pname, params); + ::glGetTexLevelParameteriv (target, level, pname, params); } - inline void glTexParameteriv (GLenum target, GLenum pname, const GLint* params) + inline void glClearIndex (GLfloat c) { - ::glTexParameteriv (target, pname, params); + ::glClearIndex(c); } - inline void glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params) + inline void glIndexMask (GLuint theMask) { - ::glGetTexParameterfv (target, pname, params); + ::glIndexMask (theMask); } - inline void glGetTexParameteriv (GLenum target, GLenum pname, GLint* params) + inline void glLogicOp (GLenum opcode) { - ::glGetTexParameteriv (target, pname, params); + ::glLogicOp(opcode); } - inline void glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat* params) + inline void glPolygonMode (GLenum theFace, GLenum theMode) { - ::glGetTexLevelParameterfv (target, level, pname, params); + ::glPolygonMode (theFace, theMode); } - inline void glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint* params) + inline void glDrawBuffer (GLenum theMode) { - ::glGetTexLevelParameteriv (target, level, pname, params); + ::glDrawBuffer (theMode); } - inline void glTexImage1D (GLenum target, GLint level, - GLint internalFormat, - GLsizei width, GLint border, - GLenum format, GLenum type, - const GLvoid* pixels) + inline void glReadBuffer (GLenum theMode) { - ::glTexImage1D(target, level, internalFormat, width, border, format, type, pixels); + ::glReadBuffer (theMode); } - inline void glTexImage2D (GLenum target, GLint level, - GLint internalFormat, - GLsizei width, GLsizei height, - GLint border, GLenum format, GLenum type, - const GLvoid* pixels) + inline void glGetDoublev (GLenum theParamName, GLdouble* theValues) { - ::glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels); + ::glGetDoublev (theParamName, theValues); } - inline void glGetTexImage (GLenum target, GLint level, - GLenum format, GLenum type, - GLvoid* pixels) + inline GLint glRenderMode (GLenum theMode) { - ::glGetTexImage(target, level, format, type, pixels); + return ::glRenderMode (theMode); } - inline void glGenTextures (GLsizei n, GLuint* textures) + inline void glArrayElement (GLint i) { - ::glGenTextures(n, textures); + ::glArrayElement (i); } - inline void glDeleteTextures (GLsizei n, const GLuint* textures) + inline void glPixelStoref (GLenum theParamName, GLfloat theParam) { - ::glDeleteTextures(n, textures); + ::glPixelStoref (theParamName, theParam); } - inline void glBindTexture (GLenum target, GLuint texture) + inline void glPixelTransferf (GLenum theParamName, GLfloat theParam) { - ::glBindTexture(target, texture); + ::glPixelTransferf (theParamName, theParam); } - inline GLboolean glIsTexture (GLuint texture) + inline void glPixelTransferi (GLenum theParamName, GLint theParam) { - return ::glIsTexture (texture); + ::glPixelTransferi (theParamName, theParam); } - inline void glTexSubImage1D (GLenum target, GLint level, - GLint xoffset, - GLsizei width, GLenum format, - GLenum type, const GLvoid* pixels) + inline void glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat* values) { - ::glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + ::glPixelMapfv (map, mapsize, values); } - inline void glTexSubImage2D (GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid* pixels) + inline void glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint* values) { - ::glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + ::glPixelMapuiv (map, mapsize, values); } - inline void glCopyTexImage1D (GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, - GLsizei width, GLint border) + inline void glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort* values) { - ::glCopyTexImage1D(target, level, internalformat, x, y, width, border); + ::glPixelMapusv (map, mapsize, values); } - inline void glCopyTexImage2D (GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLint border) + inline void glGetPixelMapfv (GLenum map, GLfloat* values) { - ::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); + ::glGetPixelMapfv (map, values); } - inline void glCopyTexSubImage1D (GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, - GLsizei width) + inline void glGetPixelMapuiv (GLenum map, GLuint* values) { - ::glCopyTexSubImage1D(target, level, xoffset, x, y, width); + ::glGetPixelMapuiv (map, values); } - inline void glCopyTexSubImage2D (GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, GLsizei height) + inline void glGetPixelMapusv (GLenum map, GLushort* values) { - ::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); + ::glGetPixelMapusv (map, values); } +#endif*/ }; diff --git a/src/OpenGl/OpenGl_GlCore12.hxx b/src/OpenGl/OpenGl_GlCore12.hxx index 406b541a41..da93402ff0 100644 --- a/src/OpenGl/OpenGl_GlCore12.hxx +++ b/src/OpenGl/OpenGl_GlCore12.hxx @@ -27,10 +27,13 @@ public: //! @name OpenGL 1.2 additives to 1.1 using theBaseClass_t::glBlendColor; using theBaseClass_t::glBlendEquation; + +#if !defined(GL_ES_VERSION_2_0) using theBaseClass_t::glDrawRangeElements; using theBaseClass_t::glTexImage3D; using theBaseClass_t::glTexSubImage3D; using theBaseClass_t::glCopyTexSubImage3D; +#endif }; diff --git a/src/OpenGl/OpenGl_GlCore13.hxx b/src/OpenGl/OpenGl_GlCore13.hxx index 0e141335cc..ac462df4fc 100644 --- a/src/OpenGl/OpenGl_GlCore13.hxx +++ b/src/OpenGl/OpenGl_GlCore13.hxx @@ -24,15 +24,18 @@ struct OpenGl_GlCore13Fwd : public OpenGl_GlCore12Fwd public: //! @name OpenGL 1.3 additives to 1.2 - using OpenGl_GlFunctions::glActiveTexture; - using OpenGl_GlFunctions::glSampleCoverage; +#if !defined(GL_ES_VERSION_2_0) using OpenGl_GlFunctions::glCompressedTexImage3D; - using OpenGl_GlFunctions::glCompressedTexImage2D; using OpenGl_GlFunctions::glCompressedTexImage1D; using OpenGl_GlFunctions::glCompressedTexSubImage3D; - using OpenGl_GlFunctions::glCompressedTexSubImage2D; using OpenGl_GlFunctions::glCompressedTexSubImage1D; using OpenGl_GlFunctions::glGetCompressedTexImage; +#endif + + using OpenGl_GlFunctions::glActiveTexture; + using OpenGl_GlFunctions::glSampleCoverage; + using OpenGl_GlFunctions::glCompressedTexImage2D; + using OpenGl_GlFunctions::glCompressedTexSubImage2D; }; @@ -42,15 +45,20 @@ struct OpenGl_GlCore13 : public OpenGl_GlCore12 public: //! @name OpenGL 1.3 additives to 1.2 - using OpenGl_GlFunctions::glActiveTexture; - using OpenGl_GlFunctions::glSampleCoverage; +#if !defined(GL_ES_VERSION_2_0) using OpenGl_GlFunctions::glCompressedTexImage3D; - using OpenGl_GlFunctions::glCompressedTexImage2D; using OpenGl_GlFunctions::glCompressedTexImage1D; using OpenGl_GlFunctions::glCompressedTexSubImage3D; - using OpenGl_GlFunctions::glCompressedTexSubImage2D; using OpenGl_GlFunctions::glCompressedTexSubImage1D; using OpenGl_GlFunctions::glGetCompressedTexImage; +#endif + + using OpenGl_GlFunctions::glActiveTexture; + using OpenGl_GlFunctions::glSampleCoverage; + using OpenGl_GlFunctions::glCompressedTexImage2D; + using OpenGl_GlFunctions::glCompressedTexSubImage2D; + +#if !defined(GL_ES_VERSION_2_0) public: //! @name Begin/End primitive specification (removed since 3.1) @@ -96,6 +104,8 @@ public: //! @name Matrix operations (removed since 3.1) using OpenGl_GlFunctions::glMultTransposeMatrixf; using OpenGl_GlFunctions::glMultTransposeMatrixd; +#endif + }; #endif // _OpenGl_GlCore13_Header diff --git a/src/OpenGl/OpenGl_GlCore14.hxx b/src/OpenGl/OpenGl_GlCore14.hxx index 9725f0f7ad..fbcc98bfba 100644 --- a/src/OpenGl/OpenGl_GlCore14.hxx +++ b/src/OpenGl/OpenGl_GlCore14.hxx @@ -25,13 +25,16 @@ struct OpenGl_TmplCore14 : public theBaseClass_t public: //! @name OpenGL 1.4 additives to 1.3 + using theBaseClass_t::glMultiDrawElements; using theBaseClass_t::glBlendFuncSeparate; + +#if !defined(GL_ES_VERSION_2_0) using theBaseClass_t::glMultiDrawArrays; - using theBaseClass_t::glMultiDrawElements; using theBaseClass_t::glPointParameterf; using theBaseClass_t::glPointParameterfv; using theBaseClass_t::glPointParameteri; using theBaseClass_t::glPointParameteriv; +#endif }; diff --git a/src/OpenGl/OpenGl_GlCore15.hxx b/src/OpenGl/OpenGl_GlCore15.hxx index 7e03674d34..fb428963d0 100644 --- a/src/OpenGl/OpenGl_GlCore15.hxx +++ b/src/OpenGl/OpenGl_GlCore15.hxx @@ -27,6 +27,7 @@ struct OpenGl_TmplCore15 : public theBaseClass_t public: //! @name OpenGL 1.5 additives to 1.4 +#if !defined(GL_ES_VERSION_2_0) using theBaseClass_t::glGenQueries; using theBaseClass_t::glDeleteQueries; using theBaseClass_t::glIsQuery; @@ -35,17 +36,20 @@ public: //! @name OpenGL 1.5 additives to 1.4 using theBaseClass_t::glGetQueryiv; using theBaseClass_t::glGetQueryObjectiv; using theBaseClass_t::glGetQueryObjectuiv; + + using theBaseClass_t::glMapBuffer; + using theBaseClass_t::glUnmapBuffer; + using theBaseClass_t::glGetBufferSubData; + using theBaseClass_t::glGetBufferPointerv; +#endif + using theBaseClass_t::glBindBuffer; using theBaseClass_t::glDeleteBuffers; using theBaseClass_t::glGenBuffers; using theBaseClass_t::glIsBuffer; using theBaseClass_t::glBufferData; using theBaseClass_t::glBufferSubData; - using theBaseClass_t::glGetBufferSubData; - using theBaseClass_t::glMapBuffer; - using theBaseClass_t::glUnmapBuffer; using theBaseClass_t::glGetBufferParameteriv; - using theBaseClass_t::glGetBufferPointerv; }; diff --git a/src/OpenGl/OpenGl_GlCore20.hxx b/src/OpenGl/OpenGl_GlCore20.hxx index b3172929b1..f6aacfa723 100644 --- a/src/OpenGl/OpenGl_GlCore20.hxx +++ b/src/OpenGl/OpenGl_GlCore20.hxx @@ -26,7 +26,6 @@ struct OpenGl_TmplCore20 : public theBaseClass_t public: //! @name OpenGL 2.0 additives to 1.5 using theBaseClass_t::glBlendEquationSeparate; - using theBaseClass_t::glDrawBuffers; using theBaseClass_t::glStencilOpSeparate; using theBaseClass_t::glStencilFuncSeparate; using theBaseClass_t::glStencilMaskSeparate; @@ -52,7 +51,6 @@ public: //! @name OpenGL 2.0 additives to 1.5 using theBaseClass_t::glGetUniformLocation; using theBaseClass_t::glGetUniformfv; using theBaseClass_t::glGetUniformiv; - using theBaseClass_t::glGetVertexAttribdv; using theBaseClass_t::glGetVertexAttribfv; using theBaseClass_t::glGetVertexAttribiv; using theBaseClass_t::glGetVertexAttribPointerv; @@ -81,24 +79,36 @@ public: //! @name OpenGL 2.0 additives to 1.5 using theBaseClass_t::glUniformMatrix3fv; using theBaseClass_t::glUniformMatrix4fv; using theBaseClass_t::glValidateProgram; - using theBaseClass_t::glVertexAttrib1d; - using theBaseClass_t::glVertexAttrib1dv; using theBaseClass_t::glVertexAttrib1f; using theBaseClass_t::glVertexAttrib1fv; - using theBaseClass_t::glVertexAttrib1s; - using theBaseClass_t::glVertexAttrib1sv; - using theBaseClass_t::glVertexAttrib2d; - using theBaseClass_t::glVertexAttrib2dv; using theBaseClass_t::glVertexAttrib2f; using theBaseClass_t::glVertexAttrib2fv; - using theBaseClass_t::glVertexAttrib2s; - using theBaseClass_t::glVertexAttrib2sv; - using theBaseClass_t::glVertexAttrib3d; - using theBaseClass_t::glVertexAttrib3dv; using theBaseClass_t::glVertexAttrib3f; using theBaseClass_t::glVertexAttrib3fv; + using theBaseClass_t::glVertexAttrib4f; + using theBaseClass_t::glVertexAttrib4fv; + using theBaseClass_t::glVertexAttribPointer; + +#if !defined(GL_ES_VERSION_2_0) + using theBaseClass_t::glDrawBuffers; + using theBaseClass_t::glGetVertexAttribdv; + using theBaseClass_t::glVertexAttrib1d; + using theBaseClass_t::glVertexAttrib1dv; + using theBaseClass_t::glVertexAttrib2d; + using theBaseClass_t::glVertexAttrib2dv; + using theBaseClass_t::glVertexAttrib3d; + using theBaseClass_t::glVertexAttrib3dv; + using theBaseClass_t::glVertexAttrib4d; + using theBaseClass_t::glVertexAttrib4dv; + using theBaseClass_t::glVertexAttrib1s; + using theBaseClass_t::glVertexAttrib1sv; + using theBaseClass_t::glVertexAttrib2s; + using theBaseClass_t::glVertexAttrib2sv; using theBaseClass_t::glVertexAttrib3s; using theBaseClass_t::glVertexAttrib3sv; + using theBaseClass_t::glVertexAttrib4s; + using theBaseClass_t::glVertexAttrib4sv; + using theBaseClass_t::glVertexAttrib4iv; using theBaseClass_t::glVertexAttrib4Nbv; using theBaseClass_t::glVertexAttrib4Niv; using theBaseClass_t::glVertexAttrib4Nsv; @@ -107,17 +117,10 @@ public: //! @name OpenGL 2.0 additives to 1.5 using theBaseClass_t::glVertexAttrib4Nuiv; using theBaseClass_t::glVertexAttrib4Nusv; using theBaseClass_t::glVertexAttrib4bv; - using theBaseClass_t::glVertexAttrib4d; - using theBaseClass_t::glVertexAttrib4dv; - using theBaseClass_t::glVertexAttrib4f; - using theBaseClass_t::glVertexAttrib4fv; - using theBaseClass_t::glVertexAttrib4iv; - using theBaseClass_t::glVertexAttrib4s; - using theBaseClass_t::glVertexAttrib4sv; using theBaseClass_t::glVertexAttrib4ubv; using theBaseClass_t::glVertexAttrib4uiv; using theBaseClass_t::glVertexAttrib4usv; - using theBaseClass_t::glVertexAttribPointer; +#endif }; diff --git a/src/OpenGl/OpenGl_GlCore21.hxx b/src/OpenGl/OpenGl_GlCore21.hxx index baedc9abb5..231e4b0669 100644 --- a/src/OpenGl/OpenGl_GlCore21.hxx +++ b/src/OpenGl/OpenGl_GlCore21.hxx @@ -25,6 +25,8 @@ struct OpenGl_TmplCore21 : public theBaseClass_t public: //! @name OpenGL 2.1 additives to 2.0 +#if !defined(GL_ES_VERSION_2_0) + using theBaseClass_t::glUniformMatrix2x3fv; using theBaseClass_t::glUniformMatrix3x2fv; using theBaseClass_t::glUniformMatrix2x4fv; @@ -32,6 +34,8 @@ public: //! @name OpenGL 2.1 additives to 2.0 using theBaseClass_t::glUniformMatrix3x4fv; using theBaseClass_t::glUniformMatrix4x3fv; +#endif + }; //! OpenGL 2.1 core based on 2.0 version. diff --git a/src/OpenGl/OpenGl_GlCore30.hxx b/src/OpenGl/OpenGl_GlCore30.hxx index d45fc848fd..2213b9e698 100644 --- a/src/OpenGl/OpenGl_GlCore30.hxx +++ b/src/OpenGl/OpenGl_GlCore30.hxx @@ -28,6 +28,8 @@ struct OpenGl_TmplCore30 : public theBaseClass_t public: //! @name GL_ARB_framebuffer_object (added to OpenGL 3.0 core) +#if !defined(GL_ES_VERSION_2_0) + using theBaseClass_t::glIsRenderbuffer; using theBaseClass_t::glBindRenderbuffer; using theBaseClass_t::glDeleteRenderbuffers; @@ -122,6 +124,8 @@ public: //! @name OpenGL 3.0 additives to 2.1 using theBaseClass_t::glClearBufferfi; using theBaseClass_t::glGetStringi; +#endif + }; //! OpenGL 3.0 core based on 2.1 version. diff --git a/src/OpenGl/OpenGl_GlCore31.hxx b/src/OpenGl/OpenGl_GlCore31.hxx index 495ac8242e..3a1c52b3f1 100644 --- a/src/OpenGl/OpenGl_GlCore31.hxx +++ b/src/OpenGl/OpenGl_GlCore31.hxx @@ -23,6 +23,8 @@ template struct OpenGl_TmplCore31 : public theBaseClass_t { +#if !defined(GL_ES_VERSION_2_0) + public: //! @name GL_ARB_uniform_buffer_object (added to OpenGL 3.1 core) using theBaseClass_t::glGetUniformIndices; @@ -44,6 +46,8 @@ public: //! @name OpenGL 3.1 additives to 3.0 using theBaseClass_t::glTexBuffer; using theBaseClass_t::glPrimitiveRestartIndex; +#endif + }; //! OpenGL 3.1 compatibility profile. diff --git a/src/OpenGl/OpenGl_GlCore32.hxx b/src/OpenGl/OpenGl_GlCore32.hxx index a32c062ed7..972686492b 100644 --- a/src/OpenGl/OpenGl_GlCore32.hxx +++ b/src/OpenGl/OpenGl_GlCore32.hxx @@ -23,6 +23,8 @@ template struct OpenGl_TmplCore32 : public 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; @@ -57,6 +59,8 @@ public: //! @name OpenGL 3.2 additives to 3.1 using theBaseClass_t::glGetBufferParameteri64v; using theBaseClass_t::glFramebufferTexture; +#endif + }; //! OpenGL 3.2 compatibility profile. diff --git a/src/OpenGl/OpenGl_GlCore33.hxx b/src/OpenGl/OpenGl_GlCore33.hxx index 192f52dbfd..605f97e745 100644 --- a/src/OpenGl/OpenGl_GlCore33.hxx +++ b/src/OpenGl/OpenGl_GlCore33.hxx @@ -23,6 +23,8 @@ template struct OpenGl_TmplCore33 : public 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; @@ -96,6 +98,8 @@ public: //! @name OpenGL 3.3 additives to 3.2 using theBaseClass_t::glVertexAttribDivisor; +#endif + }; //! OpenGL 3.3 compatibility profile. diff --git a/src/OpenGl/OpenGl_GlCore40.hxx b/src/OpenGl/OpenGl_GlCore40.hxx index c8a289cf73..60d8d41ee6 100644 --- a/src/OpenGl/OpenGl_GlCore40.hxx +++ b/src/OpenGl/OpenGl_GlCore40.hxx @@ -23,6 +23,8 @@ template struct OpenGl_TmplCore40 : public 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; @@ -90,6 +92,8 @@ public: //! @name OpenGL 4.0 additives to 3.3 using theBaseClass_t::glBlendFunci; using theBaseClass_t::glBlendFuncSeparatei; +#endif + }; //! OpenGL 4.0 compatibility profile. diff --git a/src/OpenGl/OpenGl_GlCore41.hxx b/src/OpenGl/OpenGl_GlCore41.hxx index efa57b56d1..50950811fb 100644 --- a/src/OpenGl/OpenGl_GlCore41.hxx +++ b/src/OpenGl/OpenGl_GlCore41.hxx @@ -23,6 +23,8 @@ template struct OpenGl_TmplCore41 : public 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; @@ -128,6 +130,8 @@ public: //! @name GL_ARB_viewport_array (added to OpenGL 4.1 core) public: //! @name OpenGL 4.1 additives to 4.0 +#endif + }; //! OpenGL 4.1 compatibility profile. diff --git a/src/OpenGl/OpenGl_GlCore42.hxx b/src/OpenGl/OpenGl_GlCore42.hxx index 01ba9cecf3..884d2b73bd 100644 --- a/src/OpenGl/OpenGl_GlCore42.hxx +++ b/src/OpenGl/OpenGl_GlCore42.hxx @@ -23,6 +23,8 @@ template struct OpenGl_TmplCore42 : public 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,6 +58,8 @@ public: //! @name GL_ARB_texture_storage (added to OpenGL 4.2 core) using theBaseClass_t::glTextureStorage2DEXT; using theBaseClass_t::glTextureStorage3DEXT; +#endif + }; //! OpenGL 4.2 compatibility profile. diff --git a/src/OpenGl/OpenGl_GlCore43.hxx b/src/OpenGl/OpenGl_GlCore43.hxx index 2a34586b94..e95e842137 100644 --- a/src/OpenGl/OpenGl_GlCore43.hxx +++ b/src/OpenGl/OpenGl_GlCore43.hxx @@ -25,6 +25,8 @@ struct OpenGl_TmplCore43 : public theBaseClass_t 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; @@ -69,6 +71,8 @@ public: //! @name OpenGL 4.3 additives to 4.2 using theBaseClass_t::glObjectPtrLabel; using theBaseClass_t::glGetObjectPtrLabel; +#endif + }; //! OpenGL 4.3 compatibility profile. diff --git a/src/OpenGl/OpenGl_GlCore44.hxx b/src/OpenGl/OpenGl_GlCore44.hxx index b69ec82923..91a68cb278 100644 --- a/src/OpenGl/OpenGl_GlCore44.hxx +++ b/src/OpenGl/OpenGl_GlCore44.hxx @@ -25,6 +25,8 @@ struct OpenGl_TmplCore44 : public theBaseClass_t 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; @@ -35,6 +37,8 @@ public: //! @name OpenGL 4.4 additives to 4.3 using theBaseClass_t::glBindImageTextures; using theBaseClass_t::glBindVertexBuffers; +#endif + }; //! OpenGL 4.4 compatibility profile. diff --git a/src/OpenGl/OpenGl_GlFunctions.hxx b/src/OpenGl/OpenGl_GlFunctions.hxx index aab97e89c4..080c3e0d59 100644 --- a/src/OpenGl/OpenGl_GlFunctions.hxx +++ b/src/OpenGl/OpenGl_GlFunctions.hxx @@ -40,6 +40,88 @@ #include #include #define __X_GL_H // prevent chaotic gl.h inclusions to avoid compile errors +#elif defined(HAVE_GLES2) || defined(__ANDROID__) + #include + //#include + + typedef double GLdouble; + typedef double GLclampd; + #define GL_NONE 0 + + // OpenGL ES 3.0+ or GL_OES_element_index_uint extension + #define GL_UNSIGNED_INT 0x1405 + + // in core since OpenGL ES 3.0, extension GL_EXT_texture_rg + #define GL_RED 0x1903 + #define GL_R8 0x8229 + // in core since OpenGL ES 3.0, extension GL_OES_rgb8_rgba8 + #define GL_RGB8 0x8051 + #define GL_RGBA8 0x8058 + // GL_EXT_texture_format_BGRA8888 + #define GL_BGRA_EXT 0x80E1 // same as GL_BGRA on desktop + + #define GL_R16 0x822A + #define GL_R16F 0x822D + #define GL_R32F 0x822E + #define GL_RGB16F 0x881B + #define GL_RGBA32F 0x8814 + #define GL_RGB32F 0x8815 + #define GL_RGBA16F 0x881A + #define GL_RGB16F 0x881B + #define GL_RGB4 0x804F + #define GL_RGB5 0x8050 + #define GL_RGB8 0x8051 + #define GL_RGB10 0x8052 + #define GL_RGB12 0x8053 + #define GL_RGB16 0x8054 + #define GL_RGBA8 0x8058 + #define GL_RGB10_A2 0x8059 + #define GL_RGBA12 0x805A + #define GL_RGBA16 0x805B + #define GL_ALPHA8 0x803C + #define GL_ALPHA16 0x803E + + #define GL_RG 0x8227 + #define GL_RG8 0x822B + #define GL_RG16 0x822C + #define GL_RG16F 0x822F + #define GL_RG32F 0x8230 + + // GL_OES_packed_depth_stencil + #define GL_DEPTH_STENCIL 0x84F9 + #define GL_UNSIGNED_INT_24_8 0x84FA + #define GL_DEPTH24_STENCIL8 0x88F0 + + // GL_EXT_texture_filter_anisotropic + #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE + #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF + + // debug ARB extension + #define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 + #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 + #define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 + #define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 + #define GL_DEBUG_SOURCE_API_ARB 0x8246 + #define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 + #define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 + #define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 + #define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A + #define GL_DEBUG_SOURCE_OTHER_ARB 0x824B + #define GL_DEBUG_TYPE_ERROR_ARB 0x824C + #define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D + #define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E + #define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F + #define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 + #define GL_DEBUG_TYPE_OTHER_ARB 0x8251 + #define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 + #define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 + #define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 + #define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 + #define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 + #define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 + + // GL_EXT_texture_buffer for OpenGL ES 3.1+ + #define GL_TEXTURE_BUFFER_ARB 0x8C2A #else #include #include @@ -54,29 +136,556 @@ #include // GL version can be defined by system gl.h header -#undef GL_VERSION_1_2 -#undef GL_VERSION_1_3 -#undef GL_VERSION_1_4 -#undef GL_VERSION_1_5 -#undef GL_VERSION_2_0 -#undef GL_VERSION_2_1 -#undef GL_VERSION_3_0 -#undef GL_VERSION_3_1 -#undef GL_VERSION_3_2 -#undef GL_VERSION_3_3 -#undef GL_VERSION_4_0 -#undef GL_VERSION_4_1 -#undef GL_VERSION_4_2 -#undef GL_VERSION_4_3 -#undef GL_VERSION_4_4 - -// include glext.h provided by Khronos group -#include +#if !defined(GL_ES_VERSION_2_0) + #undef GL_VERSION_1_2 + #undef GL_VERSION_1_3 + #undef GL_VERSION_1_4 + #undef GL_VERSION_1_5 + #undef GL_VERSION_2_0 + #undef GL_VERSION_2_1 + #undef GL_VERSION_3_0 + #undef GL_VERSION_3_1 + #undef GL_VERSION_3_2 + #undef GL_VERSION_3_3 + #undef GL_VERSION_4_0 + #undef GL_VERSION_4_1 + #undef GL_VERSION_4_2 + #undef GL_VERSION_4_3 + #undef GL_VERSION_4_4 + + // include glext.h provided by Khronos group + #include +#endif //! Mega structure defines the complete list of OpenGL functions. struct OpenGl_GlFunctions { +public: //! @name OpenGL ES 1.1 + +#if defined(GL_ES_VERSION_2_0) + + inline void glActiveTexture (GLenum texture) + { + ::glActiveTexture (texture); + } + + inline void 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); + } + + inline void 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); + } + + inline void glBindBuffer (GLenum target, GLuint buffer) + { + ::glBindBuffer (target, buffer); + } + + inline void glBufferData (GLenum target, GLsizeiptr size, const void* data, GLenum usage) + { + ::glBufferData (target, size, data, usage); + } + + inline void glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void* data) + { + ::glBufferSubData (target, offset, size, data); + } + + inline void glDeleteBuffers (GLsizei n, const GLuint *buffers) + { + ::glDeleteBuffers (n, buffers); + } + + inline void glDeleteTextures (GLsizei n, const GLuint *textures) + { + ::glDeleteTextures (n, textures); + } + + inline void glDepthFunc (GLenum func) + { + ::glDepthFunc (func); + } + + inline void glDepthMask (GLboolean flag) + { + ::glDepthMask (flag); + } + + inline void glDepthRangef (GLfloat n, GLfloat f) + { + ::glDepthRangef (n, f); + } + + inline void glGenBuffers (GLsizei n, GLuint *buffers) + { + ::glGenBuffers (n, buffers); + } + + inline void glGenTextures (GLsizei n, GLuint *textures) + { + ::glGenTextures (n, textures); + } + + inline void glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params) + { + ::glGetBufferParameteriv (target, pname, params); + } + + inline GLboolean glIsBuffer (GLuint buffer) + { + return ::glIsBuffer (buffer); + } + + inline void glSampleCoverage (GLfloat value, GLboolean invert) + { + ::glSampleCoverage (value, invert); + } + + inline void 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]); + } + } + +#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) + { + ::glBlendColor (red, green, blue, alpha); + } + + inline void glBlendEquation (GLenum mode) + { + ::glBlendEquation (mode); + } + + inline void glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) + { + ::glBlendFuncSeparate (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); + } + + inline void glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha) + { + ::glBlendEquationSeparate (modeRGB, modeAlpha); + } + + inline void glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) + { + ::glStencilOpSeparate (face, sfail, dpfail, dppass); + } + + inline void glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask) + { + ::glStencilFuncSeparate (face, func, ref, mask); + } + + inline void glStencilMaskSeparate (GLenum face, GLuint mask) + { + ::glStencilMaskSeparate (face, mask); + } + + inline void glAttachShader (GLuint program, GLuint shader) + { + ::glAttachShader (program, shader); + } + + inline void glBindAttribLocation (GLuint program, GLuint index, const GLchar *name) + { + ::glBindAttribLocation (program, index, name); + } + + inline void glBindFramebuffer (GLenum target, GLuint framebuffer) + { + ::glBindFramebuffer (target, framebuffer); + } + + inline void glBindRenderbuffer (GLenum target, GLuint renderbuffer) + { + ::glBindRenderbuffer (target, renderbuffer); + } + + inline GLenum glCheckFramebufferStatus (GLenum target) + { + return ::glCheckFramebufferStatus (target); + } + + inline void glCompileShader (GLuint shader) + { + ::glCompileShader (shader); + } + + inline GLuint glCreateProgram() + { + return ::glCreateProgram(); + } + + inline GLuint glCreateShader (GLenum type) + { + return ::glCreateShader (type); + } + + inline void glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers) + { + ::glDeleteFramebuffers (n, framebuffers); + } + + inline void glDeleteProgram (GLuint program) + { + ::glDeleteProgram (program); + } + + inline void glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers) + { + ::glDeleteRenderbuffers (n, renderbuffers); + } + + inline void glDeleteShader (GLuint shader) + { + ::glDeleteShader (shader); + } + + inline void glDetachShader (GLuint program, GLuint shader) + { + ::glDetachShader (program, shader); + } + + inline void glDisableVertexAttribArray (GLuint index) + { + ::glDisableVertexAttribArray (index); + } + + inline void glEnableVertexAttribArray (GLuint index) + { + ::glEnableVertexAttribArray (index); + } + + inline void glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) + { + ::glFramebufferRenderbuffer (target, attachment, renderbuffertarget, renderbuffer); + } + + inline void glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) + { + ::glFramebufferTexture2D (target, attachment, textarget, texture, level); + } + + inline void glGenerateMipmap (GLenum target) + { + ::glGenerateMipmap (target); + } + + inline void glGenFramebuffers (GLsizei n, GLuint *framebuffers) + { + ::glGenFramebuffers (n, framebuffers); + } + + inline void glGenRenderbuffers (GLsizei n, GLuint *renderbuffers) + { + ::glGenRenderbuffers (n, renderbuffers); + } + + inline void glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint* size, GLenum *type, GLchar *name) + { + ::glGetActiveAttrib (program, index, bufSize, length, size, type, name); + } + + inline void glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint* size, GLenum *type, GLchar *name) + { + ::glGetActiveUniform (program, index, bufSize, length, size, type, name); + } + + inline void glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders) + { + ::glGetAttachedShaders (program, maxCount, count, shaders); + } + + inline GLint glGetAttribLocation (GLuint program, const GLchar *name) + { + return ::glGetAttribLocation (program, name); + } + + inline void glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params) + { + ::glGetFramebufferAttachmentParameteriv (target, attachment, pname, params); + } + + inline void glGetProgramiv (GLuint program, GLenum pname, GLint* params) + { + ::glGetProgramiv (program, pname, params); + } + + inline void glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) + { + ::glGetProgramInfoLog (program, bufSize, length, infoLog); + } + + inline void glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params) + { + ::glGetRenderbufferParameteriv (target, pname, params); + } + + inline void glGetShaderiv (GLuint shader, GLenum pname, GLint* params) + { + ::glGetShaderiv (shader, pname, params); + } + + inline void glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) + { + ::glGetShaderInfoLog (shader, bufSize, length, infoLog); + } + + inline void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) + { + ::glGetShaderPrecisionFormat (shadertype, precisiontype, range, precision); + } + + inline void glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) + { + ::glGetShaderSource (shader, bufSize, length, source); + } + + inline void glGetUniformfv (GLuint program, GLint location, GLfloat* params) + { + ::glGetUniformfv (program, location, params); + } + + inline void glGetUniformiv (GLuint program, GLint location, GLint* params) + { + ::glGetUniformiv (program, location, params); + } + + GLint glGetUniformLocation (GLuint program, const GLchar *name) + { + return ::glGetUniformLocation (program, name); + } + + inline void glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params) + { + ::glGetVertexAttribfv (index, pname, params); + } + + inline void glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params) + { + ::glGetVertexAttribiv (index, pname, params); + } + + inline void glGetVertexAttribPointerv (GLuint index, GLenum pname, void* *pointer) + { + ::glGetVertexAttribPointerv (index, pname, pointer); + } + + inline GLboolean glIsFramebuffer (GLuint framebuffer) + { + return ::glIsFramebuffer (framebuffer); + } + + inline GLboolean glIsProgram (GLuint program) + { + return ::glIsProgram (program); + } + + inline GLboolean glIsRenderbuffer (GLuint renderbuffer) + { + return ::glIsRenderbuffer (renderbuffer); + } + + inline GLboolean glIsShader (GLuint shader) + { + return ::glIsShader (shader); + } + + inline void glLinkProgram (GLuint program) + { + ::glLinkProgram (program); + } + + inline void glReleaseShaderCompiler() + { + ::glReleaseShaderCompiler(); + } + + inline void glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) + { + ::glRenderbufferStorage (target, internalformat, width, height); + } + + inline void glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void* binary, GLsizei length) + { + ::glShaderBinary (count, shaders, binaryformat, binary, length); + } + + inline void glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length) + { + ::glShaderSource (shader, count, string, length); + } + + inline void glUniform1f (GLint location, GLfloat v0) + { + ::glUniform1f (location, v0); + } + + inline void glUniform1fv (GLint location, GLsizei count, const GLfloat* value) + { + ::glUniform1fv (location, count, value); + } + + inline void glUniform1i (GLint location, GLint v0) + { + ::glUniform1i (location, v0); + } + + inline void glUniform1iv (GLint location, GLsizei count, const GLint* value) + { + ::glUniform1iv (location, count, value); + } + + inline void glUniform2f (GLint location, GLfloat v0, GLfloat v1) + { + ::glUniform2f (location, v0, v1); + } + + inline void glUniform2fv (GLint location, GLsizei count, const GLfloat* value) + { + ::glUniform2fv (location, count, value); + } + + inline void glUniform2i (GLint location, GLint v0, GLint v1) + { + ::glUniform2i (location, v0, v1); + } + + inline void glUniform2iv (GLint location, GLsizei count, const GLint* value) + { + ::glUniform2iv (location, count, value); + } + + inline void glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2) + { + ::glUniform3f (location, v0, v1, v2); + } + + inline void glUniform3fv (GLint location, GLsizei count, const GLfloat* value) + { + ::glUniform3fv (location, count, value); + } + + inline void glUniform3i (GLint location, GLint v0, GLint v1, GLint v2) + { + ::glUniform3i (location, v0, v1, v2); + } + + inline void glUniform3iv (GLint location, GLsizei count, const GLint* value) + { + ::glUniform3iv (location, count, value); + } + + inline void glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) + { + ::glUniform4f (location, v0, v1, v2, v3); + } + + inline void glUniform4fv (GLint location, GLsizei count, const GLfloat* value) + { + ::glUniform4fv (location, count, value); + } + + inline void glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3) + { + ::glUniform4i (location, v0, v1, v2, v3); + } + + inline void glUniform4iv (GLint location, GLsizei count, const GLint* value) + { + ::glUniform4iv (location, count, value); + } + + inline void glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + ::glUniformMatrix2fv (location, count, transpose, value); + } + + inline void glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + ::glUniformMatrix3fv (location, count, transpose, value); + } + + inline void glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + { + ::glUniformMatrix4fv (location, count, transpose, value); + } + + inline void glUseProgram (GLuint program) + { + ::glUseProgram (program); + } + + inline void glValidateProgram (GLuint program) + { + ::glValidateProgram (program); + } + + inline void glVertexAttrib1f (GLuint index, GLfloat x) + { + ::glVertexAttrib1f (index, x); + } + + inline void glVertexAttrib1fv (GLuint index, const GLfloat* v) + { + ::glVertexAttrib1fv (index, v); + } + + inline void glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y) + { + ::glVertexAttrib2f (index, x, y); + } + + inline void glVertexAttrib2fv (GLuint index, const GLfloat* v) + { + ::glVertexAttrib2fv (index, v); + } + + inline void glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z) + { + ::glVertexAttrib3f (index, x, y, z); + } + + inline void glVertexAttrib3fv (GLuint index, const GLfloat* v) + { + ::glVertexAttrib3fv (index, v); + } + + inline void glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) + { + ::glVertexAttrib4f (index, x, y, z, w); + } + + inline void glVertexAttrib4fv (GLuint index, const GLfloat* v) + { + ::glVertexAttrib4fv (index, v); + } + + inline void glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer) + { + ::glVertexAttribPointer (index, size, type, normalized, stride, pointer); + } + +#else // OpenGL ES vs. desktop + public: //! @name OpenGL 1.2 PFNGLBLENDCOLORPROC glBlendColor; @@ -939,6 +1548,8 @@ public: //! @name glX extensions glXSwapIntervalSGI_t glXSwapIntervalSGI; #endif +#endif // OpenGL ES vs. desktop + }; #endif // _OpenGl_GlFunctions_Header diff --git a/src/OpenGl/OpenGl_GraduatedTrihedron.cxx b/src/OpenGl/OpenGl_GraduatedTrihedron.cxx index 067140b33e..6e788a1e37 100755 --- a/src/OpenGl/OpenGl_GraduatedTrihedron.cxx +++ b/src/OpenGl/OpenGl_GraduatedTrihedron.cxx @@ -46,6 +46,7 @@ float xmin = 0.0f, ymin = 0.0f, zmin = 0.0f, xmax = 100.0f, ymax = 100.0f, zmax /* Normal of the view (not normalized!) */ static float getNormal(float* normal) { +#if !defined(GL_ES_VERSION_2_0) GLint viewport[4]; GLdouble model_matrix[16], proj_matrix[16]; @@ -72,6 +73,9 @@ static float getNormal(float* normal) /* Distance corresponding to 1 pixel */ const float width = (float) sqrt(dx2 * dx2 + dy2 * dy2 + dz2 * dz2); return width / (float) viewport[2]; +#else + return 1.0f; +#endif } static float getDistance2Corner(float* normal, float* center, float x, float y, float z) @@ -131,6 +135,7 @@ static void drawArrow(float x1, float y1, float z1, float x2, float y2, float z2, float xn, float yn, float zn) { +#if !defined(GL_ES_VERSION_2_0) float h, r; float xa, ya, za; float x0, y0, z0; @@ -180,6 +185,7 @@ static void drawArrow(float x1, float y1, float z1, glVertex3f(xa2, ya2, za2); glVertex3f(x2, y2, z2); glEnd(); +#endif } // ======================================================================= @@ -277,6 +283,7 @@ OpenGl_GraduatedTrihedron::~OpenGl_GraduatedTrihedron() //call_graduatedtrihedron_redraw void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorkspace) const { +#if !defined(GL_ES_VERSION_2_0) const OpenGl_AspectLine *oldAspectLine = theWorkspace->SetAspectLine(&myDefaultAspectLine); theWorkspace->AspectLine(Standard_True); @@ -958,6 +965,7 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks glEnable(GL_LIGHTING); theWorkspace->SetAspectLine(oldAspectLine); +#endif } //call_graduatedtrihedron_minmaxvalues diff --git a/src/OpenGl/OpenGl_GraphicDriver_7.cxx b/src/OpenGl/OpenGl_GraphicDriver_7.cxx index bb716f8c75..7d77710094 100644 --- a/src/OpenGl/OpenGl_GraphicDriver_7.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_7.cxx @@ -95,12 +95,12 @@ void OpenGl_GraphicDriver::RatioWindow (const Graphic3d_CView& theCView) aCView->WS->Resize (theCView.DefWindow); } -void OpenGl_GraphicDriver::Redraw (const Graphic3d_CView& ACView, - const Aspect_CLayer2d& ACUnderLayer, - const Aspect_CLayer2d& ACOverLayer, - const Standard_Integer /*x*/, - const Standard_Integer /*y*/, - const Standard_Integer /*width*/, +void OpenGl_GraphicDriver::Redraw (const Graphic3d_CView& ACView, + const Aspect_CLayer2d& ACUnderLayer, + const Aspect_CLayer2d& ACOverLayer, + const Standard_Integer /*x*/, + const Standard_Integer /*y*/, + const Standard_Integer /*width*/, const Standard_Integer /*height*/) { if (ACView.RenderParams.Method == Graphic3d_RM_RAYTRACING @@ -240,46 +240,48 @@ inline bool getDataFormat (const Image_PixMap& theData, theDataType = GL_UNSIGNED_BYTE; switch (theData.Format()) { + #if !defined(GL_ES_VERSION_2_0) case Image_PixMap::ImgGray: thePixelFormat = GL_DEPTH_COMPONENT; theDataType = GL_UNSIGNED_BYTE; return true; - case Image_PixMap::ImgRGB: - thePixelFormat = GL_RGB; - theDataType = GL_UNSIGNED_BYTE; + case Image_PixMap::ImgGrayF: + thePixelFormat = GL_DEPTH_COMPONENT; + theDataType = GL_FLOAT; return true; case Image_PixMap::ImgBGR: thePixelFormat = GL_BGR; theDataType = GL_UNSIGNED_BYTE; return true; - case Image_PixMap::ImgRGBA: - case Image_PixMap::ImgRGB32: - thePixelFormat = GL_RGBA; - theDataType = GL_UNSIGNED_BYTE; - return true; case Image_PixMap::ImgBGRA: case Image_PixMap::ImgBGR32: thePixelFormat = GL_BGRA; theDataType = GL_UNSIGNED_BYTE; return true; - case Image_PixMap::ImgGrayF: - thePixelFormat = GL_DEPTH_COMPONENT; + case Image_PixMap::ImgBGRF: + thePixelFormat = GL_BGR; theDataType = GL_FLOAT; return true; - case Image_PixMap::ImgRGBF: - thePixelFormat = GL_RGB; + case Image_PixMap::ImgBGRAF: + thePixelFormat = GL_BGRA; theDataType = GL_FLOAT; return true; - case Image_PixMap::ImgBGRF: - thePixelFormat = GL_BGR; - theDataType = GL_FLOAT; + #endif + case Image_PixMap::ImgRGB: + thePixelFormat = GL_RGB; + theDataType = GL_UNSIGNED_BYTE; return true; - case Image_PixMap::ImgRGBAF: + case Image_PixMap::ImgRGBA: + case Image_PixMap::ImgRGB32: thePixelFormat = GL_RGBA; + theDataType = GL_UNSIGNED_BYTE; + return true; + case Image_PixMap::ImgRGBF: + thePixelFormat = GL_RGB; theDataType = GL_FLOAT; return true; - case Image_PixMap::ImgBGRAF: - thePixelFormat = GL_BGRA; + case Image_PixMap::ImgRGBAF: + thePixelFormat = GL_RGBA; theDataType = GL_FLOAT; return true; default: @@ -302,33 +304,43 @@ Standard_Boolean OpenGl_Workspace::BufferDump (OpenGl_FrameBuffer* theFB GLenum aFormat, aType; if (theImage.IsEmpty() || !getDataFormat (theImage, aFormat, aType) - || ((theBufferType == Graphic3d_BT_Depth) && (aFormat != GL_DEPTH_COMPONENT)) || !Activate()) { return Standard_False; } +#if !defined(GL_ES_VERSION_2_0) + GLint aReadBufferPrev = GL_BACK; + if (theBufferType == Graphic3d_BT_Depth + && aFormat != GL_DEPTH_COMPONENT) + { + return Standard_False; + } +#endif // bind FBO if used - GLint aReadBufferPrev = GL_BACK; if (theFBOPtr != NULL && theFBOPtr->IsValid()) { theFBOPtr->BindBuffer (GetGlContext()); } else { + #if !defined(GL_ES_VERSION_2_0) glGetIntegerv (GL_READ_BUFFER, &aReadBufferPrev); GLint aDrawBufferPrev = GL_BACK; glGetIntegerv (GL_DRAW_BUFFER, &aDrawBufferPrev); glReadBuffer (aDrawBufferPrev); + #endif } // setup alignment - const GLint anExtraBytes = (GLint )theImage.RowExtraBytes(); const GLint anAligment = Min (GLint(theImage.MaxRowAligmentBytes()), 8); // limit to 8 bytes for OpenGL glPixelStorei (GL_PACK_ALIGNMENT, anAligment); +#if !defined(GL_ES_VERSION_2_0) + const GLint anExtraBytes = (GLint )theImage.RowExtraBytes(); const GLint aPixelsWidth = GLint(theImage.SizeRowBytes() / theImage.SizePixelBytes()); glPixelStorei (GL_PACK_ROW_LENGTH, (anExtraBytes >= anAligment) ? aPixelsWidth : 0); +#endif if (theImage.IsTopDown()) { @@ -346,7 +358,9 @@ Standard_Boolean OpenGl_Workspace::BufferDump (OpenGl_FrameBuffer* theFB } glPixelStorei (GL_PACK_ALIGNMENT, 1); +#if !defined(GL_ES_VERSION_2_0) glPixelStorei (GL_PACK_ROW_LENGTH, 0); +#endif if (theFBOPtr != NULL && theFBOPtr->IsValid()) { @@ -354,7 +368,9 @@ Standard_Boolean OpenGl_Workspace::BufferDump (OpenGl_FrameBuffer* theFB } else { + #if !defined(GL_ES_VERSION_2_0) glReadBuffer (aReadBufferPrev); + #endif } return Standard_True; } diff --git a/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx b/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx index 999b8778c7..2c707a97d7 100644 --- a/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx @@ -85,7 +85,9 @@ void InitLayerProp (const int theListId) void OpenGl_GraphicDriver::Layer (Aspect_CLayer2d& ACLayer) { ACLayer.ptrLayer = new CALL_DEF_PTRLAYER(); +#if !defined(GL_ES_VERSION_2_0) ACLayer.ptrLayer->listIndex = glGenLists(1); +#endif } /*----------------------------------------------------------------------*/ @@ -96,7 +98,10 @@ void OpenGl_GraphicDriver::RemoveLayer (const Aspect_CLayer2d& ACLayer) if (!ACLayer.ptrLayer->listIndex) return; if (TheLayerProp.ListId == ACLayer.ptrLayer->listIndex) EndLayer(); + +#if !defined(GL_ES_VERSION_2_0) glDeleteLists (ACLayer.ptrLayer->listIndex, 1); +#endif ACLayer.ptrLayer->listIndex = 0; //szvgl: memory leak here? //free ( ACLayer.ptrLayer ); @@ -113,7 +118,9 @@ void OpenGl_GraphicDriver::BeginLayer (const Aspect_CLayer2d& ACLayer) InitLayerProp (ptrLayer->listIndex); if (!TheLayerProp.ListId) return; +#if !defined(GL_ES_VERSION_2_0) glNewList (TheLayerProp.ListId, GL_COMPILE); +#endif TheLayerIsOpen = Standard_True; } @@ -121,14 +128,18 @@ void OpenGl_GraphicDriver::BeginPolygon2d () { if (!TheLayerProp.ListId) return; TheLayerProp.NbPoints = 0; +#if !defined(GL_ES_VERSION_2_0) glBegin (GL_POLYGON); +#endif } void OpenGl_GraphicDriver::BeginPolyline2d () { if (!TheLayerProp.ListId) return; TheLayerProp.NbPoints = 0; +#if !defined(GL_ES_VERSION_2_0) glBegin (GL_LINE_STRIP); +#endif } void OpenGl_GraphicDriver::ClearLayer (const Aspect_CLayer2d& ACLayer) @@ -138,22 +149,28 @@ void OpenGl_GraphicDriver::ClearLayer (const Aspect_CLayer2d& ACLayer) InitLayerProp (ACLayer.ptrLayer->listIndex); if (!TheLayerProp.ListId) return; +#if !defined(GL_ES_VERSION_2_0) glNewList (TheLayerProp.ListId, GL_COMPILE); glEndList (); +#endif } void OpenGl_GraphicDriver::Draw (const Standard_ShortReal X, const Standard_ShortReal Y) { if (!TheLayerProp.ListId) return; TheLayerProp.NbPoints++; +#if !defined(GL_ES_VERSION_2_0) glVertex3f (X, Y, 0.F); +#endif } void OpenGl_GraphicDriver::Edge (const Standard_ShortReal X, const Standard_ShortReal Y) { if (!TheLayerProp.ListId) return; TheLayerProp.NbPoints++; +#if !defined(GL_ES_VERSION_2_0) glVertex3f (X, Y, 0.F); +#endif } void OpenGl_GraphicDriver::EndLayer () @@ -161,7 +178,9 @@ void OpenGl_GraphicDriver::EndLayer () if (!TheLayerProp.ListId) return; if (TheLayerIsOpen) { + #if !defined(GL_ES_VERSION_2_0) glEndList(); + #endif TheLayerIsOpen = Standard_False; } TheLayerProp.ListId = 0; @@ -170,13 +189,17 @@ void OpenGl_GraphicDriver::EndLayer () void OpenGl_GraphicDriver::EndPolygon2d () { if (!TheLayerProp.ListId) return; +#if !defined(GL_ES_VERSION_2_0) glEnd (); +#endif } void OpenGl_GraphicDriver::EndPolyline2d () { if (!TheLayerProp.ListId) return; +#if !defined(GL_ES_VERSION_2_0) glEnd (); +#endif } void OpenGl_GraphicDriver::Move (const Standard_ShortReal X, const Standard_ShortReal Y) @@ -184,18 +207,24 @@ void OpenGl_GraphicDriver::Move (const Standard_ShortReal X, const Standard_Shor if (!TheLayerProp.ListId) return; if (TheLayerProp.NbPoints) { + #if !defined(GL_ES_VERSION_2_0) glEnd (); - TheLayerProp.NbPoints = 0; glBegin (GL_LINE_STRIP); + #endif + TheLayerProp.NbPoints = 0; } TheLayerProp.NbPoints++; +#if !defined(GL_ES_VERSION_2_0) glVertex3f (X, Y, 0.F); +#endif } void OpenGl_GraphicDriver::Rectangle (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Width, const Standard_ShortReal Height) { if (!TheLayerProp.ListId) return; +#if !defined(GL_ES_VERSION_2_0) glRectf (X, Y, X + Width, Y + Height); +#endif } void OpenGl_GraphicDriver::SetColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B) @@ -204,23 +233,29 @@ void OpenGl_GraphicDriver::SetColor (const Standard_ShortReal R, const Standard_ TheLayerProp.Color.rgb[0] = R; TheLayerProp.Color.rgb[1] = G; TheLayerProp.Color.rgb[2] = B; +#if !defined(GL_ES_VERSION_2_0) glColor3fv (TheLayerProp.Color.rgb); +#endif } void OpenGl_GraphicDriver::SetTransparency (const Standard_ShortReal ATransparency) { if (!TheLayerProp.ListId) return; TheLayerProp.Color.rgb[3] = ATransparency; +#if !defined(GL_ES_VERSION_2_0) glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4fv (TheLayerProp.Color.rgb); +#endif } void OpenGl_GraphicDriver::UnsetTransparency () { if (!TheLayerProp.ListId) return; TheLayerProp.Color.rgb[3] = 1.F; +#if !defined(GL_ES_VERSION_2_0) glDisable (GL_BLEND); +#endif } void OpenGl_GraphicDriver::SetLineAttributes (const Standard_Integer theType, diff --git a/src/OpenGl/OpenGl_LineAttributes.cxx b/src/OpenGl/OpenGl_LineAttributes.cxx index adb984b3ac..409f13d8f3 100644 --- a/src/OpenGl/OpenGl_LineAttributes.cxx +++ b/src/OpenGl/OpenGl_LineAttributes.cxx @@ -520,7 +520,9 @@ void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx) { if (theGlCtx->IsValid()) { + #if !defined(GL_ES_VERSION_2_0) glDeleteLists ((GLuint )myLinestyleBase, 5); + #endif } myLinestyleBase = 0; } @@ -529,7 +531,9 @@ void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx) { if (theGlCtx->IsValid()) { + #if !defined(GL_ES_VERSION_2_0) glDeleteLists ((GLuint )myPatternBase, TEL_HS_USER_DEF_START); + #endif } myPatternBase = 0; } @@ -547,6 +551,7 @@ void OpenGl_LineAttributes::Init (const Handle(OpenGl_Context)& theGlCtx) return; } +#if !defined(GL_ES_VERSION_2_0) myLinestyleBase = theGlCtx->core11->glGenLists (5); // Line @@ -575,6 +580,7 @@ void OpenGl_LineAttributes::Init (const Handle(OpenGl_Context)& theGlCtx) glPolygonStipple ((const GLubyte* )myInteriors[i < nbi ? i : 0]); glEndList(); } +#endif } // ======================================================================= @@ -583,6 +589,7 @@ void OpenGl_LineAttributes::Init (const Handle(OpenGl_Context)& theGlCtx) // ======================================================================= void OpenGl_LineAttributes::SetTypeOfLine (const Aspect_TypeOfLine theType) const { +#if !defined(GL_ES_VERSION_2_0) if (theType != Aspect_TOL_SOLID) { glCallList ((GLuint )myLinestyleBase + (GLuint )theType); @@ -598,6 +605,7 @@ void OpenGl_LineAttributes::SetTypeOfLine (const Aspect_TypeOfLine theType) cons gl2psDisable (GL2PS_LINE_STIPPLE); #endif } +#endif } // ======================================================================= @@ -606,6 +614,7 @@ void OpenGl_LineAttributes::SetTypeOfLine (const Aspect_TypeOfLine theType) cons // ======================================================================= void OpenGl_LineAttributes::SetTypeOfHatch (const int theType) const { +#if !defined(GL_ES_VERSION_2_0) if (theType != 0) { glCallList ((GLuint )myPatternBase + (GLuint )theType); @@ -613,4 +622,5 @@ void OpenGl_LineAttributes::SetTypeOfHatch (const int theType) const } else glDisable (GL_POLYGON_STIPPLE); +#endif } diff --git a/src/OpenGl/OpenGl_PointSprite.cxx b/src/OpenGl/OpenGl_PointSprite.cxx index aee4f4c5a5..181f5f4f49 100755 --- a/src/OpenGl/OpenGl_PointSprite.cxx +++ b/src/OpenGl/OpenGl_PointSprite.cxx @@ -58,7 +58,9 @@ void OpenGl_PointSprite::Release (OpenGl_Context* theGlCtx) if (theGlCtx->IsValid()) { + #if !defined(GL_ES_VERSION_2_0) glDeleteLists (myBitmapList, 1); + #endif } myBitmapList = 0; } @@ -86,6 +88,8 @@ void OpenGl_PointSprite::DrawBitmap (const Handle(OpenGl_Context)& ) const { if (myBitmapList != 0) { + #if !defined(GL_ES_VERSION_2_0) glCallList (myBitmapList); + #endif } } diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index 766acf788c..b976c14bd7 100755 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -414,11 +414,13 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp bool hasVColors = false; if (myVboAttribs.IsNull()) { + #if !defined(GL_ES_VERSION_2_0) if (myDrawMode == GL_POINTS) { // extreme compatibility mode - without sprites but with markers drawMarkers (theWorkspace); } + #endif return; } @@ -446,7 +448,9 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp for (Standard_Integer aGroupIter = 0; aGroupIter < myBounds->NbBounds; ++aGroupIter) { const GLint aNbElemsInGroup = myBounds->Bounds[aGroupIter]; + #if !defined(GL_ES_VERSION_2_0) if (theFaceColors != NULL) glColor3fv (theFaceColors[aGroupIter].GetData()); + #endif glDrawElements (myDrawMode, aNbElemsInGroup, myVboIndices->GetDataType(), anOffset); anOffset += aStride * aNbElemsInGroup; } @@ -464,7 +468,9 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp for (Standard_Integer aGroupIter = 0; aGroupIter < myBounds->NbBounds; ++aGroupIter) { const GLint aNbElemsInGroup = myBounds->Bounds[aGroupIter]; + #if !defined(GL_ES_VERSION_2_0) if (theFaceColors != NULL) glColor3fv (theFaceColors[aGroupIter].GetData()); + #endif glDrawArrays (myDrawMode, aFirstElem, aNbElemsInGroup); aFirstElem += aNbElemsInGroup; } @@ -502,7 +508,9 @@ void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeCo return; } +#if !defined(GL_ES_VERSION_2_0) glDisable (GL_LIGHTING); +#endif const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext(); const OpenGl_AspectLine* anAspectLineOld = NULL; @@ -510,8 +518,10 @@ void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeCo anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace (Standard_True)->AspectEdge()); const OpenGl_AspectLine* anAspect = theWorkspace->AspectLine (Standard_True); +#if !defined(GL_ES_VERSION_2_0) glPushAttrib (GL_POLYGON_BIT); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); +#endif if (aGlContext->IsGlGreaterEqual (2, 0)) { @@ -523,7 +533,9 @@ void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeCo /// 2) draw elements from vertex array, when bounds defines count of primitive's vertices. /// 3) draw primitive's edges by vertexes if no edges and bounds array is specified myVboAttribs->BindPositionAttribute (aGlContext); +#if !defined(GL_ES_VERSION_2_0) glColor3fv (theEdgeColour->rgb); +#endif if (!myVboIndices.IsNull()) { myVboIndices->Bind (aGlContext); @@ -569,7 +581,9 @@ void OpenGl_PrimitiveArray::drawEdges (const TEL_COLOUR* theEdgeCo { // Restore line context theWorkspace->SetAspectLine (anAspectLineOld); + #if !defined(GL_ES_VERSION_2_0) glPopAttrib(); + #endif } } @@ -587,7 +601,9 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork && !aSpriteNorm.IsNull() && !aSpriteNorm->IsDisplayList()) { // Textured markers will be drawn with the point sprites + #if !defined(GL_ES_VERSION_2_0) glPointSize (anAspectMarker->MarkerSize()); + #endif Handle(OpenGl_Texture) aTextureBack; if (anAspectMarker->Type() != Aspect_TOM_POINT) @@ -597,8 +613,10 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork : aSpriteNorm; aTextureBack = theWorkspace->EnableTexture (aSprite); + #if !defined(GL_ES_VERSION_2_0) glEnable (GL_ALPHA_TEST); glAlphaFunc (GL_GEQUAL, 0.1f); + #endif glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -607,12 +625,16 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork glDrawArrays (myDrawMode, 0, !myVboAttribs.IsNull() ? myVboAttribs->GetElemsNb() : myAttribs->NbElements); glDisable (GL_BLEND); + #if !defined(GL_ES_VERSION_2_0) glDisable (GL_ALPHA_TEST); + #endif if (anAspectMarker->Type() != Aspect_TOM_POINT) { theWorkspace->EnableTexture (aTextureBack); } + #if !defined(GL_ES_VERSION_2_0) glPointSize (1.0f); + #endif return; } @@ -623,17 +645,22 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork const GLfloat aPntSize = anAspectMarker->Type() == Aspect_TOM_POINT ? anAspectMarker->MarkerSize() : 0.0f; + #if !defined(GL_ES_VERSION_2_0) if (aPntSize > 0.0f) { glPointSize (aPntSize); } + #endif glDrawArrays (myDrawMode, 0, !myVboAttribs.IsNull() ? myVboAttribs->GetElemsNb() : myAttribs->NbElements); + #if !defined(GL_ES_VERSION_2_0) if (aPntSize > 0.0f) { glPointSize (1.0f); } + #endif } +#if !defined(GL_ES_VERSION_2_0) if (anAspectMarker->Type() != Aspect_TOM_POINT && !aSpriteNorm.IsNull()) { @@ -655,6 +682,7 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork } } } +#endif } // ======================================================================= @@ -696,24 +724,30 @@ OpenGl_PrimitiveArray::OpenGl_PrimitiveArray (const OpenGl_GraphicDriver* case Graphic3d_TOPA_SEGMENTS: myDrawMode = GL_LINES; break; - case Graphic3d_TOPA_POLYGONS: - myDrawMode = GL_POLYGON; - break; case Graphic3d_TOPA_TRIANGLES: myDrawMode = GL_TRIANGLES; break; - case Graphic3d_TOPA_QUADRANGLES: - myDrawMode = GL_QUADS; - break; case Graphic3d_TOPA_TRIANGLESTRIPS: myDrawMode = GL_TRIANGLE_STRIP; break; - case Graphic3d_TOPA_QUADRANGLESTRIPS: - myDrawMode = GL_QUAD_STRIP; - break; case Graphic3d_TOPA_TRIANGLEFANS: myDrawMode = GL_TRIANGLE_FAN; break; + #if !defined(GL_ES_VERSION_2_0) + case Graphic3d_TOPA_POLYGONS: + myDrawMode = GL_POLYGON; + break; + case Graphic3d_TOPA_QUADRANGLES: + myDrawMode = GL_QUADS; + break; + case Graphic3d_TOPA_QUADRANGLESTRIPS: + myDrawMode = GL_QUAD_STRIP; + break; + #else + case Graphic3d_TOPA_POLYGONS: + case Graphic3d_TOPA_QUADRANGLES: + case Graphic3d_TOPA_QUADRANGLESTRIPS: + #endif case Graphic3d_TOPA_UNDEFINED: break; } @@ -791,6 +825,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace aFrontLightingModel = 0; } +#if !defined(GL_ES_VERSION_2_0) // Temporarily disable environment mapping if (myDrawMode <= GL_LINE_STRIP) { @@ -809,6 +844,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace { glEnable (GL_LIGHTING); } +#endif bindProgram (theWorkspace, anAspectFace, anAspectLine, anAspectMarker, @@ -821,7 +857,9 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace const Graphic3d_Vec4* aFaceColors = !myBounds.IsNull() && !toHilight && anAspectFace->InteriorStyle() != Aspect_IS_HIDDENLINE ? myBounds->Colors : NULL; + #if !defined(GL_ES_VERSION_2_0) glColor3fv (myDrawMode <= GL_LINE_STRIP ? aLineColor->rgb : anInteriorColor->rgb); + #endif drawArray (theWorkspace, aFaceColors); } @@ -835,9 +873,11 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace } } +#if !defined(GL_ES_VERSION_2_0) if (myDrawMode <= GL_LINE_STRIP) { glPopAttrib(); } +#endif aCtx->BindProgram (NULL); } diff --git a/src/OpenGl/OpenGl_PrinterContext.cxx b/src/OpenGl/OpenGl_PrinterContext.cxx index 900f3d0cbf..189e1751b8 100644 --- a/src/OpenGl/OpenGl_PrinterContext.cxx +++ b/src/OpenGl/OpenGl_PrinterContext.cxx @@ -29,7 +29,7 @@ OpenGl_PrinterContext::OpenGl_PrinterContext() myScaleY (1.0f), myLayerViewportX (0), myLayerViewportY (0) - + { // identity projection matrix Standard_Real anInitValue = 0.0; @@ -56,7 +56,9 @@ OpenGl_PrinterContext::~OpenGl_PrinterContext() // ======================================================================= void OpenGl_PrinterContext::LoadProjTransformation() { +#if !defined(GL_ES_VERSION_2_0) glLoadMatrixf ((GLfloat* )myProjMatrixGl); +#endif } // ======================================================================= diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index f739312559..57f75786bf 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -67,6 +67,7 @@ public: //! Render presentation virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const { + #if !defined(GL_ES_VERSION_2_0) // Apply line aspect const OpenGl_AspectLine* anAspectLine = theWorkspace->AspectLine (Standard_True); const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture(); @@ -78,7 +79,7 @@ public: } // Use highlight colors - glColor3fv ((theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) ? theWorkspace->HighlightColor->rgb : anAspectLine->Color().rgb); + theWorkspace->GetGlContext()->core11->glColor3fv ((theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) ? theWorkspace->HighlightColor->rgb : anAspectLine->Color().rgb); glEnableClientState (GL_VERTEX_ARRAY); glVertexPointer (3, GL_FLOAT, 0, (GLfloat* )&myVerts); @@ -90,6 +91,7 @@ public: { theWorkspace->EnableTexture (aPrevTexture); } + #endif } //! Release graphical resources @@ -644,10 +646,12 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const const OpenGl_Matrix *local_trsf = NULL; if (myTransformation) { + #if !defined(GL_ES_VERSION_2_0) if (isImmediate) { Tmatrix3 aModelWorld; call_util_transpose_mat (*aModelWorld, myTransformation->mat); + glGetIntegerv (GL_MATRIX_MODE, &matrix_mode); if (!aCtx->ShaderManager()->IsEmpty()) @@ -675,6 +679,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const local_trsf = AWorkspace->SetStructureMatrix (myTransformation); } + #endif } // Apply transform persistence @@ -793,6 +798,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const // Restore local transformation if (myTransformation) { + #if !defined(GL_ES_VERSION_2_0) if (isImmediate) { glPopMatrix (); @@ -812,6 +818,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const glMatrixMode (GL_MODELVIEW); glPopMatrix(); } + #endif } // Apply highlight box diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index 75e19ab122..fcb775cf89 100755 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -112,6 +112,7 @@ namespace char aPsFont[64]; getGL2PSFontName (theAspect.FontName().ToCString(), aPsFont); + #if !defined(GL_ES_VERSION_2_0) if (theIs2d) { glRasterPos2f (0.0f, 0.0f); @@ -123,6 +124,7 @@ namespace GLubyte aZero = 0; glBitmap (1, 1, 0, 0, 0, 0, &aZero); + #endif // Standard GL2PS's alignment isn't used, because it doesn't work correctly // for all formats, therefore alignment is calculated manually relative @@ -438,11 +440,12 @@ void OpenGl_Text::Render (const Handle(OpenGl_PrinterContext)& thePrintCtx, // purpose : // ======================================================================= void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx, - const Handle(OpenGl_Context)& /*theCtx*/, + const Handle(OpenGl_Context)& theCtx, const OpenGl_AspectText& theTextAspect, const OpenGl_Vec3 theDVec) const { // setup matrix +#if !defined(GL_ES_VERSION_2_0) if (myIs2d) { glLoadIdentity(); @@ -462,8 +465,8 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx, &anObjX, &anObjY, &anObjZ); glLoadIdentity(); - glTranslated (anObjX, anObjY, anObjZ); - glRotated (theTextAspect.Angle(), 0.0, 0.0, 1.0); + theCtx->core11->glTranslated (anObjX, anObjY, anObjZ); + theCtx->core11->glRotated (theTextAspect.Angle(), 0.0, 0.0, 1.0); if (!theTextAspect.IsZoomable()) { #ifdef _WIN32 @@ -477,12 +480,13 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx, // text should be scaled in all directions with same // factor to save its proportions, so use height (y) scaling // as it is better for keeping text/3d graphics proportions - glScalef (aTextScaley, aTextScaley, aTextScaley); + theCtx->core11->glScaled ((GLfloat )aTextScaley, (GLfloat )aTextScaley, (GLfloat )aTextScaley); } #endif - glScaled (myScaleHeight, myScaleHeight, myScaleHeight); + theCtx->core11->glScaled (myScaleHeight, myScaleHeight, myScaleHeight); } } +#endif } // ======================================================================= @@ -577,14 +581,18 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx, } Handle(OpenGl_Context) aCtx = theCtx; + #if !defined(GL_ES_VERSION_2_0) glPushAttrib (GL_TEXTURE_BIT); + #endif aFont = new OpenGl_Font (aFontFt, theKey); if (!aFont->Init (aCtx)) { //glPopAttrib(); //return aFont; // out of resources? } + #if !defined(GL_ES_VERSION_2_0) glPopAttrib(); // texture bit + #endif aCtx->ShareResource (theKey, aFont); } @@ -643,6 +651,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, myExportHeight = 1.0f; myScaleHeight = 1.0f; +#if !defined(GL_ES_VERSION_2_0) glMatrixMode (GL_MODELVIEW); glPushMatrix(); if (!myIs2d) @@ -690,6 +699,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, glDisable (GL_DEPTH_TEST); } + // setup alpha test GLint aTexEnvParam = GL_REPLACE; glGetTexEnviv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &aTexEnvParam); @@ -723,7 +733,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, } case Aspect_TODT_SUBTITLE: { - glColor3fv (theColorSubs.rgb); + theCtx->core11->glColor3fv (theColorSubs.rgb); setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.00001f)); glBindTexture (GL_TEXTURE_2D, 0); @@ -737,7 +747,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, } case Aspect_TODT_DEKALE: { - glColor3fv (theColorSubs.rgb); + theCtx->core11->glColor3fv (theColorSubs.rgb); setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (+1.0f, +1.0f, 0.00001f)); drawText (thePrintCtx, theCtx, theTextAspect); setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (-1.0f, -1.0f, 0.00001f)); @@ -756,7 +766,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, } // main draw call - glColor3fv (theColorText.rgb); + theCtx->core11->glColor3fv (theColorText.rgb); setupMatrix (thePrintCtx, theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f)); drawText (thePrintCtx, theCtx, theTextAspect); @@ -798,4 +808,5 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx, // revert OpenGL state glPopAttrib(); // enable bit glPopMatrix(); // model view matrix was modified +#endif } diff --git a/src/OpenGl/OpenGl_Texture.cxx b/src/OpenGl/OpenGl_Texture.cxx index bf966f0c8a..4296d7873e 100644 --- a/src/OpenGl/OpenGl_Texture.cxx +++ b/src/OpenGl/OpenGl_Texture.cxx @@ -32,7 +32,9 @@ struct OpenGl_UnpackAlignmentSentry void Reset() { glPixelStorei (GL_UNPACK_ALIGNMENT, 1); + #if !defined(GL_ES_VERSION_2_0) glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); + #endif } ~OpenGl_UnpackAlignmentSentry() @@ -197,8 +199,8 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx, { return false; } - theTextFormat = GL_RGBA8; // GL_RGBA32F - thePixelFormat = GL_BGRA; // equals to GL_BGRA_EXT + theTextFormat = GL_RGBA8; // GL_RGBA32F + thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA theDataType = GL_FLOAT; return true; } @@ -211,10 +213,14 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx, } case Image_PixMap::ImgBGRF: { - theTextFormat = GL_RGB8; // GL_RGB32F + #if !defined(GL_ES_VERSION_2_0) + theTextFormat = GL_RGB8; // GL_RGB32F thePixelFormat = GL_BGR; // equals to GL_BGR_EXT theDataType = GL_FLOAT; return true; + #else + return false; + #endif } case Image_PixMap::ImgRGBA: { @@ -229,8 +235,8 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx, { return false; } - theTextFormat = GL_RGBA8; - thePixelFormat = GL_BGRA; // equals to GL_BGRA_EXT + theTextFormat = GL_RGBA8; + thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA theDataType = GL_UNSIGNED_BYTE; return true; } @@ -247,8 +253,8 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx, { return false; } - theTextFormat = GL_RGB8; - thePixelFormat = GL_BGRA; // equals to GL_BGRA_EXT + theTextFormat = GL_RGB8; + thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA theDataType = GL_UNSIGNED_BYTE; return true; } @@ -261,6 +267,7 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx, } case Image_PixMap::ImgBGR: { + #if !defined(GL_ES_VERSION_2_0) if (!theCtx->IsGlGreaterEqual (1, 2) && !theCtx->extBgra) { return false; @@ -269,6 +276,9 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx, thePixelFormat = GL_BGR; // equals to GL_BGR_EXT theDataType = GL_UNSIGNED_BYTE; return true; + #else + return false; + #endif } case Image_PixMap::ImgGray: { @@ -316,8 +326,10 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, const GLsizei aWidthOut = toForceP2 ? OpenGl_Context::GetPowerOfTwo (aWidth, aMaxSize) : Min (aWidth, aMaxSize); const GLsizei aHeightOut = toForceP2 ? OpenGl_Context::GetPowerOfTwo (aHeight, aMaxSize) : Min (aHeight, aMaxSize); +#if !defined(GL_ES_VERSION_2_0) GLint aTestWidth = 0; GLint aTestHeight = 0; +#endif GLvoid* aDataPtr = (theImage != NULL) ? (GLvoid* )theImage->Data() : NULL; // setup the alignment @@ -327,16 +339,19 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, const GLint anAligment = Min ((GLint )theImage->MaxRowAligmentBytes(), 8); // OpenGL supports alignment upto 8 bytes glPixelStorei (GL_UNPACK_ALIGNMENT, anAligment); + #if !defined(GL_ES_VERSION_2_0) // notice that GL_UNPACK_ROW_LENGTH is not available on OpenGL ES 2.0 without GL_EXT_unpack_subimage extension const GLint anExtraBytes = GLint(theImage->RowExtraBytes()); const GLint aPixelsWidth = GLint(theImage->SizeRowBytes() / theImage->SizePixelBytes()); glPixelStorei (GL_UNPACK_ROW_LENGTH, (anExtraBytes >= anAligment) ? aPixelsWidth : 0); + #endif } switch (theType) { case Graphic3d_TOT_1D: { + #if !defined(GL_ES_VERSION_2_0) myTarget = GL_TEXTURE_1D; Bind (theCtx); glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -392,6 +407,9 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, Unbind (theCtx); return true; + #else + return false; + #endif } case Graphic3d_TOT_2D: { @@ -405,6 +423,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, { if (aWidth != aWidthOut || aHeight != aHeightOut) { + #if !defined(GL_ES_VERSION_2_0) // scale texture glPixelStorei (GL_PACK_ALIGNMENT, 1); glPixelStorei (GL_PACK_ROW_LENGTH, 0); @@ -420,9 +439,15 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, aDataPtr = (GLvoid* )aCopy.Data(); anUnpackSentry.Reset(); + #else + Unbind (theCtx); + Release (theCtx.operator->()); + return false; + #endif } } + #if !defined(GL_ES_VERSION_2_0) // use proxy to check texture could be created or not glTexImage2D (GL_PROXY_TEXTURE_2D, 0, myTextFormat, aWidthOut, aHeightOut, 0, @@ -436,6 +461,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, Release (theCtx.operator->()); return false; } + #endif glTexImage2D (GL_TEXTURE_2D, 0, myTextFormat, aWidthOut, aHeightOut, 0, @@ -464,6 +490,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, if (theCtx->arbFBO != NULL && aWidth == aWidthOut && aHeight == aHeightOut) { + #if !defined(GL_ES_VERSION_2_0) // use proxy to check texture could be created or not glTexImage2D (GL_PROXY_TEXTURE_2D, 0, myTextFormat, aWidthOut, aHeightOut, 0, @@ -477,6 +504,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, Release (theCtx.operator->()); return false; } + #endif // upload main picture glTexImage2D (GL_TEXTURE_2D, 0, myTextFormat, @@ -501,6 +529,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, } else { + #if !defined(GL_ES_VERSION_2_0) bool isCreated = gluBuild2DMipmaps (GL_TEXTURE_2D, myTextFormat, aWidth, aHeight, thePixelFormat, theDataType, theImage->Data()) == 0; @@ -512,6 +541,10 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx, Unbind (theCtx); return isCreated; + #else + Unbind (theCtx); + return false; + #endif } } default: @@ -565,12 +598,13 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx, { return false; } - + +#if !defined(GL_ES_VERSION_2_0) myTarget = GL_TEXTURE_RECTANGLE; const GLsizei aSizeX = Min (theCtx->MaxTextureSize(), theSizeX); const GLsizei aSizeY = Min (theCtx->MaxTextureSize(), theSizeY); - + Bind (theCtx); if (myParams->Filter() == Graphic3d_TOTF_NEAREST) @@ -631,4 +665,7 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx, Unbind (theCtx); return true; +#else + return false; +#endif } diff --git a/src/OpenGl/OpenGl_TextureBufferArb.cxx b/src/OpenGl/OpenGl_TextureBufferArb.cxx index f76ec028b4..f1d5aca292 100644 --- a/src/OpenGl/OpenGl_TextureBufferArb.cxx +++ b/src/OpenGl/OpenGl_TextureBufferArb.cxx @@ -98,6 +98,7 @@ bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx, const GLsizei theElemsNb, const GLfloat* theData) { +#if !defined(GL_ES_VERSION_2_0) if (theComponentsNb != 1 && theComponentsNb != 2 && theComponentsNb != 4) @@ -125,6 +126,9 @@ bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx, UnbindTexture (theGlCtx); Unbind (theGlCtx); return true; +#else + return false; +#endif } // ======================================================================= @@ -136,6 +140,7 @@ bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx, const GLsizei theElemsNb, const GLuint* theData) { +#if !defined(GL_ES_VERSION_2_0) if (theComponentsNb != 1 && theComponentsNb != 2 && theComponentsNb != 3 @@ -164,6 +169,9 @@ bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx, UnbindTexture (theGlCtx); Unbind (theGlCtx); return true; +#else + return false; +#endif } // ======================================================================= diff --git a/src/OpenGl/OpenGl_Trihedron.cxx b/src/OpenGl/OpenGl_Trihedron.cxx index adcb59a835..d1eeb492b7 100644 --- a/src/OpenGl/OpenGl_Trihedron.cxx +++ b/src/OpenGl/OpenGl_Trihedron.cxx @@ -88,6 +88,7 @@ static int theNbFacettes = 12; //call_triedron_redraw void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) const { +#if !defined(GL_ES_VERSION_2_0) const Standard_Real U = theWorkspace->ActiveView()->Height(); const Standard_Real V = theWorkspace->ActiveView()->Width(); @@ -286,6 +287,7 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con glPopMatrix (); glMatrixMode (GL_MODELVIEW); glPopMatrix (); +#endif } @@ -295,6 +297,7 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con //call_zbuffer_triedron_redraw void OpenGl_Trihedron::redrawZBuffer (const Handle(OpenGl_Workspace)& theWorkspace) const { +#if !defined(GL_ES_VERSION_2_0) const Standard_Real U = theWorkspace->ActiveView()->Height(); const Standard_Real V = theWorkspace->ActiveView()->Width(); @@ -572,6 +575,7 @@ void OpenGl_Trihedron::redrawZBuffer (const Handle(OpenGl_Workspace)& theWorkspa glMatrixMode (GL_MODELVIEW); glPopMatrix (); } +#endif } @@ -672,7 +676,9 @@ void OpenGl_Trihedron::Render (const Handle(OpenGl_Workspace)& theWorkspace) con */ if (!theWorkspace->UseGLLight()) { + #if !defined(GL_ES_VERSION_2_0) glDisable (GL_LIGHTING); + #endif } const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture(); diff --git a/src/OpenGl/OpenGl_VertexBuffer.hxx b/src/OpenGl/OpenGl_VertexBuffer.hxx index d029c00a35..ca06de3591 100644 --- a/src/OpenGl/OpenGl_VertexBuffer.hxx +++ b/src/OpenGl/OpenGl_VertexBuffer.hxx @@ -234,10 +234,14 @@ public: //! @name advanced methods case GL_UNSIGNED_BYTE: return sizeof(GLubyte); case GL_SHORT: case GL_UNSIGNED_SHORT: return sizeof(GLushort); + #ifdef GL_INT case GL_INT: + #endif case GL_UNSIGNED_INT: return sizeof(GLuint); case GL_FLOAT: return sizeof(GLfloat); + #ifdef GL_DOUBLE case GL_DOUBLE: return sizeof(GLdouble); + #endif default: return 0; } } @@ -282,7 +286,7 @@ public: //! @name advanced methods const Graphic3d_TypeOfAttribute theMode); private: - +#if !defined(GL_ES_VERSION_2_0) //! Setup FFP array pointer. static void bindFixed (const Handle(OpenGl_Context)& theGlCtx, const Graphic3d_TypeOfAttribute theMode, @@ -294,7 +298,7 @@ private: //! Disable FFP array pointer. static void unbindFixed (const Handle(OpenGl_Context)& theGlCtx, const Graphic3d_TypeOfAttribute theMode); - +#endif public: //! @name methods for interleaved attributes array //! @return true if buffer contains per-vertex color attribute diff --git a/src/OpenGl/OpenGl_VertexBuffer.lxx b/src/OpenGl/OpenGl_VertexBuffer.lxx index 866e5738bf..fb11b4887d 100644 --- a/src/OpenGl/OpenGl_VertexBuffer.lxx +++ b/src/OpenGl/OpenGl_VertexBuffer.lxx @@ -25,7 +25,9 @@ inline void OpenGl_VertexBuffer::bindAttribute (const Handle(OpenGl_Context)& { if (theCtx->ActiveProgram().IsNull()) { + #if !defined(GL_ES_VERSION_2_0) bindFixed (theCtx, theAttribute, theNbComp, theDataType, theStride, theOffset); + #endif return; } @@ -33,6 +35,7 @@ inline void OpenGl_VertexBuffer::bindAttribute (const Handle(OpenGl_Context)& theCtx->core20fwd->glVertexAttribPointer (theAttribute, theNbComp, theDataType, GL_FALSE, theStride, theOffset); } +#if !defined(GL_ES_VERSION_2_0) // ======================================================================= // function : bindFixed // purpose : @@ -78,6 +81,7 @@ inline void OpenGl_VertexBuffer::bindFixed (const Handle(OpenGl_Context)& theC } } } +#endif // ======================================================================= // function : unbindAttribute @@ -88,13 +92,16 @@ inline void OpenGl_VertexBuffer::unbindAttribute (const Handle(OpenGl_Context)& { if (theCtx->ActiveProgram().IsNull()) { + #if !defined(GL_ES_VERSION_2_0) unbindFixed (theCtx, theAttribute); + #endif return; } theCtx->core20fwd->glDisableVertexAttribArray (theAttribute); } +#if !defined(GL_ES_VERSION_2_0) // ======================================================================= // function : unbindAttribute // purpose : @@ -119,3 +126,4 @@ inline void OpenGl_VertexBuffer::unbindFixed (const Handle(OpenGl_Context)& th } } } +#endif diff --git a/src/OpenGl/OpenGl_View.cxx b/src/OpenGl/OpenGl_View.cxx index 9a8939f97f..c74a924ab9 100644 --- a/src/OpenGl/OpenGl_View.cxx +++ b/src/OpenGl/OpenGl_View.cxx @@ -267,6 +267,7 @@ void OpenGl_View::EndTransformPersistence(const Handle(OpenGl_Context)& theCtx) { if (myIsTransPers) { + #if !defined(GL_ES_VERSION_2_0) // restore matrix glMatrixMode (GL_PROJECTION); glPopMatrix(); @@ -286,6 +287,7 @@ void OpenGl_View::EndTransformPersistence(const Handle(OpenGl_Context)& theCtx) // Set OCCT state uniform variables theCtx->ShaderManager()->RevertWorldViewStateTo (&aResultWorldView); theCtx->ShaderManager()->RevertProjectionStateTo (&aResultProjection); + #endif } } @@ -303,12 +305,14 @@ const TEL_TRANSFORM_PERSISTENCE* OpenGl_View::BeginTransformPersistence (const H return aTransPersPrev; } +#if !defined(GL_ES_VERSION_2_0) GLint aViewport[4]; GLdouble aModelMatrix[4][4]; GLdouble aProjMatrix[4][4]; glGetIntegerv (GL_VIEWPORT, aViewport); glGetDoublev (GL_MODELVIEW_MATRIX, (GLdouble* )aModelMatrix); glGetDoublev (GL_PROJECTION_MATRIX, (GLdouble *)aProjMatrix); + const GLdouble aViewportW = (GLdouble )aViewport[2]; const GLdouble aViewportH = (GLdouble )aViewport[3]; @@ -418,11 +422,12 @@ const TEL_TRANSFORM_PERSISTENCE* OpenGl_View::BeginTransformPersistence (const H gluUnProject (-0.5 * aViewportW, -0.5 * aViewportH, 0.0, (GLdouble* )THE_IDENTITY_MATRIX, (GLdouble* )aProjMatrix, aViewport, &aW2, &aH2, &aDummy); + GLdouble aMoveX = 0.5 * (aW1 - aW2 - theTransPers->pointZ); GLdouble aMoveY = 0.5 * (aH1 - aH2 - theTransPers->pointZ); aMoveX = (theTransPers->pointX > 0.0) ? aMoveX : -aMoveX; aMoveY = (theTransPers->pointY > 0.0) ? aMoveY : -aMoveY; - glTranslated (aMoveX, aMoveY, 0.0); + theCtx->core11->glTranslated (aMoveX, aMoveY, 0.0); } } else if ((theTransPers->mode & TPF_PAN) != TPF_PAN) @@ -436,7 +441,7 @@ const TEL_TRANSFORM_PERSISTENCE* OpenGl_View::BeginTransformPersistence (const H &aMoveX, &aMoveY, &aMoveZ); glMatrixMode (GL_MODELVIEW); - glTranslated (aMoveX, aMoveY, aMoveZ); + theCtx->core11->glTranslated (aMoveX, aMoveY, aMoveZ); } // Note: the approach of accessing OpenGl matrices is used now since the matrix @@ -451,7 +456,7 @@ const TEL_TRANSFORM_PERSISTENCE* OpenGl_View::BeginTransformPersistence (const H // Set OCCT state uniform variables theCtx->ShaderManager()->UpdateWorldViewStateTo (&aResultWorldView); theCtx->ShaderManager()->UpdateProjectionStateTo (&aResultProjection); - +#endif return aTransPersPrev; } diff --git a/src/OpenGl/OpenGl_View_2.cxx b/src/OpenGl/OpenGl_View_2.cxx index 74cb064117..7252e06ff1 100644 --- a/src/OpenGl/OpenGl_View_2.cxx +++ b/src/OpenGl/OpenGl_View_2.cxx @@ -64,6 +64,7 @@ struct OPENGL_CLIP_PLANE * Fonctions privees */ +#if !defined(GL_ES_VERSION_2_0) /*-----------------------------------------------------------------*/ /* * Set des lumieres @@ -153,11 +154,13 @@ static void bind_light (const OpenGl_Light& theLight, glEnable (theLightGlId++); } +#endif /*----------------------------------------------------------------------*/ void OpenGl_View::DrawBackground (OpenGl_Workspace& theWorkspace) { +#if !defined(GL_ES_VERSION_2_0) if ( (theWorkspace.NamedStatus & OPENGL_NS_WHITEBACK) == 0 && ( myBgTexture.TexId != 0 || myBgGradient.type != Aspect_GFM_NONE ) ) { @@ -344,6 +347,7 @@ void OpenGl_View::DrawBackground (OpenGl_Workspace& theWorkspace) glEnable (GL_DEPTH_TEST); } } +#endif } /*----------------------------------------------------------------------*/ @@ -361,6 +365,7 @@ void OpenGl_View::Render (const Handle(OpenGl_PrinterContext)& thePrintContext, const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext(); +#if !defined(GL_ES_VERSION_2_0) // Store and disable current clipping planes Standard_Integer aMaxPlanes = aContext->MaxClipPlanes(); @@ -382,6 +387,7 @@ void OpenGl_View::Render (const Handle(OpenGl_PrinterContext)& thePrintContext, aPtrPlane->isEnabled = GL_FALSE; } } +#endif Standard_Boolean isProjectionMatUpdateNeeded = Standard_False; Standard_Boolean isOrientationMatUpdateNeeded = Standard_False; @@ -458,8 +464,10 @@ void OpenGl_View::Render (const Handle(OpenGl_PrinterContext)& thePrintContext, DrawBackground (*theWorkspace); } +#if !defined(GL_ES_VERSION_2_0) // Switch off lighting by default glDisable(GL_LIGHTING); +#endif // ================================= // Step 3: Draw underlayer @@ -485,6 +493,7 @@ void OpenGl_View::Render (const Handle(OpenGl_PrinterContext)& thePrintContext, glDisable( GL_CULL_FACE ); } +#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 = myCamera->AxialScale(); @@ -516,7 +525,7 @@ void OpenGl_View::Render (const Handle(OpenGl_PrinterContext)& thePrintContext, { myFog.Front = (Standard_ShortReal )(aFogFrontConverted - myCamera->Distance()); myFog.Back = (Standard_ShortReal )(aFogBackConverted - myCamera->Distance()); - } + } glFogi(GL_FOG_MODE, GL_LINEAR); glFogf(GL_FOG_START, (Standard_ShortReal )aFogFrontConverted); @@ -529,6 +538,7 @@ void OpenGl_View::Render (const Handle(OpenGl_PrinterContext)& thePrintContext, // Apply InteriorShadingMethod glShadeModel( myIntShadingMethod == TEL_SM_FLAT ? GL_FLAT : GL_SMOOTH ); +#endif // Apply AntiAliasing if (myAntiAliasing) @@ -572,7 +582,7 @@ void OpenGl_View::Render (const Handle(OpenGl_PrinterContext)& thePrintContext, } // safely switch to right Eye buffer aContext->SetDrawBufferRight(); - + // redraw right Eye RedrawScene (thePrintContext, theWorkspace, aRProj, aOrient); @@ -637,6 +647,7 @@ void OpenGl_View::Render (const Handle(OpenGl_PrinterContext)& thePrintContext, // =============================== // Restore clipping planes +#if !defined(GL_ES_VERSION_2_0) aClipPlaneId = GL_CLIP_PLANE0; aPtrPlane = aOldPlanes; @@ -650,6 +661,7 @@ void OpenGl_View::Render (const Handle(OpenGl_PrinterContext)& thePrintContext, } delete[] aOldPlanes; +#endif // ============================================================== // Step 8: Keep shader manager informed about last View @@ -678,27 +690,35 @@ void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace) if ( myZLayers.NbStructures() <= 0 ) return; +#if !defined(GL_ES_VERSION_2_0) glPushAttrib ( GL_DEPTH_BUFFER_BIT ); +#endif //TsmPushAttri(); /* save previous graphics context */ if ( (AWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED) == 0 ) { + #if !defined(GL_ES_VERSION_2_0) const int antiAliasingMode = AWorkspace->AntiAliasingMode(); + #endif if ( !myAntiAliasing ) { + #if !defined(GL_ES_VERSION_2_0) glDisable(GL_POINT_SMOOTH); glDisable(GL_LINE_SMOOTH); if( antiAliasingMode & 2 ) glDisable(GL_POLYGON_SMOOTH); + #endif glBlendFunc (GL_ONE, GL_ZERO); glDisable (GL_BLEND); } else { + #if !defined(GL_ES_VERSION_2_0) glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); if( antiAliasingMode & 2 ) glEnable(GL_POLYGON_SMOOTH); + #endif glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable (GL_BLEND); } @@ -706,8 +726,10 @@ void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace) myZLayers.Render (AWorkspace); +#if !defined(GL_ES_VERSION_2_0) //TsmPopAttri(); /* restore previous graphics context; before update lights */ glPopAttrib(); +#endif } /*----------------------------------------------------------------------*/ @@ -717,6 +739,7 @@ void OpenGl_View::RedrawLayer2d (const Handle(OpenGl_PrinterContext)& thePrintCo const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACLayer) { +#if !defined(GL_ES_VERSION_2_0) if (&ACLayer == NULL || ACLayer.ptrLayer == NULL || ACLayer.ptrLayer->listIndex == 0) return; @@ -841,6 +864,7 @@ void OpenGl_View::RedrawLayer2d (const Handle(OpenGl_PrinterContext)& thePrintCo glViewport (0, 0, (GLsizei) ACView.DefWindow.dx, (GLsizei) ACView.DefWindow.dy); glFlush (); +#endif } /*----------------------------------------------------------------------*/ @@ -924,9 +948,12 @@ void OpenGl_View::CreateBackgroundTexture (const Standard_CString theFilePath, glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); const GLenum aDataFormat = (anImage.Format() == Image_PixMap::ImgRGB) ? GL_RGB : GL_RGBA; + +#if !defined(GL_ES_VERSION_2_0) gluBuild2DMipmaps (GL_TEXTURE_2D, 3/*4*/, GLint(anImage.SizeX()), GLint(anImage.SizeY()), aDataFormat, GL_UNSIGNED_BYTE, anImage.Data()); +#endif myBgTexture.TexId = aTextureId; myBgTexture.Width = (Standard_Integer )anImage.SizeX(); @@ -1172,6 +1199,7 @@ void OpenGl_View::RedrawScene (const Handle(OpenGl_PrinterContext)& thePrintCont } } +#if !defined(GL_ES_VERSION_2_0) // Setup view projection glMatrixMode (GL_PROJECTION); @@ -1195,12 +1223,14 @@ void OpenGl_View::RedrawScene (const Handle(OpenGl_PrinterContext)& thePrintCont aContext->ShaderManager()->UpdateProjectionStateTo (&aResultProjection); // force shader uniform restore on next frame - myProjectionState = 0; + myProjectionState = 0; } +#endif // Setup view orientation theWorkspace->SetViewMatrix (theOrientation); +#if !defined(GL_ES_VERSION_2_0) // Apply Lights { // setup lights @@ -1229,6 +1259,7 @@ void OpenGl_View::RedrawScene (const Handle(OpenGl_PrinterContext)& thePrintCont glDisable (aLightGlId); } } +#endif // Clear status bitfields theWorkspace->NamedStatus &= ~(OPENGL_NS_2NDPASSNEED | OPENGL_NS_2NDPASSDO); @@ -1265,13 +1296,15 @@ void OpenGl_View::RedrawScene (const Handle(OpenGl_PrinterContext)& thePrintCont theWorkspace->EnableTexture (myTextureEnv); // Remember OpenGl properties - GLint aSaveBlendDst, aSaveBlendSrc; + GLint aSaveBlendDst = GL_ONE_MINUS_SRC_ALPHA, aSaveBlendSrc = GL_SRC_ALPHA; GLint aSaveZbuffFunc; GLboolean aSaveZbuffWrite; glGetBooleanv (GL_DEPTH_WRITEMASK, &aSaveZbuffWrite); glGetIntegerv (GL_DEPTH_FUNC, &aSaveZbuffFunc); + #if !defined(GL_ES_VERSION_2_0) glGetIntegerv (GL_BLEND_DST, &aSaveBlendDst); glGetIntegerv (GL_BLEND_SRC, &aSaveBlendSrc); + #endif GLboolean wasZbuffEnabled = glIsEnabled (GL_DEPTH_TEST); GLboolean wasBlendEnabled = glIsEnabled (GL_BLEND); diff --git a/src/OpenGl/OpenGl_Window.cxx b/src/OpenGl/OpenGl_Window.cxx index 43e82457f7..462dcaae98 100644 --- a/src/OpenGl/OpenGl_Window.cxx +++ b/src/OpenGl/OpenGl_Window.cxx @@ -637,6 +637,7 @@ void OpenGl_Window::ReadDepths (const Standard_Integer theX, const Standard_ if (theDepths == NULL || !Activate()) return; +#if !defined(GL_ES_VERSION_2_0) glMatrixMode (GL_PROJECTION); glLoadIdentity(); gluOrtho2D (0.0, (GLdouble )myWidth, 0.0, (GLdouble )myHeight); @@ -647,6 +648,7 @@ void OpenGl_Window::ReadDepths (const Standard_Integer theX, const Standard_ DisableFeatures(); glReadPixels (theX, theY, theWidth, theHeight, GL_DEPTH_COMPONENT, GL_FLOAT, theDepths); EnableFeatures(); +#endif } // ======================================================================= @@ -690,11 +692,12 @@ void OpenGl_Window::Init() myHeight = aNewHeight; #endif + glDisable (GL_SCISSOR_TEST); +#if !defined(GL_ES_VERSION_2_0) glMatrixMode (GL_MODELVIEW); glViewport (0, 0, myWidth, myHeight); - - glDisable (GL_SCISSOR_TEST); glDrawBuffer (GL_BACK); +#endif } #endif // !__APPLE__ @@ -714,23 +717,27 @@ void OpenGl_Window::EnableFeatures() const // ======================================================================= void OpenGl_Window::DisableFeatures() const { +#if !defined(GL_ES_VERSION_2_0) glPixelTransferi (GL_MAP_COLOR, GL_FALSE); +#endif /* * Disable stuff that's likely to slow down glDrawPixels. * (Omit as much of this as possible, when you know in advance * that the OpenGL state will already be set correctly.) */ - glDisable(GL_ALPHA_TEST); glDisable(GL_BLEND); glDisable(GL_DEPTH_TEST); - glDisable(GL_FOG); - glDisable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + glDisable(GL_STENCIL_TEST); +#if !defined(GL_ES_VERSION_2_0) + glDisable(GL_LIGHTING); + glDisable(GL_ALPHA_TEST); + glDisable(GL_FOG); glDisable(GL_LOGIC_OP); - glDisable(GL_STENCIL_TEST); glDisable(GL_TEXTURE_1D); - glDisable(GL_TEXTURE_2D); + glPixelTransferi(GL_MAP_COLOR, GL_FALSE); glPixelTransferi(GL_RED_SCALE, 1); glPixelTransferi(GL_RED_BIAS, 0); @@ -774,6 +781,7 @@ void OpenGl_Window::DisableFeatures() const glDisable(GL_TEXTURE_3D_EXT); #endif } +#endif } // ======================================================================= @@ -782,7 +790,9 @@ void OpenGl_Window::DisableFeatures() const // ======================================================================= void OpenGl_Window::MakeFrontBufCurrent() const { +#if !defined(GL_ES_VERSION_2_0) glDrawBuffer (GL_FRONT); +#endif } // ======================================================================= @@ -791,5 +801,7 @@ void OpenGl_Window::MakeFrontBufCurrent() const // ======================================================================= void OpenGl_Window::MakeBackBufCurrent() const { +#if !defined(GL_ES_VERSION_2_0) glDrawBuffer (GL_BACK); +#endif } diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index 80d04093f6..0d6a19ff5e 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -188,6 +188,7 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(Aspect_DisplayConnection)& theD // General initialization of the context +#if !defined(GL_ES_VERSION_2_0) // Eviter d'avoir les faces mal orientees en noir. // Pourrait etre utiliser pour detecter les problemes d'orientation glLightModeli ((GLenum )GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); @@ -197,6 +198,7 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(Aspect_DisplayConnection)& theD glHint (GL_POINT_SMOOTH_HINT, GL_FASTEST); glHint (GL_LINE_SMOOTH_HINT, GL_FASTEST); glHint (GL_POLYGON_SMOOTH_HINT, GL_FASTEST); +#endif // AA mode const char* anAaEnv = ::getenv ("CALL_OPENGL_ANTIALIASING_MODE"); @@ -297,18 +299,22 @@ Handle(OpenGl_Texture) OpenGl_Workspace::DisableTexture() return myTextureBound; } +#if !defined(GL_ES_VERSION_2_0) // reset texture matrix because some code may expect it is identity GLint aMatrixMode = GL_TEXTURE; glGetIntegerv (GL_MATRIX_MODE, &aMatrixMode); glMatrixMode (GL_TEXTURE); glLoadIdentity(); glMatrixMode (aMatrixMode); +#endif myTextureBound->Unbind (myGlContext); switch (myTextureBound->GetTarget()) { + #if !defined(GL_ES_VERSION_2_0) case GL_TEXTURE_1D: { + if (myTextureBound->GetParams()->GenMode() != GL_NONE) { glDisable (GL_TEXTURE_GEN_S); @@ -316,8 +322,10 @@ Handle(OpenGl_Texture) OpenGl_Workspace::DisableTexture() glDisable (GL_TEXTURE_1D); break; } + #endif case GL_TEXTURE_2D: { + #if !defined(GL_ES_VERSION_2_0) if (myTextureBound->GetParams()->GenMode() != GL_NONE) { glDisable (GL_TEXTURE_GEN_S); @@ -327,6 +335,7 @@ Handle(OpenGl_Texture) OpenGl_Workspace::DisableTexture() glDisable (GL_POINT_SPRITE); } } + #endif glDisable (GL_TEXTURE_2D); break; } @@ -351,6 +360,7 @@ void OpenGl_Workspace::setTextureParams (Handle(OpenGl_Texture)& return; } +#if !defined(GL_ES_VERSION_2_0) GLint aMatrixMode = GL_TEXTURE; glGetIntegerv (GL_MATRIX_MODE, &aMatrixMode); @@ -423,13 +433,15 @@ void OpenGl_Workspace::setTextureParams (Handle(OpenGl_Texture)& { glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, aParams->IsModulate() ? GL_MODULATE : GL_DECAL); } +#endif // setup texture filtering and wrapping //if (theTexture->GetParams() != theParams) const GLenum aFilter = (aParams->Filter() == Graphic3d_TOTF_NEAREST) ? GL_NEAREST : GL_LINEAR; - const GLenum aWrapMode = aParams->IsRepeat() ? GL_REPEAT : GL_CLAMP; + const GLenum aWrapMode = aParams->IsRepeat() ? GL_REPEAT : myGlContext->TextureWrapClamp(); switch (theTexture->GetTarget()) { + #if !defined(GL_ES_VERSION_2_0) case GL_TEXTURE_1D: { glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, aFilter); @@ -437,6 +449,7 @@ void OpenGl_Workspace::setTextureParams (Handle(OpenGl_Texture)& glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, aWrapMode); break; } + #endif case GL_TEXTURE_2D: { GLenum aFilterMin = aFilter; @@ -494,6 +507,7 @@ void OpenGl_Workspace::setTextureParams (Handle(OpenGl_Texture)& switch (theTexture->GetTarget()) { + #if !defined(GL_ES_VERSION_2_0) case GL_TEXTURE_1D: { if (aParams->GenMode() != Graphic3d_TOTM_MANUAL) @@ -503,20 +517,25 @@ void OpenGl_Workspace::setTextureParams (Handle(OpenGl_Texture)& glEnable (GL_TEXTURE_1D); break; } + #endif case GL_TEXTURE_2D: { + #if !defined(GL_ES_VERSION_2_0) if (aParams->GenMode() != Graphic3d_TOTM_MANUAL) { glEnable (GL_TEXTURE_GEN_S); glEnable (GL_TEXTURE_GEN_T); } + #endif glEnable (GL_TEXTURE_2D); break; } default: break; } +#if !defined(GL_ES_VERSION_2_0) glMatrixMode (aMatrixMode); // turn back active matrix +#endif theTexture->SetParams (aParams); } @@ -708,7 +727,11 @@ void OpenGl_Workspace::redraw1 (const Graphic3d_CView& theCView, glDisable (GL_DEPTH_TEST); } + #if !defined(GL_ES_VERSION_2_0) glClearDepth (1.0); + #else + glClearDepthf (1.0f); + #endif toClear |= GL_DEPTH_BUFFER_BIT; } else @@ -761,10 +784,12 @@ void OpenGl_Workspace::redraw1 (const Graphic3d_CView& theCView, // ======================================================================= void OpenGl_Workspace::copyBackToFront() { +#if !defined(GL_ES_VERSION_2_0) glMatrixMode (GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D (0.0, (GLdouble )myWidth, 0.0, (GLdouble )myHeight); + glMatrixMode (GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); @@ -786,6 +811,7 @@ void OpenGl_Workspace::copyBackToFront() glDrawBuffer (GL_BACK); +#endif myIsImmediateDrawn = Standard_False; } @@ -824,7 +850,9 @@ void OpenGl_Workspace::RedrawImmediate (const Graphic3d_CView& theCView, } GLboolean isDoubleBuffer = GL_FALSE; +#if !defined(GL_ES_VERSION_2_0) glGetBooleanv (GL_DOUBLEBUFFER, &isDoubleBuffer); +#endif if (myView->ImmediateStructures().IsEmpty()) { if (theToForce diff --git a/src/OpenGl/OpenGl_Workspace_5.cxx b/src/OpenGl/OpenGl_Workspace_5.cxx index d952455e6c..f8f37034bf 100644 --- a/src/OpenGl/OpenGl_Workspace_5.cxx +++ b/src/OpenGl/OpenGl_Workspace_5.cxx @@ -51,6 +51,7 @@ static void TelUpdatePolygonOffsets (const TEL_POFFSET_PARAM& theOffsetData) glDisable (GL_POLYGON_OFFSET_FILL); } +#if !defined(GL_ES_VERSION_2_0) if ((theOffsetData.mode & Aspect_POM_Line) == Aspect_POM_Line) { glEnable (GL_POLYGON_OFFSET_LINE); @@ -68,6 +69,7 @@ static void TelUpdatePolygonOffsets (const TEL_POFFSET_PARAM& theOffsetData) { glDisable (GL_POLYGON_OFFSET_POINT); } +#endif glPolygonOffset (theOffsetData.factor, theOffsetData.units); } @@ -147,11 +149,13 @@ void OpenGl_Workspace::updateMaterial (const int theFlag) // reset material if (NamedStatus & OPENGL_NS_RESMAT) { + #if !defined(GL_ES_VERSION_2_0) glMaterialfv (aFace, GL_AMBIENT, myMatTmp.Ambient.GetData()); glMaterialfv (aFace, GL_DIFFUSE, myMatTmp.Diffuse.GetData()); glMaterialfv (aFace, GL_SPECULAR, myMatTmp.Specular.GetData()); glMaterialfv (aFace, GL_EMISSION, myMatTmp.Emission.GetData()); glMaterialf (aFace, GL_SHININESS, myMatTmp.Shine()); + #endif if (theFlag == TEL_FRONT_MATERIAL) { @@ -171,7 +175,7 @@ void OpenGl_Workspace::updateMaterial (const int theFlag) OpenGl_Material& anOld = (theFlag == TEL_FRONT_MATERIAL) ? myMatFront : myMatBack; - +#if !defined(GL_ES_VERSION_2_0) if (myMatTmp.Ambient.r() != anOld.Ambient.r() || myMatTmp.Ambient.g() != anOld.Ambient.g() || myMatTmp.Ambient.b() != anOld.Ambient.b()) @@ -201,6 +205,7 @@ void OpenGl_Workspace::updateMaterial (const int theFlag) { glMaterialf (aFace, GL_SHININESS, myMatTmp.Shine()); } +#endif anOld = myMatTmp; if (aFace == GL_FRONT_AND_BACK) { @@ -291,10 +296,11 @@ const void OpenGl_Workspace::UpdateModelViewMatrix() { OpenGl_Matrix aStructureMatT; OpenGl_Transposemat3( &aStructureMatT, StructureMatrix_applied); - - glMatrixMode (GL_MODELVIEW); OpenGl_Multiplymat3 (&myModelViewMatrix, &aStructureMatT, ViewMatrix_applied); +#if !defined(GL_ES_VERSION_2_0) + glMatrixMode (GL_MODELVIEW); glLoadMatrixf ((const GLfloat* )&myModelViewMatrix.mat); +#endif } /*----------------------------------------------------------------------*/ @@ -303,7 +309,10 @@ const OpenGl_AspectLine * OpenGl_Workspace::AspectLine(const Standard_Boolean Wi { if ( WithApply && (AspectLine_set != AspectLine_applied) ) { - glColor3fv(AspectLine_set->Color().rgb); + const GLfloat* anRgb = AspectLine_set->Color().rgb; + #if !defined(GL_ES_VERSION_2_0) + glColor3fv(anRgb); + #endif if ( !AspectLine_applied || (AspectLine_set->Type() != AspectLine_applied->Type() ) ) { @@ -380,6 +389,7 @@ const OpenGl_AspectFace* OpenGl_Workspace::AspectFace (const Standard_Boolean th return AspectFace_set; } +#if !defined(GL_ES_VERSION_2_0) const Aspect_InteriorStyle anIntstyle = AspectFace_set->InteriorStyle(); if (AspectFace_applied == NULL || AspectFace_applied->InteriorStyle() != anIntstyle) { @@ -420,6 +430,7 @@ const OpenGl_AspectFace* OpenGl_Workspace::AspectFace (const Standard_Boolean th myLineAttribs->SetTypeOfHatch (hatchstyle); } } +#endif // Aspect_POM_None means: do not change current settings if ((AspectFace_set->PolygonOffset().mode & Aspect_POM_None) != Aspect_POM_None) @@ -480,10 +491,12 @@ const OpenGl_AspectMarker* OpenGl_Workspace::AspectMarker (const Standard_Boolea { if (!AspectMarker_applied || (AspectMarker_set->Scale() != AspectMarker_applied->Scale())) { + #if !defined(GL_ES_VERSION_2_0) glPointSize (AspectMarker_set->Scale()); #ifdef HAVE_GL2PS gl2psPointSize (AspectMarker_set->Scale()); #endif + #endif } AspectMarker_applied = AspectMarker_set; } diff --git a/src/OpenGl/OpenGl_Workspace_Raytrace.cxx b/src/OpenGl/OpenGl_Workspace_Raytrace.cxx index fa896d5bcb..9fc7898620 100644 --- a/src/OpenGl/OpenGl_Workspace_Raytrace.cxx +++ b/src/OpenGl/OpenGl_Workspace_Raytrace.cxx @@ -454,7 +454,11 @@ OpenGl_TriangleSet* OpenGl_Workspace::AddRaytracePrimitiveArray (const OpenGl_Pr const Handle(Graphic3d_Buffer)& anAttribs = theArray->Attributes(); const Handle(Graphic3d_BoundBuffer)& aBounds = theArray->Bounds(); if (theArray->DrawMode() < GL_TRIANGLES + #if !defined(GL_ES_VERSION_2_0) || theArray->DrawMode() > GL_POLYGON + #else + || theArray->DrawMode() > GL_TRIANGLE_FAN + #endif || anAttribs.IsNull()) { return NULL; @@ -463,12 +467,14 @@ OpenGl_TriangleSet* OpenGl_Workspace::AddRaytracePrimitiveArray (const OpenGl_Pr #ifdef RAY_TRACE_PRINT_INFO switch (theArray->DrawMode()) { - case GL_POLYGON: std::cout << "\tAdding GL_POLYGON\n"; break; case GL_TRIANGLES: std::cout << "\tAdding GL_TRIANGLES\n"; break; - case GL_QUADS: std::cout << "\tAdding GL_QUADS\n"; break; case GL_TRIANGLE_FAN: std::cout << "\tAdding GL_TRIANGLE_FAN\n"; break; case GL_TRIANGLE_STRIP: std::cout << "\tAdding GL_TRIANGLE_STRIP\n"; break; + #if !defined(GL_ES_VERSION_2_0) + case GL_QUADS: std::cout << "\tAdding GL_QUADS\n"; break; case GL_QUAD_STRIP: std::cout << "\tAdding GL_QUAD_STRIP\n"; break; + case GL_POLYGON: std::cout << "\tAdding GL_POLYGON\n"; break; + #endif } #endif @@ -597,11 +603,13 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceVertexIndices (OpenGl_TriangleSet& switch (theArray.DrawMode()) { case GL_TRIANGLES: return AddRaytraceTriangleArray (theSet, theArray.Indices(), theOffset, theCount, theMatID); - case GL_QUADS: return AddRaytraceQuadrangleArray (theSet, theArray.Indices(), theOffset, theCount, theMatID); case GL_TRIANGLE_FAN: return AddRaytraceTriangleFanArray (theSet, theArray.Indices(), theOffset, theCount, theMatID); case GL_TRIANGLE_STRIP: return AddRaytraceTriangleStripArray (theSet, theArray.Indices(), theOffset, theCount, theMatID); + #if !defined(GL_ES_VERSION_2_0) + case GL_QUADS: return AddRaytraceQuadrangleArray (theSet, theArray.Indices(), theOffset, theCount, theMatID); case GL_QUAD_STRIP: return AddRaytraceQuadrangleStripArray (theSet, theArray.Indices(), theOffset, theCount, theMatID); case GL_POLYGON: return AddRaytracePolygonArray (theSet, theArray.Indices(), theOffset, theCount, theMatID); + #endif } return Standard_False; } @@ -1483,7 +1491,7 @@ Standard_Boolean OpenGl_Workspace::InitRaytraceResources (const Graphic3d_CView& myRaytraceScreenQuad.Init (myGlContext, 3, 6, aVertices); myComputeInitStatus = OpenGl_RT_INIT; // initialized in normal way - + return Standard_True; } @@ -2230,6 +2238,7 @@ Standard_Boolean OpenGl_Workspace::Raytrace (const Graphic3d_CView& theCView, myView->RedrawLayer2d (myPrintContext, theCView, theCUnderLayer); +#if !defined(GL_ES_VERSION_2_0) // Generate ray-traced image glMatrixMode (GL_PROJECTION); glPushMatrix(); @@ -2238,6 +2247,7 @@ Standard_Boolean OpenGl_Workspace::Raytrace (const Graphic3d_CView& theCView, glMatrixMode (GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); +#endif glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_SRC_ALPHA); @@ -2263,10 +2273,12 @@ Standard_Boolean OpenGl_Workspace::Raytrace (const Graphic3d_CView& theCView, if (wasDepthTestEnabled) glEnable (GL_DEPTH_TEST); +#if !defined(GL_ES_VERSION_2_0) glMatrixMode (GL_PROJECTION); glPopMatrix(); glMatrixMode (GL_MODELVIEW); glPopMatrix(); +#endif // Redraw trihedron myView->RedrawTrihedron (this); -- 2.20.1