GHOST: WGL: Silence Errors when testing opengl context versions

This commit is contained in:
Clément Foucault 2018-12-05 21:57:35 +01:00
parent 0424ee86f0
commit 5584cad5d9
3 changed files with 16 additions and 1 deletions

View File

@ -48,6 +48,15 @@
#ifdef _WIN32
bool win32_silent_chk(bool result)
{
if (!result) {
SetLastError(NO_ERROR);
}
return result;
}
bool win32_chk(bool result, const char *file, int line, const char *text)
{
if (!result) {

View File

@ -148,12 +148,15 @@ protected:
#ifdef _WIN32
bool win32_chk(bool result, const char *file = NULL, int line = 0, const char *text = NULL);
bool win32_silent_chk(bool result);
# ifndef NDEBUG
# define WIN32_CHK(x) win32_chk((x), __FILE__, __LINE__, #x)
# else
# define WIN32_CHK(x) win32_chk(x)
# endif
#define WIN32_CHK_SILENT(x, silent) ((silent) ? win32_silent_chk(x) : WIN32_CHK(x))
#endif /* _WIN32 */

View File

@ -789,7 +789,10 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
m_hGLRC = ::wglCreateContextAttribsARB(m_hDC, NULL, &(iAttributes[0]));
}
if (!WIN32_CHK(m_hGLRC != NULL)) {
/* Silence warnings interpreted as errors by users when trying to get
* a context with version higher than 3.3 Core. */
const bool silent = m_contextMajorVersion > 3;
if (!WIN32_CHK_SILENT(m_hGLRC != NULL, silent)) {
goto error;
}