1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-21 10:13:43 +03:00

0032713: Visualization, OpenGl_GlFunctions - unify OpenGL and OpenGL ES function lists

Including system OpenGL headers has been moved from OpenGl_GlFunctions.hxx to OpenGl_GlNative.hxx.
Added OpenGl_GlTypes.hxx providing basic OpenGL 1.1 types.
Wrappers of system OpenGL 1.1 / OpenGL ES 2.0 functions have been moved to OpenGl_GlFunctions.cxx.
Avoided usage of global OpenGL functions in OpenGl package outside of OpenGl_GlFunctions.cxx.
This commit is contained in:
kgv 2021-12-04 15:19:47 +03:00 committed by smoskvin
parent bf2884afbe
commit 8f7159cbaa
45 changed files with 3598 additions and 2887 deletions

View File

@ -84,6 +84,8 @@ OpenGl_ExtGS.hxx
OpenGl_GLESExtensions.hxx OpenGl_GLESExtensions.hxx
OpenGl_GlFunctions.cxx OpenGl_GlFunctions.cxx
OpenGl_GlFunctions.hxx OpenGl_GlFunctions.hxx
OpenGl_GlNative.hxx
OpenGl_GlTypes.hxx
OpenGl_Flipper.cxx OpenGl_Flipper.cxx
OpenGl_Flipper.hxx OpenGl_Flipper.hxx
OpenGl_GlCore11.hxx OpenGl_GlCore11.hxx

View File

@ -83,15 +83,14 @@ bool OpenGl_AspectsSprite::HasPointSprite (const Handle(OpenGl_Context)& theCtx,
bool OpenGl_AspectsSprite::IsDisplayListSprite (const Handle(OpenGl_Context)& theCtx, bool OpenGl_AspectsSprite::IsDisplayListSprite (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_Aspects)& theAspects) const Handle(Graphic3d_Aspects)& theAspects)
{ {
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
return false;
}
const Handle(OpenGl_PointSprite)& aSprite = Sprite (theCtx, theAspects, false); const Handle(OpenGl_PointSprite)& aSprite = Sprite (theCtx, theAspects, false);
return !aSprite.IsNull() return !aSprite.IsNull()
&& aSprite->IsDisplayList(); && aSprite->IsDisplayList();
#else
(void )theCtx;
(void )theAspects;
return false;
#endif
} }
// ======================================================================= // =======================================================================
@ -274,7 +273,6 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
} }
else if (theCtx->core11ffp != NULL) else if (theCtx->core11ffp != NULL)
{ {
#if !defined(GL_ES_VERSION_2_0)
// Creating list with bitmap for using it in compatibility mode // Creating list with bitmap for using it in compatibility mode
GLuint aBitmapList = theCtx->core11ffp->glGenLists (1); GLuint aBitmapList = theCtx->core11ffp->glGenLists (1);
aSprite->SetDisplayList (theCtx, aBitmapList); aSprite->SetDisplayList (theCtx, aBitmapList);
@ -315,7 +313,7 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
{ {
if (aFormat.IsValid()) if (aFormat.IsValid())
{ {
aBitmapList = glGenLists (1); aBitmapList = theCtx->core11ffp->glGenLists (1);
aSpriteA->SetDisplayList (theCtx, aBitmapList); aSpriteA->SetDisplayList (theCtx, aBitmapList);
} }
@ -329,7 +327,6 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
theCtx->core11ffp->glEndList(); theCtx->core11ffp->glEndList();
} }
} }
#endif
} }
} }
// ======================================================================= // =======================================================================

View File

@ -29,17 +29,18 @@ namespace
//! Auxiliary sentry object managing stencil test. //! Auxiliary sentry object managing stencil test.
struct StencilTestSentry struct StencilTestSentry
{ {
StencilTestSentry() : myDepthFuncPrev (0) {} StencilTestSentry (const Handle(OpenGl_Context)& theCtx)
: myCtx (theCtx.get()), myDepthFuncPrev (0) {}
//! Restore previous application state. //! Restore previous application state.
~StencilTestSentry() ~StencilTestSentry()
{ {
if (myDepthFuncPrev != 0) if (myDepthFuncPrev != 0)
{ {
glClear (GL_STENCIL_BUFFER_BIT); myCtx->core11fwd->glClear (GL_STENCIL_BUFFER_BIT);
glDepthFunc (myDepthFuncPrev); myCtx->core11fwd->glDepthFunc (myDepthFuncPrev);
glStencilFunc (GL_ALWAYS, 0, 0xFF); myCtx->core11fwd->glStencilFunc (GL_ALWAYS, 0, 0xFF);
glDisable (GL_STENCIL_TEST); myCtx->core11fwd->glDisable (GL_STENCIL_TEST);
} }
} }
@ -48,13 +49,14 @@ namespace
{ {
if (myDepthFuncPrev == 0) if (myDepthFuncPrev == 0)
{ {
glEnable (GL_STENCIL_TEST); myCtx->core11fwd->glEnable (GL_STENCIL_TEST);
glGetIntegerv (GL_DEPTH_FUNC, &myDepthFuncPrev); myCtx->core11fwd->glGetIntegerv (GL_DEPTH_FUNC, &myDepthFuncPrev);
glDepthFunc (GL_LESS); myCtx->core11fwd->glDepthFunc (GL_LESS);
} }
} }
private: private:
OpenGl_Context* myCtx;
GLint myDepthFuncPrev; GLint myDepthFuncPrev;
}; };
@ -120,7 +122,7 @@ namespace
aContext->ChangeClipping().DisableAllExcept (theClipChain, theSubPlaneIndex); aContext->ChangeClipping().DisableAllExcept (theClipChain, theSubPlaneIndex);
aContext->ShaderManager()->UpdateClippingState(); aContext->ShaderManager()->UpdateClippingState();
glClear (GL_STENCIL_BUFFER_BIT); aContext->core11fwd->glClear (GL_STENCIL_BUFFER_BIT);
const bool aColorMaskBack = aContext->SetColorMask (false); const bool aColorMaskBack = aContext->SetColorMask (false);
// override aspects, disable culling // override aspects, disable culling
@ -130,14 +132,14 @@ namespace
// evaluate number of pair faces // evaluate number of pair faces
if (theWorkspace->UseZBuffer()) if (theWorkspace->UseZBuffer())
{ {
glDisable (GL_DEPTH_TEST); aContext->core11fwd->glDisable (GL_DEPTH_TEST);
} }
if (theWorkspace->UseDepthWrite()) if (theWorkspace->UseDepthWrite())
{ {
glDepthMask (GL_FALSE); aContext->core11fwd->glDepthMask (GL_FALSE);
} }
glStencilFunc (GL_ALWAYS, 1, 0x01); aContext->core11fwd->glStencilFunc (GL_ALWAYS, 1, 0x01);
glStencilOp (GL_KEEP, GL_INVERT, GL_INVERT); aContext->core11fwd->glStencilOp (GL_KEEP, GL_INVERT, GL_INVERT);
// render closed primitives // render closed primitives
if (aRenderPlane->ToUseObjectProperties()) if (aRenderPlane->ToUseObjectProperties())
@ -167,13 +169,13 @@ namespace
aContext->SetColorMask (aColorMaskBack); aContext->SetColorMask (aColorMaskBack);
if (theWorkspace->UseDepthWrite()) if (theWorkspace->UseDepthWrite())
{ {
glDepthMask (GL_TRUE); aContext->core11fwd->glDepthMask (GL_TRUE);
} }
glStencilFunc (GL_EQUAL, 1, 0x01); aContext->core11fwd->glStencilFunc (GL_EQUAL, 1, 0x01);
glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP); aContext->core11fwd->glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
if (theWorkspace->UseZBuffer()) if (theWorkspace->UseZBuffer())
{ {
glEnable (GL_DEPTH_TEST); aContext->core11fwd->glEnable (GL_DEPTH_TEST);
} }
theWorkspace->SetAspects (thePlane->AspectFace()); theWorkspace->SetAspects (thePlane->AspectFace());
@ -212,7 +214,7 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
// only filled primitives should be rendered // only filled primitives should be rendered
const Standard_Integer aPrevFilter = theWorkspace->RenderFilter(); const Standard_Integer aPrevFilter = theWorkspace->RenderFilter();
theWorkspace->SetRenderFilter (aPrevFilter | OpenGl_RenderFilter_FillModeOnly); theWorkspace->SetRenderFilter (aPrevFilter | OpenGl_RenderFilter_FillModeOnly);
StencilTestSentry aStencilSentry; StencilTestSentry aStencilSentry (aContext);
// generate capping for every clip plane // generate capping for every clip plane
for (OpenGl_ClippingIterator aCappingIt (aContext->Clipping()); aCappingIt.More(); aCappingIt.Next()) for (OpenGl_ClippingIterator aCappingIt (aContext->Clipping()); aCappingIt.More(); aCappingIt.Next())

File diff suppressed because it is too large Load Diff

View File

@ -981,7 +981,7 @@ public: //! @name methods to alter or retrieve current state
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
//! Dumps the content of openGL state into the stream //! Dumps the content of openGL state into the stream
Standard_EXPORT static void DumpJsonOpenGlState (Standard_OStream& theOStream, Standard_Integer theDepth = -1); Standard_EXPORT void DumpJsonOpenGlState (Standard_OStream& theOStream, Standard_Integer theDepth = -1);
//! Set GL_SHADE_MODEL value. //! Set GL_SHADE_MODEL value.
Standard_EXPORT void SetShadeModel (Graphic3d_TypeOfShadingModel theModel); Standard_EXPORT void SetShadeModel (Graphic3d_TypeOfShadingModel theModel);

View File

@ -203,9 +203,10 @@ bool OpenGl_Font::renderGlyph (const Handle(OpenGl_Context)& theCtx,
} }
aTexture->Bind (theCtx); aTexture->Bind (theCtx);
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
{
theCtx->core11fwd->glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE); theCtx->core11fwd->glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
#endif }
if (theCtx->hasUnpackRowLength) if (theCtx->hasUnpackRowLength)
{ {
theCtx->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); theCtx->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);

View File

@ -50,15 +50,14 @@ namespace
// while WebGL 1.0 + GL_WEBGL_depth_texture needs GL_DEPTH_STENCIL_ATTACHMENT // while WebGL 1.0 + GL_WEBGL_depth_texture needs GL_DEPTH_STENCIL_ATTACHMENT
// and NOT separate GL_DEPTH_ATTACHMENT+GL_STENCIL_ATTACHMENT calls which is different to OpenGL ES 2.0 + extension // and NOT separate GL_DEPTH_ATTACHMENT+GL_STENCIL_ATTACHMENT calls which is different to OpenGL ES 2.0 + extension
return theCtx->IsGlGreaterEqual (3, 0) || theCtx->extPDS; return theCtx->IsGlGreaterEqual (3, 0) || theCtx->extPDS;
#elif defined(GL_ES_VERSION_2_0) #else
// supported since OpenGL ES 3.0, // supported since OpenGL ES 3.0,
// while OpenGL ES 2.0 + GL_EXT_packed_depth_stencil needs separate GL_DEPTH_ATTACHMENT+GL_STENCIL_ATTACHMENT calls // while OpenGL ES 2.0 + GL_EXT_packed_depth_stencil needs separate GL_DEPTH_ATTACHMENT+GL_STENCIL_ATTACHMENT calls
return theCtx->IsGlGreaterEqual (3, 0); //
#else
// available on desktop since OpenGL 3.0 // available on desktop since OpenGL 3.0
// or OpenGL 2.0 + GL_ARB_framebuffer_object (GL_EXT_framebuffer_object is unsupported by OCCT) // or OpenGL 2.0 + GL_ARB_framebuffer_object (GL_EXT_framebuffer_object is unsupported by OCCT)
(void )theCtx; return theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES
return true; || theCtx->IsGlGreaterEqual (3, 0);
#endif #endif
} }
} }
@ -968,60 +967,104 @@ Standard_Boolean OpenGl_FrameBuffer::BufferDump (const Handle(OpenGl_Context)& t
bool toConvRgba2Rgb = false; bool toConvRgba2Rgb = false;
switch (theImage.Format()) switch (theImage.Format())
{ {
#if !defined(GL_ES_VERSION_2_0)
case Image_Format_Gray: case Image_Format_Gray:
{
if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
return false;
}
aFormat = theBufferType == Graphic3d_BT_Depth ? GL_DEPTH_COMPONENT : GL_RED; aFormat = theBufferType == Graphic3d_BT_Depth ? GL_DEPTH_COMPONENT : GL_RED;
aType = GL_UNSIGNED_BYTE; aType = GL_UNSIGNED_BYTE;
break; break;
}
case Image_Format_GrayF: case Image_Format_GrayF:
{
if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
return false;
}
aFormat = theBufferType == Graphic3d_BT_Depth ? GL_DEPTH_COMPONENT : GL_RED; aFormat = theBufferType == Graphic3d_BT_Depth ? GL_DEPTH_COMPONENT : GL_RED;
aType = GL_FLOAT; aType = GL_FLOAT;
break; break;
}
case Image_Format_RGF: case Image_Format_RGF:
{
if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
return false;
}
aFormat = GL_RG; aFormat = GL_RG;
aType = GL_FLOAT; aType = GL_FLOAT;
break; break;
}
case Image_Format_RGB: case Image_Format_RGB:
aFormat = GL_RGB; {
aType = GL_UNSIGNED_BYTE; if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
break; {
case Image_Format_BGR:
aFormat = GL_BGR;
aType = GL_UNSIGNED_BYTE;
break;
case Image_Format_BGRA:
case Image_Format_BGR32:
aFormat = GL_BGRA;
aType = GL_UNSIGNED_BYTE;
break;
case Image_Format_BGRF:
aFormat = GL_BGR;
aType = GL_FLOAT;
break;
case Image_Format_BGRAF:
aFormat = GL_BGRA;
aType = GL_FLOAT;
break;
#else
case Image_Format_Gray:
case Image_Format_GrayF:
case Image_Format_BGRF:
case Image_Format_BGRAF:
case Image_Format_RGF:
return Standard_False;
case Image_Format_BGRA:
case Image_Format_BGR32:
aFormat = GL_RGBA; aFormat = GL_RGBA;
aType = GL_UNSIGNED_BYTE;
toSwapRgbaBgra = true;
break;
case Image_Format_BGR:
case Image_Format_RGB:
aFormat = GL_RGBA;
aType = GL_UNSIGNED_BYTE;
toConvRgba2Rgb = true; toConvRgba2Rgb = true;
}
else
{
aFormat = GL_RGB;
}
aType = GL_UNSIGNED_BYTE;
break; break;
#endif }
case Image_Format_BGR:
{
if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
aFormat = GL_RGBA;
toConvRgba2Rgb = true;
}
else
{
aFormat = GL_BGR;
}
aType = GL_UNSIGNED_BYTE;
break;
}
case Image_Format_BGRA:
case Image_Format_BGR32:
{
if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
aFormat = GL_RGBA;
toSwapRgbaBgra = true;
}
else
{
aFormat = GL_BGRA;
}
aType = GL_UNSIGNED_BYTE;
break;
}
case Image_Format_BGRF:
{
if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
return false;
}
aFormat = GL_BGR;
aType = GL_FLOAT;
break;
}
case Image_Format_BGRAF:
{
if (theGlCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
return false;
}
aFormat = GL_BGRA;
aType = GL_FLOAT;
break;
}
case Image_Format_RGBA: case Image_Format_RGBA:
case Image_Format_RGB32: case Image_Format_RGB32:
aFormat = GL_RGBA; aFormat = GL_RGBA;
@ -1052,30 +1095,25 @@ Standard_Boolean OpenGl_FrameBuffer::BufferDump (const Handle(OpenGl_Context)& t
return Standard_False; return Standard_False;
} }
#if !defined(GL_ES_VERSION_2_0)
GLint aReadBufferPrev = GL_BACK; GLint aReadBufferPrev = GL_BACK;
if (theBufferType == Graphic3d_BT_Depth if (theGlCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES
&& theBufferType == Graphic3d_BT_Depth
&& aFormat != GL_DEPTH_COMPONENT) && aFormat != GL_DEPTH_COMPONENT)
{ {
return Standard_False; return Standard_False;
} }
#else
(void )theBufferType;
#endif
// bind FBO if used // bind FBO if used
if (!theFbo.IsNull() && theFbo->IsValid()) if (!theFbo.IsNull() && theFbo->IsValid())
{ {
theFbo->BindBuffer (theGlCtx); theFbo->BindBuffer (theGlCtx);
} }
else else if (theGlCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
{ {
#if !defined(GL_ES_VERSION_2_0)
theGlCtx->core11fwd->glGetIntegerv (GL_READ_BUFFER, &aReadBufferPrev); theGlCtx->core11fwd->glGetIntegerv (GL_READ_BUFFER, &aReadBufferPrev);
GLint aDrawBufferPrev = GL_BACK; GLint aDrawBufferPrev = GL_BACK;
theGlCtx->core11fwd->glGetIntegerv (GL_DRAW_BUFFER, &aDrawBufferPrev); theGlCtx->core11fwd->glGetIntegerv (GL_DRAW_BUFFER, &aDrawBufferPrev);
glReadBuffer (aDrawBufferPrev); theGlCtx->core11fwd->glReadBuffer (aDrawBufferPrev);
#endif
} }
// setup alignment // setup alignment
@ -1155,11 +1193,9 @@ Standard_Boolean OpenGl_FrameBuffer::BufferDump (const Handle(OpenGl_Context)& t
{ {
theFbo->UnbindBuffer (theGlCtx); theFbo->UnbindBuffer (theGlCtx);
} }
else else if (theGlCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
{ {
#if !defined(GL_ES_VERSION_2_0) theGlCtx->core11fwd->glReadBuffer (aReadBufferPrev);
glReadBuffer (aReadBufferPrev);
#endif
} }
if (toSwapRgbaBgra) if (toSwapRgbaBgra)

View File

@ -378,7 +378,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
if (theWorkspace->UseDepthWrite()) if (theWorkspace->UseDepthWrite())
{ {
theWorkspace->UseDepthWrite() = Standard_False; theWorkspace->UseDepthWrite() = Standard_False;
glDepthMask (GL_FALSE); aCtx->core11fwd->glDepthMask (GL_FALSE);
} }
const OpenGl_Aspects* aTextAspectBack = theWorkspace->SetAspects (&myTextAspect); const OpenGl_Aspects* aTextAspectBack = theWorkspace->SetAspects (&myTextAspect);
@ -417,8 +417,8 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
Graphic3d_AlphaMode_Blend, true, false, Graphic3d_AlphaMode_Blend, true, false,
Handle(OpenGl_ShaderProgram)()); Handle(OpenGl_ShaderProgram)());
aCtx->SetColor4fv (OpenGl_Vec4 (1.0f, 1.0f, 1.0f, 1.0f)); aCtx->SetColor4fv (OpenGl_Vec4 (1.0f, 1.0f, 1.0f, 1.0f));
glEnable (GL_BLEND); aCtx->core15fwd->glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); aCtx->core15fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
myChartVertices->Bind (aCtx); myChartVertices->Bind (aCtx);
myChartVertices->bindAttribute (aCtx, Graphic3d_TOA_POS, 3, GL_FLOAT, myChartVertices->GetComponentsNb(), NULL); myChartVertices->bindAttribute (aCtx, Graphic3d_TOA_POS, 3, GL_FLOAT, myChartVertices->GetComponentsNb(), NULL);
myChartVertices->bindAttribute (aCtx, Graphic3d_TOA_COLOR, 4, GL_UNSIGNED_BYTE, myChartVertices->GetComponentsNb(), (void* )sizeof(Graphic3d_Vec3)); myChartVertices->bindAttribute (aCtx, Graphic3d_TOA_COLOR, 4, GL_UNSIGNED_BYTE, myChartVertices->GetComponentsNb(), (void* )sizeof(Graphic3d_Vec3));
@ -429,7 +429,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
myChartVertices->Unbind (aCtx); myChartVertices->Unbind (aCtx);
myChartVertices->unbindAttribute (aCtx, Graphic3d_TOA_COLOR); myChartVertices->unbindAttribute (aCtx, Graphic3d_TOA_COLOR);
myChartVertices->unbindAttribute (aCtx, Graphic3d_TOA_POS); myChartVertices->unbindAttribute (aCtx, Graphic3d_TOA_POS);
glDisable (GL_BLEND); aCtx->core15fwd->glDisable (GL_BLEND);
myChartLines->Bind (aCtx); myChartLines->Bind (aCtx);
myChartLines->bindAttribute (aCtx, Graphic3d_TOA_POS, 3, GL_FLOAT, myChartLines->GetComponentsNb(), NULL); myChartLines->bindAttribute (aCtx, Graphic3d_TOA_POS, 3, GL_FLOAT, myChartLines->GetComponentsNb(), NULL);
@ -453,7 +453,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
if (theWorkspace->UseDepthWrite() != wasEnabledDepth) if (theWorkspace->UseDepthWrite() != wasEnabledDepth)
{ {
theWorkspace->UseDepthWrite() = wasEnabledDepth; theWorkspace->UseDepthWrite() = wasEnabledDepth;
glDepthMask (wasEnabledDepth ? GL_TRUE : GL_FALSE); aCtx->core11fwd->glDepthMask (wasEnabledDepth ? GL_TRUE : GL_FALSE);
} }
} }

View File

