diff --git a/src/xenia/gpu/gl4/gl_context.cc b/src/xenia/gpu/gl4/gl_context.cc index 6448bcd33..1e5e909dc 100644 --- a/src/xenia/gpu/gl4/gl_context.cc +++ b/src/xenia/gpu/gl4/gl_context.cc @@ -10,6 +10,7 @@ #include "xenia/gpu/gl4/gl_context.h" #include +#include #include "xenia/base/assert.h" #include "xenia/base/logging.h" @@ -196,6 +197,42 @@ std::unique_ptr GLContext::CreateShared() { return new_context; } +void FatalGLError(std::string error) { + XEFATAL( + (error + + "\nEnsure you have the latest drivers for your GPU and that it supports " + "OpenGL 4.5. See http://xenia.jp/faq/ for more information.").c_str()); +} + +void GLContext::AssertExtensionsPresent() { + if (!MakeCurrent()) { + XEFATAL("Unable to make GL context current"); + return; + } + + // Check shader version at least 4.5 (matching GL 4.5). + auto glsl_version_start = + reinterpret_cast(glGetString(GL_SHADING_LANGUAGE_VERSION)); + auto glsl_version_end = std::strchr(glsl_version_start, ' '); + std::string glsl_version(glsl_version_start, glsl_version_end); + if (glsl_version.compare("4.50") != 0) { + FatalGLError("OpenGL GLSL version 4.50 is required."); + return; + } + + if (!GLEW_ARB_bindless_texture) { + FatalGLError("OpenGL extension ARB_bindless_texture is required."); + return; + } + + // TODO(benvanik): figure out why this query fails. + // if (!GLEW_ARB_fragment_coord_conventions) { + // FatalGLError( + // "OpenGL extension ARB_fragment_coord_conventions is required."); + // return; + // } +} + void GLContext::DebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message) { diff --git a/src/xenia/gpu/gl4/gl_context.h b/src/xenia/gpu/gl4/gl_context.h index e8b6083c2..114c5e9fc 100644 --- a/src/xenia/gpu/gl4/gl_context.h +++ b/src/xenia/gpu/gl4/gl_context.h @@ -28,6 +28,7 @@ class GLContext { ~GLContext(); bool Initialize(HWND hwnd); + void AssertExtensionsPresent(); HDC dc() const { return dc_; } diff --git a/src/xenia/gpu/gl4/wgl_control.cc b/src/xenia/gpu/gl4/wgl_control.cc index 45a49a74f..213165f91 100644 --- a/src/xenia/gpu/gl4/wgl_control.cc +++ b/src/xenia/gpu/gl4/wgl_control.cc @@ -63,10 +63,12 @@ bool WGLControl::Create() { XEFATAL( "Unable to initialize GL context. Xenia requires OpenGL 4.5. Ensure " "you have the latest drivers for your GPU and that it supports OpenGL " - "4.5."); + "4.5. See http://xenia.jp/faq/ for more information."); return false; } + context_.AssertExtensionsPresent(); + SetFocus(hwnd_); OnCreate();