mirror of https://github.com/OpenTTD/OpenTTD
Fix: [OpenGL] Check maximum supported texture size against screen resolution.
parent
5ff15443e9
commit
e53313391a
|
@ -254,7 +254,7 @@ const char *VideoDriver_CocoaOpenGL::AllocateContext(bool allow_software)
|
||||||
|
|
||||||
CGLSetCurrentContext(this->gl_context);
|
CGLSetCurrentContext(this->gl_context);
|
||||||
|
|
||||||
return OpenGLBackend::Create(&GetOGLProcAddressCallback);
|
return OpenGLBackend::Create(&GetOGLProcAddressCallback, this->GetScreenSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
NSView *VideoDriver_CocoaOpenGL::AllocateDrawView()
|
NSView *VideoDriver_CocoaOpenGL::AllocateDrawView()
|
||||||
|
|
|
@ -464,16 +464,17 @@ void SetupDebugOutput()
|
||||||
/**
|
/**
|
||||||
* Create and initialize the singleton back-end class.
|
* Create and initialize the singleton back-end class.
|
||||||
* @param get_proc Callback to get an OpenGL function from the OS driver.
|
* @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.
|
* @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();
|
if (OpenGLBackend::instance != nullptr) OpenGLBackend::Destroy();
|
||||||
|
|
||||||
GetOGLProcAddress = get_proc;
|
GetOGLProcAddress = get_proc;
|
||||||
|
|
||||||
OpenGLBackend::instance = new OpenGLBackend();
|
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.
|
* Check for the needed OpenGL functionality and allocate all resources.
|
||||||
|
* @param screen_res Current display resolution.
|
||||||
* @return Error string or nullptr if successful.
|
* @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";
|
if (!BindBasicInfoProcs()) return "OpenGL not supported";
|
||||||
|
|
||||||
|
@ -581,6 +583,11 @@ const char *OpenGLBackend::Init()
|
||||||
}
|
}
|
||||||
if (this->persistent_mapping_supported) DEBUG(driver, 3, "OpenGL: Using persistent buffer mapping");
|
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. */
|
/* Check available texture units. */
|
||||||
GLint max_tex_units = 0;
|
GLint max_tex_units = 0;
|
||||||
_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_tex_units);
|
_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_tex_units);
|
||||||
|
|
|
@ -74,7 +74,7 @@ private:
|
||||||
OpenGLBackend();
|
OpenGLBackend();
|
||||||
~OpenGLBackend();
|
~OpenGLBackend();
|
||||||
|
|
||||||
const char *Init();
|
const char *Init(const Dimension &screen_res);
|
||||||
bool InitShaders();
|
bool InitShaders();
|
||||||
|
|
||||||
void InternalClearCursorCache();
|
void InternalClearCursorCache();
|
||||||
|
@ -87,7 +87,7 @@ public:
|
||||||
{
|
{
|
||||||
return OpenGLBackend::instance;
|
return OpenGLBackend::instance;
|
||||||
}
|
}
|
||||||
static const char *Create(GetOGLProcAddressProc get_proc);
|
static const char *Create(GetOGLProcAddressProc get_proc, const Dimension &screen_res);
|
||||||
static void Destroy();
|
static void Destroy();
|
||||||
|
|
||||||
void PrepareContext();
|
void PrepareContext();
|
||||||
|
|
|
@ -117,7 +117,7 @@ const char *VideoDriver_SDL_OpenGL::AllocateContext()
|
||||||
|
|
||||||
ToggleVsync(_video_vsync);
|
ToggleVsync(_video_vsync);
|
||||||
|
|
||||||
return OpenGLBackend::Create(&GetOGLProcAddressCallback);
|
return OpenGLBackend::Create(&GetOGLProcAddressCallback, this->GetScreenSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoDriver_SDL_OpenGL::PopulateSystemSprites()
|
void VideoDriver_SDL_OpenGL::PopulateSystemSprites()
|
||||||
|
|
|
@ -1380,7 +1380,7 @@ const char *VideoDriver_Win32OpenGL::AllocateContext()
|
||||||
this->ToggleVsync(_video_vsync);
|
this->ToggleVsync(_video_vsync);
|
||||||
|
|
||||||
this->gl_rc = rc;
|
this->gl_rc = rc;
|
||||||
return OpenGLBackend::Create(&GetOGLProcAddressCallback);
|
return OpenGLBackend::Create(&GetOGLProcAddressCallback, this->GetScreenSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoDriver_Win32OpenGL::ToggleFullscreen(bool full_screen)
|
bool VideoDriver_Win32OpenGL::ToggleFullscreen(bool full_screen)
|
||||||
|
|
Loading…
Reference in New Issue