Skip to content

Commit

Permalink
WGL: Add extension function macro aliases
Browse files Browse the repository at this point in the history
This should have been done when the WGL extension members were moved
from the context struct to the library struct.
  • Loading branch information
elmindreda committed May 24, 2019
1 parent 3fd4e79 commit 22a6c02
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/wgl_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ static int choosePixelFormat(_GLFWwindow* window,
{
const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB;

if (!_glfw.wgl.GetPixelFormatAttribivARB(window->context.wgl.dc,
1, 0, 1, &attrib, &nativeCount))
if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
1, 0, 1, &attrib, &nativeCount))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to retrieve pixel format attribute");
Expand Down Expand Up @@ -141,10 +141,10 @@ static int choosePixelFormat(_GLFWwindow* window,
{
// Get pixel format attributes through "modern" extension

if (!_glfw.wgl.GetPixelFormatAttribivARB(window->context.wgl.dc,
pixelFormat, 0,
attribCount,
attribs, values))
if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
pixelFormat, 0,
attribCount,
attribs, values))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to retrieve pixel format attributes");
Expand Down Expand Up @@ -362,17 +362,17 @@ static void swapIntervalWGL(int interval)
}

if (_glfw.wgl.EXT_swap_control)
_glfw.wgl.SwapIntervalEXT(interval);
wglSwapIntervalEXT(interval);
}

static int extensionSupportedWGL(const char* extension)
{
const char* extensions = NULL;

if (_glfw.wgl.GetExtensionsStringARB)
extensions = _glfw.wgl.GetExtensionsStringARB(wglGetCurrentDC());
extensions = wglGetExtensionsStringARB(wglGetCurrentDC());
else if (_glfw.wgl.GetExtensionsStringEXT)
extensions = _glfw.wgl.GetExtensionsStringEXT();
extensions = wglGetExtensionsStringEXT();

if (!extensions)
return GLFW_FALSE;
Expand Down Expand Up @@ -695,8 +695,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
setAttrib(0, 0);

window->context.wgl.handle =
_glfw.wgl.CreateContextAttribsARB(window->context.wgl.dc,
share, attribs);
wglCreateContextAttribsARB(window->context.wgl.dc, share, attribs);
if (!window->context.wgl.handle)
{
const DWORD error = GetLastError();
Expand Down
6 changes: 6 additions & 0 deletions src/wgl_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,17 @@
#define ERROR_INVALID_PROFILE_ARB 0x2096
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054

// WGL extension pointer typedefs
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC);
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*);
#define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT
#define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB
#define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT
#define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB
#define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB

// opengl32.dll function pointer typedefs
typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC);
Expand Down

0 comments on commit 22a6c02

Please sign in to comment.