chart2/source/view/inc/DummyXShape.hxx | 12 - chart2/source/view/main/DummyXShape.cxx | 293 +++++++++++-------------------- chart2/source/view/main/OpenGLRender.cxx | 6 chart2/source/view/main/OpenGLRender.hxx | 45 ++-- external/glew/ExternalProject_glew.mk | 2 5 files changed, 142 insertions(+), 216 deletions(-)
New commits: commit db5ae380a060b2f0b689dd58a3e13e33a9b209fa Author: Markus Mohrhard <[email protected]> Date: Sun Jan 19 03:50:48 2014 +0100 fix windows Change-Id: I6ca5967fd84851bb2ee5af1325b70a6a5e160644 diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx index efba1b4..103c58d 100644 --- a/chart2/source/view/main/DummyXShape.cxx +++ b/chart2/source/view/main/DummyXShape.cxx @@ -840,6 +840,8 @@ bool DummyChart::initWindow() pWindow->EnablePaint(sal_False); GLWin.hWnd = sysData->hWnd; } + + return true; } #elif defined( UNX ) commit 63ffed18da0d9e8cf31843a88f91aade291152f5 Author: Markus Mohrhard <[email protected]> Date: Sun Jan 19 03:45:13 2014 +0100 extract ugly function pointer initialization Change-Id: I4bce735da5f4d9f9b3aaae92ec0cce6725f2016d diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx index fccc6a1..efba1b4 100644 --- a/chart2/source/view/main/DummyXShape.cxx +++ b/chart2/source/view/main/DummyXShape.cxx @@ -844,6 +844,20 @@ bool DummyChart::initWindow() #elif defined( UNX ) +namespace { + +// we need them before glew can initialize them +// glew needs an OpenGL context so we need to get the address manually +void initOpenGLFunctionPointers() +{ + glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig"); + glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig"); // try to find a visual for the current set of attributes + glXGetFBConfigAttrib = (int(*)(Display *dpy, GLXFBConfig config, int attribute, int* value))glXGetProcAddressARB((GLubyte*)"glXGetFBConfigAttrib"); + +} + +} + bool DummyChart::initWindow() { const SystemEnvData* sysData(mpWindow->GetSystemData()); @@ -876,11 +890,7 @@ bool DummyChart::initWindow() const SystemEnvData* pChildSysData = NULL; pWindow.reset(); - glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig"); - glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig"); // try to find a visual for the current set of attributes - glXGetFBConfigAttrib = (int(*)(Display *dpy, GLXFBConfig config, int attribute, int* value))glXGetProcAddressARB((GLubyte*)"glXGetFBConfigAttrib"); - - + initOpenGLFunctionPointers(); int fbCount = 0; GLXFBConfig* pFBC = glXChooseFBConfig( GLWin.dpy, commit a8e8443d84f54d556f4a88f610787598e7e78ede Author: Markus Mohrhard <[email protected]> Date: Sun Jan 19 03:41:34 2014 +0100 make multisampling available on linux if available This also greatly reduces the complexity of the OpenGL initialization on Linux. We now require a RGBA framebuffer with 8 bits per channeland 24 bit depth. Change-Id: I12d4bd6c15cbf95c6211c7af6a81ffbb228f05be diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx index c281fed..fccc6a1 100644 --- a/chart2/source/view/main/DummyXShape.cxx +++ b/chart2/source/view/main/DummyXShape.cxx @@ -862,148 +862,73 @@ bool DummyChart::initWindow() GLWin.screen = XScreenNumberOfScreen( xattr.screen ); - XVisualInfo* vi( NULL ); - XVisualInfo* visinfo; - XVisualInfo* firstVisual( NULL ); - static int attrList3[] = + static int visual_attribs[] = { - GLX_RGBA,//only TrueColor or DirectColor - //single buffered - GLX_RED_SIZE,8,//use the maximum red bits, with a minimum of 4 bits - GLX_GREEN_SIZE,8,//use the maximum green bits, with a minimum of 4 bits - GLX_BLUE_SIZE,8,//use the maximum blue bits, with a minimum of 4 bits - GLX_DEPTH_SIZE,0,//no depth buffer + 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 }; - static int attrList2[] = - { - GLX_RGBA,//only TrueColor or DirectColor - /// single buffered - GLX_RED_SIZE,8,/// use the maximum red bits, with a minimum of 4 bits - GLX_GREEN_SIZE,8,/// use the maximum green bits, with a minimum of 4 bits - GLX_BLUE_SIZE,8,/// use the maximum blue bits, with a minimum of 4 bits - GLX_DEPTH_SIZE,1,/// use the maximum depth bits, making sure there is a depth buffer - None - }; - static int attrList1[] = - { - GLX_RGBA,//only TrueColor or DirectColor - GLX_DOUBLEBUFFER,/// only double buffer - GLX_RED_SIZE,8,/// use the maximum red bits, with a minimum of 4 bits - GLX_GREEN_SIZE,8,/// use the maximum green bits, with a minimum of 4 bits - GLX_BLUE_SIZE,8,/// use the maximum blue bits, with a minimum of 4 bits - GLX_DEPTH_SIZE,0,/// no depth buffer - None - }; - static int attrList0[] = - { - GLX_RGBA,//only TrueColor or DirectColor - GLX_DOUBLEBUFFER,/// only double buffer - GLX_RED_SIZE,8,/// use the maximum red bits, with a minimum of 4 bits - GLX_GREEN_SIZE,8,/// use the maximum green bits, with a minimum of 4 bits - GLX_BLUE_SIZE,8,/// use the maximum blue bits, with a minimum of 4 bits - GLX_DEPTH_SIZE,1,/// use the maximum depth bits, making sure there is a depth buffer - GLX_SAMPLE_BUFFERS, 1, - GLX_SAMPLES, 4, - None - }; - static int* attrTable[] = - { - attrList0, - attrList1, - attrList2, - attrList3, - NULL - }; - int** pAttributeTable = attrTable; const SystemEnvData* pChildSysData = NULL; pWindow.reset(); - GLXFBConfig* fbconfigs = NULL; - int nfbconfigs, value, i = 0; + glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig"); + glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig"); // try to find a visual for the current set of attributes + glXGetFBConfigAttrib = (int(*)(Display *dpy, GLXFBConfig config, int attribute, int* value))glXGetProcAddressARB((GLubyte*)"glXGetFBConfigAttrib"); + + - while( *pAttributeTable ) + int fbCount = 0; + GLXFBConfig* pFBC = glXChooseFBConfig( GLWin.dpy, + GLWin.screen, + visual_attribs, &fbCount ); + + if(!pFBC) { - // try to find a visual for the current set of attributes - vi = glXChooseVisual( GLWin.dpy, - GLWin.screen, - *pAttributeTable ); - if( vi ) + SAL_WARN("chart2.opengl", "no suitable fb format found"); + return false; + } + + int best_fbc = -1, best_num_samp = -1; + for(int i = 0; i < fbCount; ++i) + { + XVisualInfo* pVi = glXGetVisualFromFBConfig( GLWin.dpy, pFBC[i] ); + if(pVi) { - if( GLXEW_EXT_texture_from_pixmap ) - { - if( !firstVisual ) - firstVisual = vi; - OSL_TRACE("trying VisualID %08X", vi->visualid); - fbconfigs = glXGetFBConfigs (GLWin.dpy, GLWin.screen, &nfbconfigs); - - for ( ; i < nfbconfigs; i++) - { - visinfo = glXGetVisualFromFBConfig (GLWin.dpy, fbconfigs[i]); - if( !visinfo || visinfo->visualid != vi->visualid ) - continue; - - glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], GLX_DRAWABLE_TYPE, &value); - if (!(value & GLX_PIXMAP_BIT)) - continue; - - glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], - GLX_BIND_TO_TEXTURE_TARGETS_EXT, - &value); - if (!(value & GLX_TEXTURE_2D_BIT_EXT)) - continue; - - glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], - GLX_BIND_TO_TEXTURE_RGB_EXT, - &value); - if (value == sal_False) - continue; - - glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], - GLX_BIND_TO_MIPMAP_TEXTURE_EXT, - &value); - if (value == sal_False) - continue; - - // TODO: handle non Y inverted cases - break; - } - - if( i != nfbconfigs || ( firstVisual && pAttributeTable[1] == NULL ) ) { - if( i != nfbconfigs ) { - vi = glXGetVisualFromFBConfig( GLWin.dpy, fbconfigs[i] ); - // TODO:moggi - // mbHasTFPVisual = true; - OSL_TRACE("found visual suitable for texture_from_pixmap"); - } else { - vi = firstVisual; - // TODO:moggi - // mbHasTFPVisual = false; - OSL_TRACE("did not find visual suitable for texture_from_pixmap, using %08X", vi->visualid); - } - - } + // pick the one with the most samples per pixel + int nSampleBuf = 0; + int nSamples = 0; + glXGetFBConfigAttrib( GLWin.dpy, pFBC[i], GLX_SAMPLE_BUFFERS, &nSampleBuf ); + glXGetFBConfigAttrib( GLWin.dpy, pFBC[i], GLX_SAMPLES , &nSamples ); + if ( best_fbc < 0 || (nSampleBuf && ( nSamples > best_num_samp )) ) + { + best_fbc = i; + best_num_samp = nSamples; } - SystemWindowData winData; - winData.nSize = sizeof(winData); - OSL_TRACE("using VisualID %08X", vi->visualid); - winData.pVisual = (void*)(vi->visual); - pWindow.reset(new SystemChildWindow(mpWindow.get(), 0, &winData, sal_False)); - pChildSysData = pWindow->GetSystemData(); - - if( pChildSysData ) { - break; - } else { - pWindow.reset(); - } - } + XFree( pVi ); + } - ++pAttributeTable; + XVisualInfo* vi = glXGetVisualFromFBConfig( GLWin.dpy, pFBC[best_fbc] ); + if( vi ) + { + SystemWindowData winData; + winData.nSize = sizeof(winData); + OSL_TRACE("using VisualID %08X", vi->visualid); + winData.pVisual = (void*)(vi->visual); + pWindow.reset(new SystemChildWindow(mpWindow.get(), 0, &winData, sal_False)); + pChildSysData = pWindow->GetSystemData(); + + if( !pChildSysData ) + return false; } + if( pWindow ) { pWindow->SetMouseTransparent( sal_True ); @@ -1014,11 +939,6 @@ bool DummyChart::initWindow() GLWin.dpy = reinterpret_cast<Display*>(pChildSysData->pDisplay); GLWin.win = pChildSysData->aWindow; - //TODO: moggi - /* - if( mbHasTFPVisual ) - GLWin.fbc = fbconfigs[i]; - */ GLWin.vi = vi; GLWin.GLXExtensions = glXQueryExtensionsString( GLWin.dpy, GLWin.screen ); OSL_TRACE("available GLX extensions: %s", GLWin.GLXExtensions); @@ -1116,10 +1036,6 @@ bool DummyChart::initOpengl() GLWin.GLExtensions = glGetString( GL_EXTENSIONS ); OSL_TRACE("available GL extensions: %s", GLWin.GLExtensions); - // TODO: moggi - // mbTextureFromPixmap = GLWin.HasGLXExtension( "GLX_EXT_texture_from_pixmap" ); - // mbGenerateMipmap = GLWin.HasGLExtension( "GL_SGIS_generate_mipmap" ); - if( GLWin.HasGLXExtension("GLX_SGI_swap_control" ) ) { // enable vsync commit 1f330c222d27bb813a7146780d69e10b13a5e21c Author: Markus Mohrhard <[email protected]> Date: Sun Jan 19 03:41:12 2014 +0100 create symbols for glew in the debug case Change-Id: Ia40d4477344f9fc0f9942a9d942b97a416ff11d7 diff --git a/external/glew/ExternalProject_glew.mk b/external/glew/ExternalProject_glew.mk index f419ef5..73b32a2 100644 --- a/external/glew/ExternalProject_glew.mk +++ b/external/glew/ExternalProject_glew.mk @@ -24,7 +24,7 @@ else $(call gb_ExternalProject_get_state_target,glew,build) : $(call gb_ExternalProject_run,glew,\ - $(MAKE) \ + $(if $(filter TRUE,$(ENABLE_DEBUG)),STRIP=) $(MAKE) $(if $(filter TRUE,$(ENABLE_DEBUG)),debug) \ ) endif commit 500b70c8d62c9f0123413c08664e4d19a36af3df Author: Markus Mohrhard <[email protected]> Date: Wed Jan 15 23:44:31 2014 +0100 split the windows and linux intialization bits This makes it much esier now to simplify the Linux selection logic. Change-Id: I7db0daf81b1c9047d4ef95527c7b51c09e6ab80a diff --git a/chart2/source/view/inc/DummyXShape.hxx b/chart2/source/view/inc/DummyXShape.hxx index 42eec30..f915650 100644 --- a/chart2/source/view/inc/DummyXShape.hxx +++ b/chart2/source/view/inc/DummyXShape.hxx @@ -12,6 +12,8 @@ #include <cppuhelper/implbase6.hxx> +#include "OpenGLRender.hxx" + #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp> @@ -83,19 +85,9 @@ #elif defined( UNX ) #include <GL/glu.h> #include <GL/glext.h> - - namespace unx - { - #include <X11/keysym.h> - #include <X11/X.h> - #define GLX_GLXEXT_PROTOTYPES 1 - #include <GL/glx.h> - #include <GL/glxext.h> - } #endif //[mod] by gaowei -#include "OpenGLRender.hxx" //[mod] by gaowei end diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx index 39a1306..c281fed 100644 --- a/chart2/source/view/main/DummyXShape.cxx +++ b/chart2/source/view/main/DummyXShape.cxx @@ -6,7 +6,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <GL/glew.h> +#include "DummyXShape.hxx" + #include <stdio.h> #include <string> #include <vector> @@ -16,7 +17,6 @@ #include <stdlib.h> #include <string.h> -#include "DummyXShape.hxx" #include "CommonConverters.hxx" #include <rtl/ustring.hxx> @@ -819,39 +819,59 @@ void DummyXShapes::render() } } +#if defined( WNT ) + bool DummyChart::initWindow() { const SystemEnvData* sysData(mpWindow->GetSystemData()); -#if defined( WNT ) - GLWin.hWnd = sysData->hWnd; + SystemWindowData winData; + winData.nSize = sizeof(winData); + pWindow.reset(new SystemChildWindow(mpWindow.get(), 0, &winData, sal_False)); + + + if( pWindow ) + { + pWindow->SetMouseTransparent( sal_True ); + pWindow->SetParentClipMode( PARENTCLIPMODE_NOCLIP ); + pWindow->EnableEraseBackground( sal_False ); + pWindow->SetControlForeground(); + pWindow->SetControlBackground(); + pWindow->EnablePaint(sal_False); + GLWin.hWnd = sysData->hWnd; + } +} + #elif defined( UNX ) - GLWin.dpy = reinterpret_cast<unx::Display*>(sysData->pDisplay); - if( unx::glXQueryExtension( GLWin.dpy, NULL, NULL ) == false ) +bool DummyChart::initWindow() +{ + const SystemEnvData* sysData(mpWindow->GetSystemData()); + + GLWin.dpy = reinterpret_cast<Display*>(sysData->pDisplay); + + if( glXQueryExtension( GLWin.dpy, NULL, NULL ) == false ) return false; GLWin.win = sysData->aWindow; OSL_TRACE("parent window: %d", GLWin.win); - unx::XWindowAttributes xattr; - unx::XGetWindowAttributes( GLWin.dpy, GLWin.win, &xattr ); + XWindowAttributes xattr; + XGetWindowAttributes( GLWin.dpy, GLWin.win, &xattr ); GLWin.screen = XScreenNumberOfScreen( xattr.screen ); - unx::XVisualInfo* vi( NULL ); -#if defined( GLX_EXT_texture_from_pixmap ) - unx::XVisualInfo* visinfo; - unx::XVisualInfo* firstVisual( NULL ); -#endif + XVisualInfo* vi( NULL ); + XVisualInfo* visinfo; + XVisualInfo* firstVisual( NULL ); static int attrList3[] = { GLX_RGBA,//only TrueColor or DirectColor //single buffered - GLX_RED_SIZE,4,//use the maximum red bits, with a minimum of 4 bits - GLX_GREEN_SIZE,4,//use the maximum green bits, with a minimum of 4 bits - GLX_BLUE_SIZE,4,//use the maximum blue bits, with a minimum of 4 bits + GLX_RED_SIZE,8,//use the maximum red bits, with a minimum of 4 bits + GLX_GREEN_SIZE,8,//use the maximum green bits, with a minimum of 4 bits + GLX_BLUE_SIZE,8,//use the maximum blue bits, with a minimum of 4 bits GLX_DEPTH_SIZE,0,//no depth buffer None }; @@ -859,9 +879,9 @@ bool DummyChart::initWindow() { GLX_RGBA,//only TrueColor or DirectColor /// single buffered - GLX_RED_SIZE,4,/// use the maximum red bits, with a minimum of 4 bits - GLX_GREEN_SIZE,4,/// use the maximum green bits, with a minimum of 4 bits - GLX_BLUE_SIZE,4,/// use the maximum blue bits, with a minimum of 4 bits + GLX_RED_SIZE,8,/// use the maximum red bits, with a minimum of 4 bits + GLX_GREEN_SIZE,8,/// use the maximum green bits, with a minimum of 4 bits + GLX_BLUE_SIZE,8,/// use the maximum blue bits, with a minimum of 4 bits GLX_DEPTH_SIZE,1,/// use the maximum depth bits, making sure there is a depth buffer None }; @@ -869,9 +889,9 @@ bool DummyChart::initWindow() { GLX_RGBA,//only TrueColor or DirectColor GLX_DOUBLEBUFFER,/// only double buffer - GLX_RED_SIZE,4,/// use the maximum red bits, with a minimum of 4 bits - GLX_GREEN_SIZE,4,/// use the maximum green bits, with a minimum of 4 bits - GLX_BLUE_SIZE,4,/// use the maximum blue bits, with a minimum of 4 bits + GLX_RED_SIZE,8,/// use the maximum red bits, with a minimum of 4 bits + GLX_GREEN_SIZE,8,/// use the maximum green bits, with a minimum of 4 bits + GLX_BLUE_SIZE,8,/// use the maximum blue bits, with a minimum of 4 bits GLX_DEPTH_SIZE,0,/// no depth buffer None }; @@ -879,10 +899,12 @@ bool DummyChart::initWindow() { GLX_RGBA,//only TrueColor or DirectColor GLX_DOUBLEBUFFER,/// only double buffer - GLX_RED_SIZE,4,/// use the maximum red bits, with a minimum of 4 bits - GLX_GREEN_SIZE,4,/// use the maximum green bits, with a minimum of 4 bits - GLX_BLUE_SIZE,4,/// use the maximum blue bits, with a minimum of 4 bits + GLX_RED_SIZE,8,/// use the maximum red bits, with a minimum of 4 bits + GLX_GREEN_SIZE,8,/// use the maximum green bits, with a minimum of 4 bits + GLX_BLUE_SIZE,8,/// use the maximum blue bits, with a minimum of 4 bits GLX_DEPTH_SIZE,1,/// use the maximum depth bits, making sure there is a depth buffer + GLX_SAMPLE_BUFFERS, 1, + GLX_SAMPLES, 4, None }; static int* attrTable[] = @@ -893,140 +915,121 @@ bool DummyChart::initWindow() attrList3, NULL }; + int** pAttributeTable = attrTable; const SystemEnvData* pChildSysData = NULL; pWindow.reset(); -#if defined( GLX_EXT_texture_from_pixmap ) - unx::GLXFBConfig* fbconfigs = NULL; + GLXFBConfig* fbconfigs = NULL; int nfbconfigs, value, i = 0; -#endif while( *pAttributeTable ) { // try to find a visual for the current set of attributes - vi = unx::glXChooseVisual( GLWin.dpy, + vi = glXChooseVisual( GLWin.dpy, GLWin.screen, *pAttributeTable ); - -#if defined( GLX_EXT_texture_from_pixmap ) - if( vi ) { - if( !firstVisual ) - firstVisual = vi; - OSL_TRACE("trying VisualID %08X", vi->visualid); - fbconfigs = glXGetFBConfigs (GLWin.dpy, GLWin.screen, &nfbconfigs); - - for ( ; i < nfbconfigs; i++) + if( vi ) + { + if( GLXEW_EXT_texture_from_pixmap ) { - visinfo = glXGetVisualFromFBConfig (GLWin.dpy, fbconfigs[i]); - if( !visinfo || visinfo->visualid != vi->visualid ) - continue; - - glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], GLX_DRAWABLE_TYPE, &value); - if (!(value & GLX_PIXMAP_BIT)) - continue; - - glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], - GLX_BIND_TO_TEXTURE_TARGETS_EXT, - &value); - if (!(value & GLX_TEXTURE_2D_BIT_EXT)) - continue; - - glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], - GLX_BIND_TO_TEXTURE_RGB_EXT, - &value); - if (value == sal_False) - continue; - - glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], - GLX_BIND_TO_MIPMAP_TEXTURE_EXT, - &value); - if (value == sal_False) - continue; - - // TODO: handle non Y inverted cases - break; - } - - if( i != nfbconfigs || ( firstVisual && pAttributeTable[1] == NULL ) ) { - if( i != nfbconfigs ) { - vi = glXGetVisualFromFBConfig( GLWin.dpy, fbconfigs[i] ); - // TODO:moggi - // mbHasTFPVisual = true; - OSL_TRACE("found visual suitable for texture_from_pixmap"); - } else { - vi = firstVisual; - // TODO:moggi - // mbHasTFPVisual = false; - OSL_TRACE("did not find visual suitable for texture_from_pixmap, using %08X", vi->visualid); + if( !firstVisual ) + firstVisual = vi; + OSL_TRACE("trying VisualID %08X", vi->visualid); + fbconfigs = glXGetFBConfigs (GLWin.dpy, GLWin.screen, &nfbconfigs); + + for ( ; i < nfbconfigs; i++) + { + visinfo = glXGetVisualFromFBConfig (GLWin.dpy, fbconfigs[i]); + if( !visinfo || visinfo->visualid != vi->visualid ) + continue; + + glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], GLX_DRAWABLE_TYPE, &value); + if (!(value & GLX_PIXMAP_BIT)) + continue; + + glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], + GLX_BIND_TO_TEXTURE_TARGETS_EXT, + &value); + if (!(value & GLX_TEXTURE_2D_BIT_EXT)) + continue; + + glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], + GLX_BIND_TO_TEXTURE_RGB_EXT, + &value); + if (value == sal_False) + continue; + + glXGetFBConfigAttrib (GLWin.dpy, fbconfigs[i], + GLX_BIND_TO_MIPMAP_TEXTURE_EXT, + &value); + if (value == sal_False) + continue; + + // TODO: handle non Y inverted cases + break; } -#else - if( vi ) { -#endif - SystemWindowData winData; - winData.nSize = sizeof(winData); - OSL_TRACE("using VisualID %08X", vi->visualid); - winData.pVisual = (void*)(vi->visual); - pWindow.reset(new SystemChildWindow(mpWindow.get(), 0, &winData, sal_False)); - pChildSysData = pWindow->GetSystemData(); - - if( pChildSysData ) { - break; + + if( i != nfbconfigs || ( firstVisual && pAttributeTable[1] == NULL ) ) { + if( i != nfbconfigs ) { + vi = glXGetVisualFromFBConfig( GLWin.dpy, fbconfigs[i] ); + // TODO:moggi + // mbHasTFPVisual = true; + OSL_TRACE("found visual suitable for texture_from_pixmap"); } else { - pWindow.reset(); + vi = firstVisual; + // TODO:moggi + // mbHasTFPVisual = false; + OSL_TRACE("did not find visual suitable for texture_from_pixmap, using %08X", vi->visualid); } + } -#if defined( GLX_EXT_texture_from_pixmap ) + + } + SystemWindowData winData; + winData.nSize = sizeof(winData); + OSL_TRACE("using VisualID %08X", vi->visualid); + winData.pVisual = (void*)(vi->visual); + pWindow.reset(new SystemChildWindow(mpWindow.get(), 0, &winData, sal_False)); + pChildSysData = pWindow->GetSystemData(); + + if( pChildSysData ) { + break; + } else { + pWindow.reset(); } -#endif - ++pAttributeTable; } -#endif - -#if defined( WNT ) - SystemWindowData winData; - winData.nSize = sizeof(winData); - pWindow.reset(new SystemChildWindow(mpWindow.get(), 0, &winData, sal_False)); -#endif - - if( pWindow ) - { - pWindow->SetMouseTransparent( sal_True ); - pWindow->SetParentClipMode( PARENTCLIPMODE_NOCLIP ); - pWindow->EnableEraseBackground( sal_False ); - pWindow->SetControlForeground(); - pWindow->SetControlBackground(); - pWindow->EnablePaint(sal_False); -#if defined( WNT ) - GLWin.hWnd = sysData->hWnd; -#elif defined( UNX ) - GLWin.dpy = reinterpret_cast<unx::Display*>(pChildSysData->pDisplay); - GLWin.win = pChildSysData->aWindow; -#if defined( GLX_EXT_texture_from_pixmap ) - //TODO: moggi - /* - if( mbHasTFPVisual ) - GLWin.fbc = fbconfigs[i]; - */ -#endif - GLWin.vi = vi; - GLWin.GLXExtensions = unx::glXQueryExtensionsString( GLWin.dpy, GLWin.screen ); - OSL_TRACE("available GLX extensions: %s", GLWin.GLXExtensions); -#endif - - return false; - } + ++pAttributeTable; + } + if( pWindow ) + { + pWindow->SetMouseTransparent( sal_True ); + pWindow->SetParentClipMode( PARENTCLIPMODE_NOCLIP ); + pWindow->EnableEraseBackground( sal_False ); + pWindow->SetControlForeground(); + pWindow->SetControlBackground(); + + GLWin.dpy = reinterpret_cast<Display*>(pChildSysData->pDisplay); + GLWin.win = pChildSysData->aWindow; + //TODO: moggi + /* + if( mbHasTFPVisual ) + GLWin.fbc = fbconfigs[i]; + */ + GLWin.vi = vi; + GLWin.GLXExtensions = glXQueryExtensionsString( GLWin.dpy, GLWin.screen ); + OSL_TRACE("available GLX extensions: %s", GLWin.GLXExtensions); + } return true; } -#if defined( UNX ) namespace { static bool errorTriggered; -int oglErrorHandler( unx::Display* /*dpy*/, unx::XErrorEvent* /*evnt*/ ) +int oglErrorHandler( Display* /*dpy*/, XErrorEvent* /*evnt*/ ) { errorTriggered = true; @@ -1121,19 +1124,19 @@ bool DummyChart::initOpengl() { // enable vsync typedef GLint (*glXSwapIntervalProc)(GLint); - glXSwapIntervalProc glXSwapInterval = (glXSwapIntervalProc) unx::glXGetProcAddress( (const GLubyte*) "glXSwapIntervalSGI" ); + glXSwapIntervalProc glXSwapInterval = (glXSwapIntervalProc) glXGetProcAddress( (const GLubyte*) "glXSwapIntervalSGI" ); if( glXSwapInterval ) { - int (*oldHandler)(unx::Display* /*dpy*/, unx::XErrorEvent* /*evnt*/); + int (*oldHandler)(Display* /*dpy*/, XErrorEvent* /*evnt*/); // replace error handler temporarily - oldHandler = unx::XSetErrorHandler( oglErrorHandler ); + oldHandler = XSetErrorHandler( oglErrorHandler ); errorTriggered = false; glXSwapInterval( 1 ); // sync so that we possibly get an XError - unx::glXWaitGL(); + glXWaitGL(); XSync(GLWin.dpy, false); if( errorTriggered ) @@ -1142,7 +1145,7 @@ bool DummyChart::initOpengl() OSL_TRACE("set swap interval to 1 (enable vsync)"); // restore the error handler - unx::XSetErrorHandler( oldHandler ); + XSetErrorHandler( oldHandler ); } } @@ -1162,7 +1165,7 @@ bool DummyChart::initOpengl() SwapBuffers(GLWin.hDC); glFlush(); #elif defined( UNX ) - unx::glXSwapBuffers(GLWin.dpy, GLWin.win); + glXSwapBuffers(GLWin.dpy, GLWin.win); #endif glEnable(GL_LIGHTING); GLfloat light_direction[] = { 0.0 , 0.0 , 1.0 }; diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx index 11a77f3..4366425 100644 --- a/chart2/source/view/main/OpenGLRender.cxx +++ b/chart2/source/view/main/OpenGLRender.cxx @@ -502,7 +502,7 @@ int OpenGLRender::InitOpenGL(GLWindow aWindow) #if defined( WNT ) SwapBuffers(glWin.hDC); #elif defined( UNX ) - unx::glXSwapBuffers(glWin.dpy, glWin.win); + glXSwapBuffers(glWin.dpy, glWin.win); #endif glFlush(); glEnable(GL_LIGHTING); @@ -741,7 +741,7 @@ void OpenGLRender::renderToBitmap() #if defined( WNT ) SwapBuffers(glWin.hDC); #elif defined( UNX ) - unx::glXSwapBuffers(glWin.dpy, glWin.win); + glXSwapBuffers(glWin.dpy, glWin.win); #endif glFlush(); } @@ -823,7 +823,7 @@ int OpenGLRender::RenderTexture(GLuint TexID) #if defined( WNT ) SwapBuffers(glWin.hDC); #elif defined( UNX ) - unx::glXSwapBuffers(glWin.dpy, glWin.win); + glXSwapBuffers(glWin.dpy, glWin.win); #endif glFlush(); return 0; diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx index 58a3aef..dc9beb5 100644 --- a/chart2/source/view/main/OpenGLRender.hxx +++ b/chart2/source/view/main/OpenGLRender.hxx @@ -10,6 +10,12 @@ #include <com/sun/star/drawing/XDrawPage.hpp> #include <vcl/font.hxx> +#if defined( UNX ) +#include <prex.h> +#include "GL/glxew.h" +#include <postx.h> +#endif + #if defined( _WIN32 ) #include "prewin.h" #include "windows.h" @@ -24,25 +30,22 @@ #include <vcl/sysdata.hxx> #if defined( _WIN32 ) - #include <GL/glu.h> - #include <GL/glext.h> - #include <GL/wglext.h> +#include <GL/glu.h> +#include <GL/glext.h> +#include <GL/wglext.h> #elif defined( MACOSX ) - #include "premac.h" - #include <Cocoa/Cocoa.h> - #include "postmac.h" +#include "premac.h" +#include <Cocoa/Cocoa.h> +#include "postmac.h" #elif defined( UNX ) - #include <GL/glu.h> - #include <GL/glext.h> -namespace unx -{ - #include <X11/keysym.h> - #include <X11/X.h> - #define GLX_GLXEXT_PROTOTYPES 1 - #include <GL/glx.h> - #include <GL/glxext.h> -} +#include <GL/glu.h> +#include <GL/glext.h> + +#define GLX_GLXEXT_PROTOTYPES 1 +#include <GL/glx.h> +#include <GL/glxext.h> + #endif // Include GLM @@ -110,14 +113,14 @@ struct GLWindow HGLRC hRC; #elif defined( MACOSX ) #elif defined( UNX ) - unx::Display* dpy; + Display* dpy; int screen; - unx::Window win; + XLIB_Window win; #if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap ) - unx::GLXFBConfig fbc; + GLXFBConfig fbc; #endif - unx::XVisualInfo* vi; - unx::GLXContext ctx; + XVisualInfo* vi; + GLXContext ctx; bool HasGLXExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, (const GLubyte*) GLXExtensions ); } const char* GLXExtensions; commit efee96a201235a4ea14c4f3c3d8d2fe12b5b9edc Author: Markus Mohrhard <[email protected]> Date: Wed Jan 15 22:43:56 2014 +0100 even the baseline supports glx 1.3 We won't support glx < 1.3!!!! Change-Id: Icc5d15d682223b1fab3165d279b596446c920e9b diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx index 917136d..39a1306 100644 --- a/chart2/source/view/main/DummyXShape.cxx +++ b/chart2/source/view/main/DummyXShape.cxx @@ -841,7 +841,7 @@ bool DummyChart::initWindow() GLWin.screen = XScreenNumberOfScreen( xattr.screen ); unx::XVisualInfo* vi( NULL ); -#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap ) +#if defined( GLX_EXT_texture_from_pixmap ) unx::XVisualInfo* visinfo; unx::XVisualInfo* firstVisual( NULL ); #endif @@ -897,7 +897,7 @@ bool DummyChart::initWindow() const SystemEnvData* pChildSysData = NULL; pWindow.reset(); -#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap ) +#if defined( GLX_EXT_texture_from_pixmap ) unx::GLXFBConfig* fbconfigs = NULL; int nfbconfigs, value, i = 0; #endif @@ -909,7 +909,7 @@ bool DummyChart::initWindow() GLWin.screen, *pAttributeTable ); -#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap ) +#if defined( GLX_EXT_texture_from_pixmap ) if( vi ) { if( !firstVisual ) firstVisual = vi; @@ -976,7 +976,7 @@ bool DummyChart::initWindow() pWindow.reset(); } } -#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap ) +#if defined( GLX_EXT_texture_from_pixmap ) } #endif @@ -1004,7 +1004,7 @@ bool DummyChart::initWindow() #elif defined( UNX ) GLWin.dpy = reinterpret_cast<unx::Display*>(pChildSysData->pDisplay); GLWin.win = pChildSysData->aWindow; -#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap ) +#if defined( GLX_EXT_texture_from_pixmap ) //TODO: moggi /* if( mbHasTFPVisual ) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
