47 window->wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
51 window->wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
55 window->wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
60 window->wgl.ARB_multisample =
62 window->wgl.ARB_framebuffer_sRGB =
64 window->wgl.EXT_framebuffer_sRGB =
66 window->wgl.ARB_create_context =
68 window->wgl.ARB_create_context_profile =
70 window->wgl.EXT_create_context_es2_profile =
72 window->wgl.ARB_create_context_robustness =
74 window->wgl.EXT_swap_control =
76 window->wgl.ARB_pixel_format =
78 window->wgl.ARB_context_flush_control =
88 assert(window->wgl.ARB_pixel_format);
90 if (!window->wgl.GetPixelFormatAttribivARB(window->wgl.dc,
92 0, 1, &attrib, &value))
95 "WGL: Failed to retrieve pixel format attribute %i",
111 int i, nativeCount, usableCount;
113 if (window->wgl.ARB_pixel_format)
121 nativeCount = DescribePixelFormat(window->wgl.dc,
123 sizeof(PIXELFORMATDESCRIPTOR),
130 for (i = 0; i < nativeCount; i++)
135 if (window->wgl.ARB_pixel_format)
177 if (window->wgl.ARB_multisample)
180 if (window->wgl.ARB_framebuffer_sRGB ||
181 window->wgl.EXT_framebuffer_sRGB)
189 PIXELFORMATDESCRIPTOR pfd;
193 if (!DescribePixelFormat(window->wgl.dc,
195 sizeof(PIXELFORMATDESCRIPTOR),
201 if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
202 !(pfd.dwFlags & PFD_SUPPORT_OPENGL))
207 if (!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) &&
208 (pfd.dwFlags & PFD_GENERIC_FORMAT))
213 if (pfd.iPixelType != PFD_TYPE_RGBA)
231 if (pfd.dwFlags & PFD_STEREO)
233 if (pfd.dwFlags & PFD_DOUBLEBUFFER)
244 "WGL: The driver does not appear to support OpenGL");
254 "WGL: Failed to find a suitable pixel format");
260 *result = closest->wgl;
278 _glfw.wgl.opengl32.instance = LoadLibraryW(L
"opengl32.dll");
279 if (!
_glfw.wgl.opengl32.instance)
286 GetProcAddress(
_glfw.wgl.opengl32.instance,
"wglCreateContext");
288 GetProcAddress(
_glfw.wgl.opengl32.instance,
"wglDeleteContext");
290 GetProcAddress(
_glfw.wgl.opengl32.instance,
"wglGetProcAddress");
292 GetProcAddress(
_glfw.wgl.opengl32.instance,
"wglMakeCurrent");
294 GetProcAddress(
_glfw.wgl.opengl32.instance,
"wglShareLists");
296 if (!
_glfw.wgl.opengl32.CreateContext ||
297 !
_glfw.wgl.opengl32.DeleteContext ||
298 !
_glfw.wgl.opengl32.GetProcAddress ||
299 !
_glfw.wgl.opengl32.MakeCurrent ||
300 !
_glfw.wgl.opengl32.ShareLists)
303 "WGL: Failed to load opengl32 functions");
314 if (
_glfw.wgl.opengl32.instance)
315 FreeLibrary(
_glfw.wgl.opengl32.instance);
320 #define setWGLattrib(attribName, attribValue) \ 322 attribs[index++] = attribName; \ 323 attribs[index++] = attribValue; \ 324 assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \ 335 PIXELFORMATDESCRIPTOR pfd;
338 if (ctxconfig->
share)
341 window->wgl.dc = GetDC(window->win32.handle);
345 "WGL: Failed to retrieve DC for window");
352 if (!DescribePixelFormat(window->wgl.dc, pixelFormat,
sizeof(pfd), &pfd))
355 "WGL: Failed to retrieve PFD for selected pixel format");
359 if (!SetPixelFormat(window->wgl.dc, pixelFormat, &pfd))
362 "WGL: Failed to set selected pixel format");
366 if (window->wgl.ARB_create_context)
383 if (ctxconfig->
debug)
388 if (window->wgl.ARB_create_context_robustness)
407 if (window->wgl.ARB_context_flush_control)
425 if (ctxconfig->
major != 1 || ctxconfig->
minor != 0)
439 window->wgl.
context = window->wgl.CreateContextAttribsARB(window->wgl.dc,
445 "WGL: Failed to create OpenGL context");
455 "WGL: Failed to create OpenGL context");
464 "WGL: Failed to enable sharing with specified OpenGL context");
490 ReleaseDC(window->win32.handle, window->wgl.dc);
491 window->wgl.dc = NULL;
507 if (!window->wgl.ARB_create_context)
510 "WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable");
519 if (!window->wgl.ARB_create_context_profile)
522 "WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
531 if (window->wgl.ARB_context_flush_control)
537 if (!window->wgl.ARB_create_context ||
538 !window->wgl.ARB_create_context_profile ||
539 !window->wgl.EXT_create_context_es2_profile)
542 "WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable");
549 if (ctxconfig->
major != 1 || ctxconfig->
minor != 0)
551 if (window->wgl.ARB_create_context)
555 if (ctxconfig->
debug)
557 if (window->wgl.ARB_create_context)
564 if (window->wgl.ARB_multisample && window->wgl.ARB_pixel_format)
571 if ((window->wgl.ARB_framebuffer_sRGB ||
572 window->wgl.EXT_framebuffer_sRGB) &&
573 window->wgl.ARB_pixel_format)
605 int count = abs(window->wgl.interval);
610 SwapBuffers(window->wgl.dc);
617 window->wgl.interval = interval;
624 if (window->wgl.EXT_swap_control)
625 window->wgl.SwapIntervalEXT(interval);
630 const char* extensions;
634 if (window->wgl.GetExtensionsStringEXT != NULL)
636 extensions = window->wgl.GetExtensionsStringEXT();
644 if (window->wgl.GetExtensionsStringARB != NULL)
646 extensions = window->wgl.GetExtensionsStringARB(window->wgl.dc);
663 return (
GLFWglproc) GetProcAddress(
_glfw.wgl.opengl32.instance, procname);
#define WGL_NO_RESET_NOTIFICATION_ARB
#define WGL_CONTEXT_DEBUG_BIT_ARB
#define WGL_SUPPORT_OPENGL_ARB
#define WGL_ALPHA_BITS_ARB
int _glfwStringInExtensionString(const char *string, const char *extensions)
Searches an extension string for the specified extension.
int _glfwAnalyzeContext(const _GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
#define GLFW_OPENGL_COMPAT_PROFILE
#define WGL_DRAW_TO_WINDOW_ARB
#define WGL_CONTEXT_PROFILE_MASK_ARB
#define WGL_CONTEXT_FLAGS_ARB
BOOL(WINAPI * WGLMAKECURRENT_T)(HDC, HGLRC)
#define WGL_CONTEXT_MAJOR_VERSION_ARB
#define WGL_ACCUM_BLUE_BITS_ARB
const _GLFWfbconfig * _glfwChooseFBConfig(const _GLFWfbconfig *desired, const _GLFWfbconfig *alternatives, unsigned int count)
Chooses the framebuffer config that best matches the desired one.
#define setWGLattrib(attribName, attribValue)
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow *handle)
void _glfwSetContextTLS(_GLFWwindow *context)
void _glfwTerminateContextAPI(void)
#define WGL_NO_ACCELERATION_ARB
#define GLFW_LOSE_CONTEXT_ON_RESET
typedef HGLRC(WINAPI *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC
#define GLFW_API_UNAVAILABLE
GLFW could not find support for the requested client API on the system.
#define GLFW_FORMAT_UNAVAILABLE
The requested format is not supported or available.
#define WGL_STENCIL_BITS_ARB
#define WGL_BLUE_BITS_ARB
#define GLFW_RELEASE_BEHAVIOR_NONE
_GLFWlibrary _glfw
All global data protected by _glfwInitialized. This should only be touched after a call to glfwInit t...
struct GLFWwindow GLFWwindow
Opaque window object.
void _glfwDestroyContext(_GLFWwindow *window)
#define _GLFW_REQUIRE_INIT_OR_RETURN(x)
#define WGL_LOSE_CONTEXT_ON_RESET_ARB
#define _glfw_wglMakeCurrent
#define WGL_PIXEL_TYPE_ARB
typedef GLboolean(APIENTRYP PFNGLISQUERYPROC)(GLuint id)
#define WGL_DEPTH_BITS_ARB
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
GLuint GLuint GLsizei count
#define _glfw_wglGetProcAddress
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB
#define _glfw_wglShareLists
BOOL(WINAPI * WGLSHARELISTS_T)(HGLRC, HGLRC)
struct _GLFWwindow::@0 context
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
#define WGL_ACCUM_ALPHA_BITS_ARB
GLsizei const GLfloat * value
#define GLFW_RELEASE_BEHAVIOR_FLUSH
int _glfwCreateContext(_GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB
#define GLFW_VERSION_UNAVAILABLE
The requested OpenGL or OpenGL ES version is not available.
static void initWGLExtensions(_GLFWwindow *window)
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB
static GLboolean choosePixelFormat(_GLFWwindow *window, const _GLFWfbconfig *desired, int *result)
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT
HGLRC(WINAPI * WGLCREATECONTEXT_T)(HDC)
#define WGL_ACCUM_GREEN_BITS_ARB
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB
#define _glfw_wglCreateContext
#define WGL_ACCELERATION_ARB
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB
#define _glfw_wglDeleteContext
#define WGL_ACCUM_RED_BITS_ARB
#define GLFW_OPENGL_CORE_PROFILE
static int getPixelFormatAttrib(_GLFWwindow *window, int pixelFormat, int attrib)
PROC(WINAPI * WGLGETPROCADDRESS_T)(LPCSTR)
#define WGL_AUX_BUFFERS_ARB
BOOL(WINAPI * WGLDELETECONTEXT_T)(HGLRC)
void _glfwInputError(int error, const char *format,...)
Notifies shared code of an error.
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB
int _glfwCreateContextTLS(void)
#define WGL_TYPE_RGBA_ARB
const char *WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC(void)
#define WGL_CONTEXT_MINOR_VERSION_ARB
#define WGL_NUMBER_PIXEL_FORMATS_ARB
#define WGL_GREEN_BITS_ARB
Window and context structure.
Framebuffer configuration.
BOOL _glfwIsCompositionEnabled(void)
const char *WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC(HDC hdc)
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB
#define WGL_DOUBLE_BUFFER_ARB
#define GLFW_NO_RESET_NOTIFICATION
void(* GLFWglproc)(void)
Client API function pointer type.
int _glfwInitContextAPI(void)
void _glfwDestroyContextTLS(void)