diff --git a/Source/Examples/Tutorial/T03_RotatingCube.cs b/Source/Examples/Tutorial/T03_RotatingCube.cs
index 27bba48c..77a9ef93 100644
--- a/Source/Examples/Tutorial/T03_RotatingCube.cs
+++ b/Source/Examples/Tutorial/T03_RotatingCube.cs
@@ -134,7 +134,7 @@ namespace Examples.Tutorial
private void DrawCube()
{
- GL.Begin(GL.Enums.BeginMode.QUADS);
+ GL.Begin(GL.Enums.BeginMode.QUADS);
GL.Color3(1.0f, 0.0f, 0.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.Color3(0.0f, 1.0f, 1.0f);
GL.Vertex3(1.0f, -1.0f, -1.0f);
diff --git a/Source/OpenTK/Platform/DisplayMode.cs b/Source/OpenTK/Platform/DisplayMode.cs
index 4f9a359f..7aa3bba4 100644
--- a/Source/OpenTK/Platform/DisplayMode.cs
+++ b/Source/OpenTK/Platform/DisplayMode.cs
@@ -78,7 +78,7 @@ namespace OpenTK.Platform
/// Constructs a new DisplayMode with default values.
///
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
/// The Width of the DisplayMode in pixels.
/// The Height of the DisplayMode in pixels.
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(
CultureInfo.CurrentCulture,
- "{0}x{1}, {2}, {3}Hz",
+ "{0}x{1}, rgba: {2}, depth: {3}, refresh {4}Hz",
Width, Height,
- Color.ToString(),
+ Color.ToString(),
+ DepthBits,
RefreshRate
);
}
diff --git a/Source/OpenTK/Platform/X11/API.cs b/Source/OpenTK/Platform/X11/API.cs
index 0d91d2ec..9203be53 100644
--- a/Source/OpenTK/Platform/X11/API.cs
+++ b/Source/OpenTK/Platform/X11/API.cs
@@ -552,7 +552,7 @@ XF86VidModeGetGammaRampSize(
public override string 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);
}
}
diff --git a/Source/OpenTK/Platform/X11/Glx.cs b/Source/OpenTK/Platform/X11/Glx.cs
index bb5f1af0..d8fb645f 100644
--- a/Source/OpenTK/Platform/X11/Glx.cs
+++ b/Source/OpenTK/Platform/X11/Glx.cs
@@ -304,16 +304,13 @@ namespace OpenTK.Platform.X11
internal extern static IntPtr ChooseVisual(IntPtr dpy, int screen, IntPtr attriblist);
internal static IntPtr ChooseVisual(IntPtr dpy, int screen, int[] attriblist)
- {
- GCHandle h0 = GCHandle.Alloc(attriblist, GCHandleType.Pinned);
-
- try
- {
- return ChooseVisual(dpy, screen, h0.AddrOfPinnedObject());
- }
- finally
- {
- h0.Free();
+ {
+ unsafe
+ {
+ fixed (int* attriblist_ptr = attriblist)
+ {
+ return ChooseVisual(dpy, screen, (IntPtr)attriblist_ptr);
+ }
}
}
diff --git a/Source/OpenTK/Platform/X11/Structs.cs b/Source/OpenTK/Platform/X11/Structs.cs
index ca82dd8d..69f15a39 100644
--- a/Source/OpenTK/Platform/X11/Structs.cs
+++ b/Source/OpenTK/Platform/X11/Structs.cs
@@ -834,7 +834,7 @@ namespace OpenTK.Platform.X11
}
[Flags]
- internal enum EventMask : long
+ internal enum EventMask
{
NoEventMask = 0,
KeyPressMask = 1 << 0,
@@ -1654,4 +1654,4 @@ namespace OpenTK.Platform.X11
UnregisterAccelerator = 13,
ActivateAccelerator = 14
}
-}
\ No newline at end of file
+}
diff --git a/Source/OpenTK/Platform/X11/WindowInfo.cs b/Source/OpenTK/Platform/X11/WindowInfo.cs
index 62d3dd47..039da219 100644
--- a/Source/OpenTK/Platform/X11/WindowInfo.cs
+++ b/Source/OpenTK/Platform/X11/WindowInfo.cs
@@ -10,7 +10,11 @@ namespace OpenTK.Platform.X11
///
internal class WindowInfo : IWindowInfo
{
- internal WindowInfo() { }
+ internal WindowInfo()
+ {
+ visinfo = new VisualInfo();
+ }
+
internal WindowInfo(WindowInfo parent)
{
this.TopLevelWindow = parent.TopLevelWindow;
diff --git a/Source/OpenTK/Platform/X11/X11GLContext.cs b/Source/OpenTK/Platform/X11/X11GLContext.cs
index 462c70ce..f0b3428f 100644
--- a/Source/OpenTK/Platform/X11/X11GLContext.cs
+++ b/Source/OpenTK/Platform/X11/X11GLContext.cs
@@ -187,7 +187,7 @@ namespace OpenTK.Platform.X11
{
Debug.WriteLine("Creating visual.");
Debug.Indent();
-/*
+
ColorDepth color = new ColorDepth(24);
int depthBits = 16;
@@ -206,10 +206,15 @@ namespace OpenTK.Platform.X11
visualAttributes.Add((int)depthBits);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE);
-*/
-
- Debug.Print("Requesting visual: {0}... ", mode.ToString());
-
+/*
+ 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.");
+ }
+
List visualAttributes = new List();
visualAttributes.Add((int)Glx.Enums.GLXAttribute.RGBA);
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)mode.Color.Blue);
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)mode.DepthBits);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER);
visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE);
-
+*/
visual = Glx.ChooseVisual(windowInfo.Display, windowInfo.Screen, visualAttributes.ToArray());
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));
- Debug.Print("Got visual: {0}", visualInfo.ToString());
+ windowInfo.VisualInfo = (VisualInfo)Marshal.PtrToStructure(visual, typeof(VisualInfo));
+ Debug.Print("Got visual: {0}", windowInfo.VisualInfo.ToString());
Debug.Unindent();
- return visualInfo;
+ return windowInfo.VisualInfo;
}
#endregion
@@ -247,7 +252,7 @@ namespace OpenTK.Platform.X11
internal VisualInfo XVisualInfo
{
- get { return this.visualInfo; }
+ get { return windowInfo.VisualInfo; }
}
internal IntPtr XColormap
diff --git a/Source/OpenTK/Platform/X11/X11GLNative.cs b/Source/OpenTK/Platform/X11/X11GLNative.cs
index c56a916e..322c34ff 100644
--- a/Source/OpenTK/Platform/X11/X11GLNative.cs
+++ b/Source/OpenTK/Platform/X11/X11GLNative.cs
@@ -247,23 +247,23 @@ namespace OpenTK.Platform.X11
window.VisualInfo = glContext.CreateVisual();
// Create a window on this display using the visual above
- Debug.Write("Creating output window... ");
-
+ Debug.Write("Creating output window... ");
+
XSetWindowAttributes attributes = new XSetWindowAttributes();
- attributes.colormap = glContext.colormap;
+ //attributes.colormap = glContext.colormap;
attributes.event_mask = (IntPtr)(EventMask.StructureNotifyMask |
EventMask.SubstructureNotifyMask | EventMask.ExposureMask);
- SetWindowValuemask mask = SetWindowValuemask.ColorMap | SetWindowValuemask.EventMask;
-
- window.Handle = Functions.XCreateWindow(window.Display, window.RootWindow,
- 0, 0, mode.Width, mode.Height, 0, glContext.XVisualInfo.depth,
- (int)CreateWindowArgs.InputOutput, glContext.XVisualInfo.visual, (UIntPtr)mask,
+ uint mask = (uint)SetWindowValuemask.ColorMap | (uint)SetWindowValuemask.EventMask;
+
+ window.Handle = Functions.XCreateWindow(window.Display, /*window.RootWindow*/0,
+ 0, 0, mode.Width, mode.Height, 0, /*window.VisualInfo.depth*/(int)CreateWindowArgs.CopyFromParent,
+ (int)CreateWindowArgs.InputOutput, window.VisualInfo.visual, (UIntPtr)mask,
ref attributes);
if (window.Handle == IntPtr.Zero)
{
- throw new Exception("Could not create window.");
+ throw new ApplicationException("Could not create window.");
}
/*
// Set the window hints