mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 00:05:29 +00:00
Debugging X11GLControl crash on MakeCurrent.
This commit is contained in:
parent
54258c9130
commit
318c8e619d
|
@ -35,7 +35,7 @@ namespace Examples.WinForms
|
||||||
{
|
{
|
||||||
base.OnHandleCreated(e);
|
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)
|
private void redButton_Click(object sender, EventArgs e)
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace OpenTK
|
||||||
public GLControl(DisplayMode mode)
|
public GLControl(DisplayMode mode)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
/*
|
||||||
System.Diagnostics.Debug.Listeners.Clear();
|
System.Diagnostics.Debug.Listeners.Clear();
|
||||||
System.Diagnostics.Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
|
System.Diagnostics.Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
|
||||||
System.Diagnostics.Debug.AutoFlush = true;
|
System.Diagnostics.Debug.AutoFlush = true;
|
||||||
|
@ -54,11 +54,11 @@ namespace OpenTK
|
||||||
System.Diagnostics.Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
|
System.Diagnostics.Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
|
||||||
System.Diagnostics.Trace.AutoFlush = true;
|
System.Diagnostics.Trace.AutoFlush = true;
|
||||||
Trace.AutoFlush = true;
|
Trace.AutoFlush = true;
|
||||||
|
*/
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
|
||||||
Environment.OSVersion.Platform == PlatformID.Win32Windows)
|
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 ||
|
else if (Environment.OSVersion.Platform == PlatformID.Unix ||
|
||||||
Environment.OSVersion.Platform == (PlatformID)128)
|
Environment.OSVersion.Platform == (PlatformID)128)
|
||||||
|
|
|
@ -80,9 +80,9 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
Debug.WriteLine(String.Format("Failed to make context {0} current.", x11context));
|
Debug.WriteLine("failed...");
|
||||||
// probably need to recreate context here.
|
// 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
|
else
|
||||||
{
|
{
|
||||||
|
@ -151,7 +151,7 @@ namespace OpenTK.Platform.X11
|
||||||
Debug.WriteLine("Creating opengl context.");
|
Debug.WriteLine("Creating opengl context.");
|
||||||
Debug.Indent();
|
Debug.Indent();
|
||||||
|
|
||||||
IntPtr shareHandle = shareContext != null ? shareContext.Handle : IntPtr.Zero;
|
IntPtr shareHandle = shareContext != null ? shareContext.windowInfo.Handle : IntPtr.Zero;
|
||||||
Debug.WriteLine(
|
Debug.WriteLine(
|
||||||
shareHandle == IntPtr.Zero ?
|
shareHandle == IntPtr.Zero ?
|
||||||
"Context is not shared." :
|
"Context is not shared." :
|
||||||
|
@ -187,34 +187,14 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Creating visual.");
|
Debug.WriteLine("Creating visual.");
|
||||||
Debug.Indent();
|
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());
|
Debug.Print("Requesting DisplayMode: {0}. ", mode.ToString());
|
||||||
// Hack; Temp workaround for invalid depth of 24
|
// Hack; Temp workaround for invalid depth of 24
|
||||||
if (mode.DepthBits == 24)
|
//if (mode.DepthBits == 24)
|
||||||
{
|
//{
|
||||||
mode.DepthBits = 16;
|
// mode.DepthBits = 16;
|
||||||
Debug.WriteLine("Temporary workaround applied: depth changed to 16.");
|
// Debug.WriteLine("Temporary workaround applied: depth changed to 16.");
|
||||||
}
|
//}
|
||||||
|
|
||||||
List<int> visualAttributes = new List<int>();
|
List<int> visualAttributes = new List<int>();
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.RGBA);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.RGBA);
|
||||||
|
@ -247,6 +227,7 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
internal IntPtr XVisual
|
internal IntPtr XVisual
|
||||||
{
|
{
|
||||||
get { return this.visual; }
|
get { return this.visual; }
|
||||||
|
@ -257,11 +238,13 @@ namespace OpenTK.Platform.X11
|
||||||
get { return windowInfo.VisualInfo; }
|
get { return windowInfo.VisualInfo; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
internal IntPtr XColormap
|
internal IntPtr XColormap
|
||||||
{
|
{
|
||||||
get { return colormap; }
|
get { return colormap; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
internal IntPtr Handle
|
internal IntPtr Handle
|
||||||
{
|
{
|
||||||
get { return this.x11context; }
|
get { return this.x11context; }
|
||||||
|
|
|
@ -25,30 +25,32 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
#region --- Contructors ---
|
#region --- Contructors ---
|
||||||
|
|
||||||
|
[Obsolete("Use X11GLControl(UserControl c, DisplayMode mode) instead.")]
|
||||||
public X11GLControl(UserControl c, int width, int height, bool fullscreen)
|
public X11GLControl(UserControl c, int width, int height, bool fullscreen)
|
||||||
{
|
: this(c, new DisplayMode(width, height, new ColorDepth(32), 16,
|
||||||
Trace.WriteLine("Creating opengl control (X11GLControl driver)");
|
0, 0, 2, false, false, false, 0.0f)) { }
|
||||||
Trace.Indent();
|
|
||||||
|
|
||||||
c.ParentChanged += new EventHandler(c_ParentChanged);
|
public X11GLControl(UserControl c, DisplayMode mode)
|
||||||
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*/)
|
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;
|
info.Handle = c.Handle;
|
||||||
Trace.WriteLine(
|
Debug.Print("Binding to control: {0}", String.IsNullOrEmpty(c.Name) ? c.Text : c.Name);
|
||||||
String.Format(
|
|
||||||
"Binding to control: {0}",
|
|
||||||
String.IsNullOrEmpty(c.Name) ? c.Text : c.Name
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
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)
|
if (xplatui != null)
|
||||||
{
|
{
|
||||||
|
@ -64,28 +66,21 @@ namespace OpenTK.Platform.X11
|
||||||
System.Reflection.BindingFlags.Static |
|
System.Reflection.BindingFlags.Static |
|
||||||
System.Reflection.BindingFlags.NonPublic).GetValue(null);
|
System.Reflection.BindingFlags.NonPublic).GetValue(null);
|
||||||
|
|
||||||
Trace.WriteLine(
|
Debug.Print(
|
||||||
String.Format(
|
|
||||||
"Screen: {0}, Display: {1}, Root Window: {2}, Control: {3}",
|
"Screen: {0}, Display: {1}, Root Window: {2}, Control: {3}",
|
||||||
info.Screen,
|
info.Screen, info.Display, info.RootWindow, info.Handle);
|
||||||
info.Display,
|
|
||||||
info.RootWindow,
|
|
||||||
info.Handle
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
glContext = new X11GLContext(info,
|
glContext = new X11GLContext(info, mode);
|
||||||
new DisplayMode(width, height, new ColorDepth(24), 16, 0, 0, 2, false, false, false, 0.0f)
|
|
||||||
);
|
|
||||||
|
|
||||||
glContext.CreateVisual();
|
info.VisualInfo = glContext.CreateVisual();
|
||||||
|
|
||||||
xplatui.GetField(
|
xplatui.GetField(
|
||||||
"CustomVisual",
|
"CustomVisual",
|
||||||
System.Reflection.BindingFlags.Static |
|
System.Reflection.BindingFlags.Static |
|
||||||
System.Reflection.BindingFlags.NonPublic).SetValue(
|
System.Reflection.BindingFlags.NonPublic).SetValue(
|
||||||
null,
|
null,
|
||||||
glContext.XVisual
|
//glContext.XVisual
|
||||||
|
info.VisualInfo.visual
|
||||||
);
|
);
|
||||||
|
|
||||||
xplatui.GetField(
|
xplatui.GetField(
|
||||||
|
@ -93,7 +88,8 @@ namespace OpenTK.Platform.X11
|
||||||
System.Reflection.BindingFlags.Static |
|
System.Reflection.BindingFlags.Static |
|
||||||
System.Reflection.BindingFlags.NonPublic).SetValue(
|
System.Reflection.BindingFlags.NonPublic).SetValue(
|
||||||
null,
|
null,
|
||||||
glContext.XColormap
|
API.CreateColormap(info.Display, info.RootWindow, info.VisualInfo.visual, 0/*AllocNone*/)
|
||||||
|
//glContext.colormap
|
||||||
);
|
);
|
||||||
|
|
||||||
glContext.CreateContext(null, true);
|
glContext.CreateContext(null, true);
|
||||||
|
@ -103,7 +99,7 @@ namespace OpenTK.Platform.X11
|
||||||
void c_ParentChanged(object sender, EventArgs e)
|
void c_ParentChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
UserControl c = sender as UserControl;
|
UserControl c = sender as UserControl;
|
||||||
Trace.WriteLine(
|
Debug.WriteLine(
|
||||||
String.Format(
|
String.Format(
|
||||||
"TopLevel control is {0}",
|
"TopLevel control is {0}",
|
||||||
c.TopLevelControl != null ? c.TopLevelControl.ToString() : "not available"
|
c.TopLevelControl != null ? c.TopLevelControl.ToString() : "not available"
|
||||||
|
@ -120,9 +116,9 @@ namespace OpenTK.Platform.X11
|
||||||
info.TopLevelWindow = c.TopLevelControl.Handle;
|
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);
|
API.MapRaised(info.Display, info.TopLevelWindow);
|
||||||
Trace.Unindent();
|
Debug.Unindent();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue