Merge branch 'master' into jgrpp
# Conflicts: # CMakeLists.txt # COMPILING.md # src/console.cpp # src/console_cmds.cpp # src/console_internal.h # src/rev.cpp.in
This commit is contained in:
@@ -254,7 +254,7 @@ const char *VideoDriver_CocoaOpenGL::AllocateContext(bool allow_software)
|
||||
|
||||
CGLSetCurrentContext(this->gl_context);
|
||||
|
||||
return OpenGLBackend::Create(&GetOGLProcAddressCallback);
|
||||
return OpenGLBackend::Create(&GetOGLProcAddressCallback, this->GetScreenSize());
|
||||
}
|
||||
|
||||
NSView *VideoDriver_CocoaOpenGL::AllocateDrawView()
|
||||
|
||||
@@ -464,16 +464,17 @@ void SetupDebugOutput()
|
||||
/**
|
||||
* Create and initialize the singleton back-end class.
|
||||
* @param get_proc Callback to get an OpenGL function from the OS driver.
|
||||
* @param screen_res Current display resolution.
|
||||
* @return nullptr on success, error message otherwise.
|
||||
*/
|
||||
/* static */ const char *OpenGLBackend::Create(GetOGLProcAddressProc get_proc)
|
||||
/* static */ const char *OpenGLBackend::Create(GetOGLProcAddressProc get_proc, const Dimension &screen_res)
|
||||
{
|
||||
if (OpenGLBackend::instance != nullptr) OpenGLBackend::Destroy();
|
||||
|
||||
GetOGLProcAddress = get_proc;
|
||||
|
||||
OpenGLBackend::instance = new OpenGLBackend();
|
||||
return OpenGLBackend::instance->Init();
|
||||
return OpenGLBackend::instance->Init(screen_res);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -521,9 +522,10 @@ OpenGLBackend::~OpenGLBackend()
|
||||
|
||||
/**
|
||||
* Check for the needed OpenGL functionality and allocate all resources.
|
||||
* @param screen_res Current display resolution.
|
||||
* @return Error string or nullptr if successful.
|
||||
*/
|
||||
const char *OpenGLBackend::Init()
|
||||
const char *OpenGLBackend::Init(const Dimension &screen_res)
|
||||
{
|
||||
if (!BindBasicInfoProcs()) return "OpenGL not supported";
|
||||
|
||||
@@ -546,6 +548,12 @@ const char *OpenGLBackend::Init()
|
||||
_gl_major_ver = atoi(ver);
|
||||
_gl_minor_ver = minor != nullptr ? atoi(minor + 1) : 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Old drivers on Windows (especially if made by Intel) seem to be
|
||||
* unstable, so cull the oldest stuff here. */
|
||||
if (!IsOpenGLVersionAtLeast(3, 2)) return "Need at least OpenGL version 3.2 on Windows";
|
||||
#endif
|
||||
|
||||
if (!BindBasicOpenGLProcs()) return "Failed to bind basic OpenGL functions.";
|
||||
|
||||
SetupDebugOutput();
|
||||
@@ -581,6 +589,11 @@ const char *OpenGLBackend::Init()
|
||||
}
|
||||
if (this->persistent_mapping_supported) DEBUG(driver, 3, "OpenGL: Using persistent buffer mapping");
|
||||
|
||||
/* Check maximum texture size against screen resolution. */
|
||||
GLint max_tex_size = 0;
|
||||
_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_tex_size);
|
||||
if (std::max(screen_res.width, screen_res.height) > (uint)max_tex_size) return "Max supported texture size is too small";
|
||||
|
||||
/* Check available texture units. */
|
||||
GLint max_tex_units = 0;
|
||||
_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_tex_units);
|
||||
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
OpenGLBackend();
|
||||
~OpenGLBackend();
|
||||
|
||||
const char *Init();
|
||||
const char *Init(const Dimension &screen_res);
|
||||
bool InitShaders();
|
||||
|
||||
void InternalClearCursorCache();
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
{
|
||||
return OpenGLBackend::instance;
|
||||
}
|
||||
static const char *Create(GetOGLProcAddressProc get_proc);
|
||||
static const char *Create(GetOGLProcAddressProc get_proc, const Dimension &screen_res);
|
||||
static void Destroy();
|
||||
|
||||
void PrepareContext();
|
||||
|
||||
@@ -121,7 +121,7 @@ const char *VideoDriver_SDL_OpenGL::AllocateContext()
|
||||
|
||||
ToggleVsync(_video_vsync);
|
||||
|
||||
return OpenGLBackend::Create(&GetOGLProcAddressCallback);
|
||||
return OpenGLBackend::Create(&GetOGLProcAddressCallback, this->GetScreenSize());
|
||||
}
|
||||
|
||||
void VideoDriver_SDL_OpenGL::PopulateSystemSprites()
|
||||
|
||||
@@ -1368,14 +1368,22 @@ const char *VideoDriver_Win32OpenGL::AllocateContext()
|
||||
|
||||
/* Create OpenGL device context. Try to get an 3.2+ context if possible. */
|
||||
if (_wglCreateContextAttribsARB != nullptr) {
|
||||
/* Try for OpenGL 4.5 first. */
|
||||
int attribs[] = {
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 2,
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 5,
|
||||
WGL_CONTEXT_FLAGS_ARB, _debug_driver_level >= 8 ? WGL_CONTEXT_DEBUG_BIT_ARB : 0,
|
||||
_hasWGLARBCreateContextProfile ? WGL_CONTEXT_PROFILE_MASK_ARB : 0, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, // Terminate list if WGL_ARB_create_context_profile isn't supported.
|
||||
0
|
||||
};
|
||||
rc = _wglCreateContextAttribsARB(this->dc, nullptr, attribs);
|
||||
|
||||
if (rc == nullptr) {
|
||||
/* Try again for a 3.2 context. */
|
||||
attribs[1] = 3;
|
||||
attribs[3] = 2;
|
||||
rc = _wglCreateContextAttribsARB(this->dc, nullptr, attribs);
|
||||
}
|
||||
}
|
||||
|
||||
if (rc == nullptr) {
|
||||
@@ -1388,7 +1396,7 @@ const char *VideoDriver_Win32OpenGL::AllocateContext()
|
||||
this->ToggleVsync(_video_vsync);
|
||||
|
||||
this->gl_rc = rc;
|
||||
return OpenGLBackend::Create(&GetOGLProcAddressCallback);
|
||||
return OpenGLBackend::Create(&GetOGLProcAddressCallback, this->GetScreenSize());
|
||||
}
|
||||
|
||||
bool VideoDriver_Win32OpenGL::ToggleFullscreen(bool full_screen)
|
||||
|
||||
Reference in New Issue
Block a user