diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-04-27 12:09:20 +0200 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-04-27 12:34:05 +0200 |
commit | d8719aa04aa219d95b84bee9e6bd416d3e0a9207 (patch) | |
tree | 0df0eaa3b8d2c6924d92e2f56856dec8c88561aa /vcl | |
parent | d276ad15252ecd0ae2a4dfeae5b32c16082a9544 (diff) |
OpenGLContext: Provide all data for SystemChildWindow creation.
Change-Id: I7a0ceee6c784af8240fb908f19622d4ede1f5a6a
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 4b420182d2c1..4d5e59515cd2 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -684,4 +684,93 @@ bool OpenGLContext::initWindow() #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: */ |