2006-10-03 19:52:17 +02:00
|
|
|
/*
|
|
|
|
* OpenGL function forwarding to the display driver
|
|
|
|
*
|
|
|
|
* Copyright (c) 1999 Lionel Ulmer
|
|
|
|
* Copyright (c) 2005 Raphael Junqueira
|
|
|
|
* Copyright (c) 2006 Roderick Colenbrander
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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 for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winerror.h"
|
2006-10-14 12:56:07 +02:00
|
|
|
#include "winternl.h"
|
|
|
|
#include "winnt.h"
|
2006-10-03 19:52:17 +02:00
|
|
|
|
|
|
|
|
2012-06-25 21:51:16 +02:00
|
|
|
static HMODULE opengl32;
|
|
|
|
static INT (WINAPI *wglChoosePixelFormat)(HDC,const PIXELFORMATDESCRIPTOR *);
|
2012-06-25 21:59:11 +02:00
|
|
|
static INT (WINAPI *wglDescribePixelFormat)(HDC,INT,UINT,PIXELFORMATDESCRIPTOR*);
|
2012-06-28 15:51:44 +02:00
|
|
|
static INT (WINAPI *wglGetPixelFormat)(HDC);
|
2012-06-25 22:03:59 +02:00
|
|
|
static BOOL (WINAPI *wglSetPixelFormat)(HDC,INT,const PIXELFORMATDESCRIPTOR*);
|
2012-06-25 22:45:28 +02:00
|
|
|
static BOOL (WINAPI *wglSwapBuffers)(HDC);
|
2012-06-25 21:51:16 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ChoosePixelFormat (GDI32.@)
|
|
|
|
*/
|
|
|
|
INT WINAPI ChoosePixelFormat( HDC hdc, const PIXELFORMATDESCRIPTOR *pfd )
|
|
|
|
{
|
|
|
|
if (!wglChoosePixelFormat)
|
|
|
|
{
|
2020-11-06 12:08:16 +01:00
|
|
|
if (!opengl32) opengl32 = LoadLibraryW( L"opengl32.dll" );
|
2012-06-25 21:51:16 +02:00
|
|
|
if (!(wglChoosePixelFormat = (void *)GetProcAddress( opengl32, "wglChoosePixelFormat" )))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return wglChoosePixelFormat( hdc, pfd );
|
|
|
|
}
|
2012-06-25 21:59:11 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DescribePixelFormat (GDI32.@)
|
|
|
|
*/
|
|
|
|
INT WINAPI DescribePixelFormat( HDC hdc, INT fmt, UINT size, PIXELFORMATDESCRIPTOR *pfd )
|
|
|
|
{
|
|
|
|
if (!wglDescribePixelFormat)
|
|
|
|
{
|
2020-11-06 12:08:16 +01:00
|
|
|
if (!opengl32) opengl32 = LoadLibraryW( L"opengl32.dll" );
|
2012-06-25 21:59:11 +02:00
|
|
|
if (!(wglDescribePixelFormat = (void *)GetProcAddress( opengl32, "wglDescribePixelFormat" )))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return wglDescribePixelFormat( hdc, fmt, size, pfd );
|
|
|
|
}
|
2012-06-25 22:03:59 +02:00
|
|
|
|
2012-06-28 15:51:44 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetPixelFormat (GDI32.@)
|
|
|
|
*/
|
|
|
|
INT WINAPI GetPixelFormat( HDC hdc )
|
|
|
|
{
|
|
|
|
if (!wglGetPixelFormat)
|
|
|
|
{
|
2020-11-06 12:08:16 +01:00
|
|
|
if (!opengl32) opengl32 = LoadLibraryW( L"opengl32.dll" );
|
2012-06-28 15:51:44 +02:00
|
|
|
if (!(wglGetPixelFormat = (void *)GetProcAddress( opengl32, "wglGetPixelFormat" )))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return wglGetPixelFormat( hdc );
|
|
|
|
}
|
|
|
|
|
2012-06-25 22:03:59 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* SetPixelFormat (GDI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetPixelFormat( HDC hdc, INT fmt, const PIXELFORMATDESCRIPTOR *pfd )
|
|
|
|
{
|
|
|
|
if (!wglSetPixelFormat)
|
|
|
|
{
|
2020-11-06 12:08:16 +01:00
|
|
|
if (!opengl32) opengl32 = LoadLibraryW( L"opengl32.dll" );
|
2012-06-25 22:03:59 +02:00
|
|
|
if (!(wglSetPixelFormat = (void *)GetProcAddress( opengl32, "wglSetPixelFormat" )))
|
2013-11-06 21:21:08 +01:00
|
|
|
return FALSE;
|
2012-06-25 22:03:59 +02:00
|
|
|
}
|
|
|
|
return wglSetPixelFormat( hdc, fmt, pfd );
|
|
|
|
}
|
2012-06-25 22:45:28 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SwapBuffers (GDI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SwapBuffers( HDC hdc )
|
|
|
|
{
|
|
|
|
if (!wglSwapBuffers)
|
|
|
|
{
|
2020-11-06 12:08:16 +01:00
|
|
|
if (!opengl32) opengl32 = LoadLibraryW( L"opengl32.dll" );
|
2012-06-25 22:45:28 +02:00
|
|
|
if (!(wglSwapBuffers = (void *)GetProcAddress( opengl32, "wglSwapBuffers" )))
|
2013-11-06 21:21:08 +01:00
|
|
|
return FALSE;
|
2012-06-25 22:45:28 +02:00
|
|
|
}
|
|
|
|
return wglSwapBuffers( hdc );
|
|
|
|
}
|