From b6642764eb9a2905415866e86436597b1c9042a3 Mon Sep 17 00:00:00 2001 From: kanato Date: Tue, 3 Feb 2009 08:14:55 +0000 Subject: [PATCH] Fix loss of first frame with GLControl. --- Source/OpenTK/GLControl.cs | 7 ++++ Source/OpenTK/Platform/MacOS/AglContext.cs | 40 +++++++++++++--------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/Source/OpenTK/GLControl.cs b/Source/OpenTK/GLControl.cs index 6f85c319..4cb841b9 100644 --- a/Source/OpenTK/GLControl.cs +++ b/Source/OpenTK/GLControl.cs @@ -82,6 +82,13 @@ namespace OpenTK base.OnResize(e); } + protected override void OnParentChanged(EventArgs e) + { + if (context != null) + context.Update(window_info); + + base.OnParentChanged(e); + } #region --- Protected Methods --- diff --git a/Source/OpenTK/Platform/MacOS/AglContext.cs b/Source/OpenTK/Platform/MacOS/AglContext.cs index 118ec04b..55f640a2 100644 --- a/Source/OpenTK/Platform/MacOS/AglContext.cs +++ b/Source/OpenTK/Platform/MacOS/AglContext.cs @@ -193,8 +193,17 @@ namespace OpenTK.Platform.MacOS } void SetDrawable(CarbonWindowInfo carbonWindow) { - IntPtr windowPort; - + IntPtr windowPort = GetWindowPortForWindowInfo(carbonWindow); + + Agl.aglSetDrawable(contextRef, windowPort); + + MyAGLReportError("aglSetDrawable"); + + } + + private static IntPtr GetWindowPortForWindowInfo(CarbonWindowInfo carbonWindow) + { + IntPtr windowPort; if (carbonWindow.IsControl) { IntPtr controlOwner = API.GetControlOwner(carbonWindow.WindowRef); @@ -203,21 +212,18 @@ namespace OpenTK.Platform.MacOS } else windowPort = API.GetWindowPort(carbonWindow.WindowRef); - - Agl.aglSetDrawable(contextRef, windowPort); - - MyAGLReportError("aglSetDrawable"); - - } - public void Update(IWindowInfo window) + return windowPort; + } + public void Update(IWindowInfo window) { CarbonWindowInfo carbonWindow = (CarbonWindowInfo)window; - + + SetDrawable(carbonWindow); SetBufferRect(carbonWindow); Agl.aglUpdateContext(contextRef); - } + void MyAGLReportError(string function) { Agl.AglError err = Agl.GetError(); @@ -263,12 +269,12 @@ namespace OpenTK.Platform.MacOS { Debug.WriteLine("--> Resetting drawable. <--"); first = true; - SetDrawable(carbonWindow); - Update(carbonWindow); - } - - Agl.aglSwapBuffers(contextRef); - MyAGLReportError("aglSwapBuffers"); + SetDrawable(carbonWindow); + Update(carbonWindow); + } + + Agl.aglSwapBuffers(contextRef); + MyAGLReportError("aglSwapBuffers"); } public void MakeCurrent(IWindowInfo window)