Cocoa Port: Fix a longstanding bug where OpenGL video blitter would fail to render to window correctly on Retina displays.

This commit is contained in:
rogerman 2022-04-27 04:52:25 -07:00
parent cfa75df069
commit 88f2dfdb53
2 changed files with 11 additions and 3 deletions

View File

@ -6516,7 +6516,7 @@ void OGLHUDLayer::RenderOGL(bool isRenderingFlipped)
if (this->_needUpdateViewport)
{
glUniform2f(this->_uniformViewSize, this->_output->GetPresenterProperties().clientWidth, this->_output->GetPresenterProperties().clientHeight);
glUniform2f(this->_uniformViewSize, this->_output->GetViewportWidth(), this->_output->GetViewportHeight());
glUniform1i(this->_uniformRenderFlipped, (isRenderingFlipped) ? GL_TRUE : GL_FALSE);
this->_needUpdateViewport = false;
}
@ -6589,7 +6589,7 @@ void OGLHUDLayer::RenderOGL(bool isRenderingFlipped)
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
// Finally, draw each character inside the box.
const GLfloat textBoxScale = (GLfloat)HUD_TEXTBOX_BASE_SCALE * this->_output->GetHUDObjectScale() / this->_output->GetScaleFactor();
const GLfloat textBoxScale = (GLfloat)HUD_TEXTBOX_BASE_SCALE * this->_output->GetHUDObjectScale();
if (textBoxScale >= (2.0/3.0))
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

View File

@ -2101,6 +2101,13 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
localLayer = macOGLCDV->GetCALayer();
#if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
if ([[self window] respondsToSelector:@selector(backingScaleFactor)] && [localLayer respondsToSelector:@selector(setContentsScale:)])
{
[localLayer setContentsScale:[[self window] backingScaleFactor]];
}
#endif
// For macOS 10.8 Mountain Lion and later, we can use the CAOpenGLLayer directly. But for
// earlier versions of macOS, using the CALayer directly will cause too many strange issues,
// so we'll just keep using the old-school NSOpenGLContext for these older macOS versions.
@ -2268,7 +2275,8 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
}
else if ([localLayer isKindOfClass:[CAOpenGLLayer class]])
{
[localLayer setBounds:CGRectMake(0.0f, 0.0f, props.clientWidth, props.clientHeight)];
const double scaleFactor = [[self cdsVideoOutput] clientDisplay3DView]->Get3DPresenter()->GetScaleFactor();
[localLayer setBounds:CGRectMake(0.0f, 0.0f, props.clientWidth / scaleFactor, props.clientHeight / scaleFactor)];
}
#ifdef ENABLE_APPLE_METAL
else if ([localLayer isKindOfClass:[CAMetalLayer class]])