1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-27 02:20:05 +00:00

OpenGL: Set OpenGL view position correctly after adjusting the global scale factor

This commit is contained in:
reuk 2022-03-07 19:41:20 +00:00
parent c30b3a1a31
commit 7815d2007b
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -29,6 +29,7 @@ public:
void* contextToShare,
bool shouldUseMultisampling,
OpenGLVersion version)
: owner (component)
{
NSOpenGLPixelFormatAttribute attribs[64] = { 0 };
createAttribs (attribs, version, pixFormat, shouldUseMultisampling);
@ -188,7 +189,16 @@ public:
lastSwapTime = now;
}
void updateWindowPosition (Rectangle<int>) {}
void updateWindowPosition (Rectangle<int>)
{
if (auto* peer = owner.getTopLevelComponent()->getPeer())
{
const auto newArea = peer->getAreaCoveredBy (owner);
if (convertToRectInt ([view frame]) != newArea)
[view setFrame: makeNSRect (newArea)];
}
}
bool setSwapInterval (int numFramesPerSwapIn)
{
@ -237,6 +247,7 @@ public:
return NSOpenGLCPSwapInterval;
}
Component& owner;
NSOpenGLContext* renderContext = nil;
NSOpenGLView* view = nil;
ReferenceCountedObjectPtr<ReferenceCountedObject> viewAttachment;