From 53f2e4c48f0acf71e9ad13a9195870153002135d Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Tue, 7 Aug 2007 18:08:06 +0000 Subject: [PATCH] Updated ToString function for ColorDepth and DisplayMode. Corrected two warnings in GLHelper.cs Updated X11GLContext to use the correct DisplayMode. --- Source/OpenTK/OpenGL/GLHelper.cs | 4 +- Source/OpenTK/Platform/ColorDepth.cs | 4 +- Source/OpenTK/Platform/DisplayMode.cs | 24 +++-------- Source/OpenTK/Platform/X11/API.cs | 4 +- Source/OpenTK/Platform/X11/X11GLContext.cs | 48 ++++++++++------------ 5 files changed, 34 insertions(+), 50 deletions(-) diff --git a/Source/OpenTK/OpenGL/GLHelper.cs b/Source/OpenTK/OpenGL/GLHelper.cs index 78b928f7..0c9b31dc 100644 --- a/Source/OpenTK/OpenGL/GLHelper.cs +++ b/Source/OpenTK/OpenGL/GLHelper.cs @@ -422,7 +422,7 @@ Did you remember to copy OpenTK.OpenGL.dll.config to your binary's folder? { Assembly asm = Assembly.GetExecutingAssembly();//Assembly.Load("OpenTK.OpenGL"); Type delegates_class = asm.GetType("OpenTK.OpenGL.Delegates"); - Type imports_class = asm.GetType("OpenTK.OpenGL.Imports"); + //Type imports_class = asm.GetType("OpenTK.OpenGL.Imports"); FieldInfo[] v = delegates_class.GetFields(BindingFlags.Static | BindingFlags.NonPublic); foreach (FieldInfo f in v) @@ -464,7 +464,7 @@ Did you remember to copy OpenTK.OpenGL.dll.config to your binary's folder? { Assembly asm = Assembly.Load("OpenTK.OpenGL"); Type delegates_class = asm.GetType("OpenTK.OpenGL.Delegates"); - Type imports_class = asm.GetType("OpenTK.OpenGL.Imports"); + //Type imports_class = asm.GetType("OpenTK.OpenGL.Imports"); FieldInfo f = delegates_class.GetField(name); if (f == null) diff --git a/Source/OpenTK/Platform/ColorDepth.cs b/Source/OpenTK/Platform/ColorDepth.cs index ecf4544a..767a5264 100644 --- a/Source/OpenTK/Platform/ColorDepth.cs +++ b/Source/OpenTK/Platform/ColorDepth.cs @@ -88,7 +88,7 @@ namespace OpenTK.Platform public override string ToString() { - return string.Format(CultureInfo.CurrentCulture, "{0}", BitsPerPixel + (IsIndexed ? " indexed" : String.Empty) + " bpp"); + return string.Format("{0} ({1})", BitsPerPixel, (IsIndexed ? " indexed" : Red.ToString() + Green.ToString() + Blue.ToString() + Alpha.ToString())); } } -} \ No newline at end of file +} diff --git a/Source/OpenTK/Platform/DisplayMode.cs b/Source/OpenTK/Platform/DisplayMode.cs index 1662b3af..4f9a359f 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(0), 0, 0, 0, 0, false, false, false, 0.0f) + : this(0, 0, new ColorDepth(32), 0, 0, 0, 0, false, false, false, 0.0f) { } @@ -88,24 +88,10 @@ 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(0), 0, 0, 0, 0, false, false, false, 0.0f) + : this(width, height, new ColorDepth(32), 0, 0, 0, 0, false, false, false, 0.0f) { } - /* - public DisplayMode(int width, int height, int bpp, int frequency) - : this(width, height, 0, 0, 0, 0, frequency) - { - color = new ColorDepth(bpp); - } - */ - /* - public DisplayMode(int width, int height, int r, int g, int b, int a, int frequency) - { - size = new Size(width, height); - color = new ColorDepth(r, g, b, a); - displayFrequency = frequency; - } - */ + #endregion #region --- Public Properties --- @@ -139,7 +125,7 @@ namespace OpenTK.Platform get { return width; } set { - if (value > 0 /* && (value < Screen[0].Width) */) + if (value > 0) { width = value; } @@ -215,7 +201,7 @@ namespace OpenTK.Platform CultureInfo.CurrentCulture, "{0}x{1}, {2}, {3}Hz", Width, Height, - Color, + Color.ToString(), RefreshRate ); } diff --git a/Source/OpenTK/Platform/X11/API.cs b/Source/OpenTK/Platform/X11/API.cs index 8f3c4818..0d91d2ec 100644 --- a/Source/OpenTK/Platform/X11/API.cs +++ b/Source/OpenTK/Platform/X11/API.cs @@ -551,7 +551,9 @@ XF86VidModeGetGammaRampSize( public override string ToString() { - return base.ToString(); + // return base.ToString(); + return String.Format("VisualInfo: id ({0}), screen ({1}), depth ({2}), class ({3})", + visualid, screen, depth, @class); } } diff --git a/Source/OpenTK/Platform/X11/X11GLContext.cs b/Source/OpenTK/Platform/X11/X11GLContext.cs index eb4361d3..462c70ce 100644 --- a/Source/OpenTK/Platform/X11/X11GLContext.cs +++ b/Source/OpenTK/Platform/X11/X11GLContext.cs @@ -148,16 +148,16 @@ namespace OpenTK.Platform.X11 public void CreateContext(X11GLContext shareContext, bool direct) { - Trace.WriteLine("Creating opengl context."); - Trace.Indent(); + Debug.WriteLine("Creating opengl context."); + Debug.Indent(); IntPtr shareHandle = shareContext != null ? shareContext.Handle : IntPtr.Zero; - Trace.WriteLine( + Debug.WriteLine( shareHandle == IntPtr.Zero ? "Context is not shared." : String.Format("Context is shared with context: {0}", shareHandle) ); - Trace.WriteLine( + Debug.WriteLine( direct ? "Context is direct." : "Context is indirect." @@ -167,11 +167,16 @@ namespace OpenTK.Platform.X11 visual, shareHandle, direct - ); - Trace.WriteLine(String.Format("New opengl context created. (id: {0})", x11context)); - Trace.Unindent(); - - //MakeCurrent(); + ); + if (x11context != IntPtr.Zero) + { + Debug.WriteLine(String.Format("New opengl context created. (id: {0})", x11context)); + Debug.Unindent(); + } + else + { + throw new ApplicationException("Could not create opengl context."); + } } #endregion @@ -182,7 +187,7 @@ namespace OpenTK.Platform.X11 { Debug.WriteLine("Creating visual."); Debug.Indent(); - +/* ColorDepth color = new ColorDepth(24); int depthBits = 16; @@ -201,8 +206,10 @@ 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()); + List visualAttributes = new List(); visualAttributes.Add((int)Glx.Enums.GLXAttribute.RGBA); visualAttributes.Add((int)Glx.Enums.GLXAttribute.RED_SIZE); @@ -214,29 +221,18 @@ namespace OpenTK.Platform.X11 visualAttributes.Add((int)Glx.Enums.GLXAttribute.ALPHA_SIZE); visualAttributes.Add((int)mode.Color.Alpha); visualAttributes.Add((int)Glx.Enums.GLXAttribute.DEPTH_SIZE); - visualAttributes.Add((int)depthBits); + visualAttributes.Add((int)mode.DepthBits); visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER); visualAttributes.Add((int)Glx.Enums.GLXAttribute.NONE); - */ - Debug.Write( - String.Format( - "Requesting visual: {0} ({1}{2}{3}{4})... ", - mode.ToString(), - mode.Color.Red, - mode.Color.Green, - mode.Color.Blue, - mode.Color.Alpha - ) - ); visual = Glx.ChooseVisual(windowInfo.Display, windowInfo.Screen, visualAttributes.ToArray()); if (visual == IntPtr.Zero) { throw new Exception("Requested visual not available."); } - visualInfo = (VisualInfo)Marshal.PtrToStructure(visual, typeof(VisualInfo)); + visualInfo = (VisualInfo)Marshal.PtrToStructure(visual, typeof(VisualInfo)); + Debug.Print("Got visual: {0}", visualInfo.ToString()); - Debug.Print("done! (id: {0})", x11context); Debug.Unindent(); return visualInfo;