@ -18,6 +18,171 @@
#include <OpenGl_GlCore11Fwd.hxx> #include <OpenGl_GlCore11Fwd.hxx>
#ifndef GL_COMPILE
#define GL_COMPILE 0x1300
#define GL_COMPILE_AND_EXECUTE 0x1301
#define GL_RENDER_MODE 0x0C40
#define GL_RENDER 0x1C00
#define GL_FEEDBACK 0x1C01
#define GL_SELECT 0x1C02
#define GL_SHADE_MODEL 0x0B54
#define GL_FLAT 0x1D00
#define GL_SMOOTH 0x1D01
#define GL_POINT 0x1B00
#define GL_LINE 0x1B01
#define GL_FILL 0x1B02
#define GL_LINE_STIPPLE 0x0B24
#define GL_LINE_STIPPLE_PATTERN 0x0B25
#define GL_LINE_STIPPLE_REPEAT 0x0B26
#define GL_POLYGON_MODE 0x0B40
#define GL_POLYGON_SMOOTH 0x0B41
#define GL_POLYGON_STIPPLE 0x0B42
#define GL_MATRIX_MODE 0x0BA0
#define GL_NORMALIZE 0x0BA1
#define GL_TEXTURE_1D 0x0DE0
#define GL_MAX_CLIP_PLANES 0x0D32
#define GL_CLIP_PLANE0 0x3000
#define GL_CLIP_PLANE1 0x3001
#define GL_CLIP_PLANE2 0x3002
#define GL_CLIP_PLANE3 0x3003
#define GL_CLIP_PLANE4 0x3004
#define GL_CLIP_PLANE5 0x3005
#define GL_QUADS 0x0007
#define GL_QUAD_STRIP 0x0008
#define GL_POLYGON 0x0009
#define GL_LIGHTING 0x0B50
#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
#define GL_LIGHT_MODEL_AMBIENT 0x0B53
#define GL_COLOR_MATERIAL 0x0B57
#define GL_LIGHT0 0x4000
#define GL_LIGHT1 0x4001
#define GL_LIGHT2 0x4002
#define GL_LIGHT3 0x4003
#define GL_LIGHT4 0x4004
#define GL_LIGHT5 0x4005
#define GL_LIGHT6 0x4006
#define GL_LIGHT7 0x4007
// LightParameter
#define GL_AMBIENT 0x1200
#define GL_DIFFUSE 0x1201
#define GL_SPECULAR 0x1202
#define GL_POSITION 0x1203
#define GL_SPOT_DIRECTION 0x1204
#define GL_SPOT_EXPONENT 0x1205
#define GL_SPOT_CUTOFF 0x1206
#define GL_CONSTANT_ATTENUATION 0x1207
#define GL_LINEAR_ATTENUATION 0x1208
#define GL_QUADRATIC_ATTENUATION 0x1209
#define GL_EMISSION 0x1600
#define GL_SHININESS 0x1601
#define GL_AMBIENT_AND_DIFFUSE 0x1602
#define GL_COLOR_INDEXES 0x1603
// MatrixMode
#define GL_MODELVIEW 0x1700
#define GL_PROJECTION 0x1701
#define GL_TEXTURE 0x1702
#define GL_POINT_SMOOTH_HINT 0x0C51
#define GL_LINE_SMOOTH_HINT 0x0C52
#define GL_POLYGON_SMOOTH_HINT 0x0C53
#define GL_FOG_HINT 0x0C54
#define GL_FOG 0x0B60
#define GL_LOGIC_OP_MODE 0x0BF0
#define GL_INDEX_LOGIC_OP 0x0BF1
#define GL_LOGIC_OP GL_INDEX_LOGIC_OP
#define GL_COLOR_LOGIC_OP 0x0BF2
#define GL_CLEAR 0x1500
#define GL_AND 0x1501
#define GL_AND_REVERSE 0x1502
#define GL_COPY 0x1503
#define GL_AND_INVERTED 0x1504
#define GL_NOOP 0x1505
#define GL_XOR 0x1506
#define GL_OR 0x1507
#define GL_NOR 0x1508
#define GL_EQUIV 0x1509
#define GL_INVERT 0x150A
#define GL_OR_REVERSE 0x150B
#define GL_COPY_INVERTED 0x150C
#define GL_OR_INVERTED 0x150D
#define GL_NAND 0x150E
#define GL_SET 0x150F
#define GL_VERTEX_ARRAY 0x8074
#define GL_NORMAL_ARRAY 0x8075
#define GL_COLOR_ARRAY 0x8076
#define GL_INDEX_ARRAY 0x8077
#define GL_TEXTURE_COORD_ARRAY 0x8078
#define GL_PROXY_TEXTURE_1D 0x8063
#define GL_ALPHA_TEST 0x0BC0
#define GL_ALPHA_TEST_FUNC 0x0BC1
#define GL_ALPHA_TEST_REF 0x0BC2
// TextureCoordName
#define GL_S 0x2000
#define GL_T 0x2001
#define GL_R 0x2002
#define GL_Q 0x2003
// TextureEnvMode
#define GL_MODULATE 0x2100
#define GL_DECAL 0x2101
// TextureEnvParameter
#define GL_TEXTURE_ENV_MODE 0x2200
#define GL_TEXTURE_ENV_COLOR 0x2201
// TextureEnvTarget
#define GL_TEXTURE_ENV 0x2300
// TextureGenMode
#define GL_EYE_LINEAR 0x2400
#define GL_OBJECT_LINEAR 0x2401
#define GL_SPHERE_MAP 0x2402
// TextureGenParameter
#define GL_TEXTURE_GEN_MODE 0x2500
#define GL_OBJECT_PLANE 0x2501
#define GL_EYE_PLANE 0x2502
#define GL_TEXTURE_GEN_S 0x0C60
#define GL_TEXTURE_GEN_T 0x0C61
#define GL_TEXTURE_GEN_R 0x0C62
#define GL_TEXTURE_GEN_Q 0x0C63
#define GL_MAP_COLOR 0x0D10
#define GL_MAP_STENCIL 0x0D11
#define GL_RED_SCALE 0x0D14
#define GL_RED_BIAS 0x0D15
#define GL_GREEN_SCALE 0x0D18
#define GL_GREEN_BIAS 0x0D19
#define GL_BLUE_SCALE 0x0D1A
#define GL_BLUE_BIAS 0x0D1B
#define GL_ALPHA_SCALE 0x0D1C
#define GL_ALPHA_BIAS 0x0D1D
#define GL_DEPTH_SCALE 0x0D1E
#define GL_DEPTH_BIAS 0x0D1F
#define GL_STACK_OVERFLOW 0x0503
#define GL_STACK_UNDERFLOW 0x0504
#endif
//! OpenGL 1.1 core. //! OpenGL 1.1 core.
//! Notice that all functions within this structure are actually exported by system GL library. //! Notice that all functions within this structure are actually exported by system GL library.
//! The main purpose for these hint - to control visibility of functions per GL version //! The main purpose for these hint - to control visibility of functions per GL version
@ -25,272 +190,77 @@
struct OpenGl_GlCore11 : protected OpenGl_GlFunctions struct OpenGl_GlCore11 : protected OpenGl_GlFunctions
{ {
#if !defined(GL_ES_VERSION_2_0)
public: public:
inline void glTexEnvi (GLenum target, GLenum pname, GLint param) using OpenGl_GlFunctions::glTexEnvi;
{ using OpenGl_GlFunctions::glGetTexEnviv;
::glTexEnvi (target, pname, param);
OpenGl_TRACE(glTexEnvi)
}
inline void glGetTexEnviv (GLenum target, GLenum pname, GLint *params)
{
::glGetTexEnviv (target, pname, params);
OpenGl_TRACE(glGetTexEnviv)
}
inline void glLogicOp (GLenum opcode)
{
::glLogicOp (opcode);
OpenGl_TRACE(glLogicOp)
}
public: //! @name Begin/End primitive specification (removed since 3.1) public: //! @name Begin/End primitive specification (removed since 3.1)
inline void glColor4fv (const GLfloat* theVec) using OpenGl_GlFunctions::glColor4fv;
{
::glColor4fv (theVec);
OpenGl_TRACE(glColor4fv)
}
public: //! @name Matrix operations (removed since 3.1) public: //! @name Matrix operations (removed since 3.1)
inline void glMatrixMode (GLenum theMode) using OpenGl_GlFunctions::glMatrixMode;
{ using OpenGl_GlFunctions::glLoadIdentity;
::glMatrixMode (theMode); using OpenGl_GlFunctions::glLoadMatrixf;
OpenGl_TRACE(glMatrixMode)
}
inline void glLoadIdentity()
{
::glLoadIdentity();
OpenGl_TRACE(glLoadIdentity)
}
inline void glLoadMatrixf (const GLfloat* theMatrix)
{
::glLoadMatrixf (theMatrix);
OpenGl_TRACE(glLoadMatrixf)
}
public: //! @name Line and Polygon stipple (removed since 3.1) public: //! @name Line and Polygon stipple (removed since 3.1)
inline void glLineStipple (GLint theFactor, GLushort thePattern) using OpenGl_GlFunctions::glLineStipple;
{ using OpenGl_GlFunctions::glPolygonStipple;
::glLineStipple (theFactor, thePattern);
OpenGl_TRACE(glLineStipple)
}
inline void glPolygonStipple (const GLubyte* theMask)
{
::glPolygonStipple (theMask);
OpenGl_TRACE(glPolygonStipple)
}
public: //! @name Fixed pipeline lighting (removed since 3.1) public: //! @name Fixed pipeline lighting (removed since 3.1)
inline void glShadeModel (GLenum theMode) using OpenGl_GlFunctions::glShadeModel;
{ using OpenGl_GlFunctions::glLightf;
::glShadeModel (theMode); using OpenGl_GlFunctions::glLightfv;
OpenGl_TRACE(glShadeModel) using OpenGl_GlFunctions::glLightModeli;
} using OpenGl_GlFunctions::glLightModelfv;
using OpenGl_GlFunctions::glMaterialf;
inline void glLightf (GLenum theLight, GLenum pname, GLfloat param) using OpenGl_GlFunctions::glMaterialfv;
{ using OpenGl_GlFunctions::glColorMaterial;
::glLightf (theLight, pname, param);
OpenGl_TRACE(glLightf)
}
inline void glLightfv (GLenum theLight, GLenum pname, const GLfloat* params)
{
::glLightfv (theLight, pname, params);
OpenGl_TRACE(glLightfv)
}
inline void glLightModeli (GLenum pname, GLint param)
{
::glLightModeli(pname, param);
OpenGl_TRACE(glLightModeli)
}
inline void glLightModelfv (GLenum pname, const GLfloat* params)
{
::glLightModelfv(pname, params);
OpenGl_TRACE(glLightModelfv)
}
inline void glMaterialf (GLenum face, GLenum pname, GLfloat param)
{
::glMaterialf(face, pname, param);
OpenGl_TRACE(glMaterialf)
}
inline void glMaterialfv (GLenum face, GLenum pname, const GLfloat* params)
{
::glMaterialfv(face, pname, params);
OpenGl_TRACE(glMaterialfv)
}
inline void glColorMaterial (GLenum face, GLenum mode)
{
::glColorMaterial(face, mode);
OpenGl_TRACE(glColorMaterial)
}
public: //! @name clipping plane (removed since 3.1) public: //! @name clipping plane (removed since 3.1)
inline void glClipPlane (GLenum thePlane, const GLdouble* theEquation) using OpenGl_GlFunctions::glClipPlane;
{
::glClipPlane (thePlane, theEquation);
OpenGl_TRACE(glClipPlane)
}
public: //! @name Display lists (removed since 3.1) public: //! @name Display lists (removed since 3.1)
inline void glDeleteLists (GLuint theList, GLsizei theRange) using OpenGl_GlFunctions::glDeleteLists;
{ using OpenGl_GlFunctions::glGenLists;
::glDeleteLists (theList, theRange); using OpenGl_GlFunctions::glNewList;
OpenGl_TRACE(glDeleteLists) using OpenGl_GlFunctions::glEndList;
} using OpenGl_GlFunctions::glCallList;
using OpenGl_GlFunctions::glCallLists;
inline GLuint glGenLists (GLsizei theRange) using OpenGl_GlFunctions::glListBase;
{
const GLuint aRes = ::glGenLists (theRange);
OpenGl_TRACE(glGenLists)
return aRes;
}
inline void glNewList (GLuint theList, GLenum theMode)
{
::glNewList (theList, theMode);
OpenGl_TRACE(glNewList)
}
inline void glEndList()
{
::glEndList();
OpenGl_TRACE(glEndList)
}
inline void glCallList (GLuint theList)
{
::glCallList (theList);
OpenGl_TRACE(glCallList)
}
inline void glCallLists (GLsizei theNb, GLenum theType, const GLvoid* theLists)
{
::glCallLists (theNb, theType, theLists);
OpenGl_TRACE(glCallLists)
}
inline void glListBase (GLuint theBase)
{
::glListBase (theBase);
OpenGl_TRACE(glListBase)
}
public: //! @name Current raster position and Rectangles (removed since 3.1) public: //! @name Current raster position and Rectangles (removed since 3.1)
inline void glRasterPos2i (GLint x, GLint y) using OpenGl_GlFunctions::glRasterPos2i;
{ using OpenGl_GlFunctions::glRasterPos3fv;
::glRasterPos2i (x, y);
OpenGl_TRACE(glRasterPos2i)
}
inline void glRasterPos3fv (const GLfloat* theVec)
{
::glRasterPos3fv (theVec);
OpenGl_TRACE(glRasterPos3fv)
}
public: //! @name Texture mapping (removed since 3.1) public: //! @name Texture mapping (removed since 3.1)
inline void glTexGeni (GLenum coord, GLenum pname, GLint param) using OpenGl_GlFunctions::glTexGeni;
{ using OpenGl_GlFunctions::glTexGenfv;
::glTexGeni (coord, pname, param);
OpenGl_TRACE(glTexGeni)
}
inline void glTexGenfv (GLenum coord, GLenum pname, const GLfloat* params)
{
::glTexGenfv (coord, pname, params);
OpenGl_TRACE(glTexGenfv)
}
public: //! @name Pixel copying (removed since 3.1) public: //! @name Pixel copying (removed since 3.1)
inline void glDrawPixels (GLsizei width, GLsizei height, using OpenGl_GlFunctions::glDrawPixels;
GLenum format, GLenum type, using OpenGl_GlFunctions::glCopyPixels;
const GLvoid* pixels) using OpenGl_GlFunctions::glBitmap;
{
::glDrawPixels (width, height, format, type, pixels);
OpenGl_TRACE(glDrawPixels)
}
inline void glCopyPixels (GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum type)
{
::glCopyPixels (x, y, width, height, type);
OpenGl_TRACE(glCopyPixels)
}
inline void glBitmap (GLsizei width, GLsizei height,
GLfloat xorig, GLfloat yorig,
GLfloat xmove, GLfloat ymove,
const GLubyte* bitmap)
{
::glBitmap (width, height, xorig, yorig, xmove, ymove, bitmap);
OpenGl_TRACE(glBitmap)
}
public: //! @name Edge flags and fixed-function vertex processing (removed since 3.1) public: //! @name Edge flags and fixed-function vertex processing (removed since 3.1)
inline void glIndexPointer (GLenum theType, GLsizei theStride, const GLvoid* thePtr) using OpenGl_GlFunctions::glIndexPointer;
{ using OpenGl_GlFunctions::glVertexPointer;
::glIndexPointer (theType, theStride, thePtr); using OpenGl_GlFunctions::glNormalPointer;
OpenGl_TRACE(glIndexPointer) using OpenGl_GlFunctions::glColorPointer;
} using OpenGl_GlFunctions::glTexCoordPointer;
using OpenGl_GlFunctions::glEnableClientState;
inline void glVertexPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr) using OpenGl_GlFunctions::glDisableClientState;
{ using OpenGl_GlFunctions::glPixelTransferi;
::glVertexPointer (theSize, theType, theStride, thePtr);
OpenGl_TRACE(glVertexPointer)
}
inline void glNormalPointer (GLenum theType, GLsizei theStride, const GLvoid* thePtr)
{
::glNormalPointer (theType, theStride, thePtr);
OpenGl_TRACE(glNormalPointer)
}
inline void glColorPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr)
{
::glColorPointer (theSize, theType, theStride, thePtr);
OpenGl_TRACE(glColorPointer)
}
inline void glTexCoordPointer (GLint theSize, GLenum theType, GLsizei theStride, const GLvoid* thePtr)
{
::glTexCoordPointer (theSize, theType, theStride, thePtr);
OpenGl_TRACE(glTexCoordPointer)
}
inline void glEnableClientState (GLenum theCap)
{
::glEnableClientState (theCap);
OpenGl_TRACE(glEnableClientState)
}
inline void glDisableClientState (GLenum theCap)
{
::glDisableClientState (theCap);
OpenGl_TRACE(glDisableClientState)
}
#endif
}; };

View File

@ -27,542 +27,96 @@ struct OpenGl_GlCore11Fwd : protected OpenGl_GlFunctions
public: //! @name Miscellaneous public: //! @name Miscellaneous
inline void glClearColor (GLclampf theRed, GLclampf theGreen, GLclampf theBlue, GLclampf theAlpha) using OpenGl_GlFunctions::glClearColor;
{ using OpenGl_GlFunctions::glClear;
::glClearColor (theRed, theGreen, theBlue, theAlpha); using OpenGl_GlFunctions::glColorMask;
OpenGl_TRACE(glClearColor) using OpenGl_GlFunctions::glBlendFunc;
} using OpenGl_GlFunctions::glCullFace;
using OpenGl_GlFunctions::glFrontFace;
inline void glClear (GLbitfield theMask) using OpenGl_GlFunctions::glLineWidth;
{ using OpenGl_GlFunctions::glPolygonOffset;
::glClear (theMask); using OpenGl_GlFunctions::glScissor;
OpenGl_TRACE(glClear) using OpenGl_GlFunctions::glEnable;
} using OpenGl_GlFunctions::glDisable;
using OpenGl_GlFunctions::glIsEnabled;
inline void glColorMask (GLboolean theRed, GLboolean theGreen, GLboolean theBlue, GLboolean theAlpha) using OpenGl_GlFunctions::glGetBooleanv;
{ using OpenGl_GlFunctions::glGetFloatv;
::glColorMask (theRed, theGreen, theBlue, theAlpha); using OpenGl_GlFunctions::glGetIntegerv;
OpenGl_TRACE(glColorMask) using OpenGl_GlFunctions::glGetError;
} using OpenGl_GlFunctions::glGetString;
using OpenGl_GlFunctions::glFinish;
inline void glBlendFunc (GLenum sfactor, GLenum dfactor) using OpenGl_GlFunctions::glFlush;
{ using OpenGl_GlFunctions::glHint;
::glBlendFunc(sfactor, dfactor);
OpenGl_TRACE(glBlendFunc)
}
inline void glCullFace (GLenum theMode)
{
::glCullFace (theMode);
OpenGl_TRACE(glCullFace)
}
inline void glFrontFace (GLenum theMode)
{
::glFrontFace (theMode);
OpenGl_TRACE(glFrontFace)
}
inline void glLineWidth (GLfloat theWidth)
{
::glLineWidth (theWidth);
OpenGl_TRACE(glLineWidth)
}
inline void glPolygonOffset (GLfloat theFactor, GLfloat theUnits)
{
::glPolygonOffset (theFactor, theUnits);
OpenGl_TRACE(glPolygonOffset)
}
inline void glScissor (GLint theX, GLint theY, GLsizei theWidth, GLsizei theHeight)
{
::glScissor (theX, theY, theWidth, theHeight);
OpenGl_TRACE(glScissor)
}
inline void glEnable (GLenum theCap)
{
::glEnable (theCap);
OpenGl_TRACE(glEnable)
}
inline void glDisable (GLenum theCap)
{
::glDisable (theCap);
OpenGl_TRACE(glDisable)
}
inline GLboolean glIsEnabled (GLenum theCap)
{
return ::glIsEnabled (theCap);
}
inline void glGetBooleanv (GLenum theParamName, GLboolean* theValues)
{
::glGetBooleanv (theParamName, theValues);
OpenGl_TRACE(glGetBooleanv)
}
inline void glGetFloatv (GLenum theParamName, GLfloat* theValues)
{
::glGetFloatv (theParamName, theValues);
OpenGl_TRACE(glGetFloatv)
}
inline void glGetIntegerv (GLenum theParamName, GLint* theValues)
{
::glGetIntegerv (theParamName, theValues);
OpenGl_TRACE(glGetIntegerv)
}
inline GLenum glGetError()
{
return ::glGetError();
}
inline const GLubyte* glGetString (GLenum theName)
{
const GLubyte* aRes = ::glGetString (theName);
OpenGl_TRACE(glGetString)
return aRes;
}
inline void glFinish()
{
::glFinish();
OpenGl_TRACE(glFinish)
}
inline void glFlush()
{
::glFlush();
OpenGl_TRACE(glFlush)
}
inline void glHint (GLenum theTarget, GLenum theMode)
{
::glHint (theTarget, theMode);
OpenGl_TRACE(glHint)
}
public: //! @name Depth Buffer public: //! @name Depth Buffer
inline void glClearDepth (GLclampd theDepth) using OpenGl_GlFunctions::glClearDepth;
{ using OpenGl_GlFunctions::glClearDepthf;
#if defined(GL_ES_VERSION_2_0) using OpenGl_GlFunctions::glDepthFunc;
::glClearDepthf ((GLfloat )theDepth); using OpenGl_GlFunctions::glDepthMask;
#else using OpenGl_GlFunctions::glDepthRange;
::glClearDepth (theDepth); using OpenGl_GlFunctions::glDepthRangef;
#endif
OpenGl_TRACE(glClearDepth)
}
inline void glClearDepthf (GLfloat theDepth)
{
#if defined(GL_ES_VERSION_2_0)
::glClearDepthf (theDepth);
#else
::glClearDepth ((GLclampd )theDepth);
#endif
OpenGl_TRACE(glClearDepthf)
}
inline void glDepthFunc (GLenum theFunc)
{
::glDepthFunc (theFunc);
OpenGl_TRACE(glDepthFunc)
}
inline void glDepthMask (GLboolean theFlag)
{
::glDepthMask (theFlag);
OpenGl_TRACE(glDepthMask)
}
inline void glDepthRange (GLclampd theNearValue,
GLclampd theFarValue)
{
#if defined(GL_ES_VERSION_2_0)
::glDepthRangef ((GLfloat )theNearValue, (GLfloat )theFarValue);
#else
::glDepthRange (theNearValue, theFarValue);
#endif
OpenGl_TRACE(glDepthRange)
}
inline void glDepthRangef (GLfloat theNearValue,
GLfloat theFarValue)
{
#if defined(GL_ES_VERSION_2_0)
::glDepthRangef (theNearValue, theFarValue);
#else
::glDepthRange ((GLclampd )theNearValue, (GLclampd )theFarValue);
#endif
OpenGl_TRACE(glDepthRangef)
}
public: //! @name Transformation public: //! @name Transformation
inline void glViewport (GLint theX, GLint theY, GLsizei theWidth, GLsizei theHeight) using OpenGl_GlFunctions::glViewport;
{
::glViewport (theX, theY, theWidth, theHeight);
OpenGl_TRACE(glViewport)
}
public: //! @name Vertex Arrays public: //! @name Vertex Arrays
inline void glDrawArrays (GLenum theMode, GLint theFirst, GLsizei theCount) using OpenGl_GlFunctions::glDrawArrays;
{ using OpenGl_GlFunctions::glDrawElements;
::glDrawArrays (theMode, theFirst, theCount);
OpenGl_TRACE(glDrawArrays)
}
inline void glDrawElements (GLenum theMode, GLsizei theCount, GLenum theType, const GLvoid* theIndices)
{
::glDrawElements (theMode, theCount, theType, theIndices);
OpenGl_TRACE(glDrawElements)
}
public: //! @name Raster functions public: //! @name Raster functions
inline void glPixelStorei (GLenum theParamName, GLint theParam) using OpenGl_GlFunctions::glPixelStorei;
{ using OpenGl_GlFunctions::glReadPixels;
::glPixelStorei (theParamName, theParam);
OpenGl_TRACE(glPixelStorei)
}
inline void glReadPixels (GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
GLvoid* pixels)
{
::glReadPixels (x, y, width, height, format, type, pixels);
OpenGl_TRACE(glReadPixels)
}
public: //! @name Stenciling public: //! @name Stenciling
inline void glStencilFunc (GLenum func, GLint ref, GLuint mask) using OpenGl_GlFunctions::glStencilFunc;
{ using OpenGl_GlFunctions::glStencilMask;
::glStencilFunc (func, ref, mask); using OpenGl_GlFunctions::glStencilOp;
OpenGl_TRACE(glStencilFunc) using OpenGl_GlFunctions::glClearStencil;
}
inline void glStencilMask (GLuint mask)
{
::glStencilMask (mask);
OpenGl_TRACE(glStencilMask)
}
inline void glStencilOp (GLenum fail, GLenum zfail, GLenum zpass)
{
::glStencilOp (fail, zfail, zpass);
OpenGl_TRACE(glStencilOp)
}
inline void glClearStencil (GLint s)
{
::glClearStencil (s);
OpenGl_TRACE(glClearStencil)
}
public: //! @name Texture mapping public: //! @name Texture mapping
inline void glTexParameterf (GLenum target, GLenum pname, GLfloat param) using OpenGl_GlFunctions::glTexParameterf;
{ using OpenGl_GlFunctions::glTexParameteri;
::glTexParameterf (target, pname, param); using OpenGl_GlFunctions::glTexParameterfv;
OpenGl_TRACE(glTexParameterf) using OpenGl_GlFunctions::glTexParameteriv;
} using OpenGl_GlFunctions::glGetTexParameterfv;
using OpenGl_GlFunctions::glGetTexParameteriv;
using OpenGl_GlFunctions::glTexImage2D;
using OpenGl_GlFunctions::glGenTextures;
using OpenGl_GlFunctions::glDeleteTextures;
using OpenGl_GlFunctions::glBindTexture;
using OpenGl_GlFunctions::glIsTexture;
using OpenGl_GlFunctions::glTexSubImage2D;
using OpenGl_GlFunctions::glCopyTexImage2D;
using OpenGl_GlFunctions::glCopyTexSubImage2D;
inline void glTexParameteri (GLenum target, GLenum pname, GLint param) public: //! @name desktop extensions - not supported in OpenGL ES 2..0
{
::glTexParameteri (target, pname, param);
OpenGl_TRACE(glTexParameteri)
}
inline void glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params) using OpenGl_GlFunctions::glTexImage1D;
{ using OpenGl_GlFunctions::glTexSubImage1D;
::glTexParameterfv (target, pname, params); using OpenGl_GlFunctions::glCopyTexImage1D;
OpenGl_TRACE(glTexParameterfv) using OpenGl_GlFunctions::glCopyTexSubImage1D;
} using OpenGl_GlFunctions::glGetTexImage;
using OpenGl_GlFunctions::glAlphaFunc;
using OpenGl_GlFunctions::glPointSize;
inline void glTexParameteriv (GLenum target, GLenum pname, const GLint* params) // added to OpenGL ES 3.0
{ using OpenGl_GlFunctions::glReadBuffer;
::glTexParameteriv (target, pname, params); using OpenGl_GlFunctions::glDrawBuffer;
OpenGl_TRACE(glTexParameteriv)
}
inline void glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params) // added to OpenGL ES 3.1
{ using OpenGl_GlFunctions::glGetTexLevelParameteriv;
::glGetTexParameterfv (target, pname, params);
OpenGl_TRACE(glGetTexParameterfv)
}
inline void glGetTexParameteriv (GLenum target, GLenum pname, GLint* params) // added to OpenGL ES 3.2
{ using OpenGl_GlFunctions::glGetPointerv;
::glGetTexParameteriv (target, pname, params);
OpenGl_TRACE(glGetTexParameteriv)
}
inline void glTexImage2D (GLenum target, GLint level, using OpenGl_GlFunctions::glPolygonMode;
GLint internalFormat, using OpenGl_GlFunctions::glLogicOp;
GLsizei width, GLsizei height,
GLint border, GLenum format, GLenum type,
const GLvoid* pixels)
{
::glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels);
OpenGl_TRACE(glTexImage2D)
}
inline void glGenTextures (GLsizei n, GLuint* textures)
{
::glGenTextures(n, textures);
OpenGl_TRACE(glGenTextures)
}
inline void glDeleteTextures (GLsizei n, const GLuint* textures)
{
::glDeleteTextures(n, textures);
OpenGl_TRACE(glDeleteTextures)
}
inline void glBindTexture (GLenum target, GLuint texture)
{
::glBindTexture(target, texture);
OpenGl_TRACE(glBindTexture)
}
inline GLboolean glIsTexture (GLuint texture)
{
const GLboolean aRes = ::glIsTexture (texture);
OpenGl_TRACE(glIsTexture)
return aRes;
}
inline void glTexSubImage2D (GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
const GLvoid* pixels)
{
::glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
OpenGl_TRACE(glTexSubImage2D)
}
inline void glCopyTexImage2D (GLenum target, GLint level,
GLenum internalformat,
GLint x, GLint y,
GLsizei width, GLsizei height,
GLint border)
{
::glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
OpenGl_TRACE(glCopyTexImage2D)
}
inline void glCopyTexSubImage2D (GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLint x, GLint y,
GLsizei width, GLsizei height)
{
::glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
OpenGl_TRACE(glCopyTexSubImage2D)
}
#if !defined(GL_ES_VERSION_2_0)
inline void glTexImage1D (GLenum target, GLint level,
GLint internalFormat,
GLsizei width, GLint border,
GLenum format, GLenum type,
const GLvoid* pixels)
{
::glTexImage1D(target, level, internalFormat, width, border, format, type, pixels);
OpenGl_TRACE(glTexImage1D)
}
inline void glTexSubImage1D (GLenum target, GLint level,
GLint xoffset,
GLsizei width, GLenum format,
GLenum type, const GLvoid* pixels)
{
::glTexSubImage1D(target, level, xoffset, width, format, type, pixels);
OpenGl_TRACE(glTexSubImage1D)
}
inline void glCopyTexImage1D (GLenum target, GLint level,
GLenum internalformat,
GLint x, GLint y,
GLsizei width, GLint border)
{
::glCopyTexImage1D(target, level, internalformat, x, y, width, border);
OpenGl_TRACE(glCopyTexImage1D)
}
inline void glCopyTexSubImage1D (GLenum target, GLint level,
GLint xoffset, GLint x, GLint y,
GLsizei width)
{
::glCopyTexSubImage1D(target, level, xoffset, x, y, width);
OpenGl_TRACE(glCopyTexSubImage1D)
}
inline void glGetTexImage (GLenum target, GLint level,
GLenum format, GLenum type,
GLvoid* pixels)
{
::glGetTexImage (target, level, format, type, pixels);
OpenGl_TRACE(glGetTexImage)
}
#endif
#if !defined(GL_ES_VERSION_2_0)
inline void glAlphaFunc (GLenum theFunc, GLclampf theRef)
{
::glAlphaFunc (theFunc, theRef);
OpenGl_TRACE(glAlphaFunc)
}
inline void glPointSize (GLfloat theSize)
{
::glPointSize (theSize);
OpenGl_TRACE(glPointSize)
}
#endif
/*#if !defined(GL_ES_VERSION_2_0)
inline void glTexEnvf (GLenum target, GLenum pname, GLfloat param)
{
::glTexEnvf (target, pname, param);
}
inline void glTexEnvi (GLenum target, GLenum pname, GLint param)
{
::glTexEnvi (target, pname, param);
}
inline void glTexEnvfv (GLenum target, GLenum pname, const GLfloat* params)
{
::glTexEnvfv (target, pname, params);
}
inline void glTexEnviv (GLenum target, GLenum pname, const GLint* params)
{
::glTexEnviv (target, pname, params);
}
inline void glGetTexEnvfv (GLenum target, GLenum pname, GLfloat* params)
{
::glGetTexEnvfv (target, pname, params);
}
inline void glGetTexEnviv (GLenum target, GLenum pname, GLint* params)
{
::glGetTexEnviv (target, pname, params);
}
inline void glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat* params)
{
::glGetTexLevelParameterfv (target, level, pname, params);
}
inline void glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint* params)
{
::glGetTexLevelParameteriv (target, level, pname, params);
}
inline void glClearIndex (GLfloat c)
{
::glClearIndex(c);
}
inline void glIndexMask (GLuint theMask)
{
::glIndexMask (theMask);
}
inline void glLogicOp (GLenum opcode)
{
::glLogicOp(opcode);
}
inline void glPolygonMode (GLenum theFace, GLenum theMode)
{
::glPolygonMode (theFace, theMode);
}
inline void glDrawBuffer (GLenum theMode)
{
::glDrawBuffer (theMode);
}
inline void glReadBuffer (GLenum theMode)
{
::glReadBuffer (theMode);
}
inline void glGetDoublev (GLenum theParamName, GLdouble* theValues)
{
::glGetDoublev (theParamName, theValues);
}
inline GLint glRenderMode (GLenum theMode)
{
return ::glRenderMode (theMode);
}
inline void glArrayElement (GLint i)
{
::glArrayElement (i);
}
inline void glPixelStoref (GLenum theParamName, GLfloat theParam)
{
::glPixelStoref (theParamName, theParam);
}
inline void glPixelTransferf (GLenum theParamName, GLfloat theParam)
{
::glPixelTransferf (theParamName, theParam);
}
inline void glPixelTransferi (GLenum theParamName, GLint theParam)
{
::glPixelTransferi (theParamName, theParam);
}
inline void glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat* values)
{
::glPixelMapfv (map, mapsize, values);
}
inline void glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint* values)
{
::glPixelMapuiv (map, mapsize, values);
}
inline void glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort* values)
{
::glPixelMapusv (map, mapsize, values);
}
inline void glGetPixelMapfv (GLenum map, GLfloat* values)
{
::glGetPixelMapfv (map, values);
}
inline void glGetPixelMapuiv (GLenum map, GLuint* values)
{
::glGetPixelMapuiv (map, values);
}
inline void glGetPixelMapusv (GLenum map, GLushort* values)
{
::glGetPixelMapusv (map, values);
}
#endif*/
}; };

