mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-19 13:40:49 +03:00
0026732: Visualization, TKOpenGl - add option to request Core profile 3.2+ using GLX
Aspect_Window::NativeFBConfig() - extend interface with new method. Xw_Window - add Aspect_FBConfig option to constructors, use glXChooseFBConfig() instead of glXChooseVisual() on GLX1.3+. OpenGl_Window - create context using glXCreateContextAttribsARB() when GLXFBConfig is provided by Aspect_Window. This procedure now handles Core Profile and Debug Context options on Linux. OpenGl_Window - drop code implicitly creating child window when window XVisual is incomplete for OpenGL context. This should eliminate event-handling issues at application side, but would require window to be properly created by application.
This commit is contained in:
56
src/Xw/Xw_Window.cxx
Executable file → Normal file
56
src/Xw/Xw_Window.cxx
Executable file → Normal file
@@ -26,8 +26,7 @@ namespace
|
||||
{
|
||||
|
||||
//! Search for RGBA double-buffered visual with stencil buffer.
|
||||
//! Each size property should be a nonnegative minimum specification.
|
||||
static int TheDoubleBuff[] =
|
||||
static int TheDoubleBuffVisual[] =
|
||||
{
|
||||
GLX_RGBA,
|
||||
GLX_DEPTH_SIZE, 16,
|
||||
@@ -36,8 +35,20 @@ namespace
|
||||
None
|
||||
};
|
||||
|
||||
};
|
||||
//! Search for RGBA double-buffered visual with stencil buffer.
|
||||
static int TheDoubleBuffFBConfig[] =
|
||||
{
|
||||
GLX_X_RENDERABLE, True,
|
||||
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
|
||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||
GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
|
||||
GLX_DEPTH_SIZE, 16,
|
||||
GLX_STENCIL_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER, True,
|
||||
None
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Xw_Window
|
||||
@@ -48,10 +59,12 @@ Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
||||
const Standard_Integer thePxLeft,
|
||||
const Standard_Integer thePxTop,
|
||||
const Standard_Integer thePxWidth,
|
||||
const Standard_Integer thePxHeight)
|
||||
const Standard_Integer thePxHeight,
|
||||
const Aspect_FBConfig theFBConfig)
|
||||
: Aspect_Window(),
|
||||
myDisplay (theXDisplay),
|
||||
myXWindow (0),
|
||||
myFBConfig (theFBConfig),
|
||||
myXLeft (thePxLeft),
|
||||
myYTop (thePxTop),
|
||||
myXRight (thePxLeft + thePxWidth),
|
||||
@@ -77,8 +90,37 @@ Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
||||
Display* aDisp = myDisplay->GetDisplay();
|
||||
int aScreen = DefaultScreen(aDisp);
|
||||
Window aParent = RootWindow (aDisp, aScreen);
|
||||
XVisualInfo* aVisInfo = NULL;
|
||||
|
||||
XVisualInfo* aVisInfo = glXChooseVisual (aDisp, aScreen, TheDoubleBuff);
|
||||
if (myFBConfig == NULL)
|
||||
{
|
||||
// FBConfigs were added in GLX version 1.3
|
||||
int aGlxMajor = 0;
|
||||
int aGlxMinor = 0;
|
||||
const bool hasFBCfg = glXQueryVersion (aDisp, &aGlxMajor, &aGlxMinor)
|
||||
&& ((aGlxMajor == 1 && aGlxMinor >= 3) || (aGlxMajor > 1));
|
||||
if (hasFBCfg)
|
||||
{
|
||||
int aFBCount = 0;
|
||||
GLXFBConfig* aFBCfgList = NULL;
|
||||
if (hasFBCfg)
|
||||
{
|
||||
aFBCfgList = glXChooseFBConfig (aDisp, aScreen, TheDoubleBuffFBConfig, &aFBCount);
|
||||
}
|
||||
if(aFBCfgList != NULL
|
||||
&& aFBCount >= 1)
|
||||
{
|
||||
myFBConfig = aFBCfgList[0];
|
||||
aVisInfo = glXGetVisualFromFBConfig (aDisp, myFBConfig);
|
||||
}
|
||||
XFree (aFBCfgList);
|
||||
}
|
||||
}
|
||||
|
||||
if (aVisInfo == NULL)
|
||||
{
|
||||
aVisInfo = glXChooseVisual (aDisp, aScreen, TheDoubleBuffVisual);
|
||||
}
|
||||
if (aVisInfo == NULL)
|
||||
{
|
||||
Aspect_WindowDefinitionError::Raise ("Xw_Window, couldn't find compatible Visual (RGBA, double-buffered)");
|
||||
@@ -133,10 +175,12 @@ Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Xw_Window::Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
||||
const Window theXWin)
|
||||
const Window theXWin,
|
||||
const Aspect_FBConfig theFBConfig)
|
||||
: Aspect_Window(),
|
||||
myDisplay (theXDisplay),
|
||||
myXWindow (theXWin),
|
||||
myFBConfig (theFBConfig),
|
||||
myXLeft (0),
|
||||
myYTop (0),
|
||||
myXRight (512),
|
||||
|
33
src/Xw/Xw_Window.hxx
Executable file → Normal file
33
src/Xw/Xw_Window.hxx
Executable file → Normal file
@@ -50,11 +50,13 @@ public:
|
||||
const Standard_Integer thePxLeft,
|
||||
const Standard_Integer thePxTop,
|
||||
const Standard_Integer thePxWidth,
|
||||
const Standard_Integer thePxHeight);
|
||||
const Standard_Integer thePxHeight,
|
||||
const Aspect_FBConfig theFBConfig = NULL);
|
||||
|
||||
//! Creates a wrapper over existing Window handle
|
||||
Standard_EXPORT Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
|
||||
const Window theXWin);
|
||||
const Window theXWin,
|
||||
const Aspect_FBConfig theFBConfig = NULL);
|
||||
|
||||
//! Destroies the Window and all resourses attached to it
|
||||
Standard_EXPORT virtual void Destroy();
|
||||
@@ -65,32 +67,32 @@ public:
|
||||
}
|
||||
|
||||
//! Opens the window <me>
|
||||
Standard_EXPORT virtual void Map() const;
|
||||
Standard_EXPORT virtual void Map() const Standard_OVERRIDE;
|
||||
|
||||
//! Closes the window <me>
|
||||
Standard_EXPORT virtual void Unmap() const;
|
||||
Standard_EXPORT virtual void Unmap() const Standard_OVERRIDE;
|
||||
|
||||
//! Applies the resizing to the window <me>
|
||||
Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const;
|
||||
Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE;
|
||||
|
||||
//! Apply the mapping change to the window <me>
|
||||
Standard_EXPORT virtual Standard_Boolean DoMapping() const;
|
||||
Standard_EXPORT virtual Standard_Boolean DoMapping() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns True if the window <me> is opened
|
||||
Standard_EXPORT virtual Standard_Boolean IsMapped() const;
|
||||
Standard_EXPORT virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
|
||||
Standard_EXPORT virtual Quantity_Ratio Ratio() const;
|
||||
Standard_EXPORT virtual Quantity_Ratio Ratio() const Standard_OVERRIDE;
|
||||
|
||||
//! Returns The Window POSITION in PIXEL
|
||||
Standard_EXPORT virtual void Position (Standard_Integer& X1,
|
||||
Standard_Integer& Y1,
|
||||
Standard_Integer& X2,
|
||||
Standard_Integer& Y2) const;
|
||||
Standard_Integer& Y2) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns The Window SIZE in PIXEL
|
||||
Standard_EXPORT virtual void Size (Standard_Integer& theWidth,
|
||||
Standard_Integer& theHeight) const;
|
||||
Standard_Integer& theHeight) const Standard_OVERRIDE;
|
||||
|
||||
//! @return native Window handle
|
||||
Standard_EXPORT Window XWindow() const;
|
||||
@@ -99,21 +101,28 @@ public:
|
||||
Standard_EXPORT const Handle(Aspect_DisplayConnection)& DisplayConnection() const;
|
||||
|
||||
//! @return native Window handle
|
||||
virtual Aspect_Drawable NativeHandle() const
|
||||
virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE
|
||||
{
|
||||
return (Aspect_Drawable )XWindow();
|
||||
}
|
||||
|
||||
//! @return parent of native Window handle
|
||||
virtual Aspect_Drawable NativeParentHandle() const
|
||||
virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! @return native Window FB config (GLXFBConfig on Xlib)
|
||||
virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE
|
||||
{
|
||||
return myFBConfig;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Aspect_DisplayConnection) myDisplay; //!< X Display connection
|
||||
Window myXWindow; //!< XLib window handle
|
||||
Aspect_FBConfig myFBConfig; //!< GLXFBConfig
|
||||
Standard_Integer myXLeft; //!< left position in pixels
|
||||
Standard_Integer myYTop; //!< top position in pixels
|
||||
Standard_Integer myXRight; //!< right position in pixels
|
||||
|
Reference in New Issue
Block a user