summaryrefslogtreecommitdiff
path: root/indra/llwindow/llwindowmacosx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow/llwindowmacosx.cpp')
-rw-r--r--indra/llwindow/llwindowmacosx.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index fa0816c457..500ed5ef87 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -876,15 +876,12 @@ void LLWindowMacOSX::destroyContext()
// We don't have a context
return;
}
- // Unhook the GL context from any drawable it may have
- if(mContext != NULL)
- {
- LL_DEBUGS("Window") << "destroyContext: unhooking drawable " << LL_ENDL;
- CGLSetCurrentContext(NULL);
- }
-
// Clean up remaining GL state before blowing away window
+ CGLSetCurrentContext(mContext);
gGLManager.shutdownGL();
+ CGLSetCurrentContext(NULL);
+ // The Cocoa view owns this context and releases it in removeGLView().
+ mContext = NULL;
// Clean up the pixel format
if(mPixelFormat != NULL)
@@ -893,12 +890,6 @@ void LLWindowMacOSX::destroyContext()
mPixelFormat = NULL;
}
- // Clean up the GL context
- if(mContext != NULL)
- {
- CGLDestroyContext(mContext);
- }
-
// Destroy our LLOpenGLView
if(mGLView != NULL)
{
@@ -1019,6 +1010,8 @@ void LLWindowMacOSX::gatherInput(bool app_has_focus)
{
updateCursor();
LLGameControl::processEvents(app_has_focus);
+ // Cocoa event handling can change the current context between frames.
+ restoreGLContext();
}
bool LLWindowMacOSX::getPosition(LLCoordScreen *position) const
@@ -1140,12 +1133,17 @@ bool LLWindowMacOSX::setSizeImpl(const LLCoordWindow size)
void LLWindowMacOSX::swapBuffers()
{
- CGLFlushDrawable(mContext);
+ if (mContext)
+ {
+ llassert(mGLView && getCGLContextObj(mGLView) == mContext);
+ glSwapBuffers(mGLView);
+ }
}
void LLWindowMacOSX::restoreGLContext()
{
CGLSetCurrentContext(mContext);
+ llassert(CGLGetCurrentContext() == mContext);
}
F32 LLWindowMacOSX::getGamma() const