View File

@ -24,8 +24,6 @@ struct OpenGl_GlCore32 : public OpenGl_GlCore31
private: private:
typedef OpenGl_GlCore31 theBaseClass_t; typedef OpenGl_GlCore31 theBaseClass_t;
#if !defined(GL_ES_VERSION_2_0)
public: //! @name GL_ARB_draw_elements_base_vertex (added to OpenGL 3.2 core) public: //! @name GL_ARB_draw_elements_base_vertex (added to OpenGL 3.2 core)
using theBaseClass_t::glDrawElementsBaseVertex; using theBaseClass_t::glDrawElementsBaseVertex;
@ -60,8 +58,6 @@ public: //! @name OpenGL 3.2 additives to 3.1
using theBaseClass_t::glGetBufferParameteri64v; using theBaseClass_t::glGetBufferParameteri64v;
using theBaseClass_t::glFramebufferTexture; using theBaseClass_t::glFramebufferTexture;
#endif
}; };
#endif // _OpenGl_GlCore32_Header #endif // _OpenGl_GlCore32_Header

View File

@ -24,8 +24,6 @@ struct OpenGl_GlCore33 : public OpenGl_GlCore32
private: private:
typedef OpenGl_GlCore32 theBaseClass_t; typedef OpenGl_GlCore32 theBaseClass_t;
#if !defined(GL_ES_VERSION_2_0)
public: //! @name GL_ARB_blend_func_extended (added to OpenGL 3.3 core) public: //! @name GL_ARB_blend_func_extended (added to OpenGL 3.3 core)
using theBaseClass_t::glBindFragDataLocationIndexed; using theBaseClass_t::glBindFragDataLocationIndexed;
@ -69,8 +67,6 @@ public: //! @name OpenGL 3.3 additives to 3.2
using theBaseClass_t::glVertexAttribDivisor; using theBaseClass_t::glVertexAttribDivisor;
#endif
}; };
#endif // _OpenGl_GlCore33_Header #endif // _OpenGl_GlCore33_Header

View File

@ -24,8 +24,6 @@ struct OpenGl_GlCore40 : public OpenGl_GlCore33
private: private:
typedef OpenGl_GlCore33 theBaseClass_t; typedef OpenGl_GlCore33 theBaseClass_t;
#if !defined(GL_ES_VERSION_2_0)
public: //! @name GL_ARB_draw_indirect (added to OpenGL 4.0 core) public: //! @name GL_ARB_draw_indirect (added to OpenGL 4.0 core)
using theBaseClass_t::glDrawArraysIndirect; using theBaseClass_t::glDrawArraysIndirect;
@ -93,8 +91,6 @@ public: //! @name OpenGL 4.0 additives to 3.3
using theBaseClass_t::glBlendFunci; using theBaseClass_t::glBlendFunci;
using theBaseClass_t::glBlendFuncSeparatei; using theBaseClass_t::glBlendFuncSeparatei;
#endif
}; };
#endif // _OpenGl_GlCore40_Header #endif // _OpenGl_GlCore40_Header

View File

@ -24,8 +24,6 @@ struct OpenGl_GlCore41 : public OpenGl_GlCore40
private: private:
typedef OpenGl_GlCore40 theBaseClass_t; typedef OpenGl_GlCore40 theBaseClass_t;
#if !defined(GL_ES_VERSION_2_0)
public: //! @name GL_ARB_ES2_compatibility (added to OpenGL 4.1 core) public: //! @name GL_ARB_ES2_compatibility (added to OpenGL 4.1 core)
using theBaseClass_t::glReleaseShaderCompiler; using theBaseClass_t::glReleaseShaderCompiler;
@ -129,8 +127,6 @@ public: //! @name GL_ARB_viewport_array (added to OpenGL 4.1 core)
using theBaseClass_t::glGetFloati_v; using theBaseClass_t::glGetFloati_v;
using theBaseClass_t::glGetDoublei_v; using theBaseClass_t::glGetDoublei_v;
#endif
}; };
#endif // _OpenGl_GlCore41_Header #endif // _OpenGl_GlCore41_Header

View File

@ -24,8 +24,6 @@ struct OpenGl_GlCore42 : public OpenGl_GlCore41
private: private:
typedef OpenGl_GlCore41 theBaseClass_t; typedef OpenGl_GlCore41 theBaseClass_t;
#if !defined(GL_ES_VERSION_2_0)
public: //! @name GL_ARB_base_instance (added to OpenGL 4.2 core) public: //! @name GL_ARB_base_instance (added to OpenGL 4.2 core)
using theBaseClass_t::glDrawArraysInstancedBaseInstance; using theBaseClass_t::glDrawArraysInstancedBaseInstance;
@ -56,8 +54,6 @@ public: //! @name GL_ARB_texture_storage (added to OpenGL 4.2 core)
using theBaseClass_t::glTexStorage2D; using theBaseClass_t::glTexStorage2D;
using theBaseClass_t::glTexStorage3D; using theBaseClass_t::glTexStorage3D;
#endif
}; };
#endif // _OpenGl_GlCore42_Header #endif // _OpenGl_GlCore42_Header

View File

@ -26,8 +26,6 @@ private:
public: //! @name OpenGL 4.3 additives to 4.2 public: //! @name OpenGL 4.3 additives to 4.2
#if !defined(GL_ES_VERSION_2_0)
using theBaseClass_t::glClearBufferData; using theBaseClass_t::glClearBufferData;
using theBaseClass_t::glClearBufferSubData; using theBaseClass_t::glClearBufferSubData;
using theBaseClass_t::glDispatchCompute; using theBaseClass_t::glDispatchCompute;
@ -72,8 +70,6 @@ public: //! @name OpenGL 4.3 additives to 4.2
using theBaseClass_t::glObjectPtrLabel; using theBaseClass_t::glObjectPtrLabel;
using theBaseClass_t::glGetObjectPtrLabel; using theBaseClass_t::glGetObjectPtrLabel;
#endif
}; };
#endif // _OpenGl_GlCore43_Header #endif // _OpenGl_GlCore43_Header

View File

@ -26,8 +26,6 @@ private:
public: //! @name OpenGL 4.4 additives to 4.3 public: //! @name OpenGL 4.4 additives to 4.3
#if !defined(GL_ES_VERSION_2_0)
using theBaseClass_t::glBufferStorage; using theBaseClass_t::glBufferStorage;
using theBaseClass_t::glClearTexImage; using theBaseClass_t::glClearTexImage;
using theBaseClass_t::glClearTexSubImage; using theBaseClass_t::glClearTexSubImage;
@ -38,8 +36,6 @@ public: //! @name OpenGL 4.4 additives to 4.3
using theBaseClass_t::glBindImageTextures; using theBaseClass_t::glBindImageTextures;
using theBaseClass_t::glBindVertexBuffers; using theBaseClass_t::glBindVertexBuffers;
#endif
}; };
#endif // _OpenGl_GlCore44_Header #endif // _OpenGl_GlCore44_Header

View File

@ -24,7 +24,6 @@ private:
public: //! @name OpenGL 4.5 additives to 4.4 public: //! @name OpenGL 4.5 additives to 4.4
#if !defined(GL_ES_VERSION_2_0)
using theBaseClass_t::glClipControl; using theBaseClass_t::glClipControl;
using theBaseClass_t::glCreateTransformFeedbacks; using theBaseClass_t::glCreateTransformFeedbacks;
using theBaseClass_t::glTransformFeedbackBufferBase; using theBaseClass_t::glTransformFeedbackBufferBase;
@ -135,7 +134,6 @@ public: //! @name OpenGL 4.5 additives to 4.4
using theBaseClass_t::glGetnUniformuiv; using theBaseClass_t::glGetnUniformuiv;
using theBaseClass_t::glReadnPixels; using theBaseClass_t::glReadnPixels;
using theBaseClass_t::glTextureBarrier; using theBaseClass_t::glTextureBarrier;
#endif
}; };

View File

@ -24,12 +24,10 @@ private:
public: //! @name OpenGL 4.6 additives to 4.5 public: //! @name OpenGL 4.6 additives to 4.5
#if !defined(GL_ES_VERSION_2_0)
using theBaseClass_t::glSpecializeShader; using theBaseClass_t::glSpecializeShader;
using theBaseClass_t::glMultiDrawArraysIndirectCount; using theBaseClass_t::glMultiDrawArraysIndirectCount;
using theBaseClass_t::glMultiDrawElementsIndirectCount; using theBaseClass_t::glMultiDrawElementsIndirectCount;
using theBaseClass_t::glPolygonOffsetClamp; using theBaseClass_t::glPolygonOffsetClamp;
#endif
}; };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
// Copyright (c) 2021 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef OpenGl_GlNative_HeaderFile
#define OpenGl_GlNative_HeaderFile
// required for correct APIENTRY definition
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
#ifndef GLAPI
#define GLAPI extern
#endif
#ifndef GL_APICALL
#define GL_APICALL GLAPI
#endif
// exclude modern definitions and system-provided glext.h, should be defined before gl.h inclusion
#ifndef GL_GLEXT_LEGACY
#define GL_GLEXT_LEGACY
#endif
#ifndef GLX_GLXEXT_LEGACY
#define GLX_GLXEXT_LEGACY
#endif
// include main OpenGL header provided with system
#if defined(__APPLE__)
#import <TargetConditionals.h>
// macOS 10.4 deprecated OpenGL framework - suppress useless warnings
#define GL_SILENCE_DEPRECATION
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#include <OpenGLES/ES3/gl.h>
#else
#include <OpenGL/gl.h>
#endif
#define __X_GL_H // prevent chaotic gl.h inclusions to avoid compile errors
#elif defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
#if defined(_WIN32)
// Angle OpenGL ES headers do not define function prototypes even for core functions,
// however OCCT is expected to be linked against libGLESv2
#define GL_GLEXT_PROTOTYPES
#endif
#include <GLES3/gl3.h>
#else
#include <GL/gl.h>
#endif
#endif // OpenGl_GlNative_HeaderFile

View File

@ -0,0 +1,345 @@
// Copyright (c) 2021 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef OpenGl_GlTypes_HeaderFile
#define OpenGl_GlTypes_HeaderFile
#include <OpenGl_khrplatform.h>
typedef khronos_int8_t GLbyte;
typedef khronos_float_t GLclampf;
typedef khronos_int32_t GLfixed;
typedef short GLshort;
typedef unsigned short GLushort;
typedef void GLvoid;
typedef struct __GLsync *GLsync;
typedef khronos_int64_t GLint64;
typedef khronos_uint64_t GLuint64;
typedef unsigned int GLenum;
typedef unsigned int GLuint;
typedef char GLchar;
typedef khronos_float_t GLfloat;
typedef khronos_ssize_t GLsizeiptr;
typedef khronos_intptr_t GLintptr;
typedef unsigned int GLbitfield;
typedef int GLint;
typedef unsigned char GLboolean;
typedef int GLsizei;
typedef khronos_uint8_t GLubyte;
typedef double GLdouble;
typedef double GLclampd;
#define GL_NONE 0
#define GL_DEPTH_BUFFER_BIT 0x00000100
#define GL_STENCIL_BUFFER_BIT 0x00000400
#define GL_COLOR_BUFFER_BIT 0x00004000
#define GL_FALSE 0
#define GL_TRUE 1
#define GL_POINTS 0x0000
#define GL_LINES 0x0001
#define GL_LINE_LOOP 0x0002
#define GL_LINE_STRIP 0x0003
#define GL_TRIANGLES 0x0004
#define GL_TRIANGLE_STRIP 0x0005
#define GL_TRIANGLE_FAN 0x0006
#define GL_ZERO 0
#define GL_ONE 1
#define GL_SRC_COLOR 0x0300
#define GL_ONE_MINUS_SRC_COLOR 0x0301
#define GL_SRC_ALPHA 0x0302
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
#define GL_DST_ALPHA 0x0304
#define GL_ONE_MINUS_DST_ALPHA 0x0305
#define GL_DST_COLOR 0x0306
#define GL_ONE_MINUS_DST_COLOR 0x0307
#define GL_SRC_ALPHA_SATURATE 0x0308
#define GL_FUNC_ADD 0x8006
#define GL_BLEND_EQUATION 0x8009
#define GL_BLEND_EQUATION_RGB 0x8009
#define GL_BLEND_EQUATION_ALPHA 0x883D
#define GL_FUNC_SUBTRACT 0x800A
#define GL_FUNC_REVERSE_SUBTRACT 0x800B
#define GL_BLEND_DST_RGB 0x80C8
#define GL_BLEND_SRC_RGB 0x80C9
#define GL_BLEND_DST_ALPHA 0x80CA
#define GL_BLEND_SRC_ALPHA 0x80CB
#define GL_CONSTANT_COLOR 0x8001
#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
#define GL_CONSTANT_ALPHA 0x8003
#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
#define GL_BLEND_COLOR 0x8005
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_STREAM_DRAW 0x88E0
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
#define GL_CURRENT_VERTEX_ATTRIB 0x8626
#define GL_FRONT_LEFT 0x0400
#define GL_FRONT_RIGHT 0x0401
#define GL_BACK_LEFT 0x0402
#define GL_BACK_RIGHT 0x0403
#define GL_FRONT 0x0404
#define GL_BACK 0x0405
#define GL_LEFT 0x0406
#define GL_RIGHT 0x0407
#define GL_FRONT_AND_BACK 0x0408
#define GL_TEXTURE_2D 0x0DE1
#define GL_CULL_FACE 0x0B44
#define GL_BLEND 0x0BE2
#define GL_DITHER 0x0BD0
#define GL_STENCIL_TEST 0x0B90
#define GL_DEPTH_TEST 0x0B71
#define GL_SCISSOR_TEST 0x0C11
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_POLYGON_OFFSET_UNITS 0x2A00
#define GL_POLYGON_OFFSET_POINT 0x2A01
#define GL_POLYGON_OFFSET_LINE 0x2A02
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
#define GL_SAMPLE_COVERAGE 0x80A0
#define GL_NO_ERROR 0
#define GL_INVALID_ENUM 0x0500
#define GL_INVALID_VALUE 0x0501
#define GL_INVALID_OPERATION 0x0502
#define GL_OUT_OF_MEMORY 0x0505
#define GL_CW 0x0900
#define GL_CCW 0x0901
#define GL_LINE_WIDTH 0x0B21
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
#define GL_CULL_FACE_MODE 0x0B45
#define GL_FRONT_FACE 0x0B46
#define GL_DEPTH_RANGE 0x0B70
#define GL_DEPTH_WRITEMASK 0x0B72
#define GL_DEPTH_CLEAR_VALUE 0x0B73
#define GL_DEPTH_FUNC 0x0B74
#define GL_STENCIL_CLEAR_VALUE 0x0B91
#define GL_STENCIL_FUNC 0x0B92
#define GL_STENCIL_FAIL 0x0B94
#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
#define GL_STENCIL_REF 0x0B97
#define GL_STENCIL_VALUE_MASK 0x0B93
#define GL_STENCIL_WRITEMASK 0x0B98
#define GL_STENCIL_BACK_FUNC 0x8800
#define GL_STENCIL_BACK_FAIL 0x8801
#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
#define GL_STENCIL_BACK_REF 0x8CA3
#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
#define GL_VIEWPORT 0x0BA2
#define GL_SCISSOR_BOX 0x0C10
#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_COLOR_WRITEMASK 0x0C23
#define GL_UNPACK_LSB_FIRST 0x0CF1 // only desktop
#define GL_UNPACK_ROW_LENGTH 0x0CF2
#define GL_UNPACK_SKIP_ROWS 0x0CF3
#define GL_UNPACK_SKIP_PIXELS 0x0CF4
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_PACK_LSB_FIRST 0x0D01 // only desktop
#define GL_PACK_ROW_LENGTH 0x0D02
#define GL_PACK_SKIP_ROWS 0x0D03
#define GL_PACK_SKIP_PIXELS 0x0D04
#define GL_PACK_ALIGNMENT 0x0D05
#define GL_MAX_TEXTURE_SIZE 0x0D33
#define GL_MAX_VIEWPORT_DIMS 0x0D3A
#define GL_SUBPIXEL_BITS 0x0D50
#define GL_RED_BITS 0x0D52
#define GL_GREEN_BITS 0x0D53
#define GL_BLUE_BITS 0x0D54
#define GL_ALPHA_BITS 0x0D55
#define GL_DEPTH_BITS 0x0D56
#define GL_STENCIL_BITS 0x0D57
#define GL_POLYGON_OFFSET_UNITS 0x2A00
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_SAMPLE_BUFFERS 0x80A8
#define GL_SAMPLES 0x80A9
#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
#define GL_DONT_CARE 0x1100
#define GL_FASTEST 0x1101
#define GL_NICEST 0x1102
#define GL_GENERATE_MIPMAP_HINT 0x8192
#define GL_BYTE 0x1400
#define GL_UNSIGNED_BYTE 0x1401
#define GL_SHORT 0x1402
#define GL_UNSIGNED_SHORT 0x1403
#define GL_INT 0x1404
#define GL_UNSIGNED_INT 0x1405
#define GL_FLOAT 0x1406
#define GL_FIXED 0x140C
#define GL_DEPTH_COMPONENT 0x1902
#define GL_ALPHA 0x1906
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
#define GL_NEVER 0x0200
#define GL_LESS 0x0201
#define GL_EQUAL 0x0202
#define GL_LEQUAL 0x0203
#define GL_GREATER 0x0204
#define GL_NOTEQUAL 0x0205
#define GL_GEQUAL 0x0206
#define GL_ALWAYS 0x0207
#define GL_KEEP 0x1E00
#define GL_REPLACE 0x1E01
#define GL_INCR 0x1E02
#define GL_DECR 0x1E03
#define GL_INVERT 0x150A
#define GL_INCR_WRAP 0x8507
#define GL_DECR_WRAP 0x8508
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
#define GL_NEAREST 0x2600
#define GL_LINEAR 0x2601
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
#define GL_LINEAR_MIPMAP_NEAREST 0x2701
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
#define GL_TEXTURE 0x1702
#define GL_TEXTURE_CUBE_MAP 0x8513
#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
#define GL_TEXTURE0 0x84C0
#define GL_TEXTURE1 0x84C1
#define GL_TEXTURE2 0x84C2
#define GL_TEXTURE3 0x84C3
#define GL_TEXTURE4 0x84C4
#define GL_TEXTURE5 0x84C5
#define GL_TEXTURE6 0x84C6
#define GL_TEXTURE7 0x84C7
#define GL_TEXTURE8 0x84C8
#define GL_TEXTURE9 0x84C9
#define GL_TEXTURE10 0x84CA
#define GL_TEXTURE11 0x84CB
#define GL_TEXTURE12 0x84CC
#define GL_TEXTURE13 0x84CD
#define GL_TEXTURE14 0x84CE
#define GL_TEXTURE15 0x84CF
#define GL_TEXTURE16 0x84D0
#define GL_TEXTURE17 0x84D1
#define GL_TEXTURE18 0x84D2
#define GL_TEXTURE19 0x84D3
#define GL_TEXTURE20 0x84D4
#define GL_TEXTURE21 0x84D5
#define GL_TEXTURE22 0x84D6
#define GL_TEXTURE23 0x84D7
#define GL_TEXTURE24 0x84D8
#define GL_TEXTURE25 0x84D9
#define GL_TEXTURE26 0x84DA
#define GL_TEXTURE27 0x84DB
#define GL_TEXTURE28 0x84DC
#define GL_TEXTURE29 0x84DD
#define GL_TEXTURE30 0x84DE
#define GL_TEXTURE31 0x84DF
#define GL_ACTIVE_TEXTURE 0x84E0
#define GL_CLAMP 0x2900
#define GL_REPEAT 0x2901
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_MIRRORED_REPEAT 0x8370
#define GL_FLOAT_VEC2 0x8B50
#define GL_FLOAT_VEC3 0x8B51
#define GL_FLOAT_VEC4 0x8B52
#define GL_INT_VEC2 0x8B53
#define GL_INT_VEC3 0x8B54
#define GL_INT_VEC4 0x8B55
#define GL_BOOL 0x8B56
#define GL_BOOL_VEC2 0x8B57
#define GL_BOOL_VEC3 0x8B58
#define GL_BOOL_VEC4 0x8B59
#define GL_FLOAT_MAT2 0x8B5A
#define GL_FLOAT_MAT3 0x8B5B
#define GL_FLOAT_MAT4 0x8B5C
#define GL_SAMPLER_2D 0x8B5E
#define GL_SAMPLER_CUBE 0x8B60
#define GL_COLOR 0x1800
#define GL_DEPTH 0x1801
#define GL_STENCIL 0x1802
#define GL_RED 0x1903
#define GL_RGB8 0x8051
#define GL_RGBA8 0x8058
// in core since OpenGL ES 3.0, extension GL_OES_rgb8_rgba8
#define GL_LUMINANCE8 0x8040
// GL_EXT_texture_format_BGRA8888
#define GL_BGRA_EXT 0x80E1 // same as GL_BGRA on desktop
#define GL_R16 0x822A
#define GL_RGB4 0x804F
#define GL_RGB5 0x8050
#define GL_RGB10 0x8052
#define GL_RGB12 0x8053
#define GL_RGB16 0x8054
#define GL_RGB10_A2 0x8059
#define GL_RGBA12 0x805A
#define GL_RGBA16 0x805B
#define GL_ALPHA8 0x803C
#define GL_ALPHA16 0x803E
#define GL_RG16 0x822C
#define GL_R16_SNORM 0x8F98
#define GL_RG16_SNORM 0x8F99
#define GL_RGB16_SNORM 0x8F9A
#define GL_RGBA16_SNORM 0x8F9B
#define GL_RED_SNORM 0x8F90
#define GL_RG_SNORM 0x8F91
#define GL_RGB_SNORM 0x8F92
#define GL_RGBA_SNORM 0x8F93
#define GL_DRAW_BUFFER 0x0C01
#define GL_READ_BUFFER 0x0C02
#define GL_DOUBLEBUFFER 0x0C32
#define GL_STEREO 0x0C33
#define GL_PROXY_TEXTURE_2D 0x8064
#define GL_TEXTURE_WIDTH 0x1000
#define GL_TEXTURE_HEIGHT 0x1001
#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
// OpenGL ES 3.0+ or OES_texture_half_float
#define GL_HALF_FLOAT_OES 0x8D61
#endif // OpenGl_GlTypes_HeaderFile

