Fix loss of first frame with GLControl.

This commit is contained in:
kanato 2009-02-03 08:14:55 +00:00
parent 1a4a3238c2
commit b6642764eb
2 changed files with 30 additions and 17 deletions

View file

@ -82,6 +82,13 @@ namespace OpenTK
base.OnResize(e); base.OnResize(e);
} }
protected override void OnParentChanged(EventArgs e)
{
if (context != null)
context.Update(window_info);
base.OnParentChanged(e);
}
#region --- Protected Methods --- #region --- Protected Methods ---

View file

@ -193,8 +193,17 @@ namespace OpenTK.Platform.MacOS
} }
void SetDrawable(CarbonWindowInfo carbonWindow) 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) if (carbonWindow.IsControl)
{ {
IntPtr controlOwner = API.GetControlOwner(carbonWindow.WindowRef); IntPtr controlOwner = API.GetControlOwner(carbonWindow.WindowRef);
@ -203,21 +212,18 @@ namespace OpenTK.Platform.MacOS
} }
else else
windowPort = API.GetWindowPort(carbonWindow.WindowRef); windowPort = API.GetWindowPort(carbonWindow.WindowRef);
return windowPort;
Agl.aglSetDrawable(contextRef, windowPort);
MyAGLReportError("aglSetDrawable");
} }
public void Update(IWindowInfo window) public void Update(IWindowInfo window)
{ {
CarbonWindowInfo carbonWindow = (CarbonWindowInfo)window; CarbonWindowInfo carbonWindow = (CarbonWindowInfo)window;
SetDrawable(carbonWindow);
SetBufferRect(carbonWindow); SetBufferRect(carbonWindow);
Agl.aglUpdateContext(contextRef); Agl.aglUpdateContext(contextRef);
} }
void MyAGLReportError(string function) void MyAGLReportError(string function)
{ {
Agl.AglError err = Agl.GetError(); Agl.AglError err = Agl.GetError();