Kaydet (Commit) d8719aa0 authored tarafından Zolnai Tamás's avatar Zolnai Tamás

OpenGLContext: Provide all data for SystemChildWindow creation.

Change-Id: I7a0ceee6c784af8240fb908f19622d4ede1f5a6a
üst d276ad15
...@@ -157,6 +157,8 @@ public: ...@@ -157,6 +157,8 @@ public:
return mbInitialized; return mbInitialized;
} }
static SystemWindowData generateWinData(Window* pParent);
private: private:
SAL_DLLPRIVATE bool initWindow(); SAL_DLLPRIVATE bool initWindow();
......
...@@ -684,4 +684,93 @@ bool OpenGLContext::initWindow() ...@@ -684,4 +684,93 @@ bool OpenGLContext::initWindow()
#endif #endif
#if defined( WNT ) || defined( MACOSX ) || defined( IOS) || defined( ANDROID )
SystemWindowData OpenGLContext::generateWinData(Window* /*pParent*/)
{
SystemWindowData aWinData;
aWinData.nSize = sizeof(aWinData);
return aWinData;
}
#elif defined( UNX )
SystemWindowData OpenGLContext::generateWinData(Window* pParent)
{
SystemWindowData aWinData;
aWinData.nSize = sizeof(aWinData);
const SystemEnvData* sysData(pParent->GetSystemData());
Display *dpy = reinterpret_cast<Display*>(sysData->pDisplay);
if( !glXQueryExtension( dpy, NULL, NULL ) )
return aWinData;
XLIB_Window win = sysData->aWindow;
SAL_INFO("vcl.opengl", "parent window: " << win);
XWindowAttributes xattr;
XGetWindowAttributes( dpy, win, &xattr );
int screen = XScreenNumberOfScreen( xattr.screen );
static int visual_attribs[] =
{
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_ALPHA_SIZE, 8,
GLX_DEPTH_SIZE, 24,
GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
None
};
initOpenGLFunctionPointers();
int fbCount = 0;
GLXFBConfig* pFBC = glXChooseFBConfig( dpy,
screen,
visual_attribs, &fbCount );
if(!pFBC)
{
SAL_WARN("vcl.opengl", "no suitable fb format found");
return aWinData;
}
int best_fbc = -1, best_num_samp = -1;
for(int i = 0; i < fbCount; ++i)
{
XVisualInfo* pVi = glXGetVisualFromFBConfig( dpy, pFBC[i] );
if(pVi)
{
// pick the one with the most samples per pixel
int nSampleBuf = 0;
int nSamples = 0;
glXGetFBConfigAttrib( dpy, pFBC[i], GLX_SAMPLE_BUFFERS, &nSampleBuf );
glXGetFBConfigAttrib( dpy, pFBC[i], GLX_SAMPLES , &nSamples );
if ( best_fbc < 0 || (nSampleBuf && ( nSamples > best_num_samp )) )
{
best_fbc = i;
best_num_samp = nSamples;
}
}
XFree( pVi );
}
XVisualInfo* vi = glXGetVisualFromFBConfig( dpy, pFBC[best_fbc] );
if( vi )
{
SAL_INFO("vcl.opengl", "using VisualID " << vi->visualid);
aWinData.pVisual = (void*)(vi->visual);
}
return aWinData;
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment