diff --git a/slideshow/Library_OGLTrans.mk b/slideshow/Library_OGLTrans.mk index 44db60bdf289..1dd2f15e773d 100644 --- a/slideshow/Library_OGLTrans.mk +++ b/slideshow/Library_OGLTrans.mk @@ -46,6 +46,7 @@ endif $(eval $(call gb_Library_use_sdk_api,OGLTrans)) $(eval $(call gb_Library_use_libraries,OGLTrans,\ + basegfx \ canvastools \ comphelper \ cppu \ @@ -87,8 +88,8 @@ $(eval $(call gb_Library_use_system_win32_libs,OGLTrans,\ $(eval $(call gb_Library_add_exception_objects,OGLTrans,\ slideshow/source/engine/OGLTrans/unx/OGLTrans_Shaders \ - slideshow/source/engine/OGLTrans/win/OGLTrans_TransitionerImpl \ - slideshow/source/engine/OGLTrans/win/OGLTrans_TransitionImpl \ + slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionerImpl \ + slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionImpl \ )) else diff --git a/slideshow/source/engine/OGLTrans/unx/OGLTrans_Shaders.cxx b/slideshow/source/engine/OGLTrans/unx/OGLTrans_Shaders.cxx index e7e6424e4a94..e2f1a58a1cdb 100644 --- a/slideshow/source/engine/OGLTrans/unx/OGLTrans_Shaders.cxx +++ b/slideshow/source/engine/OGLTrans/unx/OGLTrans_Shaders.cxx @@ -30,16 +30,26 @@ #include "OGLTrans_Shaders.hxx" +#ifdef _WIN32 + +#elif defined(MACOSX) + +#else // UNX == X11 + namespace unx { +#define GLX_GLXEXT_PROTOTYPES 1 #include #include } +#endif + bool OGLShaders::cbInitialized = false; #ifdef GL_VERSION_2_0 +PFNGLACTIVETEXTUREPROC OGLShaders::glActiveTexture = NULL; PFNGLCREATESHADERPROC OGLShaders::glCreateShader = NULL; PFNGLSHADERSOURCEPROC OGLShaders::glShaderSource = NULL; PFNGLCOMPILESHADERPROC OGLShaders::glCompileShader = NULL; @@ -62,6 +72,28 @@ bool OGLShaders::Initialize() { #ifdef GL_VERSION_2_0 if( !cbInitialized ) { +#ifdef _WIN32 + glActiveTexture = (PFNGLACTIVETEXTUREPROC) wglGetProcAddress( "glActiveTexture" ); + glCreateShader = (PFNGLCREATESHADERPROC) wglGetProcAddress( "glCreateShader" ); + glShaderSource = (PFNGLSHADERSOURCEPROC) wglGetProcAddress( "glShaderSource" ); + glCompileShader = (PFNGLCOMPILESHADERPROC) wglGetProcAddress( "glCompileShader" ); + glGetShaderiv = (PFNGLGETSHADERIVPROC) wglGetProcAddress( "glGetShaderiv" ); + glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) wglGetProcAddress( "glGetShaderInfoLog" ); + glDeleteShader = (PFNGLDELETESHADERPROC) wglGetProcAddress( "glDeleteShader" ); + glCreateProgram = (PFNGLCREATEPROGRAMPROC) wglGetProcAddress( "glCreateProgram" ); + glAttachShader = (PFNGLATTACHSHADERPROC) wglGetProcAddress( "glAttachShader" ); + glLinkProgram = (PFNGLLINKPROGRAMPROC) wglGetProcAddress( "glLinkProgram" ); + glGetProgramiv = (PFNGLGETPROGRAMIVPROC) wglGetProcAddress( "glGetProgramiv" ); + glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) wglGetProcAddress( "glGetProgramInfoLog" ); + glUseProgram = (PFNGLUSEPROGRAMPROC) wglGetProcAddress( "glUseProgram" ); + glDeleteProgram = (PFNGLDELETEPROGRAMPROC) wglGetProcAddress( "glDeleteProgram" ); + glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) wglGetProcAddress( "glGetUniformLocation" ); + glUniform1i = (PFNGLUNIFORM1IPROC) wglGetProcAddress( "glUniform1i" ); + glUniform1f = (PFNGLUNIFORM1FPROC) wglGetProcAddress( "glUniform1f" ); + cbInitialized = true; +#elif defined(MACOSX) +#else + glActiveTexture = (PFNGLCREATESHADERPROC) unx::glXGetProcAddress( (unsigned char *) "glActiveTexture" ); glCreateShader = (PFNGLCREATESHADERPROC) unx::glXGetProcAddress( (unsigned char *) "glCreateShader" ); glShaderSource = (PFNGLSHADERSOURCEPROC) unx::glXGetProcAddress( (unsigned char *) "glShaderSource" ); glCompileShader = (PFNGLCOMPILESHADERPROC) unx::glXGetProcAddress( (unsigned char *) "glCompileShader" ); @@ -79,6 +111,7 @@ bool OGLShaders::Initialize() glUniform1i = (PFNGLUNIFORM1IPROC) unx::glXGetProcAddress( (unsigned char *) "glUniform1i" ); glUniform1f = (PFNGLUNIFORM1FPROC) unx::glXGetProcAddress( (unsigned char *) "glUniform1f" ); cbInitialized = true; +#endif } return glCreateShader != NULL; diff --git a/slideshow/source/engine/OGLTrans/unx/OGLTrans_Shaders.hxx b/slideshow/source/engine/OGLTrans/unx/OGLTrans_Shaders.hxx index 016f8ac5445a..d6a2cb66e8a3 100644 --- a/slideshow/source/engine/OGLTrans/unx/OGLTrans_Shaders.hxx +++ b/slideshow/source/engine/OGLTrans/unx/OGLTrans_Shaders.hxx @@ -45,6 +45,8 @@ public: */ #ifdef GL_VERSION_2_0 + static PFNGLACTIVETEXTUREPROC glActiveTexture; + static PFNGLCREATESHADERPROC glCreateShader; static PFNGLSHADERSOURCEPROC glShaderSource; static PFNGLCOMPILESHADERPROC glCompileShader; diff --git a/slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionImpl.cxx b/slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionImpl.cxx index 1df780221d69..2e1709e098e9 100644 --- a/slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionImpl.cxx +++ b/slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionImpl.cxx @@ -1419,9 +1419,9 @@ void ShaderTransition::displaySlides_( double nTime, ::sal_Int32 glLeavingSlideT } } - glActiveTexture( GL_TEXTURE2 ); + OGLShaders::glActiveTexture( GL_TEXTURE2 ); glBindTexture( GL_TEXTURE_2D, glEnteringSlideTex ); - glActiveTexture( GL_TEXTURE0 ); + OGLShaders::glActiveTexture( GL_TEXTURE0 ); #endif displaySlide( nTime, glLeavingSlideTex, getScene().getLeavingSlide(), SlideWidthScale, SlideHeightScale ); @@ -1517,10 +1517,10 @@ void ShaderTransition::impl_preparePermShader() OGLShaders::glUniform1i( location, 0 ); // texture unit 0 } - glActiveTexture(GL_TEXTURE1); + OGLShaders::glActiveTexture(GL_TEXTURE1); if( !m_nHelperTexture ) initPermTexture( &m_nHelperTexture ); - glActiveTexture(GL_TEXTURE0); + OGLShaders::glActiveTexture(GL_TEXTURE0); location = OGLShaders::glGetUniformLocation( m_nProgramObject, "permTexture" ); if( location != -1 ) { diff --git a/slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionImpl.hxx b/slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionImpl.hxx index 9b27b47dc8d7..f2c691106403 100644 --- a/slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionImpl.hxx +++ b/slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionImpl.hxx @@ -35,6 +35,14 @@ #include #include + +#ifdef _WIN32 +// includes , so include that early through +// to avoid name clashes from at least GDI's Rectangle(). +#include +#include +#endif + #include class Primitive; diff --git a/slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionerImpl.cxx b/slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionerImpl.cxx index 93c1d13e97ac..2dd366f5db70 100644 --- a/slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionerImpl.cxx +++ b/slideshow/source/engine/OGLTrans/unx/OGLTrans_TransitionerImpl.cxx @@ -26,7 +26,7 @@ * ************************************************************************/ -#define GLX_GLXEXT_PROTOTYPES 1 +// Includes #include "OGLTrans_TransitionImpl.hxx" #include @@ -38,6 +38,8 @@ #include #include #include +#undef IN +#undef OUT #include #include #include @@ -63,26 +65,29 @@ #include -#include -#include - - -#if defined( WNT ) - #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE - #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#elif defined( QUARTZ ) +#if defined( _WIN32 ) + // OGLTrans_TransitionImpl.hxx already included and thus + #include + #include + #include +#elif defined( MACOSX ) #include "premac.h" #include #include "postmac.h" #elif defined( UNX ) -namespace unx -{ -#include -#include -#include -#include -} + #include + #include + + namespace unx + { + #include + #include + #define GLX_GLXEXT_PROTOTYPES 1 + #include + #include + } #endif + #include #if OSL_DEBUG_LEVEL > 1 @@ -163,6 +168,8 @@ int calcComponentOrderIndex(const uno::Sequence& rTags) return -1; } +#ifdef UNX + // not thread safe static bool errorTriggered; int oglErrorHandler( unx::Display* /*dpy*/, unx::XErrorEvent* /*evnt*/ ) @@ -172,6 +179,8 @@ int oglErrorHandler( unx::Display* /*dpy*/, unx::XErrorEvent* /*evnt*/ ) return 0; } +#endif + /** This is the Transitioner class for OpenGL 3D transitions in * slideshow. At the moment, it's Linux only. This class is implicitly * constructed from XTransitionFactory. @@ -236,29 +245,30 @@ private: /// Holds the information of our new child window struct GLWindow { -#if defined( WNT ) - HWND hWnd; - HDC hDC; - HGLRC hRC; -#elif defined( QUARTZ ) +#if defined( _WIN32 ) + HWND hWnd; + HDC hDC; + HGLRC hRC; +#elif defined( MACOSX ) #elif defined( UNX ) - unx::Display* dpy; - int screen; - unx::Window win; + unx::Display* dpy; + int screen; + unx::Window win; #if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap ) - unx::GLXFBConfig fbc; + unx::GLXFBConfig fbc; #endif - unx::XVisualInfo* vi; - unx::GLXContext ctx; + unx::XVisualInfo* vi; + unx::GLXContext ctx; + + bool HasGLXExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, (const GLubyte*) GLXExtensions ); } + const char* GLXExtensions; #endif unsigned int bpp; unsigned int Width; unsigned int Height; - const char* GLXExtensions; - const GLubyte* GLExtensions; + const GLubyte* GLExtensions; - bool HasGLXExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, (const GLubyte*) GLXExtensions ); } - bool HasGLExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, GLExtensions ); } + bool HasGLExtension( const char* name ) { return gluCheckExtension( (const GLubyte*) name, GLExtensions ); } } GLWin; /** OpenGL handle to the leaving slide's texture @@ -293,8 +303,10 @@ private: bool mbUseEnteringPixmap; bool mbFreeLeavingPixmap; bool mbFreeEnteringPixmap; +#ifdef UNX unx::Pixmap maLeavingPixmap; unx::Pixmap maEnteringPixmap; +#endif /** the form the raw bytes are in for the bitmaps */ @@ -316,17 +328,20 @@ public: /** GL version */ static float cnGLVersion; + +#ifdef UNX float mnGLXVersion; +#endif + + /** + Whether the display has GLX extension on X11, always true otherwise (?) + */ + static bool cbGLXPresent; /** Whether Mesa is the OpenGL vendor */ static bool cbMesa; - /** - whether the display has GLX extension - */ - static bool cbGLXPresent; - /** whether texture from pixmap extension is available */ @@ -426,7 +441,7 @@ lcl_createSystemWindow( bool OGLTransitionerImpl::createWindow( Window* pPWindow ) { const SystemEnvData* sysData(pPWindow->GetSystemData()); -#if defined( WNT ) +#if defined( _WIN32 ) GLWin.hWnd = sysData->hWnd; #elif defined( UNX ) GLWin.dpy = reinterpret_cast(sysData->pDisplay); @@ -573,7 +588,7 @@ bool OGLTransitionerImpl::createWindow( Window* pPWindow ) } #endif -#if defined( WNT ) +#if defined( _WIN32 ) SystemWindowData winData; winData.nSize = sizeof(winData); pWindow=new SystemChildWindow(pPWindow, 0, &winData, sal_False); @@ -588,7 +603,7 @@ bool OGLTransitionerImpl::createWindow( Window* pPWindow ) pWindow->SetControlForeground(); pWindow->SetControlBackground(); pWindow->EnablePaint(sal_False); -#if defined( WNT ) +#if defined( _WIN32 ) GLWin.hWnd = sysData->hWnd; #elif defined( UNX ) GLWin.dpy = reinterpret_cast(pChildSysData->pDisplay); @@ -642,7 +657,7 @@ bool OGLTransitionerImpl::initWindowFromSlideShowView( const Reference< presenta GLWin.Height = aCanvasArea.Height; SAL_INFO("slideshow.opengl", "canvas area: " << aCanvasArea.X << "," << aCanvasArea.Y << " - " << aCanvasArea.Width << "x" << aCanvasArea.Height); -#if defined( WNT ) +#if defined( _WIN32 ) GLWin.hDC = GetDC(GLWin.hWnd); #elif defined( UNX ) GLWin.ctx = glXCreateContext(GLWin.dpy, @@ -655,7 +670,7 @@ bool OGLTransitionerImpl::initWindowFromSlideShowView( const Reference< presenta } #endif -#if defined( WNT ) +#if defined( _WIN32 ) PIXELFORMATDESCRIPTOR PixelFormatFront = // PixelFormat Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), @@ -679,7 +694,7 @@ bool OGLTransitionerImpl::initWindowFromSlideShowView( const Reference< presenta }; int WindowPix = ChoosePixelFormat(GLWin.hDC,&PixelFormatFront); SetPixelFormat(GLWin.hDC,WindowPix,&PixelFormatFront); - GLWin.hRC = wglCreateContext(GLWin.hDC); + GLWin.hRC = wglCreateContext(GLWin.hDC); wglMakeCurrent(GLWin.hDC,GLWin.hRC); #elif defined( UNX ) if( !glXMakeCurrent( GLWin.dpy, GLWin.win, GLWin.ctx ) ) { @@ -732,7 +747,7 @@ bool OGLTransitionerImpl::initWindowFromSlideShowView( const Reference< presenta glCullFace(GL_BACK); glClearColor (0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); -#if defined( WNT ) +#if defined( _WIN32 ) SwapBuffers(GLWin.hDC); #elif defined( UNX ) unx::glXSwapBuffers(GLWin.dpy, GLWin.win); @@ -786,7 +801,6 @@ void OGLTransitionerImpl::impl_prepareSlides() mbUseLeavingPixmap = false; mbUseEnteringPixmap = false; -#ifdef UNX #if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap ) if( mnGLXVersion >= 1.2999 && mbTextureFromPixmap && xLeavingSet.is() && xEnteringSet.is() && mbHasTFPVisual ) { @@ -861,7 +875,6 @@ void OGLTransitionerImpl::impl_prepareSlides() } } -#endif #endif if( !mbUseLeavingPixmap ) LeavingBytes = mxLeavingBitmap->getData(SlideBitmapLayout,SlideRect); @@ -1229,7 +1242,7 @@ namespace *pColors++ = vcl::unotools::toByteColor(pIn->Red); *pColors++ = vcl::unotools::toByteColor(pIn->Green); *pColors++ = vcl::unotools::toByteColor(pIn->Blue); - *pColors++ = 255; + *pColors++ = -127; ++pIn; } return aRes; @@ -1554,7 +1567,7 @@ void SAL_CALL OGLTransitionerImpl::update( double nTime ) throw (uno::RuntimeExc if (isDisposed() || !cbGLXPresent || mpTransition->getSettings().mnRequiredGLVersion > cnGLVersion) return; -#ifdef WNT +#ifdef _WIN32 wglMakeCurrent(GLWin.hDC,GLWin.hRC); #endif #ifdef UNX @@ -1570,7 +1583,7 @@ void SAL_CALL OGLTransitionerImpl::update( double nTime ) throw (uno::RuntimeExc static_cast(GLWin.Width), static_cast(GLWin.Height) ); -#if defined( WNT ) +#if defined( _WIN32 ) SwapBuffers(GLWin.hDC); #elif defined( UNX ) unx::glXSwapBuffers(GLWin.dpy, GLWin.win); @@ -1612,7 +1625,7 @@ void SAL_CALL OGLTransitionerImpl::viewChanged( const Reference< presentation::X void OGLTransitionerImpl::disposeContextAndWindow() { -#if defined( WNT ) +#if defined( _WIN32 ) if (GLWin.hRC) { wglMakeCurrent( GLWin.hDC, 0 ); // kill Device Context @@ -1628,18 +1641,18 @@ void OGLTransitionerImpl::disposeContextAndWindow() } glXDestroyContext(GLWin.dpy, GLWin.ctx); GLWin.ctx = NULL; + GLWin.win = 0; } #endif if( pWindow ) { delete pWindow; pWindow = NULL; - GLWin.win = 0; } } void OGLTransitionerImpl::disposeTextures() { -#ifdef WNT +#ifdef _WIN32 wglMakeCurrent(GLWin.hDC,GLWin.hRC); #endif #ifdef UNX @@ -1743,7 +1756,7 @@ OGLTransitionerImpl::OGLTransitionerImpl() : SlideBitmapLayout(), SlideSize() { -#if defined( WNT ) +#if defined( _WIN32 ) GLWin.hWnd = 0; #elif defined( UNX ) GLWin.ctx = 0; diff --git a/slideshow/source/engine/OGLTrans/win/OGLTrans_Shaders.hxx b/slideshow/source/engine/OGLTrans/win/OGLTrans_Shaders.hxx deleted file mode 100644 index 016f8ac5445a..000000000000 --- a/slideshow/source/engine/OGLTrans/win/OGLTrans_Shaders.hxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_OGLTRANS_SHADERS_HXX_ -#define INCLUDED_OGLTRANS_SHADERS_HXX_ - -#define GL_GLEXT_PROTOTYPES 1 -#include -#include - -class OGLShaders { - static bool Initialize(); - static bool cbInitialized; - -public: - - static GLuint LinkProgram( const char *vertexShader, const char *fragmentShader ); - - /** GL shader functions - */ -#ifdef GL_VERSION_2_0 - - static PFNGLCREATESHADERPROC glCreateShader; - static PFNGLSHADERSOURCEPROC glShaderSource; - static PFNGLCOMPILESHADERPROC glCompileShader; - static PFNGLGETSHADERIVPROC glGetShaderiv; - static PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; - static PFNGLDELETESHADERPROC glDeleteShader; - - static PFNGLCREATEPROGRAMPROC glCreateProgram; - static PFNGLATTACHSHADERPROC glAttachShader; - static PFNGLLINKPROGRAMPROC glLinkProgram; - static PFNGLGETPROGRAMIVPROC glGetProgramiv; - static PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; - static PFNGLUSEPROGRAMPROC glUseProgram; - static PFNGLDELETEPROGRAMPROC glDeleteProgram; - - static PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; - static PFNGLUNIFORM1IPROC glUniform1i; - static PFNGLUNIFORM1FPROC glUniform1f; -#endif -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */