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

0032732: Visualization, TKOpenGl - do not include system headers within OpenGl_GlFunctions.hxx

This commit is contained in:
kgv 2021-12-15 16:47:25 +03:00 committed by smoskvin
parent f291ad2528
commit 4d476dd2ed
11 changed files with 65 additions and 74 deletions

View File

@ -7,6 +7,8 @@ Upgrade from older OCCT versions {#occt__upgrade}
This document provides technical details on changes made in particular versions of OCCT. It can help to upgrade user applications based on previous versions of OCCT to newer ones.
@ref upgrade_occt770 "SEEK TO THE LAST CHAPTER (UPGRADE TO 7.7.0)"
@subsection upgrade_intro_precautions Precautions
Back-up your code before the upgrade.
@ -24,7 +26,6 @@ The automatic upgrade tool is provided as is, without warranty of any kind, and
It is your responsibility to ensure that the changes you made in your code are correct.
When you upgrade the code by an automatic script, make sure to carefully review the introduced changes at each step before committing them.
@section upgrade_65 Upgrade to OCCT 6.5.0
Porting of user applications from an earlier OCCT version to version 6.5 requires taking into account the following major changes:
@ -2321,3 +2322,10 @@ aValidateEdge.Process();
`Prs3d_Drawer` getters no more implicitly create "default" aspects.
If specific property has not been set before to this drawer instance nor to linked drawer instance, then NULL property will be returned.
Make sure to set property beforehand or to call `SetOwn*` / `SetupOwn*` methods to derive from defaults.
@subsection upgrade_occt770_opengl OpenGL functions
Applications extending OCCT 3D Viewer and calling OpenGL functions directly (like @c @::glEnable(), e.g. using global namespace) might be affected by changes in `OpenGl_GlFunctions.hxx`.
This header, as well as `OpenGl_GlCore20.hxx` and similar, no more include system OpenGL / OpenGL ES headers to define function table.
Application code calling OpenGL functions directly should be changed to either use `OpenGl_Context::core11fwd` (as designed)
or to include system OpenGL headers in advance (with help of `OpenGl_GlNative.hxx`).

View File

@ -56,7 +56,6 @@ D3DHost_FrameBuffer::~D3DHost_FrameBuffer()
// =======================================================================
void D3DHost_FrameBuffer::Release (OpenGl_Context* theCtx)
{
#if !defined(GL_ES_VERSION_2_0)
if (myGlD3dDevice != NULL)
{
const OpenGl_GlFunctions* aFuncs = (theCtx != NULL && theCtx->IsValid())
@ -77,7 +76,6 @@ void D3DHost_FrameBuffer::Release (OpenGl_Context* theCtx)
}
myGlD3dDevice = NULL;
}
#endif
if (myD3dSurf != NULL)
{
@ -146,7 +144,7 @@ Standard_Boolean D3DHost_FrameBuffer::InitD3dInterop (const Handle(OpenGl_Contex
const Standard_Integer theDepthFormat)
{
Release (theCtx.operator->());
#if !defined(GL_ES_VERSION_2_0)
myDepthFormat = theDepthFormat;
myVPSizeX = theSizeX;
myVPSizeY = theSizeY;
@ -207,14 +205,6 @@ Standard_Boolean D3DHost_FrameBuffer::InitD3dInterop (const Handle(OpenGl_Contex
myD3dFallback = Standard_False;
return Standard_True;
#else
(void )theD3DDevice;
(void )theIsD3dEx;
(void )theSizeX;
(void )theSizeY;
(void )theDepthFormat;
return Standard_False;
#endif
}
// =======================================================================
@ -223,10 +213,6 @@ Standard_Boolean D3DHost_FrameBuffer::InitD3dInterop (const Handle(OpenGl_Contex
// =======================================================================
Standard_Boolean D3DHost_FrameBuffer::registerD3dBuffer (const Handle(OpenGl_Context)& theCtx)
{
#if defined(GL_ES_VERSION_2_0)
(void )theCtx;
return Standard_False;
#else
const OpenGl_GlFunctions* aFuncs = theCtx->Functions();
if (myGlD3dSurf != NULL)
{
@ -264,7 +250,6 @@ Standard_Boolean D3DHost_FrameBuffer::registerD3dBuffer (const Handle(OpenGl_Con
}
return Standard_True;
#endif
}
// =======================================================================
@ -292,35 +277,15 @@ void D3DHost_FrameBuffer::BindBuffer (const Handle(OpenGl_Context)& theCtx)
const OpenGl_TextureFormat aDepthFormat = OpenGl_TextureFormat::FindSizedFormat (theCtx, myDepthFormat);
if (myDepthStencilTexture->IsValid())
{
#ifdef GL_DEPTH_STENCIL_ATTACHMENT
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
#else
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
if (aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL)
{
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
}
#endif
}
if (theCtx->arbFBO->glCheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
if (myDepthStencilTexture->IsValid())
{
#ifdef GL_DEPTH_STENCIL_ATTACHMENT
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
myDepthStencilTexture->GetTarget(), 0, 0);
#else
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
myDepthStencilTexture->GetTarget(), 0, 0);
if (aDepthFormat.PixelFormat() == GL_DEPTH_STENCIL)
{
theCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
myDepthStencilTexture->GetTarget(), 0, 0);
}
#endif
}
if (theCtx->arbFBO->glCheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
@ -353,16 +318,12 @@ void D3DHost_FrameBuffer::LockSurface (const Handle(OpenGl_Context)& theCtx)
return;
}
#if !defined(GL_ES_VERSION_2_0)
const OpenGl_GlFunctions* aFuncs = theCtx->Functions();
if (!aFuncs->wglDXLockObjectsNV (myGlD3dDevice, 1, &myGlD3dSurf))
{
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
"D3DHost_FrameBuffer::LockSurface(), lock failed!");
}
#else
(void )theCtx;
#endif
}
// =======================================================================
@ -416,8 +377,6 @@ void D3DHost_FrameBuffer::UnlockSurface (const Handle(OpenGl_Context)& theCtx)
return;
}
#if !defined(GL_ES_VERSION_2_0)
const OpenGl_GlFunctions* aFuncs = theCtx->Functions();
aFuncs->wglDXUnlockObjectsNV (myGlD3dDevice, 1, &myGlD3dSurf);
#endif
}

View File

@ -15,8 +15,6 @@
#include <OpenGl_Caps.hxx>
#include <OpenGl_GlCore20.hxx>
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Caps,Standard_Transient)
// =======================================================================
@ -40,11 +38,7 @@ OpenGl_Caps::OpenGl_Caps()
contextDebug (Standard_False),
contextSyncDebug (Standard_False),
contextNoAccel (Standard_False),
#if !defined(GL_ES_VERSION_2_0)
contextCompatible (Standard_True),
#else
contextCompatible (Standard_False),
#endif
contextNoExtensions (Standard_False),
contextMajorVersionUpper (-1),
contextMinorVersionUpper (-1),

View File

@ -2533,9 +2533,7 @@ void OpenGl_Context::SetPointSpriteOrigin()
if (myPointSpriteOrig != aNewState)
{
myPointSpriteOrig = aNewState;
#if !defined(GL_ES_VERSION_2_0)
core15fwd->glPointParameteri (GL_POINT_SPRITE_COORD_ORIGIN, aNewState);
#endif
}
}

View File

@ -90,11 +90,11 @@ void OpenGl_Context::SwapBuffers()
return;
}
::glBindRenderbuffer (GL_RENDERBUFFER, myDefaultFbo->ColorRenderBuffer());
myFuncs->glBindRenderbuffer (GL_RENDERBUFFER, myDefaultFbo->ColorRenderBuffer());
[myGContext presentRenderbuffer: GL_RENDERBUFFER];
//::glBindRenderbuffer (GL_RENDERBUFFER, 0);
#else
glFinish();
core11fwd->glFinish();
[myGContext flushBuffer];
#endif
}

