Debugging crash on X11 32bits.
This commit is contained in:
parent
81a26ab792
commit
4497fcfc1b
8 changed files with 48 additions and 41 deletions
|
@ -134,7 +134,7 @@ namespace Examples.Tutorial
|
||||||
|
|
||||||
private void DrawCube()
|
private void DrawCube()
|
||||||
{
|
{
|
||||||
GL.Begin(GL.Enums.BeginMode.QUADS);
|
GL.Begin(GL.Enums.BeginMode.QUADS);
|
||||||
|
|
||||||
GL.Color3(1.0f, 0.0f, 0.0f);
|
GL.Color3(1.0f, 0.0f, 0.0f);
|
||||||
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||||
|
@ -164,7 +164,7 @@ namespace Examples.Tutorial
|
||||||
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||||
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||||
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||||
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||||
|
|
||||||
GL.Color3(0.0f, 1.0f, 1.0f);
|
GL.Color3(0.0f, 1.0f, 1.0f);
|
||||||
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace OpenTK.Platform
|
||||||
/// Constructs a new DisplayMode with default values.
|
/// Constructs a new DisplayMode with default values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DisplayMode()
|
public DisplayMode()
|
||||||
: this(0, 0, new ColorDepth(32), 0, 0, 0, 0, false, false, false, 0.0f)
|
: this(0, 0, new ColorDepth(32), 16, 0, 0, 0, false, false, false, 0.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ namespace OpenTK.Platform
|
||||||
/// <param name="width">The Width of the DisplayMode in pixels.</param>
|
/// <param name="width">The Width of the DisplayMode in pixels.</param>
|
||||||
/// <param name="height">The Height of the DisplayMode in pixels.</param>
|
/// <param name="height">The Height of the DisplayMode in pixels.</param>
|
||||||
public DisplayMode(int width, int height)
|
public DisplayMode(int width, int height)
|
||||||
: this(width, height, new ColorDepth(32), 0, 0, 0, 0, false, false, false, 0.0f)
|
: this(width, height, new ColorDepth(32), 16, 0, 0, 0, false, false, false, 0.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,9 +199,10 @@ namespace OpenTK.Platform
|
||||||
{
|
{
|
||||||
return string.Format(
|
return string.Format(
|
||||||
CultureInfo.CurrentCulture,
|
CultureInfo.CurrentCulture,
|
||||||
"{0}x{1}, {2}, {3}Hz",
|
"{0}x{1}, rgba: {2}, depth: {3}, refresh {4}Hz",
|
||||||
Width, Height,
|
Width, Height,
|
||||||
Color.ToString(),
|
Color.ToString(),
|
||||||
|
DepthBits,
|
||||||
RefreshRate
|
RefreshRate
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -552,7 +552,7 @@ XF86VidModeGetGammaRampSize(
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
// return base.ToString();
|
// return base.ToString();
|
||||||
return String.Format("VisualInfo: id ({0}), screen ({1}), depth ({2}), class ({3})",
|
return String.Format("id ({0}), screen ({1}), depth ({2}), class ({3})",
|
||||||
visualid, screen, depth, @class);
|
visualid, screen, depth, @class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,16 +304,13 @@ namespace OpenTK.Platform.X11
|
||||||
internal extern static IntPtr ChooseVisual(IntPtr dpy, int screen, IntPtr attriblist);
|
internal extern static IntPtr ChooseVisual(IntPtr dpy, int screen, IntPtr attriblist);
|
||||||
|
|
||||||
internal static IntPtr ChooseVisual(IntPtr dpy, int screen, int[] attriblist)
|
internal static IntPtr ChooseVisual(IntPtr dpy, int screen, int[] attriblist)
|
||||||
{
|
{
|
||||||
GCHandle h0 = GCHandle.Alloc(attriblist, GCHandleType.Pinned);
|
unsafe
|
||||||
|
{
|
||||||
try
|
fixed (int* attriblist_ptr = attriblist)
|
||||||
{
|
{
|
||||||
return ChooseVisual(dpy, screen, h0.AddrOfPinnedObject());
|
return ChooseVisual(dpy, screen, (IntPtr)attriblist_ptr);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
h0.Free();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -834,7 +834,7 @@ namespace OpenTK.Platform.X11
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
internal enum EventMask : long
|
internal enum EventMask
|
||||||
{
|
{
|
||||||
NoEventMask = 0,
|
NoEventMask = 0,
|
||||||
KeyPressMask = 1 << 0,
|
KeyPressMask = 1 << 0,
|
||||||
|
@ -1654,4 +1654,4 @@ namespace OpenTK.Platform.X11
|
||||||
UnregisterAccelerator = 13,
|
UnregisterAccelerator = 13,
|
||||||
ActivateAccelerator = 14
|
ActivateAccelerator = 14
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,11 @@ namespace OpenTK.Platform.X11
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class WindowInfo : IWindowInfo
|
internal class WindowInfo : IWindowInfo
|
||||||
{
|
{
|
||||||
internal WindowInfo() { }
|
internal WindowInfo()
|
||||||
|
{
|
||||||
|
visinfo = new VisualInfo();
|
||||||
|
}
|
||||||
|
|
||||||
internal WindowInfo(WindowInfo parent)
|
internal WindowInfo(WindowInfo parent)
|
||||||
{
|
{
|
||||||
this.TopLevelWindow = parent.TopLevelWindow;
|
this.TopLevelWindow = parent.TopLevelWindow;
|
||||||
|
|
|
@ -187,7 +187,7 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Creating visual.");
|
Debug.WriteLine("Creating visual.");
|
||||||
Debug.Indent();
|
Debug.Indent();
|
||||||
/*
|
|
||||||
ColorDepth color = new ColorDepth(24);
|
ColorDepth color = new ColorDepth(24);
|
||||||
int depthBits = 16;
|
int depthBits = 16;
|
||||||
|
|
||||||
|
@ -206,10 +206,15 @@ namespace OpenTK.Platform.X11
|
||||||
visualAttributes.Add((int)depthBits);
|
visualAttributes.Add((int)depthBits);
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER);
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE);
|
||||||
*/
|
/*
|
||||||
|
Debug.Print("Requesting DisplayMode: {0}. ", mode.ToString());
|
||||||
Debug.Print("Requesting visual: {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.");
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.RED_SIZE);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.RED_SIZE);
|
||||||
|
@ -219,23 +224,23 @@ namespace OpenTK.Platform.X11
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.BLUE_SIZE);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.BLUE_SIZE);
|
||||||
visualAttributes.Add((int)mode.Color.Blue);
|
visualAttributes.Add((int)mode.Color.Blue);
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.ALPHA_SIZE);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.ALPHA_SIZE);
|
||||||
visualAttributes.Add((int)mode.Color.Alpha);
|
visualAttributes.Add((int)mode.Color.Alpha);
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DEPTH_SIZE);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DEPTH_SIZE);
|
||||||
visualAttributes.Add((int)mode.DepthBits);
|
visualAttributes.Add((int)mode.DepthBits);
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER);
|
||||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE);
|
visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE);
|
||||||
|
*/
|
||||||
visual = Glx.ChooseVisual(windowInfo.Display, windowInfo.Screen, visualAttributes.ToArray());
|
visual = Glx.ChooseVisual(windowInfo.Display, windowInfo.Screen, visualAttributes.ToArray());
|
||||||
if (visual == IntPtr.Zero)
|
if (visual == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
throw new Exception("Requested visual not available.");
|
throw new ApplicationException("Requested mode not available.");
|
||||||
}
|
}
|
||||||
visualInfo = (VisualInfo)Marshal.PtrToStructure(visual, typeof(VisualInfo));
|
windowInfo.VisualInfo = (VisualInfo)Marshal.PtrToStructure(visual, typeof(VisualInfo));
|
||||||
Debug.Print("Got visual: {0}", visualInfo.ToString());
|
Debug.Print("Got visual: {0}", windowInfo.VisualInfo.ToString());
|
||||||
|
|
||||||
Debug.Unindent();
|
Debug.Unindent();
|
||||||
|
|
||||||
return visualInfo;
|
return windowInfo.VisualInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -247,7 +252,7 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
internal VisualInfo XVisualInfo
|
internal VisualInfo XVisualInfo
|
||||||
{
|
{
|
||||||
get { return this.visualInfo; }
|
get { return windowInfo.VisualInfo; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal IntPtr XColormap
|
internal IntPtr XColormap
|
||||||
|
|
|
@ -247,23 +247,23 @@ namespace OpenTK.Platform.X11
|
||||||
window.VisualInfo = glContext.CreateVisual();
|
window.VisualInfo = glContext.CreateVisual();
|
||||||
|
|
||||||
// Create a window on this display using the visual above
|
// Create a window on this display using the visual above
|
||||||
Debug.Write("Creating output window... ");
|
Debug.Write("Creating output window... ");
|
||||||
|
|
||||||
XSetWindowAttributes attributes = new XSetWindowAttributes();
|
XSetWindowAttributes attributes = new XSetWindowAttributes();
|
||||||
attributes.colormap = glContext.colormap;
|
//attributes.colormap = glContext.colormap;
|
||||||
attributes.event_mask = (IntPtr)(EventMask.StructureNotifyMask |
|
attributes.event_mask = (IntPtr)(EventMask.StructureNotifyMask |
|
||||||
EventMask.SubstructureNotifyMask | EventMask.ExposureMask);
|
EventMask.SubstructureNotifyMask | EventMask.ExposureMask);
|
||||||
|
|
||||||
SetWindowValuemask mask = SetWindowValuemask.ColorMap | SetWindowValuemask.EventMask;
|
uint mask = (uint)SetWindowValuemask.ColorMap | (uint)SetWindowValuemask.EventMask;
|
||||||
|
|
||||||
window.Handle = Functions.XCreateWindow(window.Display, window.RootWindow,
|
window.Handle = Functions.XCreateWindow(window.Display, /*window.RootWindow*/0,
|
||||||
0, 0, mode.Width, mode.Height, 0, glContext.XVisualInfo.depth,
|
0, 0, mode.Width, mode.Height, 0, /*window.VisualInfo.depth*/(int)CreateWindowArgs.CopyFromParent,
|
||||||
(int)CreateWindowArgs.InputOutput, glContext.XVisualInfo.visual, (UIntPtr)mask,
|
(int)CreateWindowArgs.InputOutput, window.VisualInfo.visual, (UIntPtr)mask,
|
||||||
ref attributes);
|
ref attributes);
|
||||||
|
|
||||||
if (window.Handle == IntPtr.Zero)
|
if (window.Handle == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
throw new Exception("Could not create window.");
|
throw new ApplicationException("Could not create window.");
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
// Set the window hints
|
// Set the window hints
|
||||||
|
|
Loading…
Reference in a new issue