diff options
Diffstat (limited to 'vcl/aqua/source/gdi/salogl.cxx')
-rw-r--r-- | vcl/aqua/source/gdi/salogl.cxx | 250 |
1 files changed, 10 insertions, 240 deletions
diff --git a/vcl/aqua/source/gdi/salogl.cxx b/vcl/aqua/source/gdi/salogl.cxx index f4bc6def0789..9fb5283d4914 100644 --- a/vcl/aqua/source/gdi/salogl.cxx +++ b/vcl/aqua/source/gdi/salogl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: salogl.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: pluby $ $Date: 2000-11-01 03:12:45 $ + * last change: $Author: pluby $ $Date: 2000-11-01 22:12:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,85 +59,26 @@ * ************************************************************************/ -#ifndef _SVWIN_H -#include <tools/svwin.h> -#endif - #define _SV_SALOGL_CXX -#ifndef _SV_SALOGL_HXX -#include <salogl.hxx> -#endif #ifndef _SV_SALGDI_HXX #include <salgdi.hxx> #endif - -// ------------------------------- -// - Additional typedefs for init. -// ------------------------------- - -typedef HGLRC ( *OGLFncCreateContext )( VCLVIEW hDC ); -typedef BOOL ( *OGLFncDeleteContext )( HGLRC hContext ); -typedef HGLRC ( *OGLFncGetCurrentContext )( void ); -typedef void ( *OGLFncMakeCurrent )( VCLVIEW hDC, HGLRC hContext ); - -// ------------ -// - Lib-Name - -// ------------ - -#ifdef WIN -#define OGL_LIBNAME "OPENGL32.DLL" +#ifndef _SV_SALOGL_HXX +#include <salogl.hxx> #endif -// ---------- -// - Macros - -// ---------- -#ifdef WIN -#define INIT_OGLFNC_WGL( FncName ) static OGLFnc##FncName pImplOpenWGLFnc##FncName = NULL; -#define GET_OGLFNC_WGL( FncName ) \ -pImplOpenWGLFnc##FncName = (OGLFnc##FncName##) GetProcAddress( hImplOGLLib, "wgl" #FncName ); \ -if( !pImplOpenWGLFnc##FncName ) bRet = FALSE; -#endif - -// ----------------- -// - Statics init. - -// ----------------- +// ======================================================================== -// Members -HGLRC SalOpenGL::mhOGLContext = 0; +// Initialize static data members VCLVIEW SalOpenGL::mhOGLLastDC = 0; ULONG SalOpenGL::mnOGLState = OGL_STATE_UNLOADED; -#ifdef WIN -INIT_OGLFNC_WGL( CreateContext ); -INIT_OGLFNC_WGL( DeleteContext ); -INIT_OGLFNC_WGL( GetCurrentContext ); -INIT_OGLFNC_WGL( MakeCurrent ); -#endif - -// ----------- -// - WndProc - -// ----------- - -#ifdef WIN -LRESULT CALLBACK OpenGLWndProc( VCLWINDOW hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 ) -{ - return DefWindowProc( hWnd, nMsg, nPar1, nPar2 ); -} -#endif - -// ------------- -// - SalOpenGL - -// ------------- +// ======================================================================== SalOpenGL::SalOpenGL( SalGraphics* pGraphics ) { - // Set mhOGLLastDC only the first time a - // SalOpenGL object is created; we need - // this DC in SalOpenGL::Create(); - if ( OGL_STATE_UNLOADED == mnOGLState ) - mhOGLLastDC = pGraphics->maGraphicsData.mhDC; } // ------------------------------------------------------------------------ @@ -150,157 +91,26 @@ SalOpenGL::~SalOpenGL() BOOL SalOpenGL::Create() { - BOOL bRet = FALSE; - - if ( OGL_STATE_UNLOADED == mnOGLState ) - { - if( ImplInitLib() ) - { -#ifdef WIN - USHORT nBitCount = GetDeviceCaps( mhOGLLastDC, BITSPIXEL ); - PIXELFORMATDESCRIPTOR pfd = - { - sizeof( PIXELFORMATDESCRIPTOR ), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL, - PFD_TYPE_RGBA, - (BYTE) nBitCount, - 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, - 16, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - const int nIndex = ChoosePixelFormat( mhOGLLastDC, &pfd ); - - if( nIndex && SetPixelFormat( mhOGLLastDC, nIndex, &pfd ) ) - { - if ( (nBitCount > 8) && ImplInit() && - (mhOGLContext = pImplOpenWGLFncCreateContext( mhOGLLastDC )) != 0 ) - { - WNDCLASS aWc; - VCLWINDOW hDummyWnd; - - SaveDC( mhOGLLastDC ); - SelectClipRgn( mhOGLLastDC, NULL ); - pImplOpenWGLFncMakeCurrent( mhOGLLastDC, mhOGLContext ); - RestoreDC( mhOGLLastDC, -1 ); - mnOGLState = OGL_STATE_VALID; - bRet = TRUE; - - memset( &aWc, 0, sizeof( aWc ) ); - aWc.hInstance = GetModuleHandle( NULL ); - aWc.lpfnWndProc = OpenGLWndProc; - aWc.lpszClassName = "OpenGLWnd"; - RegisterClass( &aWc ); - hDummyWnd = CreateWindow( aWc.lpszClassName, NULL, WS_OVERLAPPED, 0, -50, 1, 1, VCLWINDOW_DESKTOP, NULL, aWc.hInstance, 0 ); - ShowWindow( hDummyWnd, SW_SHOW ); - DestroyWindow( hDummyWnd ); - UnregisterClass( aWc.lpszClassName, aWc.hInstance ); - } - else - { - ImplFreeLib(); - mnOGLState = OGL_STATE_INVALID; - } - } - else - mnOGLState = OGL_STATE_INVALID; -#endif - } - else - mnOGLState = OGL_STATE_INVALID; - } - else if( OGL_STATE_VALID == mnOGLState ) - bRet = TRUE; - - return bRet; + return FALSE; } // ------------------------------------------------------------------------ void SalOpenGL::Release() { - ImplFreeLib(); } // ------------------------------------------------------------------------ -void* SalOpenGL::GetOGLFnc( const char* pFncName ) +void *SalOpenGL::GetOGLFnc( const char* pFncName ) { -#ifdef WIN - if ( hImplOGLLib ) - return (void*)GetProcAddress( hImplOGLLib, pFncName ); - else -#endif - return NULL; + return NULL; } // ------------------------------------------------------------------------ -#ifdef WIN -typedef BOOL (WINAPI *MyFuncType)(VCLVIEW, HGLRC); -#endif - void SalOpenGL::OGLEntry( SalGraphics* pGraphics ) { - if ( pGraphics->maGraphicsData.mhDC != mhOGLLastDC ) - { -#ifdef WIN - PIXELFORMATDESCRIPTOR pfd = - { - sizeof( PIXELFORMATDESCRIPTOR ), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL, - PFD_TYPE_RGBA, - GetDeviceCaps( pGraphics->maGraphicsData.mhDC, BITSPIXEL ), - 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, - 16, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - const int nIndex = ChoosePixelFormat( pGraphics->maGraphicsData.mhDC, &pfd ); - if ( nIndex && SetPixelFormat( pGraphics->maGraphicsData.mhDC, nIndex, &pfd ) ) - { - WNDCLASS aWc; - VCLWINDOW hDummyWnd; - - pImplOpenWGLFncDeleteContext( mhOGLContext ); - mhOGLLastDC = pGraphics->maGraphicsData.mhDC; - mhOGLContext = pImplOpenWGLFncCreateContext( mhOGLLastDC ); - - SaveDC( mhOGLLastDC ); - SelectClipRgn( mhOGLLastDC, NULL ); - pImplOpenWGLFncMakeCurrent( mhOGLLastDC, mhOGLContext ); - RestoreDC( mhOGLLastDC, -1 ); - - memset( &aWc, 0, sizeof( aWc ) ); - aWc.hInstance = GetModuleHandle( NULL ); - aWc.lpfnWndProc = OpenGLWndProc; - aWc.lpszClassName = "OpenGLWnd"; - RegisterClass( &aWc ); - hDummyWnd = CreateWindow( aWc.lpszClassName, NULL, WS_OVERLAPPED, 0, -50, 1, 1, VCLWINDOW_DESKTOP, NULL, aWc.hInstance, 0 ); - ShowWindow( hDummyWnd, SW_SHOW ); - DestroyWindow( hDummyWnd ); - UnregisterClass( aWc.lpszClassName, aWc.hInstance ); - } -#endif - } } // ------------------------------------------------------------------------ @@ -308,43 +118,3 @@ void SalOpenGL::OGLEntry( SalGraphics* pGraphics ) void SalOpenGL::OGLExit( SalGraphics* pGraphics ) { } - -// ------------------------------------------------------------------------ - -BOOL SalOpenGL::ImplInitLib() -{ -#ifdef WIN - return ((hImplOGLLib = LoadLibrary( OGL_LIBNAME )) != NULL); -#endif -} - -// ------------------------------------------------------------------------ - -void SalOpenGL::ImplFreeLib() -{ -#ifdef WIN - if ( hImplOGLLib ) - { - FreeLibrary( hImplOGLLib ); - hImplOGLLib = NULL; - mnOGLState = OGL_STATE_UNLOADED; - } -#endif -} - -// ------------------------------------------------------------------------ - -BOOL SalOpenGL::ImplInit() -{ - BOOL bRet = TRUE; - -#ifdef WIN - // Internal use - GET_OGLFNC_WGL( CreateContext ); - GET_OGLFNC_WGL( DeleteContext ); - GET_OGLFNC_WGL( GetCurrentContext ); - GET_OGLFNC_WGL( MakeCurrent ); -#endif - - return bRet; -} |