View File

@ -16,8 +16,6 @@
#ifndef OpenGl_GlFunctions_HeaderFile
#define OpenGl_GlFunctions_HeaderFile
#include <OpenGl_GlNative.hxx>
#include <Standard_Macro.hxx>
#include <Standard_TypeDef.hxx>

View File

@ -14,6 +14,38 @@
#ifndef OpenGl_GlTypes_HeaderFile
#define OpenGl_GlTypes_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
#if defined(__APPLE__)
#import <TargetConditionals.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 <OpenGl_khrplatform.h>
typedef khronos_int8_t GLbyte;

View File

@ -173,6 +173,9 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnectio
myEglDisplay = (Aspect_Display )EGL_NO_DISPLAY;
myEglContext = (Aspect_RenderingContext )EGL_NO_CONTEXT;
#endif
#if defined(OpenGl_USE_GLES2)
myCaps->contextCompatible = false;
#endif
#if defined(HAVE_XLIB)
if (myDisplayConnection.IsNull())

View File

@ -388,7 +388,6 @@ Standard_Boolean OpenGl_RaytraceGeometry::AcquireTextures (const Handle(OpenGl_C
return Standard_True;
}
#if !defined(GL_ES_VERSION_2_0)
Standard_Integer aTexIter = 0;
for (NCollection_Vector<Handle(OpenGl_Texture)>::Iterator aTexSrcIter (myTextures); aTexSrcIter.More(); aTexSrcIter.Next(), ++aTexIter)
{
@ -425,7 +424,6 @@ Standard_Boolean OpenGl_RaytraceGeometry::AcquireTextures (const Handle(OpenGl_C
return Standard_False;
}
}
#endif
return Standard_True;
}
@ -441,7 +439,6 @@ Standard_Boolean OpenGl_RaytraceGeometry::ReleaseTextures (const Handle(OpenGl_C
return Standard_True;
}
#if !defined(GL_ES_VERSION_2_0)
for (size_t aTexIter = 0; aTexIter < myTextureHandles.size(); ++aTexIter)
{
theContext->arbTexBindless->glMakeTextureHandleNonResidentARB (myTextureHandles[aTexIter]);
@ -453,7 +450,6 @@ Standard_Boolean OpenGl_RaytraceGeometry::ReleaseTextures (const Handle(OpenGl_C
return Standard_False;
}
}
#endif
return Standard_True;
}
@ -499,7 +495,6 @@ Standard_Boolean OpenGl_RaytraceGeometry::UpdateTextureHandles (const Handle(Ope
myTextureHandles.clear();
myTextureHandles.resize (myTextures.Size());
#if !defined(GL_ES_VERSION_2_0)
Standard_Integer aTexIter = 0;
for (NCollection_Vector<Handle(OpenGl_Texture)>::Iterator aTexSrcIter (myTextures); aTexSrcIter.More(); aTexSrcIter.Next(), ++aTexIter)
{
@ -524,7 +519,6 @@ Standard_Boolean OpenGl_RaytraceGeometry::UpdateTextureHandles (const Handle(Ope
return Standard_False;
}
}
#endif
return Standard_True;
}

View File

@ -13,6 +13,10 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#if defined(_WIN32)
#include <windows.h>
#endif
#include <OpenGl_GlCore12.hxx>
#include <OpenGl_Context.hxx>

View File

@ -326,12 +326,12 @@ void OpenGl_Window::Init()
EAGLContext* aGLCtx = myGlContext->myGContext;
CAEAGLLayer* anEaglLayer = (CAEAGLLayer* )myUIView.layer;
GLuint aWinRBColor = 0;
::glGenRenderbuffers (1, &aWinRBColor);
::glBindRenderbuffer (GL_RENDERBUFFER, aWinRBColor);
myGlContext->Functions()->glGenRenderbuffers (1, &aWinRBColor);
myGlContext->Functions()->glBindRenderbuffer (GL_RENDERBUFFER, aWinRBColor);
[aGLCtx renderbufferStorage: GL_RENDERBUFFER fromDrawable: anEaglLayer];
::glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &myWidth);
::glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &myHeight);
::glBindRenderbuffer (GL_RENDERBUFFER, 0);
myGlContext->Functions()->glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &myWidth);
myGlContext->Functions()->glGetRenderbufferParameteriv (GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &myHeight);
myGlContext->Functions()->glBindRenderbuffer (GL_RENDERBUFFER, 0);
if (!aDefFbo->InitWithRB (myGlContext, Graphic3d_Vec2i (myWidth, myHeight), GL_RGBA8, GL_DEPTH24_STENCIL8, aWinRBColor))
{
@ -380,16 +380,17 @@ Standard_ENABLE_DEPRECATION_WARNINGS
myHeightPt = Standard_Integer(aBounds.size.height);
#endif
::glDisable (GL_DITHER);
::glDisable (GL_SCISSOR_TEST);
::glViewport (0, 0, myWidth, myHeight);
#if !defined(GL_ES_VERSION_2_0)
::glDrawBuffer (GL_BACK);
if (myGlContext->core11ffp != NULL)
myGlContext->core11fwd->glDisable (GL_DITHER);
myGlContext->core11fwd->glDisable (GL_SCISSOR_TEST);
myGlContext->core11fwd->glViewport (0, 0, myWidth, myHeight);
if (myGlContext->GraphicsLibrary() != Aspect_GraphicsLibrary_OpenGLES)
{
::glMatrixMode (GL_MODELVIEW);
myGlContext->core11fwd->glDrawBuffer (GL_BACK);
if (myGlContext->core11ffp != NULL)
{
myGlContext->core11ffp->glMatrixMode (GL_MODELVIEW);
}
}
#endif
}
// =======================================================================