View File

@ -14,7 +14,7 @@
// commercial license or contractual agreement. // commercial license or contractual agreement.
#if defined(_WIN32) #if defined(_WIN32)
#include <windows.h> #include <windows.h> // for UWP
#endif #endif
#include <OpenGl_GraphicDriver.hxx> #include <OpenGl_GraphicDriver.hxx>
@ -59,6 +59,10 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraphicDriver,Graphic3d_GraphicDriver)
#endif #endif
#endif #endif
#if defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
#define OpenGl_USE_GLES2
#endif
namespace namespace
{ {
static const Handle(OpenGl_Context) TheNullGlCtx; static const Handle(OpenGl_Context) TheNullGlCtx;
@ -75,7 +79,7 @@ namespace
EGL_ALPHA_SIZE, 0, EGL_ALPHA_SIZE, 0,
EGL_DEPTH_SIZE, 24, EGL_DEPTH_SIZE, 24,
EGL_STENCIL_SIZE, 8, EGL_STENCIL_SIZE, 8,
#if defined(GL_ES_VERSION_2_0) #if defined(OpenGl_USE_GLES2)
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
#else #else
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
@ -87,7 +91,7 @@ namespace
EGLint aNbConfigs = 0; EGLint aNbConfigs = 0;
for (Standard_Integer aGlesVer = 3; aGlesVer >= 2; --aGlesVer) for (Standard_Integer aGlesVer = 3; aGlesVer >= 2; --aGlesVer)
{ {
#if defined(GL_ES_VERSION_2_0) #if defined(OpenGl_USE_GLES2)
aConfigAttribs[6 * 2 + 1] = aGlesVer == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT; aConfigAttribs[6 * 2 + 1] = aGlesVer == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT;
#else #else
if (aGlesVer == 2) if (aGlesVer == 2)
@ -317,7 +321,7 @@ Standard_Boolean OpenGl_GraphicDriver::InitContext()
return Standard_False; return Standard_False;
} }
#if defined(GL_ES_VERSION_2_0) #if defined(OpenGl_USE_GLES2)
EGLint anEglCtxAttribs3[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE, EGL_NONE }; EGLint anEglCtxAttribs3[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE, EGL_NONE };
EGLint anEglCtxAttribs2[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE }; EGLint anEglCtxAttribs2[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
if (eglBindAPI (EGL_OPENGL_ES_API) != EGL_TRUE) if (eglBindAPI (EGL_OPENGL_ES_API) != EGL_TRUE)

View File

@ -573,11 +573,11 @@ void OpenGl_LayerList::renderLayer (const Handle(OpenGl_Workspace)& theWorkspace
if (aLayerSettings.ToEnableDepthTest()) if (aLayerSettings.ToEnableDepthTest())
{ {
// assuming depth test is enabled by default // assuming depth test is enabled by default
glDepthFunc (theDefaultSettings.DepthFunc); aCtx->core11fwd->glDepthFunc (theDefaultSettings.DepthFunc);
} }
else else
{ {
glDepthFunc (GL_ALWAYS); aCtx->core11fwd->glDepthFunc (GL_ALWAYS);
} }
// save environment texture // save environment texture
@ -592,7 +592,7 @@ void OpenGl_LayerList::renderLayer (const Handle(OpenGl_Workspace)& theWorkspace
// handle depth write // handle depth write
theWorkspace->UseDepthWrite() = aLayerSettings.ToEnableDepthWrite() && theDefaultSettings.DepthMask == GL_TRUE; theWorkspace->UseDepthWrite() = aLayerSettings.ToEnableDepthWrite() && theDefaultSettings.DepthMask == GL_TRUE;
glDepthMask (theWorkspace->UseDepthWrite() ? GL_TRUE : GL_FALSE); aCtx->core11fwd->glDepthMask (theWorkspace->UseDepthWrite() ? GL_TRUE : GL_FALSE);
const Standard_Boolean hasLocalCS = !aLayerSettings.OriginTransformation().IsNull(); const Standard_Boolean hasLocalCS = !aLayerSettings.OriginTransformation().IsNull();
const Handle(OpenGl_ShaderManager)& aManager = aCtx->ShaderManager(); const Handle(OpenGl_ShaderManager)& aManager = aCtx->ShaderManager();
@ -863,8 +863,8 @@ void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace)& theWorkspace,
if (aClearDepthLayer > aClearDepthLayerPrev) if (aClearDepthLayer > aClearDepthLayerPrev)
{ {
aClearDepthLayerPrev = aClearDepthLayer; aClearDepthLayerPrev = aClearDepthLayer;
glDepthMask (GL_TRUE); aCtx->core11fwd->glDepthMask (GL_TRUE);
glClear (GL_DEPTH_BUFFER_BIT); aCtx->core11fwd->glClear (GL_DEPTH_BUFFER_BIT);
} }
} }

View File

@ -44,7 +44,6 @@ OpenGl_LineAttributes::~OpenGl_LineAttributes()
// ======================================================================= // =======================================================================
void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx) void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx)
{ {
#if !defined(GL_ES_VERSION_2_0)
if (theGlCtx != NULL if (theGlCtx != NULL
&& theGlCtx->IsValid()) && theGlCtx->IsValid())
{ {
@ -53,9 +52,6 @@ void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx)
theGlCtx->core11ffp->glDeleteLists ((GLuint)anIter.Value(), 1); theGlCtx->core11ffp->glDeleteLists ((GLuint)anIter.Value(), 1);
} }
} }
#else
(void )theGlCtx;
#endif
myStyles.Clear(); myStyles.Clear();
} }
@ -66,17 +62,11 @@ void OpenGl_LineAttributes::Release (OpenGl_Context* theGlCtx)
unsigned int OpenGl_LineAttributes::init (const OpenGl_Context* theGlCtx, unsigned int OpenGl_LineAttributes::init (const OpenGl_Context* theGlCtx,
const Handle(Graphic3d_HatchStyle)& theStyle) const Handle(Graphic3d_HatchStyle)& theStyle)
{ {
#if !defined(GL_ES_VERSION_2_0)
const unsigned int aListId = theGlCtx->core11ffp->glGenLists(1); const unsigned int aListId = theGlCtx->core11ffp->glGenLists(1);
theGlCtx->core11ffp->glNewList ((GLuint)aListId, GL_COMPILE); theGlCtx->core11ffp->glNewList ((GLuint)aListId, GL_COMPILE);
theGlCtx->core11ffp->glPolygonStipple ((const GLubyte*)theStyle->Pattern()); theGlCtx->core11ffp->glPolygonStipple ((const GLubyte*)theStyle->Pattern());
theGlCtx->core11ffp->glEndList(); theGlCtx->core11ffp->glEndList();
return aListId; return aListId;
#else
(void )theGlCtx;
(void )theStyle;
return 0;
#endif
} }
// ======================================================================= // =======================================================================
@ -100,8 +90,6 @@ bool OpenGl_LineAttributes::SetTypeOfHatch (const OpenGl_Context*
myStyles.Bind (theStyle, aGpuListId); myStyles.Bind (theStyle, aGpuListId);
} }
#if !defined(GL_ES_VERSION_2_0)
theGlCtx->core11ffp->glCallList ((GLuint)aGpuListId); theGlCtx->core11ffp->glCallList ((GLuint)aGpuListId);
#endif
return true; return true;
} }

View File

@ -468,12 +468,11 @@ bool OpenGl_PBREnvironment::processSpecIBLMap (const Handle(OpenGl_Context)& the
const bool canRenderMipmaps = theCtx->hasFboRenderMipmap; const bool canRenderMipmaps = theCtx->hasFboRenderMipmap;
const OpenGl_TextureFormat aTexFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, myIBLMaps[OpenGl_TypeOfIBLMap_Specular].SizedFormat()); const OpenGl_TextureFormat aTexFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, myIBLMaps[OpenGl_TypeOfIBLMap_Specular].SizedFormat());
#if !defined(GL_ES_VERSION_2_0)
const GLint anIntFormat = aTexFormat.InternalFormat();
#else
// ES 2.0 does not support sized formats and format conversions - them detected from data type // ES 2.0 does not support sized formats and format conversions - them detected from data type
const GLint anIntFormat = theCtx->IsGlGreaterEqual (3, 0) ? aTexFormat.InternalFormat() : aTexFormat.PixelFormat(); const GLint anIntFormat = (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES
#endif || theCtx->IsGlGreaterEqual (3, 0))
? aTexFormat.InternalFormat()
: aTexFormat.PixelFormat();
for (int aLevelIter = mySpecMapLevelsNumber - 1;; --aLevelIter) for (int aLevelIter = mySpecMapLevelsNumber - 1;; --aLevelIter)
{ {

View File

@ -59,9 +59,7 @@ void OpenGl_PointSprite::Release (OpenGl_Context* theGlCtx)
if (theGlCtx->IsValid()) if (theGlCtx->IsValid())
{ {
#if !defined(GL_ES_VERSION_2_0) theGlCtx->core11ffp->glDeleteLists (myBitmapList, 1);
glDeleteLists (myBitmapList, 1);
#endif
} }
myBitmapList = 0; myBitmapList = 0;
} }
@ -84,12 +82,10 @@ void OpenGl_PointSprite::SetDisplayList (const Handle(OpenGl_Context)& theCtx,
// function : DrawBitmap // function : DrawBitmap
// purpose : // purpose :
// ======================================================================= // =======================================================================
void OpenGl_PointSprite::DrawBitmap (const Handle(OpenGl_Context)& ) const void OpenGl_PointSprite::DrawBitmap (const Handle(OpenGl_Context)& theCtx) const
{ {
if (myBitmapList != 0) if (myBitmapList != 0)
{ {
#if !defined(GL_ES_VERSION_2_0) theCtx->core11ffp->glCallList (myBitmapList);
glCallList (myBitmapList);
#endif
} }
} }

View File

@ -416,19 +416,18 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp
const Graphic3d_Vec4* theFaceColors, const Graphic3d_Vec4* theFaceColors,
const Standard_Boolean theHasVertColor) const const Standard_Boolean theHasVertColor) const
{ {
const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext();
if (myVboAttribs.IsNull()) if (myVboAttribs.IsNull())
{ {
#if !defined(GL_ES_VERSION_2_0) if (myDrawMode == GL_POINTS
if (myDrawMode == GL_POINTS) && aGlContext->core11ffp != NULL)
{ {
// extreme compatibility mode - without sprites but with markers // extreme compatibility mode - without sprites but with markers
drawMarkers (theWorkspace); drawMarkers (theWorkspace);
} }
#endif
return; return;
} }
const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext();
const bool toHilight = theWorkspace->ToHighlight(); const bool toHilight = theWorkspace->ToHighlight();
const GLenum aDrawMode = !aGlContext->ActiveProgram().IsNull() const GLenum aDrawMode = !aGlContext->ActiveProgram().IsNull()
&& aGlContext->ActiveProgram()->HasTessellationStage() && aGlContext->ActiveProgram()->HasTessellationStage()
@ -452,14 +451,14 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp
{ {
const GLint aNbElemsInGroup = myBounds->Bounds[aGroupIter]; const GLint aNbElemsInGroup = myBounds->Bounds[aGroupIter];
if (theFaceColors != NULL) aGlContext->SetColor4fv (theFaceColors[aGroupIter]); if (theFaceColors != NULL) aGlContext->SetColor4fv (theFaceColors[aGroupIter]);
glDrawElements (aDrawMode, aNbElemsInGroup, myVboIndices->GetDataType(), anOffset); aGlContext->core11fwd->glDrawElements (aDrawMode, aNbElemsInGroup, myVboIndices->GetDataType(), anOffset);
anOffset += aStride * aNbElemsInGroup; anOffset += aStride * aNbElemsInGroup;
} }
} }
else else
{ {
// draw one (or sequential) primitive by the indices // draw one (or sequential) primitive by the indices
glDrawElements (aDrawMode, myVboIndices->GetElemsNb(), myVboIndices->GetDataType(), anOffset); aGlContext->core11fwd->glDrawElements (aDrawMode, myVboIndices->GetElemsNb(), myVboIndices->GetDataType(), anOffset);
} }
myVboIndices->Unbind (aGlContext); myVboIndices->Unbind (aGlContext);
} }
@ -470,7 +469,7 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp
{ {
const GLint aNbElemsInGroup = myBounds->Bounds[aGroupIter]; const GLint aNbElemsInGroup = myBounds->Bounds[aGroupIter];
if (theFaceColors != NULL) aGlContext->SetColor4fv (theFaceColors[aGroupIter]); if (theFaceColors != NULL) aGlContext->SetColor4fv (theFaceColors[aGroupIter]);
glDrawArrays (aDrawMode, aFirstElem, aNbElemsInGroup); aGlContext->core11fwd->glDrawArrays (aDrawMode, aFirstElem, aNbElemsInGroup);
aFirstElem += aNbElemsInGroup; aFirstElem += aNbElemsInGroup;
} }
} }
@ -482,7 +481,7 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp
} }
else else
{ {
glDrawArrays (aDrawMode, 0, myVboAttribs->GetElemsNb()); aGlContext->core11fwd->glDrawArrays (aDrawMode, 0, myVboAttribs->GetElemsNb());
} }
} }
@ -503,9 +502,7 @@ void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorksp
} }
const OpenGl_Aspects* anAspect = theWorkspace->Aspects(); const OpenGl_Aspects* anAspect = theWorkspace->Aspects();
#if !defined(GL_ES_VERSION_2_0)
const Standard_Integer aPolyModeOld = aGlContext->SetPolygonMode (GL_LINE); const Standard_Integer aPolyModeOld = aGlContext->SetPolygonMode (GL_LINE);
#endif
if (aGlContext->core20fwd != NULL) if (aGlContext->core20fwd != NULL)
{ {
@ -518,13 +515,11 @@ void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorksp
&& aGlContext->ActiveProgram()->HasTessellationStage() && aGlContext->ActiveProgram()->HasTessellationStage()
? GL_PATCHES ? GL_PATCHES
: myDrawMode; : myDrawMode;
#if !defined(GL_ES_VERSION_2_0)
if (aGlContext->ActiveProgram().IsNull() if (aGlContext->ActiveProgram().IsNull()
&& aGlContext->core11ffp != NULL) && aGlContext->core11ffp != NULL)
{ {
aGlContext->core11fwd->glDisable (GL_LIGHTING); aGlContext->core11fwd->glDisable (GL_LIGHTING);
} }
#endif
/// OCC22236 NOTE: draw edges for all situations: /// OCC22236 NOTE: draw edges for all situations:
/// 1) draw elements with GL_LINE style as edges from myPArray->bufferVBO[VBOEdges] indices array /// 1) draw elements with GL_LINE style as edges from myPArray->bufferVBO[VBOEdges] indices array
@ -580,9 +575,7 @@ void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorksp
myVboAttribs->UnbindAttribute (aGlContext, Graphic3d_TOA_POS); myVboAttribs->UnbindAttribute (aGlContext, Graphic3d_TOA_POS);
// restore line context // restore line context
#if !defined(GL_ES_VERSION_2_0)
aGlContext->SetPolygonMode (aPolyModeOld); aGlContext->SetPolygonMode (aPolyModeOld);
#endif
} }
// ======================================================================= // =======================================================================
@ -605,13 +598,12 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork
return; return;
} }
#if !defined(GL_ES_VERSION_2_0)
if (aCtx->core11ffp != NULL) if (aCtx->core11ffp != NULL)
{ {
aCtx->core11fwd->glEnable (GL_ALPHA_TEST); aCtx->core11fwd->glEnable (GL_ALPHA_TEST);
aCtx->core11fwd->glAlphaFunc (GL_GEQUAL, 0.1f); aCtx->core11fwd->glAlphaFunc (GL_GEQUAL, 0.1f);
} }
#endif
aCtx->core11fwd->glEnable (GL_BLEND); aCtx->core11fwd->glEnable (GL_BLEND);
aCtx->core11fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); aCtx->core11fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -625,7 +617,6 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork
aCtx->SetPointSize (1.0f); aCtx->SetPointSize (1.0f);
} }
#if !defined(GL_ES_VERSION_2_0)
// Textured markers will be drawn with the glBitmap // Textured markers will be drawn with the glBitmap
else if (const Handle(OpenGl_PointSprite)& aSprite = anAspectMarker->SpriteRes (aCtx, theWorkspace->ToHighlight())) else if (const Handle(OpenGl_PointSprite)& aSprite = anAspectMarker->SpriteRes (aCtx, theWorkspace->ToHighlight()))
{ {
@ -635,10 +626,8 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork
aSprite->DrawBitmap (theWorkspace->GetGlContext()); aSprite->DrawBitmap (theWorkspace->GetGlContext());
} }
} }
#endif
aCtx->core11fwd->glDisable (GL_BLEND); aCtx->core11fwd->glDisable (GL_BLEND);
#if !defined(GL_ES_VERSION_2_0)
if (aCtx->core11ffp != NULL) if (aCtx->core11ffp != NULL)
{ {
if (aCtx->ShaderManager()->MaterialState().AlphaCutoff() >= ShortRealLast()) if (aCtx->ShaderManager()->MaterialState().AlphaCutoff() >= ShortRealLast())
@ -650,7 +639,6 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork
aCtx->core11fwd->glAlphaFunc (GL_GEQUAL, aCtx->ShaderManager()->MaterialState().AlphaCutoff()); aCtx->core11fwd->glAlphaFunc (GL_GEQUAL, aCtx->ShaderManager()->MaterialState().AlphaCutoff());
} }
} }
#endif
} }
// ======================================================================= // =======================================================================
@ -696,13 +684,12 @@ OpenGl_PrimitiveArray::OpenGl_PrimitiveArray (const OpenGl_GraphicDriver*
if (theDriver != NULL) if (theDriver != NULL)
{ {
myUID = theDriver->GetNextPrimitiveArrayUID(); myUID = theDriver->GetNextPrimitiveArrayUID();
#if defined (GL_ES_VERSION_2_0)
const Handle(OpenGl_Context)& aCtx = theDriver->GetSharedContext(); const Handle(OpenGl_Context)& aCtx = theDriver->GetSharedContext();
if (!aCtx.IsNull()) if (!aCtx.IsNull()
&& aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{ {
processIndices (aCtx); processIndices (aCtx);
} }
#endif
} }
setDrawMode (theType); setDrawMode (theType);
@ -838,7 +825,6 @@ void OpenGl_PrimitiveArray::UpdateDrawStats (Graphic3d_FrameStatsDataTmp& theSta
theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices - 4 * aNbBounds; theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices - 4 * aNbBounds;
break; break;
} }
#if !defined(GL_ES_VERSION_2_0)
case GL_QUADS: case GL_QUADS:
{ {
theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices / 2; theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += aNbIndices / 2;
@ -849,7 +835,6 @@ void OpenGl_PrimitiveArray::UpdateDrawStats (Graphic3d_FrameStatsDataTmp& theSta
theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += (aNbIndices / 2 - aNbBounds) * 2; theStats[Graphic3d_FrameStatsCounter_NbTrianglesNotCulled] += (aNbIndices / 2 - aNbBounds) * 2;
break; break;
} }
#endif
} }
} }
@ -876,10 +861,10 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
{ {
toDrawInteriorEdges = 1; toDrawInteriorEdges = 1;
toDrawArray = true; toDrawArray = true;
#if !defined(GL_ES_VERSION_2_0) if (aCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES
if (anAspectFace->Aspect()->EdgeLineType() != Aspect_TOL_SOLID && (anAspectFace->Aspect()->EdgeLineType() != Aspect_TOL_SOLID
|| aCtx->hasGeometryStage == OpenGl_FeatureNotAvailable || aCtx->hasGeometryStage == OpenGl_FeatureNotAvailable
|| aCtx->caps->usePolygonMode) || aCtx->caps->usePolygonMode))
{ {
toDrawInteriorEdges = 2; toDrawInteriorEdges = 2;
if (anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_EMPTY) if (anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_EMPTY)
@ -894,7 +879,6 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
} }
} }
} }
#endif
} }
} }
else else
@ -921,9 +905,10 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
// compatibility - keep data to draw markers using display lists // compatibility - keep data to draw markers using display lists
Standard_Boolean toKeepData = myDrawMode == GL_POINTS Standard_Boolean toKeepData = myDrawMode == GL_POINTS
&& anAspectFace->IsDisplayListSprite (aCtx); && anAspectFace->IsDisplayListSprite (aCtx);
#if defined (GL_ES_VERSION_2_0) if (aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
processIndices (aCtx); processIndices (aCtx);
#endif }
buildVBO (aCtx, toKeepData); buildVBO (aCtx, toKeepData);
myIsVboInit = Standard_True; myIsVboInit = Standard_True;
} }
@ -984,14 +969,10 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
{ {
aCtx->ShaderManager()->PushInteriorState (aCtx->ActiveProgram(), anAspectFace->Aspect()); aCtx->ShaderManager()->PushInteriorState (aCtx->ActiveProgram(), anAspectFace->Aspect());
} }
#if !defined (GL_ES_VERSION_2_0)
else if (toSetLinePolygMode) else if (toSetLinePolygMode)
{ {
aCtx->SetPolygonMode (GL_LINE); aCtx->SetPolygonMode (GL_LINE);
} }
#else
(void )toSetLinePolygMode;
#endif
break; break;
} }
} }
@ -1067,7 +1048,6 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
} }
} }
#if !defined(GL_ES_VERSION_2_0)
// draw triangulation edges using Polygon Mode // draw triangulation edges using Polygon Mode
if (toDrawInteriorEdges == 2) if (toDrawInteriorEdges == 2)
{ {
@ -1081,7 +1061,6 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
drawEdges (theWorkspace); drawEdges (theWorkspace);
} }
} }
#endif
} }
// ======================================================================= // =======================================================================
@ -1141,7 +1120,6 @@ void OpenGl_PrimitiveArray::setDrawMode (const Graphic3d_TypeOfPrimitiveArray th
myIsFillType = true; myIsFillType = true;
break; break;
// //
#if !defined(GL_ES_VERSION_2_0)
case Graphic3d_TOPA_QUADRANGLES: case Graphic3d_TOPA_QUADRANGLES:
myDrawMode = GL_QUADS; myDrawMode = GL_QUADS;
myIsFillType = true; myIsFillType = true;
@ -1154,11 +1132,6 @@ void OpenGl_PrimitiveArray::setDrawMode (const Graphic3d_TypeOfPrimitiveArray th
myDrawMode = GL_POLYGON; myDrawMode = GL_POLYGON;
myIsFillType = true; myIsFillType = true;
break; break;
#else
case Graphic3d_TOPA_QUADRANGLES:
case Graphic3d_TOPA_QUADRANGLESTRIPS:
case Graphic3d_TOPA_POLYGONS:
#endif
case Graphic3d_TOPA_UNDEFINED: case Graphic3d_TOPA_UNDEFINED:
myDrawMode = DRAW_MODE_NONE; myDrawMode = DRAW_MODE_NONE;
myIsFillType = false; myIsFillType = false;
@ -1218,9 +1191,11 @@ void OpenGl_PrimitiveArray::InitBuffers (const Handle(OpenGl_Context)& th
myIndices = theIndices; myIndices = theIndices;
myAttribs = theAttribs; myAttribs = theAttribs;
myBounds = theBounds; myBounds = theBounds;
#if defined(GL_ES_VERSION_2_0) if (!theContext.IsNull()
&& theContext->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
processIndices (theContext); processIndices (theContext);
#endif }
setDrawMode (theType); setDrawMode (theType);
} }

View File

@ -217,12 +217,11 @@ void OpenGl_Sampler::applySamplerParams (const Handle(OpenGl_Context)& theCtx,
// setup texture wrapping // setup texture wrapping
const GLenum aWrapMode = theParams->IsRepeat() ? GL_REPEAT : theCtx->TextureWrapClamp(); const GLenum aWrapMode = theParams->IsRepeat() ? GL_REPEAT : theCtx->TextureWrapClamp();
setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_WRAP_S, aWrapMode); setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_WRAP_S, aWrapMode);
#if !defined(GL_ES_VERSION_2_0)
if (theTarget == GL_TEXTURE_1D) if (theTarget == GL_TEXTURE_1D)
{ {
return; return;
} }
#endif
setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_WRAP_T, aWrapMode); setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_WRAP_T, aWrapMode);
if (theTarget == GL_TEXTURE_3D if (theTarget == GL_TEXTURE_3D
|| theTarget == GL_TEXTURE_CUBE_MAP) || theTarget == GL_TEXTURE_CUBE_MAP)
@ -284,11 +283,6 @@ void OpenGl_Sampler::applyGlobalTextureParams (const Handle(OpenGl_Context)& the
const OpenGl_Texture& theTexture, const OpenGl_Texture& theTexture,
const Handle(Graphic3d_TextureParams)& theParams) const Handle(Graphic3d_TextureParams)& theParams)
{ {
#if defined(GL_ES_VERSION_2_0)
(void )theCtx;
(void )theTexture;
(void )theParams;
#else
if (theCtx->core11ffp == NULL if (theCtx->core11ffp == NULL
|| theParams->TextureUnit() >= theCtx->MaxTextureUnitsFFP()) || theParams->TextureUnit() >= theCtx->MaxTextureUnitsFFP())
{ {
@ -386,7 +380,6 @@ void OpenGl_Sampler::applyGlobalTextureParams (const Handle(OpenGl_Context)& the
} }
default: break; default: break;
} }
#endif
} }
// ======================================================================= // =======================================================================
@ -397,11 +390,6 @@ void OpenGl_Sampler::resetGlobalTextureParams (const Handle(OpenGl_Context)& the
const OpenGl_Texture& theTexture, const OpenGl_Texture& theTexture,
const Handle(Graphic3d_TextureParams)& theParams) const Handle(Graphic3d_TextureParams)& theParams)
{ {
#if defined(GL_ES_VERSION_2_0)
(void )theCtx;
(void )theTexture;
(void )theParams;
#else
if (theCtx->core11ffp == NULL) if (theCtx->core11ffp == NULL)
{ {
return; return;
@ -442,5 +430,4 @@ void OpenGl_Sampler::resetGlobalTextureParams (const Handle(OpenGl_Context)& the
} }
default: break; default: break;
} }
#endif
} }

View File

@ -30,8 +30,6 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_ShaderManager, Graphic3d_ShaderManager)
namespace namespace
{ {
#if !defined(GL_ES_VERSION_2_0)
static const GLfloat THE_DEFAULT_AMBIENT[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; static const GLfloat THE_DEFAULT_AMBIENT[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
static const GLfloat THE_DEFAULT_SPOT_DIR[3] = { 0.0f, 0.0f, -1.0f }; static const GLfloat THE_DEFAULT_SPOT_DIR[3] = { 0.0f, 0.0f, -1.0f };
static const GLfloat THE_DEFAULT_SPOT_EXPONENT = 0.0f; static const GLfloat THE_DEFAULT_SPOT_EXPONENT = 0.0f;
@ -112,9 +110,8 @@ namespace
theCtx->core11ffp->glLoadMatrixf (theModelView.GetData()); theCtx->core11ffp->glLoadMatrixf (theModelView.GetData());
} }
glEnable (theLightGlId); theCtx->core11fwd->glEnable (theLightGlId);
} }
#endif
} }
// ======================================================================= // =======================================================================
@ -122,11 +119,7 @@ namespace
// purpose : Creates new empty shader manager // purpose : Creates new empty shader manager
// ======================================================================= // =======================================================================
OpenGl_ShaderManager::OpenGl_ShaderManager (OpenGl_Context* theContext) OpenGl_ShaderManager::OpenGl_ShaderManager (OpenGl_Context* theContext)
#if defined(GL_ES_VERSION_2_0) : Graphic3d_ShaderManager (theContext->GraphicsLibrary()),
: Graphic3d_ShaderManager (Aspect_GraphicsLibrary_OpenGLES),
#else
: Graphic3d_ShaderManager (Aspect_GraphicsLibrary_OpenGL),
#endif
myFfpProgram (new OpenGl_ShaderProgramFFP()), myFfpProgram (new OpenGl_ShaderProgramFFP()),
myShadingModel (Graphic3d_TypeOfShadingModel_Gouraud), myShadingModel (Graphic3d_TypeOfShadingModel_Gouraud),
myUnlitPrograms (new OpenGl_SetOfPrograms()), myUnlitPrograms (new OpenGl_SetOfPrograms()),
@ -366,7 +359,6 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr
theProgram->UpdateState (OpenGl_LIGHT_SOURCES_STATE, myLightSourceState.Index()); theProgram->UpdateState (OpenGl_LIGHT_SOURCES_STATE, myLightSourceState.Index());
if (theProgram == myFfpProgram) if (theProgram == myFfpProgram)
{ {
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11ffp == NULL) if (myContext->core11ffp == NULL)
{ {
return; return;
@ -409,7 +401,6 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr
{ {
myContext->core11fwd->glDisable (aLightGlId); myContext->core11fwd->glDisable (aLightGlId);
} }
#endif
return; return;
} }
@ -596,13 +587,11 @@ void OpenGl_ShaderManager::pushProjectionState (const Handle(OpenGl_ShaderProgra
theProgram->UpdateState (OpenGl_PROJECTION_STATE, myProjectionState.Index()); theProgram->UpdateState (OpenGl_PROJECTION_STATE, myProjectionState.Index());
if (theProgram == myFfpProgram) if (theProgram == myFfpProgram)
{ {
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11ffp != NULL) if (myContext->core11ffp != NULL)
{ {
myContext->core11ffp->glMatrixMode (GL_PROJECTION); myContext->core11ffp->glMatrixMode (GL_PROJECTION);
myContext->core11ffp->glLoadMatrixf (myProjectionState.ProjectionMatrix().GetData()); myContext->core11ffp->glLoadMatrixf (myProjectionState.ProjectionMatrix().GetData());
} }
#endif
return; return;
} }
@ -636,7 +625,6 @@ void OpenGl_ShaderManager::pushModelWorldState (const Handle(OpenGl_ShaderProgra
theProgram->UpdateState (OpenGl_MODEL_WORLD_STATE, myModelWorldState.Index()); theProgram->UpdateState (OpenGl_MODEL_WORLD_STATE, myModelWorldState.Index());
if (theProgram == myFfpProgram) if (theProgram == myFfpProgram)
{ {
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11ffp != NULL) if (myContext->core11ffp != NULL)
{ {
const OpenGl_Mat4 aModelView = myWorldViewState.WorldViewMatrix() * myModelWorldState.ModelWorldMatrix(); const OpenGl_Mat4 aModelView = myWorldViewState.WorldViewMatrix() * myModelWorldState.ModelWorldMatrix();
@ -644,7 +632,6 @@ void OpenGl_ShaderManager::pushModelWorldState (const Handle(OpenGl_ShaderProgra
myContext->core11ffp->glLoadMatrixf (aModelView.GetData()); myContext->core11ffp->glLoadMatrixf (aModelView.GetData());
theProgram->UpdateState (OpenGl_WORLD_VIEW_STATE, myWorldViewState.Index()); theProgram->UpdateState (OpenGl_WORLD_VIEW_STATE, myWorldViewState.Index());
} }
#endif
return; return;
} }
@ -683,7 +670,6 @@ void OpenGl_ShaderManager::pushWorldViewState (const Handle(OpenGl_ShaderProgram
theProgram->UpdateState (OpenGl_WORLD_VIEW_STATE, myWorldViewState.Index()); theProgram->UpdateState (OpenGl_WORLD_VIEW_STATE, myWorldViewState.Index());
if (theProgram == myFfpProgram) if (theProgram == myFfpProgram)
{ {
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11ffp != NULL) if (myContext->core11ffp != NULL)
{ {
const OpenGl_Mat4 aModelView = myWorldViewState.WorldViewMatrix() * myModelWorldState.ModelWorldMatrix(); const OpenGl_Mat4 aModelView = myWorldViewState.WorldViewMatrix() * myModelWorldState.ModelWorldMatrix();
@ -691,7 +677,6 @@ void OpenGl_ShaderManager::pushWorldViewState (const Handle(OpenGl_ShaderProgram
myContext->core11ffp->glLoadMatrixf (aModelView.GetData()); myContext->core11ffp->glLoadMatrixf (aModelView.GetData());
theProgram->UpdateState (OpenGl_MODEL_WORLD_STATE, myModelWorldState.Index()); theProgram->UpdateState (OpenGl_MODEL_WORLD_STATE, myModelWorldState.Index());
} }
#endif
return; return;
} }
@ -743,7 +728,6 @@ void OpenGl_ShaderManager::pushClippingState (const Handle(OpenGl_ShaderProgram)
theProgram->UpdateState (OpenGl_CLIP_PLANES_STATE, myClippingState.Index()); theProgram->UpdateState (OpenGl_CLIP_PLANES_STATE, myClippingState.Index());
if (theProgram == myFfpProgram) if (theProgram == myFfpProgram)
{ {
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11ffp == NULL) if (myContext->core11ffp == NULL)
{ {
return; return;
@ -814,7 +798,6 @@ void OpenGl_ShaderManager::pushClippingState (const Handle(OpenGl_ShaderProgram)
const OpenGl_Mat4 aModelView = myWorldViewState.WorldViewMatrix() * myModelWorldState.ModelWorldMatrix(); const OpenGl_Mat4 aModelView = myWorldViewState.WorldViewMatrix() * myModelWorldState.ModelWorldMatrix();
myContext->core11ffp->glLoadMatrixf (aModelView.GetData()); myContext->core11ffp->glLoadMatrixf (aModelView.GetData());
} }
#endif
return; return;
} }
@ -917,7 +900,6 @@ void OpenGl_ShaderManager::pushMaterialState (const Handle(OpenGl_ShaderProgram)
theProgram->UpdateState (OpenGl_MATERIAL_STATE, myMaterialState.Index()); theProgram->UpdateState (OpenGl_MATERIAL_STATE, myMaterialState.Index());
if (theProgram == myFfpProgram) if (theProgram == myFfpProgram)
{ {
#if !defined(GL_ES_VERSION_2_0)
if (myContext->core11ffp == NULL) if (myContext->core11ffp == NULL)
{ {
return; return;
@ -951,7 +933,6 @@ void OpenGl_ShaderManager::pushMaterialState (const Handle(OpenGl_ShaderProgram)
myContext->core11ffp->glMaterialfv(GL_BACK, GL_EMISSION, aBackMat.Emission.GetData()); myContext->core11ffp->glMaterialfv(GL_BACK, GL_EMISSION, aBackMat.Emission.GetData());
myContext->core11ffp->glMaterialf (GL_BACK, GL_SHININESS, aBackMat.Shine()); myContext->core11ffp->glMaterialf (GL_BACK, GL_SHININESS, aBackMat.Shine());
} }
#endif
return; return;
} }
@ -1050,7 +1031,6 @@ void OpenGl_ShaderManager::PushState (const Handle(OpenGl_ShaderProgram)& thePro
(float )myContext->Viewport()[2], (float )myContext->Viewport()[3])); (float )myContext->Viewport()[2], (float )myContext->Viewport()[3]));
} }
} }
#if !defined(GL_ES_VERSION_2_0)
else if (myContext->core11ffp != NULL) else if (myContext->core11ffp != NULL)
{ {
// manage FFP lighting // manage FFP lighting
@ -1064,9 +1044,6 @@ void OpenGl_ShaderManager::PushState (const Handle(OpenGl_ShaderProgram)& thePro
myContext->core11fwd->glEnable (GL_LIGHTING); myContext->core11fwd->glEnable (GL_LIGHTING);
} }
} }
#else
(void )theShadingModel;
#endif
} }
// ======================================================================= // =======================================================================

View File

@ -217,7 +217,8 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
} }
// detect the minimum GLSL version required for defined Shader Objects // detect the minimum GLSL version required for defined Shader Objects
#if defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
if (myHasTessShader) if (myHasTessShader)
{ {
if (!theCtx->IsGlGreaterEqual (3, 2)) if (!theCtx->IsGlGreaterEqual (3, 2))
@ -272,7 +273,9 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
aHeaderVer = "#version 310 es"; aHeaderVer = "#version 310 es";
} }
} }
#else }
else
{
if ((aShaderMask & Graphic3d_TOS_COMPUTE) != 0) if ((aShaderMask & Graphic3d_TOS_COMPUTE) != 0)
{ {
if (!theCtx->IsGlGreaterEqual (4, 3)) if (!theCtx->IsGlGreaterEqual (4, 3))
@ -312,7 +315,7 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
aHeaderVer = "#version 150"; aHeaderVer = "#version 150";
} }
} }
#endif }
for (Graphic3d_ShaderObjectList::Iterator anIter (theShaders); anIter.More(); anIter.Next()) for (Graphic3d_ShaderObjectList::Iterator anIter (theShaders); anIter.More(); anIter.Next())
{ {
@ -380,36 +383,34 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
if (theCtx->hasSampleVariables == OpenGl_FeatureInExtensions) if (theCtx->hasSampleVariables == OpenGl_FeatureInExtensions)
{ {
#if defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
if (theCtx->oesSampleVariables) && theCtx->oesSampleVariables)
{ {
anExtensions += "#extension GL_OES_sample_variables : enable\n"; anExtensions += "#extension GL_OES_sample_variables : enable\n";
} }
#else else if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGL
if (theCtx->arbSampleShading) && theCtx->arbSampleShading)
{ {
anExtensions += "#extension GL_ARB_sample_shading : enable\n"; anExtensions += "#extension GL_ARB_sample_shading : enable\n";
} }
#endif
} }
#if defined(GL_ES_VERSION_2_0)
if (theCtx->hasGeometryStage == OpenGl_FeatureInExtensions) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
&& theCtx->hasGeometryStage == OpenGl_FeatureInExtensions)
{ {
anExtensions += "#extension GL_EXT_geometry_shader : enable\n" anExtensions += "#extension GL_EXT_geometry_shader : enable\n"
"#extension GL_EXT_shader_io_blocks : enable\n"; "#extension GL_EXT_shader_io_blocks : enable\n";
} }
#endif
TCollection_AsciiString aPrecisionHeader; TCollection_AsciiString aPrecisionHeader;
if (anIter.Value()->Type() == Graphic3d_TOS_FRAGMENT) if (anIter.Value()->Type() == Graphic3d_TOS_FRAGMENT
&& theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{ {
#if defined(GL_ES_VERSION_2_0)
aPrecisionHeader = theCtx->hasHighp aPrecisionHeader = theCtx->hasHighp
? "precision highp float;\n" ? "precision highp float;\n"
"precision highp int;\n" "precision highp int;\n"
: "precision mediump float;\n" : "precision mediump float;\n"
"precision mediump int;\n"; "precision mediump int;\n";
#endif
} }
TCollection_AsciiString aHeaderType; TCollection_AsciiString aHeaderType;
@ -999,19 +1000,23 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
return false; return false;
} }
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
if (theCtx->core32 != NULL)
{ {
theCtx->core32->glUniform2uiv (theLocation, 1, theValue.GetData());
return true;
}
#else
if (theCtx->core30 != NULL) if (theCtx->core30 != NULL)
{ {
theCtx->core30->glUniform2uiv (theLocation, 1, theValue.GetData()); theCtx->core30->glUniform2uiv (theLocation, 1, theValue.GetData());
return true; return true;
} }
#endif }
else
{
if (theCtx->core32 != NULL)
{
theCtx->core32->glUniform2uiv (theLocation, 1, theValue.GetData());
return true;
}
}
return false; return false;
} }
@ -1041,19 +1046,22 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
return false; return false;
} }
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
if (theCtx->core32 != NULL)
{ {
theCtx->core32->glUniform2uiv (theLocation, theCount, theValue->GetData());
return true;
}
#else
if (theCtx->core30 != NULL) if (theCtx->core30 != NULL)
{ {
theCtx->core30->glUniform2uiv (theLocation, theCount, theValue->GetData()); theCtx->core30->glUniform2uiv (theLocation, theCount, theValue->GetData());
return true; return true;
} }
#endif }
else
{
if (theCtx->core32 != NULL)
{
theCtx->core32->glUniform2uiv (theLocation, theCount, theValue->GetData());
return true;
}
}
return false; return false;
} }

View File

@ -15,6 +15,8 @@
#include <OpenGl_GlCore11.hxx> #include <OpenGl_GlCore11.hxx>
#include <OpenGl_StencilTest.hxx> #include <OpenGl_StencilTest.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Workspace.hxx>
#include <Standard_Dump.hxx> #include <Standard_Dump.hxx>
OpenGl_StencilTest::OpenGl_StencilTest() OpenGl_StencilTest::OpenGl_StencilTest()
@ -26,16 +28,17 @@ OpenGl_StencilTest::OpenGl_StencilTest()
// function : Render // function : Render
// purpose : // purpose :
// ======================================================================= // =======================================================================
void OpenGl_StencilTest::Render (const Handle(OpenGl_Workspace)&) const void OpenGl_StencilTest::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{ {
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
if (myIsEnabled) if (myIsEnabled)
{ {
glEnable (GL_STENCIL_TEST); aCtx->core11fwd->glEnable (GL_STENCIL_TEST);
glStencilFunc (GL_NOTEQUAL, 1, 0xFF); aCtx->core11fwd->glStencilFunc (GL_NOTEQUAL, 1, 0xFF);
} }
else else
{ {
glDisable (GL_STENCIL_TEST); aCtx->core11fwd->glDisable (GL_STENCIL_TEST);
} }
} }

View File

@ -59,7 +59,6 @@ void OpenGl_Structure::renderBoundingBox (const Handle(OpenGl_Workspace)& theWor
aCtx->core20fwd->glDrawArrays (GL_LINES, 0, aBoundBoxVertBuffer->GetElemsNb()); aCtx->core20fwd->glDrawArrays (GL_LINES, 0, aBoundBoxVertBuffer->GetElemsNb());
aBoundBoxVertBuffer->UnbindAttribute(aCtx, Graphic3d_TOA_POS); aBoundBoxVertBuffer->UnbindAttribute(aCtx, Graphic3d_TOA_POS);
} }
#if !defined(GL_ES_VERSION_2_0)
else if (aCtx->core11ffp != NULL) else if (aCtx->core11ffp != NULL)
{ {
const Graphic3d_Vec3d aMind = myBndBox.CornerMin() + aMoveVec; const Graphic3d_Vec3d aMind = myBndBox.CornerMin() + aMoveVec;
@ -94,7 +93,6 @@ void OpenGl_Structure::renderBoundingBox (const Handle(OpenGl_Workspace)& theWor
aCtx->core11fwd->glDrawArrays (GL_LINE_STRIP, 0, 16); aCtx->core11fwd->glDrawArrays (GL_LINE_STRIP, 0, 16);
aCtx->core11ffp->glDisableClientState (GL_VERTEX_ARRAY); aCtx->core11ffp->glDisableClientState (GL_VERTEX_ARRAY);
} }
#endif
aCtx->BindTextures (aPrevTexture, Handle(OpenGl_ShaderProgram)()); aCtx->BindTextures (aPrevTexture, Handle(OpenGl_ShaderProgram)());
} }
@ -444,7 +442,7 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
aModelWorld = myRenderTrsf; aModelWorld = myRenderTrsf;
const Standard_Boolean anOldGlNormalize = aCtx->IsGlNormalizeEnabled(); const Standard_Boolean anOldGlNormalize = aCtx->IsGlNormalizeEnabled();
#if !defined(GL_ES_VERSION_2_0)
// detect scale transform // detect scale transform
if (aCtx->core11ffp != NULL if (aCtx->core11ffp != NULL
&& !myTrsf.IsNull()) && !myTrsf.IsNull())
@ -455,7 +453,6 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
aCtx->SetGlNormalizeEnabled (Standard_True); aCtx->SetGlNormalizeEnabled (Standard_True);
} }
} }
#endif
bool anOldCastShadows = false; bool anOldCastShadows = false;
#ifdef GL_DEPTH_CLAMP #ifdef GL_DEPTH_CLAMP
@ -703,7 +700,6 @@ void OpenGl_Structure::applyPersistence (const Handle(OpenGl_Context)& theCtx,
theCtx->VirtualViewport()[2], theCtx->VirtualViewport()[3]); theCtx->VirtualViewport()[2], theCtx->VirtualViewport()[3]);
} }
#if !defined(GL_ES_VERSION_2_0)
if (!theCtx->IsGlNormalizeEnabled() if (!theCtx->IsGlNormalizeEnabled()
&& theCtx->core11ffp != NULL) && theCtx->core11ffp != NULL)
{ {
@ -713,7 +709,6 @@ void OpenGl_Structure::applyPersistence (const Handle(OpenGl_Context)& theCtx,
theCtx->SetGlNormalizeEnabled (true); theCtx->SetGlNormalizeEnabled (true);
} }
} }
#endif
} }
// ======================================================================= // =======================================================================

View File

