mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-15 00:24:19 +00:00
OpenGL: removed the artifical render-throttling code, allowing the rendering to be kept in sync by the native GL swap-interval.
This commit is contained in:
parent
136041daa7
commit
0abd7a3fa1
3 changed files with 9 additions and 14 deletions
|
|
@ -143,8 +143,6 @@ public:
|
|||
renderContext = [[[NSOpenGLContext alloc] initWithFormat: format
|
||||
shareContext: (NSOpenGLContext*) contextToShare] autorelease];
|
||||
|
||||
setSwapInterval (1);
|
||||
|
||||
[view setOpenGLContext: renderContext];
|
||||
[format release];
|
||||
|
||||
|
|
|
|||
|
|
@ -42,9 +42,14 @@ public:
|
|||
nativeContext = new NativeContext (component, pixFormat, contextToShare);
|
||||
|
||||
if (nativeContext->createdOk())
|
||||
{
|
||||
nativeContext->setSwapInterval (1);
|
||||
context.nativeContext = nativeContext;
|
||||
}
|
||||
else
|
||||
{
|
||||
nativeContext = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
~CachedImage()
|
||||
|
|
@ -295,10 +300,8 @@ public:
|
|||
|
||||
while (! threadShouldExit())
|
||||
{
|
||||
const uint32 frameRenderStartTime = Time::getMillisecondCounter();
|
||||
|
||||
if (renderFrame())
|
||||
waitForNextFrame (frameRenderStartTime);
|
||||
if (! renderFrame())
|
||||
wait (5); // failed to render, so avoid a tight fail-loop.
|
||||
}
|
||||
|
||||
shutdownOnThread();
|
||||
|
|
@ -332,14 +335,6 @@ public:
|
|||
associatedObjects.clear();
|
||||
}
|
||||
|
||||
void waitForNextFrame (const uint32 frameRenderStartTime)
|
||||
{
|
||||
const int defaultFPS = 60;
|
||||
|
||||
const int elapsed = (int) (Time::getMillisecondCounter() - frameRenderStartTime);
|
||||
wait (jmax (1, (1000 / defaultFPS - 1) - elapsed));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static CachedImage* get (Component& c) noexcept
|
||||
{
|
||||
|
|
|
|||
|
|
@ -188,6 +188,8 @@ public:
|
|||
fairly system-dependent, but 0 turns off syncing, 1 makes it swap on frame-boundaries,
|
||||
and greater numbers indicate that it should swap less often.
|
||||
|
||||
By default, this will be set to 1.
|
||||
|
||||
Returns true if it sets the value successfully - some platforms won't support
|
||||
this setting.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue