ReactOS  r76032
wingl.c File Reference
#include <precomp.h>
#include <debug.h>
Include dependency graph for wingl.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Typedefs

typedef CONST
PIXELFORMATDESCRIPTOR *typedef 
BOOL (WINAPI *SETPIXELFMT)(HDC
 
typedef CONST
PIXELFORMATDESCRIPTOR *typedef 
int
 

Functions

typedef int (WINAPI *CHOOSEPIXELFMT)(HDC
 
static BOOL OpenGLInitFunction (PCSTR name, FARPROC *funcptr)
 
static BOOL OpenGLEnable (void)
 
INT WINAPI ChoosePixelFormat (HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd)
 
INT WINAPI DescribePixelFormat (HDC hdc, INT iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
 
INT WINAPI GetPixelFormat (HDC hdc)
 
BOOL WINAPI SetPixelFormat (HDC hdc, INT iPixelFormat, CONST PIXELFORMATDESCRIPTOR *ppfd)
 
BOOL WINAPI SwapBuffers (HDC hdc)
 

Variables

typedef UINT
 
typedef LPPIXELFORMATDESCRIPTOR
 
static CHOOSEPIXELFMT glChoosePixelFormat = NULL
 
static SETPIXELFMT glSetPixelFormat = NULL
 
static SWAPBUFFERS glSwapBuffers = NULL
 
static DESCRIBEPIXELFMT glDescribePixelFormat = NULL
 
static GETPIXELFMT glGetPixelFormat = NULL
 
HINSTANCE hOpenGL = NULL
 

Macro Definition Documentation

#define NDEBUG

Definition at line 26 of file wingl.c.

Typedef Documentation

typedef CONST PIXELFORMATDESCRIPTOR* typedef CONST PIXELFORMATDESCRIPTOR* typedef BOOL(WINAPI *SWAPBUFFERS)(HDC hdc)

Definition at line 32 of file wingl.c.

typedef int

Definition at line 32 of file wingl.c.

Function Documentation

INT WINAPI ChoosePixelFormat ( HDC  hdc,
CONST PIXELFORMATDESCRIPTOR ppfd 
)

Definition at line 113 of file wingl.c.

115 {
116  if (glChoosePixelFormat == NULL)
117  if (OpenGLEnable() == FALSE)
118  return(0);
119 
120  return(glChoosePixelFormat(hdc, ppfd));
121 }
_In_ LONG _In_ ULONG _Out_opt_ PIXELFORMATDESCRIPTOR * ppfd
Definition: winddi.h:3488
#define FALSE
Definition: types.h:117
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:557
static CHOOSEPIXELFMT glChoosePixelFormat
Definition: wingl.c:38
static BOOL OpenGLEnable(void)
Definition: wingl.c:66
INT WINAPI DescribePixelFormat ( HDC  hdc,
INT  iPixelFormat,
UINT  nBytes,
LPPIXELFORMATDESCRIPTOR  ppfd 
)

Definition at line 130 of file wingl.c.

134 {
136  if (OpenGLEnable() == FALSE)
137  return(0);
138 
139  return(glDescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd));
140 }
static DESCRIBEPIXELFMT glDescribePixelFormat
Definition: wingl.c:41
#define FALSE
Definition: types.h:117
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:557
_In_ LONG iPixelFormat
Definition: winddi.h:3488
static BOOL OpenGLEnable(void)
Definition: wingl.c:66
INT WINAPI GetPixelFormat ( HDC  hdc)

Definition at line 149 of file wingl.c.

Referenced by SetPixelFormat().

150 {
151  if (glGetPixelFormat == NULL)
152  if (OpenGLEnable() == FALSE)
153  return(0);
154 
155  return(glGetPixelFormat(hdc));
156 }
#define FALSE
Definition: types.h:117
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:557
static GETPIXELFMT glGetPixelFormat
Definition: wingl.c:42
static BOOL OpenGLEnable(void)
Definition: wingl.c:66
typedef int ( WINAPI CHOOSEPIXELFMT)
static BOOL OpenGLEnable ( void  )
static

Definition at line 66 of file wingl.c.

Referenced by ChoosePixelFormat(), DescribePixelFormat(), GetPixelFormat(), SetPixelFormat(), and SwapBuffers().

67 {
68  HMODULE hModOpengl32;
69  BOOL Ret = TRUE;
70 
71  hModOpengl32 = LoadLibraryW(L"OPENGL32.DLL");
72  if (hModOpengl32 == NULL)
73  return FALSE;
74 
76  (PVOID)hModOpengl32,
77  NULL) != NULL)
78  {
79  FreeLibrary(hModOpengl32);
80 
81  /* NOTE: Even though another thread was faster loading the
82  library we can't just bail out here. We really need
83  to *try* to locate every function. This is slow but
84  thread-safe */
85  }
86 
87 
88  if (!OpenGLInitFunction("wglChoosePixelFormat", &glChoosePixelFormat))
89  Ret = FALSE;
90 
91  if (!OpenGLInitFunction("wglSetPixelFormat", &glSetPixelFormat))
92  Ret = FALSE;
93 
94  if (!OpenGLInitFunction("wglSwapBuffers", &glSwapBuffers))
95  Ret = FALSE;
96 
97  if (!OpenGLInitFunction("wglDescribePixelFormat", &glDescribePixelFormat))
98  Ret = FALSE;
99 
100  if (!OpenGLInitFunction("wglGetPixelFormat", &glGetPixelFormat))
101  Ret = FALSE;
102 
103  return Ret;
104 }
DWORD *typedef PVOID
Definition: winlogon.h:52
static BOOL OpenGLInitFunction(PCSTR name, FARPROC *funcptr)
Definition: wingl.c:49
#define TRUE
Definition: types.h:120
Definition: bidi.c:75
static DESCRIBEPIXELFMT glDescribePixelFormat
Definition: wingl.c:41
#define FALSE
Definition: types.h:117
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
#define LoadLibraryW(x)
Definition: compat.h:404
smooth NULL
Definition: ftsmooth.c:557
#define FreeLibrary(x)
Definition: compat.h:405
unsigned int BOOL
Definition: ntddk_ex.h:94
static SETPIXELFMT glSetPixelFormat
Definition: wingl.c:39
static GETPIXELFMT glGetPixelFormat
Definition: wingl.c:42
HINSTANCE hOpenGL
Definition: wingl.c:47
static CHOOSEPIXELFMT glChoosePixelFormat
Definition: wingl.c:38
HANDLE HMODULE
Definition: typedefs.h:75
static SWAPBUFFERS glSwapBuffers
Definition: wingl.c:40
static BOOL OpenGLInitFunction ( PCSTR  name,
FARPROC funcptr 
)
static

