diff --git a/include/SFML/Window/Context.hpp b/include/SFML/Window/Context.hpp index ca1befeb0..1457eab01 100644 --- a/include/SFML/Window/Context.hpp +++ b/include/SFML/Window/Context.hpp @@ -131,6 +131,9 @@ public: //////////////////////////////////////////////////////////// /// \brief Get the address of an OpenGL function /// + /// On Windows when not using OpenGL ES, a context must be + /// active for this function to succeed. + /// /// \param name Name of the function to get the address of /// /// \return Address of the OpenGL function, 0 on failure diff --git a/src/SFML/Window/Win32/WglContext.cpp b/src/SFML/Window/Win32/WglContext.cpp index 357a74f7e..5eabc4a5b 100644 --- a/src/SFML/Window/Win32/WglContext.cpp +++ b/src/SFML/Window/Win32/WglContext.cpp @@ -203,8 +203,8 @@ WglContext::~WglContext() //////////////////////////////////////////////////////////// GlFunctionPointer WglContext::getFunction(const char* name) { - assert(WglContextImpl::currentContext != nullptr && - "Current WGL context cannot be null. Call WglContext::makeCurrent() to initialize it."); + if (WglContextImpl::currentContext == nullptr) + return nullptr; // If we are using the generic GDI implementation, skip to loading directly from OpenGL32.dll since it doesn't support extensions if (!WglContextImpl::currentContext->m_isGeneric)