From 5584cad5d90ec56febaca96e6ea1326c15523fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 5 Dec 2018 21:57:35 +0100 Subject: GHOST: WGL: Silence Errors when testing opengl context versions --- intern/ghost/intern/GHOST_Context.cpp | 9 +++++++++ intern/ghost/intern/GHOST_Context.h | 3 +++ intern/ghost/intern/GHOST_ContextWGL.cpp | 5 ++++- 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'intern') diff --git a/intern/ghost/intern/GHOST_Context.cpp b/intern/ghost/intern/GHOST_Context.cpp index e02f73ad12a..775492755a9 100644 --- a/intern/ghost/intern/GHOST_Context.cpp +++ b/intern/ghost/intern/GHOST_Context.cpp @@ -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) { diff --git a/intern/ghost/intern/GHOST_Context.h b/intern/ghost/intern/GHOST_Context.h index 327ecd4b245..842736691e3 100644 --- a/intern/ghost/intern/GHOST_Context.h +++ b/intern/ghost/intern/GHOST_Context.h @@ -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 */ diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp index 9605f7ddff2..6cb92567b99 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.cpp +++ b/intern/ghost/intern/GHOST_ContextWGL.cpp @@ -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; } -- cgit v1.2.3