mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0029075: Configuration - fix TKService linkage errors due to usage of GLX functions while using EGL
Xw_Window, fixed usage of GLX functions for choosing Visual when building with HAVE_EGL/HAVE_GLES2 options.
This commit is contained in:
parent
be7fc29e2a
commit
1136702b93
@ -59,7 +59,7 @@ vdimension ad_1 -angle -shapes as_38 as_49 -color black
|
|||||||
vdimension ad_2 -angle -shapes bs_24 bs_25 -color black
|
vdimension ad_2 -angle -shapes bs_24 bs_25 -color black
|
||||||
vdimension ad_3 -angle -shapes as_48 as_43 -color black
|
vdimension ad_3 -angle -shapes as_48 as_43 -color black
|
||||||
|
|
||||||
puts "Changing text and arrow paramaters of dimensions..."
|
puts "Changing text and arrow parameters of dimensions..."
|
||||||
foreach i $aList {
|
foreach i $aList {
|
||||||
vdimparam $i -text 3d sh 6 -arrowlength 4 -arrowangle $anArrAngle
|
vdimparam $i -text 3d sh 6 -arrowlength 4 -arrowangle $anArrAngle
|
||||||
}
|
}
|
||||||
|
@ -155,10 +155,7 @@ void VUserDrawObj::ComputeSelection (const Handle(SelectMgr_Selection)& theSelec
|
|||||||
|
|
||||||
void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
|
void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||||
{
|
{
|
||||||
// this sample does not use GLSL programs - make sure it is disabled
|
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
|
||||||
Handle(OpenGl_Context) aCtx = theWorkspace->GetGlContext();
|
|
||||||
aCtx->BindProgram (Handle(OpenGl_ShaderProgram)());
|
|
||||||
aCtx->ShaderManager()->PushState (Handle(OpenGl_ShaderProgram)());
|
|
||||||
|
|
||||||
// To test linking against OpenGl_Workspace and all aspect classes
|
// To test linking against OpenGl_Workspace and all aspect classes
|
||||||
const OpenGl_AspectMarker* aMA = theWorkspace->AspectMarker();
|
const OpenGl_AspectMarker* aMA = theWorkspace->AspectMarker();
|
||||||
@ -167,19 +164,24 @@ void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
|
|||||||
aTA->Aspect()->Font();
|
aTA->Aspect()->Font();
|
||||||
OpenGl_Vec4 aColor = theWorkspace->LineColor();
|
OpenGl_Vec4 aColor = theWorkspace->LineColor();
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
aCtx->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), false, false, false, Handle(OpenGl_ShaderProgram)());
|
||||||
|
aCtx->SetColor4fv (aColor);
|
||||||
|
|
||||||
|
const OpenGl_Vec3 aVertArray[4] =
|
||||||
|
{
|
||||||
|
OpenGl_Vec3(myCoords[0], myCoords[1], myCoords[2]),
|
||||||
|
OpenGl_Vec3(myCoords[3], myCoords[4], myCoords[2]),
|
||||||
|
OpenGl_Vec3(myCoords[3], myCoords[4], myCoords[5]),
|
||||||
|
OpenGl_Vec3(myCoords[0], myCoords[1], myCoords[5]),
|
||||||
|
};
|
||||||
|
Handle(OpenGl_VertexBuffer) aVertBuffer = new OpenGl_VertexBuffer();
|
||||||
|
aVertBuffer->Init (aCtx, 3, 4, aVertArray[0].GetData());
|
||||||
|
|
||||||
// Finally draw something to make sure UserDraw really works
|
// Finally draw something to make sure UserDraw really works
|
||||||
glPushAttrib(GL_ENABLE_BIT);
|
aVertBuffer->BindAttribute (aCtx, Graphic3d_TOA_POS);
|
||||||
glDisable(GL_LIGHTING);
|
glDrawArrays(GL_LINE_LOOP, 0, aVertBuffer->GetElemsNb());
|
||||||
glColor4fv(aColor.GetData());
|
aVertBuffer->UnbindAttribute(aCtx, Graphic3d_TOA_POS);
|
||||||
glBegin(GL_LINE_LOOP);
|
aVertBuffer->Release (aCtx.get());
|
||||||
glVertex3f(myCoords[0], myCoords[1], myCoords[2]);
|
|
||||||
glVertex3f(myCoords[3], myCoords[4], myCoords[2]);
|
|
||||||
glVertex3f(myCoords[3], myCoords[4], myCoords[5]);
|
|
||||||
glVertex3f(myCoords[0], myCoords[1], myCoords[5]);
|
|
||||||
glEnd();
|
|
||||||
glPopAttrib();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
@ -19,10 +19,13 @@
|
|||||||
|
|
||||||
#include <Aspect_Convert.hxx>
|
#include <Aspect_Convert.hxx>
|
||||||
#include <Aspect_WindowDefinitionError.hxx>
|
#include <Aspect_WindowDefinitionError.hxx>
|
||||||
|
#include <Message.hxx>
|
||||||
|
#include <Message_Messenger.hxx>
|
||||||
|
|
||||||
#include <GL/glx.h>
|
#if defined(HAVE_EGL) || defined(HAVE_GLES2)
|
||||||
|
#include <EGL/egl.h>
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(Xw_Window,Aspect_Window)
|
#else
|
||||||
|
#include <GL/glx.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -52,6 +55,10 @@ namespace
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IMPLEMENT_STANDARD_RTTIEXT(Xw_Window, Aspect_Window)
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : Xw_Window
|
// function : Xw_Window
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -73,7 +80,6 @@ Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
|||||||
myYBottom (thePxTop + thePxHeight),
|
myYBottom (thePxTop + thePxHeight),
|
||||||
myIsOwnWin (Standard_True)
|
myIsOwnWin (Standard_True)
|
||||||
{
|
{
|
||||||
int aDummy = 0;
|
|
||||||
if (thePxWidth <= 0 || thePxHeight <= 0)
|
if (thePxWidth <= 0 || thePxHeight <= 0)
|
||||||
{
|
{
|
||||||
throw Aspect_WindowDefinitionError("Xw_Window, Coordinate(s) out of range");
|
throw Aspect_WindowDefinitionError("Xw_Window, Coordinate(s) out of range");
|
||||||
@ -83,17 +89,68 @@ Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
|||||||
throw Aspect_WindowDefinitionError("Xw_Window, X Display connection is undefined");
|
throw Aspect_WindowDefinitionError("Xw_Window, X Display connection is undefined");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!glXQueryExtension (myDisplay->GetDisplay(), &aDummy, &aDummy))
|
|
||||||
{
|
|
||||||
throw Aspect_WindowDefinitionError("Xw_Window, GLX extension is unavailable");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Display* aDisp = myDisplay->GetDisplay();
|
Display* aDisp = myDisplay->GetDisplay();
|
||||||
int aScreen = DefaultScreen(aDisp);
|
int aScreen = DefaultScreen(aDisp);
|
||||||
Window aParent = RootWindow (aDisp, aScreen);
|
Window aParent = RootWindow (aDisp, aScreen);
|
||||||
XVisualInfo* aVisInfo = NULL;
|
XVisualInfo* aVisInfo = NULL;
|
||||||
|
|
||||||
|
#if defined(HAVE_EGL) || defined(HAVE_GLES2)
|
||||||
|
EGLDisplay anEglDisplay = eglGetDisplay (aDisp);
|
||||||
|
EGLint aVerMajor = 0; EGLint aVerMinor = 0;
|
||||||
|
XVisualInfo aVisInfoTmp; memset (&aVisInfoTmp, 0, sizeof(aVisInfoTmp));
|
||||||
|
if (anEglDisplay != EGL_NO_DISPLAY
|
||||||
|
&& eglInitialize (anEglDisplay, &aVerMajor, &aVerMinor) == EGL_TRUE)
|
||||||
|
{
|
||||||
|
EGLint aConfigAttribs[] =
|
||||||
|
{
|
||||||
|
EGL_RED_SIZE, 8,
|
||||||
|
EGL_GREEN_SIZE, 8,
|
||||||
|
EGL_BLUE_SIZE, 8,
|
||||||
|
EGL_ALPHA_SIZE, 0,
|
||||||
|
EGL_DEPTH_SIZE, 24,
|
||||||
|
EGL_STENCIL_SIZE, 8,
|
||||||
|
#if defined(HAVE_GLES2)
|
||||||
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||||
|
#else
|
||||||
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||||
|
#endif
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
|
||||||
|
EGLint aNbConfigs = 0;
|
||||||
|
void* anEglConfig = NULL;
|
||||||
|
if (eglChooseConfig (anEglDisplay, aConfigAttribs, &anEglConfig, 1, &aNbConfigs) != EGL_TRUE
|
||||||
|
|| anEglConfig == NULL)
|
||||||
|
{
|
||||||
|
eglGetError();
|
||||||
|
aConfigAttribs[4 * 2 + 1] = 16; // try config with smaller depth buffer
|
||||||
|
if (eglChooseConfig (anEglDisplay, aConfigAttribs, &anEglConfig, 1, &aNbConfigs) != EGL_TRUE
|
||||||
|
|| anEglConfig == NULL)
|
||||||
|
{
|
||||||
|
anEglConfig = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anEglConfig != NULL
|
||||||
|
&& eglGetConfigAttrib (anEglDisplay, anEglConfig, EGL_NATIVE_VISUAL_ID, (EGLint* )&aVisInfoTmp.visualid) == EGL_TRUE)
|
||||||
|
{
|
||||||
|
int aNbVisuals = 0;
|
||||||
|
aVisInfoTmp.screen = DefaultScreen (aDisp);
|
||||||
|
aVisInfo = XGetVisualInfo (aDisp, VisualIDMask | VisualScreenMask, &aVisInfoTmp, &aNbVisuals);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (aVisInfo == NULL)
|
||||||
|
{
|
||||||
|
Message::DefaultMessenger()->Send ("Warning: cannot choose Visual using EGL while creating Xw_Window", Message_Warning);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int aDummy = 0;
|
||||||
|
if (!glXQueryExtension (myDisplay->GetDisplay(), &aDummy, &aDummy))
|
||||||
|
{
|
||||||
|
throw Aspect_WindowDefinitionError("Xw_Window, GLX extension is unavailable");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (myFBConfig == NULL)
|
if (myFBConfig == NULL)
|
||||||
{
|
{
|
||||||
// FBConfigs were added in GLX version 1.3
|
// FBConfigs were added in GLX version 1.3
|
||||||
@ -128,23 +185,31 @@ Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
|||||||
throw Aspect_WindowDefinitionError("Xw_Window, couldn't find compatible Visual (RGBA, double-buffered)");
|
throw Aspect_WindowDefinitionError("Xw_Window, couldn't find compatible Visual (RGBA, double-buffered)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
unsigned long aMask = 0;
|
unsigned long aMask = 0;
|
||||||
XSetWindowAttributes aWinAttr;
|
XSetWindowAttributes aWinAttr;
|
||||||
memset(&aWinAttr, 0, sizeof(XSetWindowAttributes));
|
memset(&aWinAttr, 0, sizeof(XSetWindowAttributes));
|
||||||
aWinAttr.event_mask = ExposureMask | StructureNotifyMask;
|
aWinAttr.event_mask = ExposureMask | StructureNotifyMask;
|
||||||
aMask |= CWEventMask;
|
aMask |= CWEventMask;
|
||||||
aWinAttr.colormap = XCreateColormap(aDisp, aParent, aVisInfo->visual, AllocNone);
|
if (aVisInfo != NULL)
|
||||||
|
{
|
||||||
|
aWinAttr.colormap = XCreateColormap(aDisp, aParent, aVisInfo->visual, AllocNone);
|
||||||
|
}
|
||||||
aWinAttr.border_pixel = 0;
|
aWinAttr.border_pixel = 0;
|
||||||
aWinAttr.override_redirect = False;
|
aWinAttr.override_redirect = False;
|
||||||
|
|
||||||
myXWindow = XCreateWindow(aDisp, aParent,
|
myXWindow = XCreateWindow(aDisp, aParent,
|
||||||
myXLeft, myYTop, thePxWidth, thePxHeight,
|
myXLeft, myYTop, thePxWidth, thePxHeight,
|
||||||
0, aVisInfo->depth,
|
0, aVisInfo != NULL ? aVisInfo->depth : CopyFromParent,
|
||||||
InputOutput,
|
InputOutput,
|
||||||
aVisInfo->visual,
|
aVisInfo != NULL ? aVisInfo->visual : CopyFromParent,
|
||||||
CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &aWinAttr);
|
CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &aWinAttr);
|
||||||
XFree (aVisInfo); aVisInfo = NULL;
|
if (aVisInfo != NULL)
|
||||||
|
{
|
||||||
|
XFree (aVisInfo);
|
||||||
|
aVisInfo = NULL;
|
||||||
|
}
|
||||||
if (myXWindow == 0)
|
if (myXWindow == 0)
|
||||||
{
|
{
|
||||||
throw Aspect_WindowDefinitionError("Xw_Window, Unable to create window");
|
throw Aspect_WindowDefinitionError("Xw_Window, Unable to create window");
|
||||||
@ -189,7 +254,6 @@ Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
|||||||
myYBottom (512),
|
myYBottom (512),
|
||||||
myIsOwnWin (Standard_False)
|
myIsOwnWin (Standard_False)
|
||||||
{
|
{
|
||||||
int aDummy = 0;
|
|
||||||
if (theXWin == 0)
|
if (theXWin == 0)
|
||||||
{
|
{
|
||||||
throw Aspect_WindowDefinitionError("Xw_Window, given invalid X window");
|
throw Aspect_WindowDefinitionError("Xw_Window, given invalid X window");
|
||||||
@ -200,24 +264,25 @@ Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
|||||||
throw Aspect_WindowDefinitionError("Xw_Window, X Display connection is undefined");
|
throw Aspect_WindowDefinitionError("Xw_Window, X Display connection is undefined");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!glXQueryExtension (myDisplay->GetDisplay(), &aDummy, &aDummy))
|
#if !defined(HAVE_EGL) && !defined(HAVE_GLES2)
|
||||||
|
int aDummy = 0;
|
||||||
|
if (!glXQueryExtension (myDisplay->GetDisplay(), &aDummy, &aDummy))
|
||||||
{
|
{
|
||||||
myXWindow = 0;
|
myXWindow = 0;
|
||||||
throw Aspect_WindowDefinitionError("Xw_Window, GLX extension is unavailable");
|
throw Aspect_WindowDefinitionError("Xw_Window, GLX extension is unavailable");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Display* aDisp = myDisplay->GetDisplay();
|
Display* aDisp = myDisplay->GetDisplay();
|
||||||
|
|
||||||
XWindowAttributes aWinAttr;
|
XWindowAttributes aWinAttr;
|
||||||
XGetWindowAttributes (aDisp, myXWindow, &aWinAttr);
|
XGetWindowAttributes (aDisp, myXWindow, &aWinAttr);
|
||||||
const int aScreen = DefaultScreen (aDisp);
|
|
||||||
const long aVisInfoMask = VisualIDMask | VisualScreenMask;
|
|
||||||
XVisualInfo aVisInfoTmp;
|
XVisualInfo aVisInfoTmp;
|
||||||
aVisInfoTmp.visualid = aWinAttr.visual->visualid;
|
aVisInfoTmp.visualid = aWinAttr.visual->visualid;
|
||||||
aVisInfoTmp.screen = aScreen;
|
aVisInfoTmp.screen = DefaultScreen (aDisp);
|
||||||
int aNbItems = 0;
|
int aNbItems = 0;
|
||||||
XVisualInfo* aVisInfo = XGetVisualInfo (aDisp, aVisInfoMask, &aVisInfoTmp, &aNbItems);
|
XVisualInfo* aVisInfo = XGetVisualInfo (aDisp, VisualIDMask | VisualScreenMask, &aVisInfoTmp, &aNbItems);
|
||||||
if (aVisInfo == NULL)
|
if (aVisInfo == NULL)
|
||||||
{
|
{
|
||||||
throw Aspect_WindowDefinitionError("Xw_Window, Visual is unavailable");
|
throw Aspect_WindowDefinitionError("Xw_Window, Visual is unavailable");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user