@ -375,10 +375,8 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
unsigned int theResolution, unsigned int theResolution,
Font_Hinting theFontHinting) const Font_Hinting theFontHinting) const
{ {
#if !defined(GL_ES_VERSION_2_0)
const Standard_Integer aPrevPolygonMode = theCtx->SetPolygonMode (GL_FILL); const Standard_Integer aPrevPolygonMode = theCtx->SetPolygonMode (GL_FILL);
const bool aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false); const bool aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false);
#endif
render (theCtx, theTextAspect, render (theCtx, theTextAspect,
theTextAspect.Aspect()->ColorRGBA(), theTextAspect.Aspect()->ColorRGBA(),
@ -386,10 +384,8 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
theResolution, theResolution,
theFontHinting); theFontHinting);
#if !defined(GL_ES_VERSION_2_0)
theCtx->SetPolygonMode (aPrevPolygonMode); theCtx->SetPolygonMode (aPrevPolygonMode);
theCtx->SetPolygonHatchEnabled (aPrevHatchingMode); theCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
#endif
} }
// ======================================================================= // =======================================================================
@ -645,13 +641,12 @@ void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx,
Graphic3d_AlphaMode_Opaque, Standard_False, Standard_False, Graphic3d_AlphaMode_Opaque, Standard_False, Standard_False,
Handle(OpenGl_ShaderProgram)()); Handle(OpenGl_ShaderProgram)());
#if !defined(GL_ES_VERSION_2_0)
if (theCtx->core11ffp != NULL if (theCtx->core11ffp != NULL
&& theCtx->ActiveProgram().IsNull()) && theCtx->ActiveProgram().IsNull())
{ {
theCtx->core11fwd->glBindTexture (GL_TEXTURE_2D, 0); theCtx->core11fwd->glBindTexture (GL_TEXTURE_2D, 0);
} }
#endif
theCtx->SetColor4fv (theColorSubs); theCtx->SetColor4fv (theColorSubs);
setupMatrix (theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f)); setupMatrix (theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f));
myBndVertsVbo->BindAttribute (theCtx, Graphic3d_TOA_POS); myBndVertsVbo->BindAttribute (theCtx, Graphic3d_TOA_POS);
@ -759,13 +754,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
} }
} }
#if !defined(GL_ES_VERSION_2_0)
if (theCtx->core11ffp != NULL if (theCtx->core11ffp != NULL
&& theCtx->caps->ffpEnable) && theCtx->caps->ffpEnable)
{ {
theCtx->core11fwd->glDisable (GL_LIGHTING); theCtx->core11fwd->glDisable (GL_LIGHTING);
} }
#endif
// setup depth test // setup depth test
const bool hasDepthTest = !myIs2d const bool hasDepthTest = !myIs2d
@ -779,14 +772,13 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
{ {
theCtx->core15fwd->glActiveTexture (GL_TEXTURE0); theCtx->core15fwd->glActiveTexture (GL_TEXTURE0);
} }
#if !defined(GL_ES_VERSION_2_0)
// activate texture unit // activate texture unit
if (theCtx->core11ffp != NULL && theCtx->ActiveProgram().IsNull()) if (theCtx->core11ffp != NULL && theCtx->ActiveProgram().IsNull())
{ {
const Handle(OpenGl_Texture)& aTexture = myFont->Texture(); const Handle(OpenGl_Texture)& aTexture = myFont->Texture();
OpenGl_Sampler::applyGlobalTextureParams (theCtx, *aTexture, aTexture->Sampler()->Parameters()); OpenGl_Sampler::applyGlobalTextureParams (theCtx, *aTexture, aTexture->Sampler()->Parameters());
} }
#endif
// setup blending // setup blending
if (theTextAspect.Aspect()->AlphaMode() == Graphic3d_AlphaMode_MaskBlend) if (theTextAspect.Aspect()->AlphaMode() == Graphic3d_AlphaMode_MaskBlend)
@ -803,10 +795,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
{ {
case Aspect_TODT_BLEND: case Aspect_TODT_BLEND:
{ {
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGL)
{
theCtx->core11fwd->glEnable (GL_COLOR_LOGIC_OP); theCtx->core11fwd->glEnable (GL_COLOR_LOGIC_OP);
theCtx->core11ffp->glLogicOp (GL_XOR); theCtx->core11fwd->glLogicOp (GL_XOR);
#endif }
break; break;
} }
case Aspect_TODT_SUBTITLE: case Aspect_TODT_SUBTITLE:
@ -855,13 +848,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
theCtx->ApplyProjectionMatrix(); theCtx->ApplyProjectionMatrix();
} }
#if !defined(GL_ES_VERSION_2_0)
if (theCtx->core11ffp != NULL && theCtx->ActiveProgram().IsNull()) if (theCtx->core11ffp != NULL && theCtx->ActiveProgram().IsNull())
{ {
const Handle(OpenGl_Texture)& aTexture = myFont->Texture(); const Handle(OpenGl_Texture)& aTexture = myFont->Texture();
OpenGl_Sampler::resetGlobalTextureParams (theCtx, *aTexture, aTexture->Sampler()->Parameters()); OpenGl_Sampler::resetGlobalTextureParams (theCtx, *aTexture, aTexture->Sampler()->Parameters());
} }
#endif
if (theTextAspect.Aspect()->TextDisplayType() == Aspect_TODT_DIMENSION) if (theTextAspect.Aspect()->TextDisplayType() == Aspect_TODT_DIMENSION)
{ {
@ -873,12 +864,11 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
{ {
theCtx->core11fwd->glDisable (GL_DEPTH_TEST); theCtx->core11fwd->glDisable (GL_DEPTH_TEST);
} }
#if !defined(GL_ES_VERSION_2_0)
if (theCtx->core11ffp != NULL) if (theCtx->core11ffp != NULL)
{ {
theCtx->core11fwd->glDisable (GL_TEXTURE_2D); theCtx->core11fwd->glDisable (GL_TEXTURE_2D);
} }
#endif
const bool aColorMaskBack = theCtx->SetColorMask (false); const bool aColorMaskBack = theCtx->SetColorMask (false);
theCtx->core11fwd->glClear (GL_STENCIL_BUFFER_BIT); theCtx->core11fwd->glClear (GL_STENCIL_BUFFER_BIT);
@ -899,9 +889,10 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
theCtx->core11fwd->glDisable (GL_BLEND); theCtx->core11fwd->glDisable (GL_BLEND);
} }
theCtx->core11fwd->glDisable (GL_STENCIL_TEST); theCtx->core11fwd->glDisable (GL_STENCIL_TEST);
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGL)
{
theCtx->core11fwd->glDisable (GL_COLOR_LOGIC_OP); theCtx->core11fwd->glDisable (GL_COLOR_LOGIC_OP);
#endif }
// model view matrix was modified // model view matrix was modified
theCtx->WorldViewState.Pop(); theCtx->WorldViewState.Pop();

View File

@ -244,13 +244,10 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
return false; return false;
} }
#if !defined(GL_ES_VERSION_2_0) const GLenum aTarget = (theType == Graphic3d_TOT_1D
const GLenum aTarget = theType == Graphic3d_TOT_1D && theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
? GL_TEXTURE_1D ? GL_TEXTURE_1D
: GL_TEXTURE_2D; : GL_TEXTURE_2D;
#else
const GLenum aTarget = GL_TEXTURE_2D;
#endif
const bool toPatchExisting = IsValid() const bool toPatchExisting = IsValid()
&& myTextFormat == theFormat.PixelFormat() && myTextFormat == theFormat.PixelFormat()
&& myTarget == aTarget && myTarget == aTarget
@ -280,12 +277,12 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
myTextFormat = theFormat.PixelFormat(); myTextFormat = theFormat.PixelFormat();
mySizedFormat = theFormat.InternalFormat(); mySizedFormat = theFormat.InternalFormat();
myNbSamples = 1; myNbSamples = 1;
#if !defined(GL_ES_VERSION_2_0)
const GLint anIntFormat = theFormat.InternalFormat();
#else
// ES 2.0 does not support sized formats and format conversions - them detected from data type // ES 2.0 does not support sized formats and format conversions - them detected from data type
const GLint anIntFormat = theCtx->IsGlGreaterEqual (3, 0) ? theFormat.InternalFormat() : theFormat.PixelFormat(); const GLint anIntFormat = (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES
#endif || theCtx->IsGlGreaterEqual (3, 0))
? theFormat.InternalFormat()
: theFormat.PixelFormat();
if (theFormat.DataType() == GL_FLOAT if (theFormat.DataType() == GL_FLOAT
&& !theCtx->arbTexFloat) && !theCtx->arbTexFloat)
@ -307,8 +304,9 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
Release (theCtx.get()); Release (theCtx.get());
return false; return false;
} }
#if !defined(GL_ES_VERSION_2_0) else if (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGL
else if (!theCtx->IsGlGreaterEqual (3, 0) && !theCtx->arbNPTW) && !theCtx->IsGlGreaterEqual (3, 0)
&& !theCtx->arbNPTW)
{ {
// Notice that formally general NPOT textures are required by OpenGL 2.0 specifications // Notice that formally general NPOT textures are required by OpenGL 2.0 specifications
// however some hardware (NV30 - GeForce FX, RadeOn 9xxx and Xxxx) supports GLSL but not NPOT! // however some hardware (NV30 - GeForce FX, RadeOn 9xxx and Xxxx) supports GLSL but not NPOT!
@ -326,8 +324,9 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
return false; return false;
} }
} }
#else else if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
else if (!theCtx->IsGlGreaterEqual (3, 0) && theType == Graphic3d_TOT_2D_MIPMAP) && !theCtx->IsGlGreaterEqual (3, 0)
&& theType == Graphic3d_TOT_2D_MIPMAP)
{ {
// Mipmap NPOT textures are not supported by OpenGL ES 2.0. // Mipmap NPOT textures are not supported by OpenGL ES 2.0.
const GLsizei aWidthP2 = OpenGl_Context::GetPowerOfTwo (theSizeXY.x(), aMaxSize); const GLsizei aWidthP2 = OpenGl_Context::GetPowerOfTwo (theSizeXY.x(), aMaxSize);
@ -341,11 +340,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
myMaxMipLevel = 0; myMaxMipLevel = 0;
} }
} }
#endif
#if !defined(GL_ES_VERSION_2_0)
GLint aTestWidth = 0, aTestHeight = 0; GLint aTestWidth = 0, aTestHeight = 0;
#endif
GLvoid* aDataPtr = (theImage != NULL) ? (GLvoid* )theImage->Data() : NULL; GLvoid* aDataPtr = (theImage != NULL) ? (GLvoid* )theImage->Data() : NULL;
// setup the alignment // setup the alignment
@ -376,7 +372,14 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
{ {
case Graphic3d_TOT_1D: case Graphic3d_TOT_1D:
{ {
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString ( "Error: 1D textures are not supported by hardware [") + myResourceId +"]");
Release (theCtx.get());
return false;
}
Bind (theCtx); Bind (theCtx);
applyDefaultSamplerParams (theCtx); applyDefaultSamplerParams (theCtx);
if (toPatchExisting) if (toPatchExisting)
@ -391,8 +394,8 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
theCtx->core11fwd->glTexImage1D (GL_PROXY_TEXTURE_1D, 0, anIntFormat, theCtx->core11fwd->glTexImage1D (GL_PROXY_TEXTURE_1D, 0, anIntFormat,
theSizeXY.x(), 0, theSizeXY.x(), 0,
theFormat.PixelFormat(), theFormat.DataType(), NULL); theFormat.PixelFormat(), theFormat.DataType(), NULL);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &aTestWidth); theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat); theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
if (aTestWidth == 0) if (aTestWidth == 0)
{ {
// no memory or broken input parameters // no memory or broken input parameters
@ -416,12 +419,6 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
Unbind (theCtx); Unbind (theCtx);
return true; return true;
#else
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString ( "Error: 1D textures are not supported by hardware [") + myResourceId +"]");
Release (theCtx.get());
return false;
#endif
} }
case Graphic3d_TOT_2D: case Graphic3d_TOT_2D:
case Graphic3d_TOT_2D_MIPMAP: case Graphic3d_TOT_2D_MIPMAP:
@ -449,14 +446,15 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
return true; return true;
} }
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGL)
{
// use proxy to check texture could be created or not // use proxy to check texture could be created or not
theCtx->core11fwd->glTexImage2D (GL_PROXY_TEXTURE_2D, 0, anIntFormat, theCtx->core11fwd->glTexImage2D (GL_PROXY_TEXTURE_2D, 0, anIntFormat,
theSizeXY.x(), theSizeXY.y(), 0, theSizeXY.x(), theSizeXY.y(), 0,
theFormat.PixelFormat(), theFormat.DataType(), NULL); theFormat.PixelFormat(), theFormat.DataType(), NULL);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestWidth); theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &aTestHeight); theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &aTestHeight);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat); theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
if (aTestWidth == 0 || aTestHeight == 0) if (aTestWidth == 0 || aTestHeight == 0)
{ {
// no memory or broken input parameters // no memory or broken input parameters
@ -464,7 +462,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
Release (theCtx.get()); Release (theCtx.get());
return false; return false;
} }
#endif }
theCtx->core11fwd->glTexImage2D (GL_TEXTURE_2D, 0, anIntFormat, theCtx->core11fwd->glTexImage2D (GL_TEXTURE_2D, 0, anIntFormat,
theSizeXY.x(), theSizeXY.y(), 0, theSizeXY.x(), theSizeXY.y(), 0,
@ -496,16 +494,15 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
if (anErr != GL_NO_ERROR) if (anErr != GL_NO_ERROR)
{ {
myMaxMipLevel = 0; myMaxMipLevel = 0;
#if defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
if (theFormat.InternalFormat() == GL_RGB8 && (theFormat.InternalFormat() == GL_RGB8
|| theFormat.InternalFormat() == GL_SRGB8) || theFormat.InternalFormat() == GL_SRGB8))
{ {
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH, theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString ("Warning: generating mipmaps requires color-renderable format, while giving ") TCollection_AsciiString ("Warning: generating mipmaps requires color-renderable format, while giving ")
+ OpenGl_TextureFormat::FormatFormat (anIntFormat) + " [" + myResourceId +"]"); + OpenGl_TextureFormat::FormatFormat (anIntFormat) + " [" + myResourceId +"]");
} }
else else
#endif
{ {
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH, theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString ("Warning: generating mipmaps has failed [") + myResourceId +"]"); TCollection_AsciiString ("Warning: generating mipmaps has failed [") + myResourceId +"]");
@ -737,17 +734,15 @@ bool OpenGl_Texture::Init2DMultisample (const Handle(OpenGl_Context)& theCtx,
//myTextFormat = theTextFormat; //myTextFormat = theTextFormat;
mySizedFormat = theTextFormat; mySizedFormat = theTextFormat;
if (theCtx->HasTextureMultisampling() if (theCtx->HasTextureMultisampling()
&& theCtx->Functions()->glTexStorage2DMultisample != NULL) && theCtx->Functions()->glTexStorage2DMultisample != NULL) // OpenGL 4.3
{ {
theCtx->Functions()->glTexStorage2DMultisample (myTarget, myNbSamples, theTextFormat, theSizeX, theSizeY, GL_FALSE); theCtx->Functions()->glTexStorage2DMultisample (myTarget, myNbSamples, theTextFormat, theSizeX, theSizeY, GL_FALSE);
} }
#if !defined(GL_ES_VERSION_2_0)
else if (theCtx->HasTextureMultisampling() else if (theCtx->HasTextureMultisampling()
&& theCtx->Functions()->glTexImage2DMultisample != NULL) && theCtx->Functions()->glTexImage2DMultisample != NULL) // OpenGL 3.2
{ {
theCtx->Functions()->glTexImage2DMultisample (myTarget, myNbSamples, theTextFormat, theSizeX, theSizeY, GL_FALSE); theCtx->Functions()->glTexImage2DMultisample (myTarget, myNbSamples, theTextFormat, theSizeX, theSizeY, GL_FALSE);
} }
#endif
else else
{ {
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
@ -783,12 +778,13 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx,
const Standard_Integer theSizeY, const Standard_Integer theSizeY,
const OpenGl_TextureFormat& theFormat) const OpenGl_TextureFormat& theFormat)
{ {
if (!Create (theCtx) || !theCtx->IsGlGreaterEqual (3, 0)) if (!theCtx->IsGlGreaterEqual (3, 0)
|| !Create (theCtx)
|| theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{ {
return false; return false;
} }
#if !defined(GL_ES_VERSION_2_0)
myTarget = GL_TEXTURE_RECTANGLE; myTarget = GL_TEXTURE_RECTANGLE;
myNbSamples = 1; myNbSamples = 1;
myMaxMipLevel = 0; myMaxMipLevel = 0;
@ -810,9 +806,9 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx,
myTextFormat, GL_FLOAT, NULL); myTextFormat, GL_FLOAT, NULL);
GLint aTestSizeX = 0, aTestSizeY = 0; GLint aTestSizeX = 0, aTestSizeY = 0;
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_WIDTH, &aTestSizeX); theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_WIDTH, &aTestSizeX);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_HEIGHT, &aTestSizeY); theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_HEIGHT, &aTestSizeY);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat); theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
if (aTestSizeX == 0 || aTestSizeY == 0) if (aTestSizeX == 0 || aTestSizeY == 0)
{ {
Unbind (theCtx); Unbind (theCtx);
@ -832,12 +828,6 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx,
mySizeY = aSizeY; mySizeY = aSizeY;
Unbind (theCtx); Unbind (theCtx);
return true; return true;
#else
(void )theSizeX;
(void )theSizeY;
(void )theFormat;
return false;
#endif
} }
// ======================================================================= // =======================================================================
@ -891,23 +881,24 @@ bool OpenGl_Texture::Init3D (const Handle(OpenGl_Context)& theCtx,
// setup the alignment // setup the alignment
OpenGl_UnpackAlignmentSentry::Reset (*theCtx); OpenGl_UnpackAlignmentSentry::Reset (*theCtx);
#if !defined (GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGL)
theCtx->core15fwd->glTexImage3D (GL_PROXY_TEXTURE_3D, 0, mySizedFormat, {
theCtx->Functions()->glTexImage3D (GL_PROXY_TEXTURE_3D, 0, mySizedFormat,
aSizeXYZ.x(), aSizeXYZ.y(), aSizeXYZ.z(), 0, aSizeXYZ.x(), aSizeXYZ.y(), aSizeXYZ.z(), 0,
theFormat.PixelFormat(), theFormat.DataType(), NULL); theFormat.PixelFormat(), theFormat.DataType(), NULL);
NCollection_Vec3<GLint> aTestSizeXYZ; NCollection_Vec3<GLint> aTestSizeXYZ;
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &aTestSizeXYZ.x()); theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &aTestSizeXYZ.x());
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_HEIGHT, &aTestSizeXYZ.y()); theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_HEIGHT, &aTestSizeXYZ.y());
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_DEPTH, &aTestSizeXYZ.z()); theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_DEPTH, &aTestSizeXYZ.z());
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat); theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);
if (aTestSizeXYZ.x() == 0 || aTestSizeXYZ.y() == 0 || aTestSizeXYZ.z() == 0) if (aTestSizeXYZ.x() == 0 || aTestSizeXYZ.y() == 0 || aTestSizeXYZ.z() == 0)
{ {
Unbind (theCtx); Unbind (theCtx);
Release (theCtx.get()); Release (theCtx.get());
return false; return false;
} }
#endif }
applyDefaultSamplerParams (theCtx); applyDefaultSamplerParams (theCtx);
theCtx->Functions()->glTexImage3D (myTarget, 0, mySizedFormat, theCtx->Functions()->glTexImage3D (myTarget, 0, mySizedFormat,
@ -1030,8 +1021,8 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx,
return false; return false;
} }
#if defined(GL_ES_VERSION_2_0)
if (theToGenMipmap if (theToGenMipmap
&& theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
&& !theCtx->IsGlGreaterEqual (3, 0) && !theCtx->IsGlGreaterEqual (3, 0)
&& (aFormat.PixelFormat() == GL_SRGB_EXT && (aFormat.PixelFormat() == GL_SRGB_EXT
|| aFormat.PixelFormat() == GL_SRGB_ALPHA_EXT)) || aFormat.PixelFormat() == GL_SRGB_ALPHA_EXT))
@ -1042,7 +1033,6 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx,
aFormat.SetPixelFormat (aFormat.PixelFormat() == GL_SRGB_EXT ? GL_RGB : GL_RGBA); aFormat.SetPixelFormat (aFormat.PixelFormat() == GL_SRGB_EXT ? GL_RGB : GL_RGBA);
aFormat.SetInternalFormat(aFormat.PixelFormat() == GL_SRGB_EXT ? GL_RGB8 : GL_RGBA8); aFormat.SetInternalFormat(aFormat.PixelFormat() == GL_SRGB_EXT ? GL_RGB8 : GL_RGBA8);
} }
#endif
myTarget = GL_TEXTURE_CUBE_MAP; myTarget = GL_TEXTURE_CUBE_MAP;
myNbSamples = 1; myNbSamples = 1;
@ -1050,12 +1040,12 @@ bool OpenGl_Texture::InitCubeMap (const Handle(OpenGl_Context)& theCtx,
mySizeY = (GLsizei )theSize; mySizeY = (GLsizei )theSize;
myTextFormat = aFormat.Format(); myTextFormat = aFormat.Format();
mySizedFormat = aFormat.Internal(); mySizedFormat = aFormat.Internal();
#if !defined(GL_ES_VERSION_2_0)
const GLint anIntFormat = aFormat.InternalFormat();
#else
// ES 2.0 does not support sized formats and format conversions - them detected from data type // ES 2.0 does not support sized formats and format conversions - them detected from data type
const GLint anIntFormat = theCtx->IsGlGreaterEqual (3, 0) ? aFormat.InternalFormat() : aFormat.PixelFormat(); const GLint anIntFormat = (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES
#endif || theCtx->IsGlGreaterEqual (3, 0))
? aFormat.InternalFormat()
: aFormat.PixelFormat();
Bind (theCtx); Bind (theCtx);
applyDefaultSamplerParams (theCtx); applyDefaultSamplerParams (theCtx);
@ -1290,10 +1280,10 @@ bool OpenGl_Texture::ImageDump (Image_PixMap& theImage,
Standard_Integer theLevel, Standard_Integer theLevel,
Standard_Integer theCubeSide) const Standard_Integer theCubeSide) const
{ {
#if !defined(GL_ES_VERSION_2_0)
const OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, mySizedFormat); const OpenGl_TextureFormat aFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, mySizedFormat);
if (theCtx.IsNull() if (theCtx.IsNull()
|| !IsValid() || !IsValid()
|| theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES // glGetTexImage() is unavailable in OpenGL ES
|| theLevel < 0 || theLevel < 0
|| !aFormat.IsValid() || !aFormat.IsValid()
|| aFormat.ImageFormat() == Image_Format_UNKNOWN || aFormat.ImageFormat() == Image_Format_UNKNOWN
@ -1341,13 +1331,4 @@ bool OpenGl_Texture::ImageDump (Image_PixMap& theImage,
const bool hasErrors = theCtx->ResetErrors (true); const bool hasErrors = theCtx->ResetErrors (true);
theCtx->core11fwd->glPixelStorei (GL_PACK_ALIGNMENT, 1); theCtx->core11fwd->glPixelStorei (GL_PACK_ALIGNMENT, 1);
return !hasErrors; return !hasErrors;
#else
// glGetTexImage() is unavailable in OpenGL ES
(void )theImage;
(void )theCtx;
(void )theTexUnit;
(void )theLevel;
(void )theCubeSide;
return false;
#endif
} }

View File

@ -125,11 +125,8 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
{ {
OpenGl_TextureFormat aFormat; OpenGl_TextureFormat aFormat;
aFormat.SetImageFormat (theFormat); aFormat.SetImageFormat (theFormat);
#if defined(GL_ES_VERSION_2_0) const bool useRedRedAlpha = theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES
const bool useRedRedAlpha = false; && theCtx->core11ffp == NULL;
#else
const bool useRedRedAlpha = (theCtx->core11ffp == NULL);
#endif
switch (theFormat) switch (theFormat)
{ {
case Image_Format_GrayF: case Image_Format_GrayF:
@ -142,11 +139,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
} }
else else
{ {
#if !defined(GL_ES_VERSION_2_0) aFormat.SetInternalFormat (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
aFormat.SetInternalFormat (GL_LUMINANCE8); ? GL_LUMINANCE
#else : GL_LUMINANCE8);
aFormat.SetInternalFormat (GL_LUMINANCE);
#endif
aFormat.SetPixelFormat (GL_LUMINANCE); aFormat.SetPixelFormat (GL_LUMINANCE);
} }
aFormat.SetDataType (GL_FLOAT); aFormat.SetDataType (GL_FLOAT);
@ -162,11 +157,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
} }
else else
{ {
#if !defined(GL_ES_VERSION_2_0) aFormat.SetInternalFormat (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
aFormat.SetInternalFormat (GL_ALPHA8); ? GL_ALPHA
#else : GL_ALPHA8);
aFormat.SetInternalFormat (GL_ALPHA);
#endif
aFormat.SetPixelFormat (GL_ALPHA); aFormat.SetPixelFormat (GL_ALPHA);
} }
aFormat.SetDataType (GL_FLOAT); aFormat.SetDataType (GL_FLOAT);
@ -214,15 +207,16 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
} }
case Image_Format_BGRF: case Image_Format_BGRF:
{ {
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
return OpenGl_TextureFormat();
}
aFormat.SetNbComponents (3); aFormat.SetNbComponents (3);
aFormat.SetInternalFormat (theCtx->arbTexFloat ? GL_RGB32F : GL_RGB8); aFormat.SetInternalFormat (theCtx->arbTexFloat ? GL_RGB32F : GL_RGB8);
aFormat.SetPixelFormat (GL_BGR); // equals to GL_BGR_EXT aFormat.SetPixelFormat (GL_BGR); // equals to GL_BGR_EXT
aFormat.SetDataType (GL_FLOAT); aFormat.SetDataType (GL_FLOAT);
return aFormat; return aFormat;
#else
return OpenGl_TextureFormat();
#endif
} }
case Image_Format_RGF_half: case Image_Format_RGF_half:
{ {
@ -230,11 +224,10 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
aFormat.SetInternalFormat (GL_RG16F); aFormat.SetInternalFormat (GL_RG16F);
aFormat.SetPixelFormat (GL_RG); aFormat.SetPixelFormat (GL_RG);
aFormat.SetDataType (GL_HALF_FLOAT); aFormat.SetDataType (GL_HALF_FLOAT);
if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions) if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions
&& theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{ {
#if defined(GL_ES_VERSION_2_0)
aFormat.SetDataType (GL_HALF_FLOAT_OES); aFormat.SetDataType (GL_HALF_FLOAT_OES);
#endif
} }
return aFormat; return aFormat;
} }
@ -244,11 +237,10 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
aFormat.SetInternalFormat (GL_RGBA16F); aFormat.SetInternalFormat (GL_RGBA16F);
aFormat.SetPixelFormat (GL_RGBA); aFormat.SetPixelFormat (GL_RGBA);
aFormat.SetDataType (GL_HALF_FLOAT); aFormat.SetDataType (GL_HALF_FLOAT);
if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions) if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions
&& theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{ {
#if defined(GL_ES_VERSION_2_0)
aFormat.SetDataType (GL_HALF_FLOAT_OES); aFormat.SetDataType (GL_HALF_FLOAT_OES);
#endif
} }
return aFormat; return aFormat;
} }
@ -261,19 +253,19 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
if (theIsColorMap if (theIsColorMap
&& theCtx->ToRenderSRGB()) && theCtx->ToRenderSRGB())
{ {
#if defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
if (!theCtx->IsGlGreaterEqual (3, 0)) && !theCtx->IsGlGreaterEqual (3, 0))
{ {
aFormat.SetPixelFormat (GL_SRGB_ALPHA_EXT); aFormat.SetPixelFormat (GL_SRGB_ALPHA_EXT);
} }
#endif
aFormat.SetInternalFormat (GL_SRGB8_ALPHA8); aFormat.SetInternalFormat (GL_SRGB8_ALPHA8);
} }
return aFormat; return aFormat;
} }
case Image_Format_BGRA: case Image_Format_BGRA:
{ {
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
{
if (!theCtx->IsGlGreaterEqual (1, 2) if (!theCtx->IsGlGreaterEqual (1, 2)
&& !theCtx->extBgra) && !theCtx->extBgra)
{ {
@ -286,7 +278,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
{ {
aFormat.SetInternalFormat (GL_SRGB8_ALPHA8); aFormat.SetInternalFormat (GL_SRGB8_ALPHA8);
} }
#else }
else
{
if (theIsColorMap if (theIsColorMap
&& theCtx->ToRenderSRGB()) && theCtx->ToRenderSRGB())
{ {
@ -298,14 +292,15 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
} }
aFormat.SetNbComponents (4); aFormat.SetNbComponents (4);
aFormat.SetInternalFormat (GL_BGRA_EXT); aFormat.SetInternalFormat (GL_BGRA_EXT);
#endif }
aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA
aFormat.SetDataType (GL_UNSIGNED_BYTE); aFormat.SetDataType (GL_UNSIGNED_BYTE);
return aFormat; return aFormat;
} }
case Image_Format_RGB32: case Image_Format_RGB32:
{ {
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
{
// ask driver to convert data to RGB8 to save memory // ask driver to convert data to RGB8 to save memory
aFormat.SetNbComponents (3); aFormat.SetNbComponents (3);
aFormat.SetInternalFormat (GL_RGB8); aFormat.SetInternalFormat (GL_RGB8);
@ -316,7 +311,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
{ {
aFormat.SetInternalFormat (GL_SRGB8); aFormat.SetInternalFormat (GL_SRGB8);
} }
#else }
else
{
// conversion is not supported // conversion is not supported
aFormat.SetNbComponents (4); aFormat.SetNbComponents (4);
aFormat.SetInternalFormat (GL_RGBA8); aFormat.SetInternalFormat (GL_RGBA8);
@ -331,12 +328,13 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
} }
aFormat.SetInternalFormat (GL_SRGB8_ALPHA8); aFormat.SetInternalFormat (GL_SRGB8_ALPHA8);
} }
#endif }
return aFormat; return aFormat;
} }
case Image_Format_BGR32: case Image_Format_BGR32:
{ {
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
{
if (!theCtx->IsGlGreaterEqual(1, 2) && !theCtx->extBgra) if (!theCtx->IsGlGreaterEqual(1, 2) && !theCtx->extBgra)
{ {
return OpenGl_TextureFormat(); return OpenGl_TextureFormat();
@ -348,7 +346,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
{ {
aFormat.SetInternalFormat (GL_SRGB8); aFormat.SetInternalFormat (GL_SRGB8);
} }
#else }
else
{
if (theIsColorMap if (theIsColorMap
&& theCtx->ToRenderSRGB()) && theCtx->ToRenderSRGB())
{ {
@ -360,7 +360,7 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
} }
aFormat.SetNbComponents (4); aFormat.SetNbComponents (4);
aFormat.SetInternalFormat (GL_BGRA_EXT); aFormat.SetInternalFormat (GL_BGRA_EXT);
#endif }
aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA aFormat.SetPixelFormat (GL_BGRA_EXT); // equals to GL_BGRA
aFormat.SetDataType (GL_UNSIGNED_BYTE); aFormat.SetDataType (GL_UNSIGNED_BYTE);
return aFormat; return aFormat;
@ -374,19 +374,22 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
if (theIsColorMap if (theIsColorMap
&& theCtx->ToRenderSRGB()) && theCtx->ToRenderSRGB())
{ {
#if defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
if (!theCtx->IsGlGreaterEqual (3, 0)) && !theCtx->IsGlGreaterEqual (3, 0))
{ {
aFormat.SetPixelFormat (GL_SRGB_EXT); aFormat.SetPixelFormat (GL_SRGB_EXT);
} }
#endif
aFormat.SetInternalFormat (GL_SRGB8); aFormat.SetInternalFormat (GL_SRGB8);
} }
return aFormat; return aFormat;
} }
case Image_Format_BGR: case Image_Format_BGR:
{ {
#if !defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
return OpenGl_TextureFormat();
}
if (!theCtx->IsGlGreaterEqual (1, 2) if (!theCtx->IsGlGreaterEqual (1, 2)
&& !theCtx->extBgra) && !theCtx->extBgra)
{ {
@ -401,7 +404,6 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
{ {
aFormat.SetInternalFormat (GL_SRGB8); aFormat.SetInternalFormat (GL_SRGB8);
} }
#endif
return aFormat; return aFormat;
} }
case Image_Format_Gray: case Image_Format_Gray:
@ -414,11 +416,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
} }
else else
{ {
#if !defined(GL_ES_VERSION_2_0) aFormat.SetInternalFormat (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
aFormat.SetInternalFormat (GL_LUMINANCE8); ? GL_LUMINANCE
#else : GL_LUMINANCE8);
aFormat.SetInternalFormat (GL_LUMINANCE);
#endif
aFormat.SetPixelFormat (GL_LUMINANCE); aFormat.SetPixelFormat (GL_LUMINANCE);
} }
aFormat.SetDataType (GL_UNSIGNED_BYTE); aFormat.SetDataType (GL_UNSIGNED_BYTE);
@ -434,11 +434,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindFormat (const Handle(OpenGl_Conte
} }
else else
{ {
#if !defined(GL_ES_VERSION_2_0) aFormat.SetInternalFormat (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
aFormat.SetInternalFormat (GL_ALPHA8); ? GL_ALPHA
#else : GL_ALPHA8);
aFormat.SetInternalFormat (GL_ALPHA);
#endif
aFormat.SetPixelFormat (GL_ALPHA); aFormat.SetPixelFormat (GL_ALPHA);
} }
aFormat.SetDataType (GL_UNSIGNED_BYTE); aFormat.SetDataType (GL_UNSIGNED_BYTE);
@ -498,11 +496,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_
aFormat.SetImageFormat (Image_Format_RGBAF_half); aFormat.SetImageFormat (Image_Format_RGBAF_half);
if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions) if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions)
{ {
#if defined(GL_ES_VERSION_2_0) aFormat.SetDataType (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
aFormat.SetDataType (GL_HALF_FLOAT_OES); ? GL_HALF_FLOAT_OES
#else : GL_FLOAT);
aFormat.SetDataType (GL_FLOAT);
#endif
} }
return aFormat; return aFormat;
} }
@ -515,11 +511,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_
aFormat.SetImageFormat (Image_Format_GrayF); aFormat.SetImageFormat (Image_Format_GrayF);
if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions) if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions)
{ {
#if defined(GL_ES_VERSION_2_0) aFormat.SetDataType (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
aFormat.SetDataType (GL_HALF_FLOAT_OES); ? GL_HALF_FLOAT_OES
#else : GL_FLOAT);
aFormat.SetDataType (GL_FLOAT);
#endif
} }
return aFormat; return aFormat;
} }
@ -532,11 +526,9 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_
aFormat.SetImageFormat (Image_Format_RGF_half); aFormat.SetImageFormat (Image_Format_RGF_half);
if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions) if (theCtx->hasHalfFloatBuffer == OpenGl_FeatureInExtensions)
{ {
#if defined(GL_ES_VERSION_2_0) aFormat.SetDataType (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
aFormat.SetDataType (GL_HALF_FLOAT_OES); ? GL_HALF_FLOAT_OES
#else : GL_FLOAT);
aFormat.SetDataType (GL_FLOAT);
#endif
} }
return aFormat; return aFormat;
} }
@ -554,12 +546,11 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_
{ {
if (theCtx->ToRenderSRGB()) if (theCtx->ToRenderSRGB())
{ {
#if defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
if (!theCtx->IsGlGreaterEqual (3, 0)) && !theCtx->IsGlGreaterEqual (3, 0))
{ {
aFormat.SetPixelFormat (GL_SRGB_ALPHA_EXT); aFormat.SetPixelFormat (GL_SRGB_ALPHA_EXT);
} }
#endif
} }
else else
{ {
@ -582,12 +573,11 @@ OpenGl_TextureFormat OpenGl_TextureFormat::FindSizedFormat (const Handle(OpenGl_
{ {
if (theCtx->ToRenderSRGB()) if (theCtx->ToRenderSRGB())
{ {
#if defined(GL_ES_VERSION_2_0) if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
if (!theCtx->IsGlGreaterEqual (3, 0)) && !theCtx->IsGlGreaterEqual (3, 0))
{ {
aFormat.SetPixelFormat (GL_SRGB_EXT); aFormat.SetPixelFormat (GL_SRGB_EXT);
} }
#endif
} }
else else
{ {

View File

@ -47,7 +47,7 @@ void OpenGl_TileSampler::GrabVarianceMap (const Handle(OpenGl_Context)& theConte
} }
myVarianceRaw.Init (0); myVarianceRaw.Init (0);
#if !defined(GL_ES_VERSION_2_0)
theTexture->Bind (theContext); theTexture->Bind (theContext);
theContext->core11fwd->glPixelStorei (GL_PACK_ALIGNMENT, 1); theContext->core11fwd->glPixelStorei (GL_PACK_ALIGNMENT, 1);
theContext->core11fwd->glPixelStorei (GL_PACK_ROW_LENGTH, 0); theContext->core11fwd->glPixelStorei (GL_PACK_ROW_LENGTH, 0);
@ -60,10 +60,6 @@ void OpenGl_TileSampler::GrabVarianceMap (const Handle(OpenGl_Context)& theConte
TCollection_AsciiString ("Error! Failed to fetch visual error map from the GPU ") + OpenGl_Context::FormatGlError (anErr)); TCollection_AsciiString ("Error! Failed to fetch visual error map from the GPU ") + OpenGl_Context::FormatGlError (anErr));
return; return;
} }
#else
// glGetTexImage() is unavailable on OpenGL ES, FBO + glReadPixels() can be used instead
(void )theContext;
#endif
const float aFactor = 1.0f / myScaleFactor; const float aFactor = 1.0f / myScaleFactor;
for (Standard_Size aColIter = 0; aColIter < myVarianceMap.SizeX; ++aColIter) for (Standard_Size aColIter = 0; aColIter < myVarianceMap.SizeX; ++aColIter)
@ -274,9 +270,10 @@ bool OpenGl_TileSampler::upload (const Handle(OpenGl_Context)& theContext,
{ {
theSamplesTexture->Bind (theContext); theSamplesTexture->Bind (theContext);
theContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1); theContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
#if !defined(GL_ES_VERSION_2_0) if (theContext->hasUnpackRowLength)
{
theContext->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); theContext->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
#endif }
if (theSamplesTexture->SizeX() == (int )myTileSamples.SizeX if (theSamplesTexture->SizeX() == (int )myTileSamples.SizeX
&& theSamplesTexture->SizeY() == (int )myTileSamples.SizeY) && theSamplesTexture->SizeY() == (int )myTileSamples.SizeY)
{ {
@ -314,9 +311,10 @@ bool OpenGl_TileSampler::upload (const Handle(OpenGl_Context)& theContext,
{ {
theOffsetsTexture->Bind (theContext); theOffsetsTexture->Bind (theContext);
theContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1); theContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
#if !defined(GL_ES_VERSION_2_0) if (theContext->hasUnpackRowLength)
{
theContext->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); theContext->core11fwd->glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
#endif }
theContext->core11fwd->glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, (int )anOffsets.SizeX, (int )anOffsets.SizeY, GL_RG_INTEGER, GL_INT, anOffsets.Data()); theContext->core11fwd->glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, (int )anOffsets.SizeX, (int )anOffsets.SizeY, GL_RG_INTEGER, GL_INT, anOffsets.Data());
if (theContext->core11fwd->glGetError() != GL_NO_ERROR) if (theContext->core11fwd->glGetError() != GL_NO_ERROR)
{ {

View File

@ -136,13 +136,11 @@ void OpenGl_VertexBuffer::bindAttribute (const Handle(OpenGl_Context)& theCtx,
{ {
if (theCtx->ActiveProgram().IsNull()) if (theCtx->ActiveProgram().IsNull())
{ {
#if !defined(GL_ES_VERSION_2_0)
if (theCtx->core11ffp != NULL) if (theCtx->core11ffp != NULL)
{ {
bindFixed (theCtx, theAttribute, theNbComp, theDataType, theStride, theOffset); bindFixed (theCtx, theAttribute, theNbComp, theDataType, theStride, theOffset);
} }
else else
#endif
{ {
// OpenGL handles vertex attribute setup independently from active GLSL program, // OpenGL handles vertex attribute setup independently from active GLSL program,
// but OCCT historically requires program to be bound beforehand (this check could be removed in future). // but OCCT historically requires program to be bound beforehand (this check could be removed in future).
@ -164,19 +162,16 @@ void OpenGl_VertexBuffer::unbindAttribute (const Handle(OpenGl_Context)& theCt
{ {
if (theCtx->ActiveProgram().IsNull()) if (theCtx->ActiveProgram().IsNull())
{ {
#if !defined(GL_ES_VERSION_2_0)
if (theCtx->core11ffp != NULL) if (theCtx->core11ffp != NULL)
{ {
unbindFixed (theCtx, theAttribute); unbindFixed (theCtx, theAttribute);
} }
#endif
return; return;
} }
theCtx->core20fwd->glDisableVertexAttribArray (theAttribute); theCtx->core20fwd->glDisableVertexAttribArray (theAttribute);
} }
#if !defined(GL_ES_VERSION_2_0)
// ======================================================================= // =======================================================================
// function : bindFixed // function : bindFixed
// purpose : // purpose :
@ -255,4 +250,3 @@ void OpenGl_VertexBuffer::unbindFixedColor (const Handle(OpenGl_Context)& theCtx
// invalidate FFP material state after GL_COLOR_MATERIAL has modified it (took values from the vertex color) // invalidate FFP material state after GL_COLOR_MATERIAL has modified it (took values from the vertex color)
theCtx->ShaderManager()->UpdateMaterialState(); theCtx->ShaderManager()->UpdateMaterialState();
} }
#endif

View File

@ -84,7 +84,7 @@ public: //! @name advanced methods
const Graphic3d_TypeOfAttribute theMode); const Graphic3d_TypeOfAttribute theMode);
private: private:
#if !defined(GL_ES_VERSION_2_0)
//! Setup FFP array pointer. //! Setup FFP array pointer.
Standard_EXPORT static void bindFixed (const Handle(OpenGl_Context)& theGlCtx, Standard_EXPORT static void bindFixed (const Handle(OpenGl_Context)& theGlCtx,
const Graphic3d_TypeOfAttribute theMode, const Graphic3d_TypeOfAttribute theMode,
@ -100,7 +100,6 @@ private:
//! Disable FFP color array pointer. //! Disable FFP color array pointer.
Standard_EXPORT static void unbindFixedColor (const Handle(OpenGl_Context)& theCtx); Standard_EXPORT static void unbindFixedColor (const Handle(OpenGl_Context)& theCtx);
#endif
public: //! @name methods for interleaved attributes array public: //! @name methods for interleaved attributes array
//! @return true if buffer contains per-vertex color attribute //! @return true if buffer contains per-vertex color attribute

View File

@ -464,6 +464,7 @@ void OpenGl_View::GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, c
// ======================================================================= // =======================================================================
Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3d_BufferType& theBufferType) Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3d_BufferType& theBufferType)
{ {
const Handle(OpenGl_Context)& aCtx = myWorkspace->GetGlContext();
if (theBufferType != Graphic3d_BT_RGB_RayTraceHdrLeft) if (theBufferType != Graphic3d_BT_RGB_RayTraceHdrLeft)
{ {
return myWorkspace->BufferDump(myFBO, theImage, theBufferType); return myWorkspace->BufferDump(myFBO, theImage, theBufferType);
@ -474,9 +475,10 @@ Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3
return myWorkspace->BufferDump(myAccumFrames % 2 ? myRaytraceFBO2[0] : myRaytraceFBO1[0], theImage, theBufferType); return myWorkspace->BufferDump(myAccumFrames % 2 ? myRaytraceFBO2[0] : myRaytraceFBO1[0], theImage, theBufferType);
} }
#if defined(GL_ES_VERSION_2_0) if (aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
return false; return false;
#else }
if (theImage.Format() != Image_Format_RGBF) if (theImage.Format() != Image_Format_RGBF)
{ {
return false; return false;
@ -499,9 +501,9 @@ Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3
return false; return false;
} }
glBindTexture (GL_TEXTURE_RECTANGLE, myRaytraceOutputTexture[0]->TextureId()); aCtx->core11fwd->glBindTexture (GL_TEXTURE_RECTANGLE, myRaytraceOutputTexture[0]->TextureId());
glGetTexImage (GL_TEXTURE_RECTANGLE, 0, OpenGl_TextureFormat::Create<GLfloat, 1>().Format(), GL_FLOAT, &aValues[0]); aCtx->core11fwd->glGetTexImage (GL_TEXTURE_RECTANGLE, 0, OpenGl_TextureFormat::Create<GLfloat, 1>().Format(), GL_FLOAT, &aValues[0]);
glBindTexture (GL_TEXTURE_RECTANGLE, 0); aCtx->core11fwd->glBindTexture (GL_TEXTURE_RECTANGLE, 0);
for (unsigned int aRow = 0; aRow < aH; aRow += 2) for (unsigned int aRow = 0; aRow < aH; aRow += 2)
{ {
for (unsigned int aCol = 0; aCol < aW; aCol += 3) for (unsigned int aCol = 0; aCol < aW; aCol += 3)
@ -515,7 +517,6 @@ Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3
} }
return true; return true;
#endif
} }
// ======================================================================= // =======================================================================
@ -989,7 +990,7 @@ void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace,
} }
#ifdef GL_DEPTH_CLAMP #ifdef GL_DEPTH_CLAMP
const bool wasDepthClamped = aCtx->arbDepthClamp && glIsEnabled (GL_DEPTH_CLAMP); const bool wasDepthClamped = aCtx->arbDepthClamp && aCtx->core11fwd->glIsEnabled (GL_DEPTH_CLAMP);
if (aCtx->arbDepthClamp && !wasDepthClamped) if (aCtx->arbDepthClamp && !wasDepthClamped)
{ {
// make sure background is always drawn (workaround skybox rendering on some hardware) // make sure background is always drawn (workaround skybox rendering on some hardware)
@ -1280,14 +1281,18 @@ bool OpenGl_View::prepareFrameBuffers (Graphic3d_Camera::Projection& theProj)
if (!aCtx->GetResource (THE_SHARED_ENV_LUT_KEY, anEnvLUT)) if (!aCtx->GetResource (THE_SHARED_ENV_LUT_KEY, anEnvLUT))
{ {
bool toConvertHalfFloat = false; bool toConvertHalfFloat = false;
#if defined(GL_ES_VERSION_2_0)
// GL_RG32F is not texture-filterable format in OpenGL ES without OES_texture_float_linear extension. // GL_RG32F is not texture-filterable format in OpenGL ES without OES_texture_float_linear extension.
// GL_RG16F is texture-filterable since OpenGL ES 3.0 or OpenGL ES 2.0 + OES_texture_half_float_linear. // GL_RG16F is texture-filterable since OpenGL ES 3.0 or OpenGL ES 2.0 + OES_texture_half_float_linear.
// OpenGL ES 3.0 allows initialization of GL_RG16F from 32-bit float data, but OpenGL ES 2.0 + OES_texture_half_float does not. // OpenGL ES 3.0 allows initialization of GL_RG16F from 32-bit float data, but OpenGL ES 2.0 + OES_texture_half_float does not.
// Note that it is expected that GL_RG16F has enough precision for this table, so that it can be used also on desktop OpenGL. // Note that it is expected that GL_RG16F has enough precision for this table, so that it can be used also on desktop OpenGL.
const bool hasHalfFloat = aCtx->IsGlGreaterEqual (3, 0) || aCtx->CheckExtension ("GL_OES_texture_half_float_linear"); const bool hasHalfFloat = aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
&& (aCtx->IsGlGreaterEqual (3, 0) || aCtx->CheckExtension ("GL_OES_texture_half_float_linear"));
if (aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
toConvertHalfFloat = !aCtx->IsGlGreaterEqual (3, 0) && hasHalfFloat; toConvertHalfFloat = !aCtx->IsGlGreaterEqual (3, 0) && hasHalfFloat;
#endif }
Image_Format anImgFormat = Image_Format_UNKNOWN; Image_Format anImgFormat = Image_Format_UNKNOWN;
if (aCtx->arbTexRG) if (aCtx->arbTexRG)
{ {
@ -1330,13 +1335,12 @@ bool OpenGl_View::prepareFrameBuffers (Graphic3d_Camera::Projection& theProj)
} }
OpenGl_TextureFormat aTexFormat = OpenGl_TextureFormat::FindFormat (aCtx, aPixMap->Format(), false); OpenGl_TextureFormat aTexFormat = OpenGl_TextureFormat::FindFormat (aCtx, aPixMap->Format(), false);
#if defined(GL_ES_VERSION_2_0) if (aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
if (aTexFormat.IsValid() && aTexFormat.IsValid()
&& hasHalfFloat) && hasHalfFloat)
{ {
aTexFormat.SetInternalFormat (aCtx->arbTexRG ? GL_RG16F : GL_RGBA16F); aTexFormat.SetInternalFormat (aCtx->arbTexRG ? GL_RG16F : GL_RGBA16F);
} }
#endif
Handle(Graphic3d_TextureParams) aParams = new Graphic3d_TextureParams(); Handle(Graphic3d_TextureParams) aParams = new Graphic3d_TextureParams();
aParams->SetFilter (Graphic3d_TOTF_BILINEAR); aParams->SetFilter (Graphic3d_TOTF_BILINEAR);
@ -1677,18 +1681,14 @@ void OpenGl_View::Redraw()
anImmFbosOit[1] = NULL; anImmFbosOit[1] = NULL;
} }
#if !defined(GL_ES_VERSION_2_0)
aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_LEFT : GL_BACK); aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_LEFT : GL_BACK);
#endif
aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(),
aMainFbos[0] != NULL ? myRenderParams.RenderResolutionScale : 1.0f); aMainFbos[0] != NULL ? myRenderParams.RenderResolutionScale : 1.0f);
redraw (Graphic3d_Camera::Projection_MonoLeftEye, aMainFbos[0], aMainFbosOit[0]); redraw (Graphic3d_Camera::Projection_MonoLeftEye, aMainFbos[0], aMainFbosOit[0]);
myBackBufferRestored = Standard_True; myBackBufferRestored = Standard_True;
myIsImmediateDrawn = Standard_False; myIsImmediateDrawn = Standard_False;
#if !defined(GL_ES_VERSION_2_0)
aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_LEFT : GL_BACK); aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_LEFT : GL_BACK);
#endif
aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(),
anImmFbos[0] != NULL ? myRenderParams.RenderResolutionScale : 1.0f); anImmFbos[0] != NULL ? myRenderParams.RenderResolutionScale : 1.0f);
if (!redrawImmediate (Graphic3d_Camera::Projection_MonoLeftEye, aMainFbos[0], anImmFbos[0], anImmFbosOit[0])) if (!redrawImmediate (Graphic3d_Camera::Projection_MonoLeftEye, aMainFbos[0], anImmFbos[0], anImmFbosOit[0]))
@ -1708,18 +1708,15 @@ void OpenGl_View::Redraw()
{ {
blitBuffers (aMainFbos[0], anXRFbo); // resize or resolve MSAA samples blitBuffers (aMainFbos[0], anXRFbo); // resize or resolve MSAA samples
} }
#if !defined(GL_ES_VERSION_2_0) const Aspect_GraphicsLibrary aGraphicsLib = aCtx->GraphicsLibrary();
const Aspect_GraphicsLibrary aGraphicsLib = Aspect_GraphicsLibrary_OpenGL;
#else
const Aspect_GraphicsLibrary aGraphicsLib = Aspect_GraphicsLibrary_OpenGLES;
#endif
myXRSession->SubmitEye ((void* )(size_t )anXRFbo->ColorTexture()->TextureId(), myXRSession->SubmitEye ((void* )(size_t )anXRFbo->ColorTexture()->TextureId(),
aGraphicsLib, Aspect_ColorSpace_sRGB, Aspect_Eye_Left); aGraphicsLib, Aspect_ColorSpace_sRGB, Aspect_Eye_Left);
} }
#if !defined(GL_ES_VERSION_2_0) if (aCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
{
aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_RIGHT : GL_BACK); aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_RIGHT : GL_BACK);
#endif }
aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(),
aMainFbos[1] != NULL ? myRenderParams.RenderResolutionScale : 1.0f); aMainFbos[1] != NULL ? myRenderParams.RenderResolutionScale : 1.0f);
@ -1741,11 +1738,8 @@ void OpenGl_View::Redraw()
{ {
blitBuffers (aMainFbos[1], anXRFbo); // resize or resolve MSAA samples blitBuffers (aMainFbos[1], anXRFbo); // resize or resolve MSAA samples
} }
#if !defined(GL_ES_VERSION_2_0)
const Aspect_GraphicsLibrary aGraphicsLib = Aspect_GraphicsLibrary_OpenGL; const Aspect_GraphicsLibrary aGraphicsLib = aCtx->GraphicsLibrary();
#else
const Aspect_GraphicsLibrary aGraphicsLib = Aspect_GraphicsLibrary_OpenGLES;
#endif
myXRSession->SubmitEye ((void* )(size_t )anXRFbo->ColorTexture()->TextureId(), myXRSession->SubmitEye ((void* )(size_t )anXRFbo->ColorTexture()->TextureId(),
aGraphicsLib, Aspect_ColorSpace_sRGB, Aspect_Eye_Right); aGraphicsLib, Aspect_ColorSpace_sRGB, Aspect_Eye_Right);
aCtx->core11fwd->glFinish(); aCtx->core11fwd->glFinish();
@ -1778,12 +1772,10 @@ void OpenGl_View::Redraw()
anImmFboOit = myImmediateSceneFbosOit[0]->IsValid() ? myImmediateSceneFbosOit[0].operator->() : NULL; anImmFboOit = myImmediateSceneFbosOit[0]->IsValid() ? myImmediateSceneFbosOit[0].operator->() : NULL;
} }
#if !defined(GL_ES_VERSION_2_0)
if (aMainFbo == NULL) if (aMainFbo == NULL)
{ {
aCtx->SetReadDrawBuffer (GL_BACK); aCtx->SetReadDrawBuffer (GL_BACK);
} }
#endif
aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(),
aMainFbo != aFrameBuffer ? myRenderParams.RenderResolutionScale : 1.0f); aMainFbo != aFrameBuffer ? myRenderParams.RenderResolutionScale : 1.0f);
@ -1920,12 +1912,10 @@ void OpenGl_View::RedrawImmediate()
{ {
aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER); aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER);
} }
#if !defined(GL_ES_VERSION_2_0)
if (anImmFbos[0] == NULL) if (anImmFbos[0] == NULL)
{ {
aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_LEFT : GL_BACK); aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_LEFT : GL_BACK);
} }
#endif
aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(),
anImmFbos[0] != NULL ? myRenderParams.RenderResolutionScale : 1.0f); anImmFbos[0] != NULL ? myRenderParams.RenderResolutionScale : 1.0f);
@ -1946,12 +1936,10 @@ void OpenGl_View::RedrawImmediate()
{ {
aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER); aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER);
} }
#if !defined(GL_ES_VERSION_2_0)
if (anImmFbos[1] == NULL) if (anImmFbos[1] == NULL)
{ {
aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_RIGHT : GL_BACK); aCtx->SetReadDrawBuffer (aStereoMode == Graphic3d_StereoMode_QuadBuffer ? GL_BACK_RIGHT : GL_BACK);
} }
#endif
aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(),
anImmFbos[1] != NULL ? myRenderParams.RenderResolutionScale : 1.0f); anImmFbos[1] != NULL ? myRenderParams.RenderResolutionScale : 1.0f);
toSwap = redrawImmediate (Graphic3d_Camera::Projection_MonoRightEye, toSwap = redrawImmediate (Graphic3d_Camera::Projection_MonoRightEye,
@ -1974,12 +1962,10 @@ void OpenGl_View::RedrawImmediate()
anImmFbo = myImmediateSceneFbos[0].operator->(); anImmFbo = myImmediateSceneFbos[0].operator->();
anImmFboOit = myImmediateSceneFbosOit[0]->IsValid() ? myImmediateSceneFbosOit[0].operator->() : NULL; anImmFboOit = myImmediateSceneFbosOit[0]->IsValid() ? myImmediateSceneFbosOit[0].operator->() : NULL;
} }
#if !defined(GL_ES_VERSION_2_0)
if (aMainFbo == NULL) if (aMainFbo == NULL)
{ {
aCtx->SetReadDrawBuffer (GL_BACK); aCtx->SetReadDrawBuffer (GL_BACK);
} }
#endif
aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(), aCtx->SetResolution (myRenderParams.Resolution, myRenderParams.ResolutionRatio(),
anImmFbo != aFrameBuffer ? myRenderParams.RenderResolutionScale : 1.0f); anImmFbo != aFrameBuffer ? myRenderParams.RenderResolutionScale : 1.0f);
toSwap = redrawImmediate (aProjectType, toSwap = redrawImmediate (aProjectType,
@ -2090,9 +2076,10 @@ bool OpenGl_View::redrawImmediate (const Graphic3d_Camera::Projection theProject
} }
else if (theDrawFbo == NULL) else if (theDrawFbo == NULL)
{ {
#if !defined(GL_ES_VERSION_2_0) if (aCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
{
aCtx->core11fwd->glGetBooleanv (GL_DOUBLEBUFFER, &toCopyBackToFront); aCtx->core11fwd->glGetBooleanv (GL_DOUBLEBUFFER, &toCopyBackToFront);
#endif }
if (toCopyBackToFront if (toCopyBackToFront
&& myTransientDrawToFront) && myTransientDrawToFront)
{ {
@ -2204,7 +2191,6 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
&& theOutputFBO != NULL && theOutputFBO != NULL
&& theOutputFBO->NbSamples() != 0); && theOutputFBO->NbSamples() != 0);
#if !defined(GL_ES_VERSION_2_0)
// Disable current clipping planes // Disable current clipping planes
if (aContext->core11ffp != NULL) if (aContext->core11ffp != NULL)
{ {
@ -2214,7 +2200,6 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
aContext->core11fwd->glDisable (aClipPlaneId); aContext->core11fwd->glDisable (aClipPlaneId);
} }
} }
#endif
// update states of OpenGl_BVHTreeSelector (frustum culling algorithm); // update states of OpenGl_BVHTreeSelector (frustum culling algorithm);
// note that we pass here window dimensions ignoring Graphic3d_RenderingParams::RenderResolutionScale // note that we pass here window dimensions ignoring Graphic3d_RenderingParams::RenderResolutionScale
@ -2262,20 +2247,17 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
drawBackground (myWorkspace, theProjection); drawBackground (myWorkspace, theProjection);
} }
#if !defined(GL_ES_VERSION_2_0)
// Switch off lighting by default // Switch off lighting by default
if (aContext->core11ffp != NULL if (aContext->core11ffp != NULL
&& aContext->caps->ffpEnable) && aContext->caps->ffpEnable)
{ {
aContext->core11fwd->glDisable (GL_LIGHTING); aContext->core11fwd->glDisable (GL_LIGHTING);
} }
#endif
// ================================= // =================================
// Step 3: Redraw main plane // Step 3: Redraw main plane
// ================================= // =================================
#if !defined(GL_ES_VERSION_2_0)
// if the view is scaled normal vectors are scaled to unit // if the view is scaled normal vectors are scaled to unit
// length for correct displaying of shaded objects // length for correct displaying of shaded objects
const gp_Pnt anAxialScale = aContext->Camera()->AxialScale(); const gp_Pnt anAxialScale = aContext->Camera()->AxialScale();
@ -2289,7 +2271,6 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
{ {
aContext->SetGlNormalizeEnabled (Standard_False); aContext->SetGlNormalizeEnabled (Standard_False);
} }
#endif
aManager->SetShadingModel (OpenGl_ShaderManager::PBRShadingModelFallback (myRenderParams.ShadingModel, checkPBRAvailability())); aManager->SetShadingModel (OpenGl_ShaderManager::PBRShadingModelFallback (myRenderParams.ShadingModel, checkPBRAvailability()));
@ -2558,14 +2539,15 @@ void OpenGl_View::bindDefaultFbo (OpenGl_FrameBuffer* theCustomFbo)
} }
else else
{ {
#if !defined(GL_ES_VERSION_2_0) if (aCtx->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
{
aCtx->SetReadDrawBuffer (GL_BACK); aCtx->SetReadDrawBuffer (GL_BACK);
#else }
if (aCtx->arbFBO != NULL) else if (aCtx->arbFBO != NULL)
{ {
aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER); aCtx->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, OpenGl_FrameBuffer::NO_FRAMEBUFFER);
} }
#endif
const Standard_Integer aViewport[4] = { 0, 0, myWindow->Width(), myWindow->Height() }; const Standard_Integer aViewport[4] = { 0, 0, myWindow->Width(), myWindow->Height() };
aCtx->ResizeViewport (aViewport); aCtx->ResizeViewport (aViewport);
} }
@ -2744,13 +2726,12 @@ bool OpenGl_View::blitBuffers (OpenGl_FrameBuffer* theReadFbo,
aCtx->core20fwd->glDepthFunc (GL_ALWAYS); aCtx->core20fwd->glDepthFunc (GL_ALWAYS);
aCtx->core20fwd->glDepthMask (GL_TRUE); aCtx->core20fwd->glDepthMask (GL_TRUE);
aCtx->core20fwd->glEnable (GL_DEPTH_TEST); aCtx->core20fwd->glEnable (GL_DEPTH_TEST);
#if defined(GL_ES_VERSION_2_0) if (aCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
if (!aCtx->IsGlGreaterEqual (3, 0) && !aCtx->IsGlGreaterEqual (3, 0)
&& !aCtx->extFragDepth) && !aCtx->extFragDepth)
{ {
aCtx->core20fwd->glDisable (GL_DEPTH_TEST); aCtx->core20fwd->glDisable (GL_DEPTH_TEST);
} }
#endif
aCtx->BindTextures (Handle(OpenGl_TextureSet)(), Handle(OpenGl_ShaderProgram)()); aCtx->BindTextures (Handle(OpenGl_TextureSet)(), Handle(OpenGl_ShaderProgram)());
@ -2995,7 +2976,6 @@ void OpenGl_View::drawStereoPair (OpenGl_FrameBuffer* theDrawFbo)
bool OpenGl_View::copyBackToFront() bool OpenGl_View::copyBackToFront()
{ {
myIsImmediateDrawn = Standard_False; myIsImmediateDrawn = Standard_False;
#if !defined(GL_ES_VERSION_2_0)
const Handle(OpenGl_Context)& aCtx = myWorkspace->GetGlContext(); const Handle(OpenGl_Context)& aCtx = myWorkspace->GetGlContext();
if (aCtx->core11ffp == NULL) if (aCtx->core11ffp == NULL)
{ {
@ -3056,9 +3036,6 @@ bool OpenGl_View::copyBackToFront()
// read/write from front buffer now // read/write from front buffer now
aCtx->SetReadBuffer (aCtx->DrawBuffer()); aCtx->SetReadBuffer (aCtx->DrawBuffer());
return true; return true;
#else
return false;
#endif
} }
// ======================================================================= // =======================================================================

View File

@ -600,11 +600,7 @@ Handle(OpenGl_TriangleSet) OpenGl_View::addRaytracePrimitiveArray (const OpenGl_
const Handle(Graphic3d_Buffer)& anAttribs = theArray->Attributes(); const Handle(Graphic3d_Buffer)& anAttribs = theArray->Attributes();
if (theArray->DrawMode() < GL_TRIANGLES if (theArray->DrawMode() < GL_TRIANGLES
#ifndef GL_ES_VERSION_2_0
|| theArray->DrawMode() > GL_POLYGON || theArray->DrawMode() > GL_POLYGON
#else
|| theArray->DrawMode() > GL_TRIANGLE_FAN
#endif
|| anAttribs.IsNull()) || anAttribs.IsNull())
{ {
return Handle(OpenGl_TriangleSet)(); return Handle(OpenGl_TriangleSet)();
@ -755,11 +751,9 @@ Standard_Boolean OpenGl_View::addRaytraceVertexIndices (OpenGl_TriangleSet&
case GL_TRIANGLES: return addRaytraceTriangleArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); case GL_TRIANGLES: return addRaytraceTriangleArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
case GL_TRIANGLE_FAN: return addRaytraceTriangleFanArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); case GL_TRIANGLE_FAN: return addRaytraceTriangleFanArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
case GL_TRIANGLE_STRIP: return addRaytraceTriangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); case GL_TRIANGLE_STRIP: return addRaytraceTriangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
#if !defined(GL_ES_VERSION_2_0)
case GL_QUAD_STRIP: return addRaytraceQuadrangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); case GL_QUAD_STRIP: return addRaytraceQuadrangleStripArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
case GL_QUADS: return addRaytraceQuadrangleArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); case GL_QUADS: return addRaytraceQuadrangleArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
case GL_POLYGON: return addRaytracePolygonArray (theSet, theMatID, theCount, theOffset, theArray.Indices()); case GL_POLYGON: return addRaytracePolygonArray (theSet, theMatID, theCount, theOffset, theArray.Indices());
#endif
} }
return Standard_False; return Standard_False;
@ -1031,16 +1025,14 @@ const TCollection_AsciiString OpenGl_View::ShaderSource::EMPTY_PREFIX;
TCollection_AsciiString OpenGl_View::ShaderSource::Source (const Handle(OpenGl_Context)& theCtx, TCollection_AsciiString OpenGl_View::ShaderSource::Source (const Handle(OpenGl_Context)& theCtx,
const GLenum theType) const const GLenum theType) const
{ {
TCollection_AsciiString aVersion = TCollection_AsciiString aVersion = theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES
#if defined(GL_ES_VERSION_2_0) ? "#version 320 es\n"
"#version 320 es\n"; : "#version 140\n";
#else
"#version 140\n";
#endif
TCollection_AsciiString aPrecisionHeader; TCollection_AsciiString aPrecisionHeader;
if (theType == GL_FRAGMENT_SHADER) if (theType == GL_FRAGMENT_SHADER
&& theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{ {
#if defined(GL_ES_VERSION_2_0)
aPrecisionHeader = theCtx->hasHighp aPrecisionHeader = theCtx->hasHighp
? "precision highp float;\n" ? "precision highp float;\n"
"precision highp int;\n" "precision highp int;\n"
@ -1050,9 +1042,6 @@ TCollection_AsciiString OpenGl_View::ShaderSource::Source (const Handle(OpenGl_C
"precision mediump int;\n" "precision mediump int;\n"
"precision mediump samplerBuffer;\n" "precision mediump samplerBuffer;\n"
"precision mediump isamplerBuffer;\n"; "precision mediump isamplerBuffer;\n";
#else
(void )theCtx;
#endif
} }
if (myPrefix.IsEmpty()) if (myPrefix.IsEmpty())
{ {
@ -1480,12 +1469,15 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Standard_Integer theS
{ {
myAccumFrames = 0; // accumulation should be restarted myAccumFrames = 0; // accumulation should be restarted
#if defined(GL_ES_VERSION_2_0) if (theGlContext->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
if (!theGlContext->IsGlGreaterEqual (3, 2)) if (!theGlContext->IsGlGreaterEqual (3, 2))
{ {
return safeFailBack ("Ray-tracing requires OpenGL ES 3.2 and higher", theGlContext); return safeFailBack ("Ray-tracing requires OpenGL ES 3.2 and higher", theGlContext);
} }
#else }
else
{
if (!theGlContext->IsGlGreaterEqual (3, 1)) if (!theGlContext->IsGlGreaterEqual (3, 1))
{ {
return safeFailBack ("Ray-tracing requires OpenGL 3.1 and higher", theGlContext); return safeFailBack ("Ray-tracing requires OpenGL 3.1 and higher", theGlContext);
@ -1498,7 +1490,7 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Standard_Integer theS
{ {
return safeFailBack ("Ray-tracing requires EXT_framebuffer_blit extension", theGlContext); return safeFailBack ("Ray-tracing requires EXT_framebuffer_blit extension", theGlContext);
} }
#endif }
myRaytraceParameters.NbBounces = myRenderParams.RaytracingDepth; myRaytraceParameters.NbBounces = myRenderParams.RaytracingDepth;
@ -2119,19 +2111,22 @@ void OpenGl_View::updatePerspCameraPT (const OpenGl_Mat4& theOrientati
// ======================================================================= // =======================================================================
Standard_Boolean OpenGl_View::uploadRaytraceData (const Handle(OpenGl_Context)& theGlContext) Standard_Boolean OpenGl_View::uploadRaytraceData (const Handle(OpenGl_Context)& theGlContext)
{ {
#if defined(GL_ES_VERSION_2_0) if (theGlContext->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGLES)
{
if (!theGlContext->IsGlGreaterEqual (3, 2)) if (!theGlContext->IsGlGreaterEqual (3, 2))
{ {
Message::SendFail() << "Error: OpenGL ES version is less than 3.2"; Message::SendFail() << "Error: OpenGL ES version is less than 3.2";
return Standard_False; return Standard_False;
} }
#else }
else
{
if (!theGlContext->IsGlGreaterEqual (3, 1)) if (!theGlContext->IsGlGreaterEqual (3, 1))
{ {
Message::SendFail() << "Error: OpenGL version is less than 3.1"; Message::SendFail() << "Error: OpenGL version is less than 3.1";
return Standard_False; return Standard_False;
} }
#endif }
myAccumFrames = 0; // accumulation should be restarted myAccumFrames = 0; // accumulation should be restarted
@ -2748,7 +2743,6 @@ void OpenGl_View::bindRaytraceTextures (const Handle(OpenGl_Context)& theGlConte
if (myRaytraceParameters.AdaptiveScreenSampling if (myRaytraceParameters.AdaptiveScreenSampling
&& myRaytraceParameters.GlobalIllumination) && myRaytraceParameters.GlobalIllumination)
{ {
#if !defined(GL_ES_VERSION_2_0)
theGlContext->core42->glBindImageTexture (OpenGl_RT_OutputImage, theGlContext->core42->glBindImageTexture (OpenGl_RT_OutputImage,
myRaytraceOutputTexture[theStereoView]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32F); myRaytraceOutputTexture[theStereoView]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32F);
theGlContext->core42->glBindImageTexture (OpenGl_RT_VisualErrorImage, theGlContext->core42->glBindImageTexture (OpenGl_RT_VisualErrorImage,
@ -2763,9 +2757,6 @@ void OpenGl_View::bindRaytraceTextures (const Handle(OpenGl_Context)& theGlConte
theGlContext->core42->glBindImageTexture (OpenGl_RT_TileSamplesImage, theGlContext->core42->glBindImageTexture (OpenGl_RT_TileSamplesImage,
myRaytraceTileSamplesTexture[theStereoView]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32I); myRaytraceTileSamplesTexture[theStereoView]->TextureId(), 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32I);
} }
#else
(void )theStereoView;
#endif
} }
const Handle(OpenGl_TextureSet)& anEnvTextureSet = myRaytraceParameters.CubemapForBack const Handle(OpenGl_TextureSet)& anEnvTextureSet = myRaytraceParameters.CubemapForBack
@ -2996,15 +2987,11 @@ Standard_Boolean OpenGl_View::runPathtrace (const Standard_Integer
myTileSampler.UploadSamples (theGlContext, myRaytraceTileSamplesTexture[aFBOIdx], false); myTileSampler.UploadSamples (theGlContext, myRaytraceTileSamplesTexture[aFBOIdx], false);
} }
#if !defined(GL_ES_VERSION_2_0)
theGlContext->core44->glClearTexImage (myRaytraceOutputTexture[aFBOIdx]->TextureId(), 0, GL_RED, GL_FLOAT, NULL); theGlContext->core44->glClearTexImage (myRaytraceOutputTexture[aFBOIdx]->TextureId(), 0, GL_RED, GL_FLOAT, NULL);
#endif
} }
// Clear adaptive screen sampling images // Clear adaptive screen sampling images
#if !defined(GL_ES_VERSION_2_0)
theGlContext->core44->glClearTexImage (myRaytraceVisualErrorTexture[aFBOIdx]->TextureId(), 0, GL_RED_INTEGER, GL_INT, NULL); theGlContext->core44->glClearTexImage (myRaytraceVisualErrorTexture[aFBOIdx]->TextureId(), 0, GL_RED_INTEGER, GL_INT, NULL);
#endif
} }
bindRaytraceTextures (theGlContext, aFBOIdx); bindRaytraceTextures (theGlContext, aFBOIdx);
@ -3065,9 +3052,7 @@ Standard_Boolean OpenGl_View::runPathtrace (const Standard_Integer
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6); theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
if (myRaytraceParameters.AdaptiveScreenSampling) if (myRaytraceParameters.AdaptiveScreenSampling)
{ {
#if !defined(GL_ES_VERSION_2_0)
theGlContext->core44->glMemoryBarrier (GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); theGlContext->core44->glMemoryBarrier (GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
#endif
} }
} }
aRenderImageFramebuffer->UnbindBuffer (theGlContext); aRenderImageFramebuffer->UnbindBuffer (theGlContext);

View File

@ -804,17 +804,15 @@ void OpenGl_Window::Init()
// //
#endif #endif
glDisable (GL_DITHER); myGlContext->core11fwd->glDisable (GL_DITHER);
glDisable (GL_SCISSOR_TEST); myGlContext->core11fwd->glDisable (GL_SCISSOR_TEST);
const Standard_Integer aViewport[4] = { 0, 0, myWidth, myHeight }; const Standard_Integer aViewport[4] = { 0, 0, myWidth, myHeight };
myGlContext->ResizeViewport (aViewport); myGlContext->ResizeViewport (aViewport);
#if !defined(GL_ES_VERSION_2_0)
myGlContext->SetDrawBuffer (GL_BACK); myGlContext->SetDrawBuffer (GL_BACK);
if (myGlContext->core11ffp != NULL) if (myGlContext->core11ffp != NULL)
{ {
glMatrixMode (GL_MODELVIEW); myGlContext->core11ffp->glMatrixMode (GL_MODELVIEW);
} }
#endif
} }
// ======================================================================= // =======================================================================

View File

@ -124,7 +124,6 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1); myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
// General initialization of the context // General initialization of the context
#if !defined(GL_ES_VERSION_2_0)
if (myGlContext->core11ffp != NULL) if (myGlContext->core11ffp != NULL)
{ {
// enable two-side lighting by default // enable two-side lighting by default
@ -136,15 +135,17 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
} }
} }
if (myGlContext->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
{
myGlContext->core11fwd->glHint (GL_LINE_SMOOTH_HINT, GL_FASTEST); myGlContext->core11fwd->glHint (GL_LINE_SMOOTH_HINT, GL_FASTEST);
myGlContext->core11fwd->glHint (GL_POLYGON_SMOOTH_HINT, GL_FASTEST); myGlContext->core11fwd->glHint (GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
}
if (myGlContext->Vendor() == "microsoft corporation" if (myGlContext->Vendor() == "microsoft corporation"
&& !myGlContext->IsGlGreaterEqual (1, 2)) && !myGlContext->IsGlGreaterEqual (1, 2))
{ {
// this software implementation causes too slow rendering into GL_FRONT on modern Windows // this software implementation causes too slow rendering into GL_FRONT on modern Windows
theView->SetImmediateModeDrawToFront (false); theView->SetImmediateModeDrawToFront (false);
} }
#endif
} }
myNoneCulling .Aspect()->SetFaceCulling (Graphic3d_TypeOfBackfacingModel_DoubleSided); myNoneCulling .Aspect()->SetFaceCulling (Graphic3d_TypeOfBackfacingModel_DoubleSided);
@ -171,11 +172,9 @@ Standard_Boolean OpenGl_Workspace::Activate()
{ {
if (myGlContext->caps->ffpEnable) if (myGlContext->caps->ffpEnable)
{ {
#if defined(GL_ES_VERSION_2_0) Message::SendWarning (myGlContext->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES
Message::SendWarning ("Warning: FFP is unsupported by OpenGL ES"); ? "Warning: FFP is unsupported by OpenGL ES"
#else : "Warning: FFP is unsupported by OpenGL Core Profile");
Message::SendWarning ("Warning: FFP is unsupported by OpenGL Core Profile");
#endif
myGlContext->caps->ffpEnable = false; myGlContext->caps->ffpEnable = false;
} }
} }
@ -187,12 +186,10 @@ Standard_Boolean OpenGl_Workspace::Activate()
myGlContext->caps->useZeroToOneDepth = false; myGlContext->caps->useZeroToOneDepth = false;
} }
myView->Camera()->SetZeroToOneDepth (myGlContext->caps->useZeroToOneDepth); myView->Camera()->SetZeroToOneDepth (myGlContext->caps->useZeroToOneDepth);
#if !defined(GL_ES_VERSION_2_0)
if (myGlContext->arbClipControl) if (myGlContext->arbClipControl)
{ {
myGlContext->Functions()->glClipControl (GL_LOWER_LEFT, myGlContext->caps->useZeroToOneDepth ? GL_ZERO_TO_ONE : GL_NEGATIVE_ONE_TO_ONE); myGlContext->Functions()->glClipControl (GL_LOWER_LEFT, myGlContext->caps->useZeroToOneDepth ? GL_ZERO_TO_ONE : GL_NEGATIVE_ONE_TO_ONE);
} }
#endif
ResetAppliedAspect(); ResetAppliedAspect();
@ -305,18 +302,14 @@ const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects (bool theToBindTextures)
if (myAspectsApplied.IsNull() if (myAspectsApplied.IsNull()
|| myAspectsApplied->InteriorStyle() != anIntstyle) || myAspectsApplied->InteriorStyle() != anIntstyle)
{ {
#if !defined(GL_ES_VERSION_2_0)
myGlContext->SetPolygonMode (anIntstyle == Aspect_IS_POINT ? GL_POINT : GL_FILL); myGlContext->SetPolygonMode (anIntstyle == Aspect_IS_POINT ? GL_POINT : GL_FILL);
myGlContext->SetPolygonHatchEnabled (anIntstyle == Aspect_IS_HATCH); myGlContext->SetPolygonHatchEnabled (anIntstyle == Aspect_IS_HATCH);
#endif
} }
#if !defined(GL_ES_VERSION_2_0)
if (anIntstyle == Aspect_IS_HATCH) if (anIntstyle == Aspect_IS_HATCH)
{ {
myGlContext->SetPolygonHatchStyle (myAspectsSet->Aspect()->HatchStyle()); myGlContext->SetPolygonHatchStyle (myAspectsSet->Aspect()->HatchStyle());
} }
#endif
// Case of hidden line // Case of hidden line
if (anIntstyle == Aspect_IS_HIDDENLINE) if (anIntstyle == Aspect_IS_HIDDENLINE)

View File

@ -199,7 +199,7 @@ void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
// Finally draw something to make sure UserDraw really works // Finally draw something to make sure UserDraw really works
aVertBuffer->BindAttribute (aCtx, Graphic3d_TOA_POS); aVertBuffer->BindAttribute (aCtx, Graphic3d_TOA_POS);
glDrawArrays(GL_LINE_LOOP, 0, aVertBuffer->GetElemsNb()); aCtx->core11fwd->glDrawArrays (GL_LINE_LOOP, 0, aVertBuffer->GetElemsNb());
aVertBuffer->UnbindAttribute(aCtx, Graphic3d_TOA_POS); aVertBuffer->UnbindAttribute(aCtx, Graphic3d_TOA_POS);
aVertBuffer->Release (aCtx.get()); aVertBuffer->Release (aCtx.get());
} }
@ -350,10 +350,15 @@ static int VGlDebug (Draw_Interpretor& theDI,
const char** theArgVec) const char** theArgVec)
{ {
Handle(OpenGl_GraphicDriver) aDriver; Handle(OpenGl_GraphicDriver) aDriver;
Handle(OpenGl_Context) aGlCtx;
Handle(V3d_View) aView = ViewerTest::CurrentView(); Handle(V3d_View) aView = ViewerTest::CurrentView();
if (!aView.IsNull()) if (!aView.IsNull())
{ {
aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver()); aDriver = Handle(OpenGl_GraphicDriver)::DownCast (aView->Viewer()->Driver());
if (!aDriver.IsNull())
{
aGlCtx = aDriver->GetSharedContext();
}
} }
OpenGl_Caps* aDefCaps = getDefaultCaps().get(); OpenGl_Caps* aDefCaps = getDefaultCaps().get();
OpenGl_Caps* aCaps = !aDriver.IsNull() ? &aDriver->ChangeOptions() : NULL; OpenGl_Caps* aCaps = !aDriver.IsNull() ? &aDriver->ChangeOptions() : NULL;
@ -365,15 +370,15 @@ static int VGlDebug (Draw_Interpretor& theDI,
{ {
aCaps = aDefCaps; aCaps = aDefCaps;
} }
else else if (!aGlCtx.IsNull())
{ {
Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )::glGetString (GL_EXTENSIONS), Standard_Boolean isActive = OpenGl_Context::CheckExtension ((const char* )aGlCtx->core11fwd->glGetString (GL_EXTENSIONS),
"GL_ARB_debug_output"); "GL_ARB_debug_output");
aDebActive = isActive ? " (active)" : " (inactive)"; aDebActive = isActive ? " (active)" : " (inactive)";
if (isActive) if (isActive)
{ {
// GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB // GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
aSyncActive = ::glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)"; aSyncActive = aGlCtx->core11fwd->glIsEnabled (0x8242) == GL_TRUE ? " (active)" : " (inactive)";
} }
} }