Debugging X11GLControl crash on MakeCurrent.

This commit is contained in:
the_fiddler 2007-08-09 12:06:09 +00:00
parent cccbb9823b
commit ee05b9e5c1
4 changed files with 53 additions and 74 deletions

View file

@ -35,7 +35,7 @@ namespace Examples.WinForms
{
base.OnHandleCreated(e);
input = new OpenTK.InputDriver(OpenTK.Platform.Utilities.GetWindowInfo(this));
//input = new OpenTK.InputDriver(OpenTK.Platform.Utilities.GetWindowInfo(this));
}
private void redButton_Click(object sender, EventArgs e)
@ -89,4 +89,4 @@ namespace Examples.WinForms
#endregion
}
}
}

View file

@ -46,7 +46,7 @@ namespace OpenTK
public GLControl(DisplayMode mode)
{
InitializeComponent();
/*
System.Diagnostics.Debug.Listeners.Clear();
System.Diagnostics.Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
System.Diagnostics.Debug.AutoFlush = true;
@ -54,11 +54,11 @@ namespace OpenTK
System.Diagnostics.Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
System.Diagnostics.Trace.AutoFlush = true;
Trace.AutoFlush = true;
*/
if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
Environment.OSVersion.Platform == PlatformID.Win32Windows)
{
glControl = new OpenTK.Platform.Windows.WinGLControl(this, Width, Height, false);
glControl = new OpenTK.Platform.Windows.WinGLControl(this, new DisplayMode(Width, Height));
}
else if (Environment.OSVersion.Platform == PlatformID.Unix ||
Environment.OSVersion.Platform == (PlatformID)128)

View file

