43 if (!
_glfw.wgl.GetPixelFormatAttribivARB(window->
context.wgl.dc,
45 0, 1, &attrib, &value))
48 "WGL: Failed to retrieve pixel format attribute");
63 int i, pixelFormat, nativeCount, usableCount;
65 if (
_glfw.wgl.ARB_pixel_format)
73 nativeCount = DescribePixelFormat(window->
context.wgl.dc,
75 sizeof(PIXELFORMATDESCRIPTOR),
82 for (i = 0; i < nativeCount; i++)
87 if (
_glfw.wgl.ARB_pixel_format)
129 if (
_glfw.wgl.ARB_multisample)
134 if (
_glfw.wgl.ARB_framebuffer_sRGB ||
135 _glfw.wgl.EXT_framebuffer_sRGB)
143 if (
_glfw.wgl.EXT_colorspace)
157 PIXELFORMATDESCRIPTOR pfd;
159 if (!DescribePixelFormat(window->
context.wgl.dc,
161 sizeof(PIXELFORMATDESCRIPTOR),
167 if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
168 !(pfd.dwFlags & PFD_SUPPORT_OPENGL))
173 if (!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) &&
174 (pfd.dwFlags & PFD_GENERIC_FORMAT))
179 if (pfd.iPixelType != PFD_TYPE_RGBA)
197 if (pfd.dwFlags & PFD_STEREO)
199 if (pfd.dwFlags & PFD_DOUBLEBUFFER)
210 "WGL: The driver does not appear to support OpenGL");
220 "WGL: Failed to find a suitable pixel format");
226 pixelFormat = (int) closest->
handle;
241 "WGL: Failed to make context current");
250 "WGL: Failed to clear current context");
275 SwapBuffers(window->
context.wgl.dc);
282 window->
context.wgl.interval = interval;
297 if (
_glfw.wgl.EXT_swap_control)
298 _glfw.wgl.SwapIntervalEXT(interval);
303 const char* extensions =
NULL;
305 if (
_glfw.wgl.GetExtensionsStringARB)
307 else if (
_glfw.wgl.GetExtensionsStringEXT)
308 extensions =
_glfw.wgl.GetExtensionsStringEXT();
329 if (window->
context.wgl.handle)
345 PIXELFORMATDESCRIPTOR pfd;
349 if (
_glfw.wgl.instance)
352 _glfw.wgl.instance = LoadLibraryA(
"opengl32.dll");
353 if (!
_glfw.wgl.instance)
356 "WGL: Failed to load opengl32.dll");
361 GetProcAddress(
_glfw.wgl.instance,
"wglCreateContext");
363 GetProcAddress(
_glfw.wgl.instance,
"wglDeleteContext");
365 GetProcAddress(
_glfw.wgl.instance,
"wglGetProcAddress");
367 GetProcAddress(
_glfw.wgl.instance,
"wglGetCurrentDC");
369 GetProcAddress(
_glfw.wgl.instance,
"wglGetCurrentContext");
371 GetProcAddress(
_glfw.wgl.instance,
"wglMakeCurrent");
373 GetProcAddress(
_glfw.wgl.instance,
"wglShareLists");
380 dc = GetDC(
_glfw.win32.helperWindowHandle);;
382 ZeroMemory(&pfd,
sizeof(pfd));
383 pfd.nSize =
sizeof(pfd);
385 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
386 pfd.iPixelType = PFD_TYPE_RGBA;
389 if (!SetPixelFormat(dc, ChoosePixelFormat(dc, &pfd), &pfd))
392 "WGL: Failed to set pixel format for dummy context");
400 "WGL: Failed to create dummy context");
410 "WGL: Failed to make dummy context current");
431 _glfw.wgl.ARB_multisample =
433 _glfw.wgl.ARB_framebuffer_sRGB =
435 _glfw.wgl.EXT_framebuffer_sRGB =
437 _glfw.wgl.ARB_create_context =
439 _glfw.wgl.ARB_create_context_profile =
441 _glfw.wgl.EXT_create_context_es2_profile =
443 _glfw.wgl.ARB_create_context_robustness =
445 _glfw.wgl.ARB_create_context_no_error =
447 _glfw.wgl.EXT_swap_control =
449 _glfw.wgl.EXT_colorspace =
451 _glfw.wgl.ARB_pixel_format =
453 _glfw.wgl.ARB_context_flush_control =
465 if (
_glfw.wgl.instance)
466 FreeLibrary(
_glfw.wgl.instance);
469 #define setAttrib(a, v) \ 471 assert((size_t) (index + 1) < sizeof(attribs) / sizeof(attribs[0])); \ 472 attribs[index++] = a; \ 473 attribs[index++] = v; \ 484 PIXELFORMATDESCRIPTOR pfd;
487 if (ctxconfig->
share)
490 window->
context.wgl.dc = GetDC(window->win32.handle);
494 "WGL: Failed to retrieve DC for window");
502 if (!DescribePixelFormat(window->
context.wgl.dc,
503 pixelFormat,
sizeof(pfd), &pfd))
506 "WGL: Failed to retrieve PFD for selected pixel format");
510 if (!SetPixelFormat(window->
context.wgl.dc, pixelFormat, &pfd))
513 "WGL: Failed to set selected pixel format");
521 if (!
_glfw.wgl.ARB_create_context)
524 "WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable");
531 if (!
_glfw.wgl.ARB_create_context_profile)
534 "WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
541 if (!
_glfw.wgl.ARB_create_context ||
542 !
_glfw.wgl.ARB_create_context_profile ||
543 !
_glfw.wgl.EXT_create_context_es2_profile)
546 "WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable");
551 if (
_glfw.wgl.ARB_create_context)
568 if (ctxconfig->
debug)
573 if (
_glfw.wgl.ARB_create_context_robustness)
592 if (
_glfw.wgl.ARB_context_flush_control)
609 if (
_glfw.wgl.ARB_create_context_no_error)
616 if (ctxconfig->
major != 1 || ctxconfig->
minor != 0)
631 _glfw.wgl.CreateContextAttribsARB(window->
context.wgl.dc,
633 if (!window->
context.wgl.handle)
635 const DWORD
error = GetLastError();
642 "WGL: Driver does not support OpenGL version %i.%i",
649 "WGL: Driver does not support OpenGL ES version %i.%i",
657 "WGL: Driver does not support the requested OpenGL profile");
662 "WGL: The share context is not compatible with the requested context");
669 "WGL: Failed to create OpenGL context");
674 "WGL: Failed to create OpenGL ES context");
684 if (!window->
context.wgl.handle)
687 "WGL: Failed to create OpenGL context");
696 "WGL: Failed to enable sharing with specified OpenGL context");
730 return window->
context.wgl.handle;
_GLFWswapbuffersfun swapBuffers
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB
#define ERROR_INVALID_VERSION_ARB
static int extensionSupportedWGL(const char *extension)
_GLFWgetprocaddressfun getProcAddress
#define WGL_ACCELERATION_ARB
#define WGL_BLUE_BITS_ARB
#define GLFW_OPENGL_COMPAT_PROFILE
#define WGL_AUX_BUFFERS_ARB
#define WGL_NO_ACCELERATION_ARB
GLuint64 GLenum void * handle
HGLRC(WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int *)
BOOL(WINAPI * PFN_wglDeleteContext)(HGLRC)
_GLFWdestroycontextfun destroy
#define WGL_NUMBER_PIXEL_FORMATS_ARB
static void makeContextCurrentWGL(_GLFWwindow *window)
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow *handle)
BOOL(WINAPI * PFN_wglMakeCurrent)(HDC, HGLRC)
#define GLFW_NO_WINDOW_CONTEXT
The specified window does not have an OpenGL or OpenGL ES context.
#define WGL_ACCUM_GREEN_BITS_ARB
#define GLFW_LOSE_CONTEXT_ON_RESET
#define GLFW_API_UNAVAILABLE
GLFW could not find support for the requested API on the system.
GLFWbool _glfwCreateContextWGL(_GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
#define WGL_COLORSPACE_EXT
#define GLFW_FORMAT_UNAVAILABLE
The requested format is not supported or available.
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB
#define GLFW_RELEASE_BEHAVIOR_NONE
HGLRC(WINAPI * PFN_wglGetCurrentContext)(void)
BOOL(WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int)
#define _GLFW_REQUIRE_INIT_OR_RETURN(x)
const _GLFWfbconfig * _glfwChooseFBConfig(const _GLFWfbconfig *desired, const _GLFWfbconfig *alternatives, unsigned int count)
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
#define WGL_CONTEXT_DEBUG_BIT_ARB
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
HGLRC(WINAPI * PFN_wglCreateContext)(HDC)
#define WGL_CONTEXT_PROFILE_MASK_ARB
#define WGL_STENCIL_BITS_ARB
GLFWbool _glfwStringInExtensionString(const char *string, const char *extensions)
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB
#define WGL_LOSE_CONTEXT_ON_RESET_ARB
void _glfwInputErrorWin32(int error, const char *description)
#define WGL_DRAW_TO_WINDOW_ARB
_GLFWmakecontextcurrentfun makeCurrent
GLenum GLenum GLsizei const GLuint GLboolean enabled
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC)
BOOL(WINAPI * PFN_wglShareLists)(HGLRC, HGLRC)
void _glfwInputError(int code, const char *format,...)
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB
_GLFWextensionsupportedfun extensionSupported
#define GLFW_RELEASE_BEHAVIOR_FLUSH
#define WGL_ALPHA_BITS_ARB
static void swapBuffersWGL(_GLFWwindow *window)
#define WGL_TYPE_RGBA_ARB
#define GLFW_VERSION_UNAVAILABLE
The requested OpenGL or OpenGL ES version is not available.
#define wglGetProcAddress
_GLFWswapintervalfun swapInterval
HDC(WINAPI * PFN_wglGetCurrentDC)(void)
#define wglGetCurrentContext
static void destroyContextWGL(_GLFWwindow *window)
#define GLFW_INVALID_VALUE
One of the arguments to the function was an invalid value.
void _glfwPlatformSetTls(_GLFWtls *tls, void *value)
#define WGL_ACCUM_BLUE_BITS_ARB
#define WGL_NO_RESET_NOTIFICATION_ARB
#define WGL_GREEN_BITS_ARB
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB
void _glfwTerminateWGL(void)
static GLFWglproc getProcAddressWGL(const char *procname)
static int choosePixelFormat(_GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
#define WGL_ACCUM_ALPHA_BITS_ARB
#define GLFW_OPENGL_CORE_PROFILE
static int getPixelFormatAttrib(_GLFWwindow *window, int pixelFormat, int attrib)
#define WGL_CONTEXT_FLAGS_ARB
#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB
GLFWbool _glfwInitWGL(void)
#define WGL_ACCUM_RED_BITS_ARB
static void swapIntervalWGL(int interval)
void * _glfwPlatformGetTls(_GLFWtls *tls)
#define WGL_DEPTH_BITS_ARB
PROC(WINAPI * PFN_wglGetProcAddress)(LPCSTR)
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB
#define WGL_SUPPORT_OPENGL_ARB
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB
const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void)
#define WGL_CONTEXT_MAJOR_VERSION_ARB
#define ERROR_INVALID_PROFILE_ARB
#define WGL_DOUBLE_BUFFER_ARB
#define WGL_PIXEL_TYPE_ARB
#define GLFW_NO_RESET_NOTIFICATION
BOOL(WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC, int, int, UINT, const int *, int *)
struct GLFWwindow GLFWwindow
#define WGL_CONTEXT_MINOR_VERSION_ARB
#define WGL_COLORSPACE_SRGB_EXT