14# define WIN32_LEAN_AND_MEAN
17# include <epoxy/wgl.h>
20# ifndef ERROR_PROFILE_DOES_NOT_MATCH_DEVICE
21# define ERROR_PROFILE_DOES_NOT_MATCH_DEVICE 0x7E7
25#ifdef WITH_OPENGL_BACKEND
34bool win32_silent_chk(
bool result)
37 SetLastError(NO_ERROR);
43bool win32_chk(
bool result,
const char *file,
int line,
const char *text)
46 LPTSTR formattedMsg =
nullptr;
48 DWORD
error = GetLastError();
57 switch (
error & 0x0000FFFF) {
58 case ERROR_INVALID_VERSION_ARB:
60 "The specified OpenGL version and feature set are either invalid or not supported.\n";
63 case ERROR_INVALID_PROFILE_ARB:
65 "The specified OpenGL profile and feature set are either invalid or not supported.\n";
68 case ERROR_INVALID_PIXEL_TYPE_ARB:
69 msg =
"The specified pixel type is invalid.\n";
72 case ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB:
74 (
"The device contexts specified are not compatible. "
75 "This can occur if the device contexts are managed by "
76 "different drivers or possibly on different graphics adapters.\n");
80 case ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV:
81 msg =
"The device context(s) and rendering context have non-matching affinity masks.\n";
84 case ERROR_MISSING_AFFINITY_MASK_NV:
85 msg =
"The rendering context does not have an affinity mask set.\n";
89 case ERROR_PROFILE_DOES_NOT_MATCH_DEVICE:
91 (
"The specified profile is intended for a device of a "
92 "different type than the specified device.\n");
96 count = FormatMessage((FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
97 FORMAT_MESSAGE_IGNORE_INSERTS),
100 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
101 (LPTSTR)(&formattedMsg),
105 msg =
count > 0 ? formattedMsg :
"<no system message>\n";
112 stderr,
"%s:%d: [%s] -> Win32 Error# (%lu): %s", file, line, text,
ulong(
error), msg);
117 _ftprintf(stderr,
"Win32 Error# (%lu): %s",
ulong(
error), msg);
120 SetLastError(NO_ERROR);
123 LocalFree(formattedMsg);
132#ifdef WITH_OPENGL_BACKEND
133void GHOST_Context::initClearGL()
135 glClearColor(0.294, 0.294, 0.294, 0.000);
136 glClear(GL_COLOR_BUFFER_BIT);
137 glClearColor(0.000, 0.000, 0.000, 0.000);
static void error(const char *str)