@ -80,9 +80,9 @@ namespace OpenTK.Platform.X11
if (!result)
{
Debug.WriteLine(String.Format("Failed to make context {0} current.", x11context));
Debug.WriteLine("failed...");
// probably need to recreate context here.
throw new Exception(String.Format("Failed to make context {0} current.", x11context));
//throw new Exception(String.Format("Failed to make context {0} current.", x11context));
}
else
{
@ -151,7 +151,7 @@ namespace OpenTK.Platform.X11
Debug.WriteLine("Creating opengl context.");
Debug.Indent();
IntPtr shareHandle = shareContext != null ? shareContext.Handle : IntPtr.Zero;
IntPtr shareHandle = shareContext != null ? shareContext.windowInfo.Handle : IntPtr.Zero;
Debug.WriteLine(
shareHandle == IntPtr.Zero ?
"Context is not shared." :
@ -187,34 +187,14 @@ namespace OpenTK.Platform.X11
{
Debug.WriteLine("Creating visual.");
Debug.Indent();
/*
ColorDepth color = new ColorDepth(24);
int depthBits = 16;
// Create the Visual
List<int> visualAttributes = new List<int>();
visualAttributes.Add((int)Glx.Enums.GLXAttribute.RGBA);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.RED_SIZE);
visualAttributes.Add((int)color.Red);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.GREEN_SIZE);
visualAttributes.Add((int)color.Green);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.BLUE_SIZE);
visualAttributes.Add((int)color.Blue);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.ALPHA_SIZE);
visualAttributes.Add((int)color.Alpha);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DEPTH_SIZE);
visualAttributes.Add((int)depthBits);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE);
*/
Debug.Print("Requesting DisplayMode: {0}. ", mode.ToString());
// Hack; Temp workaround for invalid depth of 24
if (mode.DepthBits == 24)
{
mode.DepthBits = 16;
Debug.WriteLine("Temporary workaround applied: depth changed to 16.");
}
//if (mode.DepthBits == 24)
//{
// mode.DepthBits = 16;
// Debug.WriteLine("Temporary workaround applied: depth changed to 16.");
//}
List<int> visualAttributes = new List<int>();
visualAttributes.Add((int)Glx.Enums.GLXAttribute.RGBA);
@ -246,22 +226,25 @@ namespace OpenTK.Platform.X11
}
#endregion
[Obsolete]
internal IntPtr XVisual
{
get { return this.visual; }
}
internal VisualInfo XVisualInfo
{
get { return windowInfo.VisualInfo; }
}
[Obsolete]
internal IntPtr XColormap
{
get { return colormap; }
}
[Obsolete]
internal IntPtr Handle
{
get { return this.x11context; }

View file

@ -24,31 +24,33 @@ namespace OpenTK.Platform.X11
private bool fullscreen;
#region --- Contructors ---
public X11GLControl(UserControl c, int width, int height, bool fullscreen)
[Obsolete("Use X11GLControl(UserControl c, DisplayMode mode) instead.")]
public X11GLControl(UserControl c, int width, int height, bool fullscreen)
: this(c, new DisplayMode(width, height, new ColorDepth(32), 16,
0, 0, 2, false, false, false, 0.0f)) { }
public X11GLControl(UserControl c, DisplayMode mode)
{
Trace.WriteLine("Creating opengl control (X11GLControl driver)");
Trace.Indent();
c.ParentChanged += new EventHandler(c_ParentChanged);
if (c.ParentForm != null)
throw new Exception("I was stupid!");
Debug.WriteLine("Creating opengl control (X11GLControl driver)");
Debug.Indent();
if (c == null/* || c.TopLevelControl == null*/)
{
throw new Exception("Attempted to bind to non-existent control.");
throw new ArgumentException("UserControl c may not be null.");
}
c.ParentChanged += new EventHandler(c_ParentChanged);
if (c.ParentForm != null)
{
throw new ApplicationException("Internal OpenTK error, please report at http://opentk.sourceforge.net");
}
info.Handle = c.Handle;
Trace.WriteLine(
String.Format(
"Binding to control: {0}",
String.IsNullOrEmpty(c.Name) ? c.Text : c.Name
)
);
Debug.Print("Binding to control: {0}", String.IsNullOrEmpty(c.Name) ? c.Text : c.Name);
xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
Trace.WriteLine("Acquired System.Windows.Forms.XplatUIX11 type.");
Debug.Write("System.Windows.Forms.XplatUIX11: ");
if (xplatui != null)
{
@ -64,36 +66,30 @@ namespace OpenTK.Platform.X11
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.NonPublic).GetValue(null);
Trace.WriteLine(
String.Format(
"Screen: {0}, Display: {1}, Root Window: {2}, Control: {3}",
info.Screen,
info.Display,
info.RootWindow,
info.Handle
)
);
Debug.Print(
"Screen: {0}, Display: {1}, Root Window: {2}, Control: {3}",
info.Screen, info.Display, info.RootWindow, info.Handle);
glContext = new X11GLContext(info,
new DisplayMode(width, height, new ColorDepth(24), 16, 0, 0, 2, false, false, false, 0.0f)
);
glContext = new X11GLContext(info, mode);
glContext.CreateVisual();
info.VisualInfo = glContext.CreateVisual();
xplatui.GetField(
"CustomVisual",
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.NonPublic).SetValue(
null,
glContext.XVisual
//glContext.XVisual
info.VisualInfo.visual
);
xplatui.GetField(
"CustomColormap",
System.Reflection.BindingFlags.Static |
System.Reflection.BindingFlags.NonPublic).SetValue(
null,
glContext.XColormap
null,
API.CreateColormap(info.Display, info.RootWindow, info.VisualInfo.visual, 0/*AllocNone*/)
//glContext.colormap
);
glContext.CreateContext(null, true);
@ -103,7 +99,7 @@ namespace OpenTK.Platform.X11
void c_ParentChanged(object sender, EventArgs e)
{
UserControl c = sender as UserControl;
Trace.WriteLine(
Debug.WriteLine(
String.Format(
"TopLevel control is {0}",
c.TopLevelControl != null ? c.TopLevelControl.ToString() : "not available"
@ -120,9 +116,9 @@ namespace OpenTK.Platform.X11
info.TopLevelWindow = c.TopLevelControl.Handle;
}
Trace.WriteLine(String.Format("Mapping window to top level: {0}", info.TopLevelWindow));
Debug.WriteLine(String.Format("Mapping window to top level: {0}", info.TopLevelWindow));
API.MapRaised(info.Display, info.TopLevelWindow);
Trace.Unindent();
Debug.Unindent();
}
#endregion