Definition at line 49 of file wingl.c.

Referenced by OpenGLEnable().

51 {
52  PVOID func;
53 
54  func = (PVOID)GetProcAddress(hOpenGL, name);
55  if (func != NULL)
56  {
58  func,
59  NULL);
60  return TRUE;
61  }
62 
63  return FALSE;
64 }
DWORD *typedef PVOID
Definition: winlogon.h:52
GLenum func
Definition: glext.h:6028
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
smooth NULL
Definition: ftsmooth.c:557
HINSTANCE hOpenGL
Definition: wingl.c:47
Definition: name.c:23
#define GetProcAddress(x, y)
Definition: compat.h:410
BOOL WINAPI SetPixelFormat ( HDC  hdc,
INT  iPixelFormat,
CONST PIXELFORMATDESCRIPTOR ppfd 
)

Definition at line 165 of file wingl.c.

168 {
169  /* Can only be set once */
171  if(current) return current == iPixelFormat ;
172 
173  if (glSetPixelFormat == NULL)
174  if (OpenGLEnable() == FALSE)
175  return(0);
176 
178 }
_In_ LONG _In_ ULONG _Out_opt_ PIXELFORMATDESCRIPTOR * ppfd
Definition: winddi.h:3488
int32_t INT
Definition: typedefs.h:56
#define FALSE
Definition: types.h:117
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:557
static SETPIXELFMT glSetPixelFormat
Definition: wingl.c:39
INT WINAPI GetPixelFormat(HDC hdc)
Definition: wingl.c:149
_In_ LONG iPixelFormat
Definition: winddi.h:3488
static BOOL OpenGLEnable(void)
Definition: wingl.c:66
struct task_struct * current
Definition: linux.c:32
BOOL WINAPI SwapBuffers ( HDC  hdc)

Definition at line 187 of file wingl.c.

Referenced by DrawScene(), OnPaint(), ScreenSaverProc(), test_destroy(), test_destroy_read(), and test_message_window().

188 {
189  if (glSwapBuffers == NULL)
190  if (OpenGLEnable() == FALSE)
191  return(0);
192 
193 
194  return(glSwapBuffers(hdc));
195 }
#define FALSE
Definition: types.h:117
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:557
static BOOL OpenGLEnable(void)
Definition: wingl.c:66
static SWAPBUFFERS glSwapBuffers
Definition: wingl.c:40

Variable Documentation

CHOOSEPIXELFMT glChoosePixelFormat = NULL
static

Definition at line 38 of file wingl.c.

Referenced by ChoosePixelFormat(), and OpenGLEnable().

DESCRIBEPIXELFMT glDescribePixelFormat = NULL
static

Definition at line 41 of file wingl.c.

Referenced by DescribePixelFormat(), and OpenGLEnable().

GETPIXELFMT glGetPixelFormat = NULL
static

Definition at line 42 of file wingl.c.

Referenced by GetPixelFormat(), and OpenGLEnable().

SETPIXELFMT glSetPixelFormat = NULL
static

Definition at line 39 of file wingl.c.

Referenced by OpenGLEnable(), and SetPixelFormat().

SWAPBUFFERS glSwapBuffers = NULL
static

Definition at line 40 of file wingl.c.

Referenced by OpenGLEnable(), and SwapBuffers().

HINSTANCE hOpenGL = NULL

Definition at line 47 of file wingl.c.

Referenced by OpenGLEnable(), and OpenGLInitFunction().

Definition at line 34 of file wingl.c.

typedef UINT

Definition at line 34 of file wingl.c.