SL-16330 Allow vsync update without restart on mac

master
Mnikolenko ProductEngine 2021-11-17 17:51:50 +02:00
parent 4745aab376
commit fdeeb0190e
5 changed files with 22 additions and 17 deletions

View File

@ -88,11 +88,11 @@ public:
//Must be called on the same thread that called createSharedContext()
virtual void destroySharedContext(void* context) = 0;
virtual void toggleVSync(bool enable_vsync) = 0;
virtual BOOL setCursorPosition(LLCoordWindow position) = 0;
virtual BOOL getCursorPosition(LLCoordWindow *position) = 0;
#if LL_WINDOWS
virtual void toggleVSync(bool enable_vsync) = 0;
virtual BOOL getCursorDelta(LLCoordCommon* delta) = 0;
#endif
virtual void showCursor() = 0;

View File

@ -52,10 +52,10 @@ public:
void* createSharedContext() { return nullptr; }
void makeContextCurrent(void*) {}
void destroySharedContext(void*) {}
/*virtual*/ BOOL setCursorPosition(LLCoordWindow position) {return FALSE;};
/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position) {return FALSE;};
/*virtual*/ void toggleVSync(bool enable_vsync) { }
/*virtual*/ BOOL setCursorPosition(LLCoordWindow position) {return FALSE;};
/*virtual*/ BOOL getCursorPosition(LLCoordWindow *position) {return FALSE;};
#if LL_WINDOWS
/*virtual*/ virtual void toggleVSync(bool enable_vsync) { }
/*virtual*/ BOOL getCursorDelta(LLCoordCommon* delta) { return FALSE; }
#endif
/*virtual*/ void showCursor() {};

View File

@ -661,17 +661,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
}
// Disable vertical sync for swap
GLint frames_per_swap = 0;
if (!enable_vsync)
{
frames_per_swap = 0;
}
else
{
frames_per_swap = 1;
}
CGLSetParameter(mContext, kCGLCPSwapInterval, &frames_per_swap);
toggleVSync(enable_vsync);
//enable multi-threaded OpenGL
if (sUseMultGL)
@ -1944,6 +1934,21 @@ void LLWindowMacOSX::destroySharedContext(void* context)
delete sc;
}
void LLWindowMacOSX::toggleVSync(bool enable_vsync)
{
GLint frames_per_swap = 0;
if (!enable_vsync)
{
frames_per_swap = 0;
}
else
{
frames_per_swap = 1;
}
CGLSetParameter(mContext, kCGLCPSwapInterval, &frames_per_swap);
}
void LLWindowMacOSX::interruptLanguageTextInput()
{
commitCurrentPreedit(mGLView);

View File

@ -140,6 +140,8 @@ public:
//Must be called on the same thread that called createSharedContext()
void destroySharedContext(void* context) override;
void toggleVSync(bool enable_vsync) override;
protected:
LLWindowMacOSX(LLWindowCallbacks* callbacks,
const std::string& title, const std::string& name, int x, int y, int width, int height, U32 flags,

View File

@ -260,9 +260,7 @@ static bool handleAnisotropicChanged(const LLSD& newvalue)
static bool handleVSyncChanged(const LLSD& newvalue)
{
#if LL_WINDOWS
gViewerWindow->getWindow()->toggleVSync(newvalue.asBoolean());
#endif
return true;
}