diff --git a/Source/OpenTK/Graphics/GraphicsContext.cs b/Source/OpenTK/Graphics/GraphicsContext.cs index 81cb7fa6..352e2d87 100644 --- a/Source/OpenTK/Graphics/GraphicsContext.cs +++ b/Source/OpenTK/Graphics/GraphicsContext.cs @@ -83,10 +83,10 @@ namespace OpenTK.Graphics implementation = new OpenTK.Platform.X11.X11GLContext(mode, window, shareContext, DirectRendering); else throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information."); - - lock (context_lock) + + lock (context_lock) { - available_contexts.Add((this as IGraphicsContextInternal).Context, new WeakReference(this)); + available_contexts.Add((this as IGraphicsContextInternal).Context, new WeakReference(this)); } //(implementation as IGraphicsContextInternal).LoadAll(); } @@ -121,8 +121,8 @@ namespace OpenTK.Graphics public static GraphicsContext CurrentContext { get - { - lock (context_lock) + { + lock (context_lock) { if (available_contexts.Count > 0) { @@ -130,7 +130,7 @@ namespace OpenTK.Graphics if (handle.Handle != IntPtr.Zero) return (GraphicsContext)available_contexts[handle].Target; } - return null; + return null; } } //set @@ -205,10 +205,10 @@ namespace OpenTK.Graphics void CreateContext(bool direct, IGraphicsContext source) { this.Destroy += ContextDestroyed; - + lock (context_lock) - { - available_contexts.Add((this as IGraphicsContextInternal).Context, new WeakReference(this)); + { + available_contexts.Add((this as IGraphicsContextInternal).Context, new WeakReference(this)); } //OpenTK.Graphics.OpenGL.GL.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit); @@ -333,15 +333,6 @@ namespace OpenTK.Graphics dispose_queue.Clear(); } - /// - /// Returns the display modes supported by the current opengl context. - /// - /// An IEnumerable containing all supported display modes. - IEnumerable IGraphicsContextInternal.GetDisplayModes() - { - return (implementation as IGraphicsContextInternal).GetDisplayModes(); - } - /// /// Gets the address of an OpenGL extension function. /// @@ -372,12 +363,12 @@ namespace OpenTK.Graphics void Dispose(bool manual) { if (!disposed) - { - Debug.WriteLine("Disposing context {0}.", (this as IGraphicsContextInternal).Context.ToString()); - lock (context_lock) + { + Debug.WriteLine("Disposing context {0}.", (this as IGraphicsContextInternal).Context.ToString()); + lock (context_lock) { - available_contexts.Remove((this as IGraphicsContextInternal).Context); - } + available_contexts.Remove((this as IGraphicsContextInternal).Context); + } if (manual) { @@ -409,4 +400,4 @@ namespace OpenTK.Graphics } #endregion -} +} diff --git a/Source/OpenTK/Graphics/IGraphicsContext.cs b/Source/OpenTK/Graphics/IGraphicsContext.cs index d813da02..a91d1071 100644 --- a/Source/OpenTK/Graphics/IGraphicsContext.cs +++ b/Source/OpenTK/Graphics/IGraphicsContext.cs @@ -105,12 +105,6 @@ namespace OpenTK.Graphics /// void DisposeResources(); - /// - /// Returns the display modes supported by the current opengl context. - /// - /// An IEnumerable containing all supported display modes. - IEnumerable GetDisplayModes(); - /// /// Gets the address of an OpenGL extension function. /// diff --git a/Source/OpenTK/Platform/Windows/WinGLContext.cs b/Source/OpenTK/Platform/Windows/WinGLContext.cs index 2136ae2c..c2834812 100644 --- a/Source/OpenTK/Platform/Windows/WinGLContext.cs +++ b/Source/OpenTK/Platform/Windows/WinGLContext.cs @@ -253,15 +253,6 @@ namespace OpenTK.Platform.Windows #endregion - #region public DisplayMode[] GetDisplayModes() - - public IEnumerable GetDisplayModes() - { - throw new NotSupportedException("See OpenTK.Graphics.DisplayDevice.AvailableModes instead."); - } - - #endregion - #region void IGLContextInternal.RegisterForDisposal(IDisposable resource) void IGraphicsContextInternal.RegisterForDisposal(IDisposable resource) diff --git a/Source/OpenTK/Platform/X11/X11GLContext.cs b/Source/OpenTK/Platform/X11/X11GLContext.cs index 134e22f0..b0f90044 100644 --- a/Source/OpenTK/Platform/X11/X11GLContext.cs +++ b/Source/OpenTK/Platform/X11/X11GLContext.cs @@ -63,17 +63,17 @@ namespace OpenTK.Platform.X11 XVisualInfo info = new XVisualInfo(); info.visualid = (IntPtr)mode.Index; info.screen = currentWindow.Screen; - int items; - - lock (API.Lock) + int items; + + lock (API.Lock) { IntPtr vs = Functions.XGetVisualInfo(currentWindow.Display, XVisualInfoMask.ID | XVisualInfoMask.Screen, ref info, out items); if (items == 0) throw new GraphicsModeException(String.Format("Invalid GraphicsMode specified ({0}).", mode)); info = (XVisualInfo)Marshal.PtrToStructure(vs, typeof(XVisualInfo)); - Functions.XFree(vs); - } + Functions.XFree(vs); + } return info; } @@ -93,9 +93,9 @@ namespace OpenTK.Platform.X11 Debug.Write(direct ? "direct, " : "indirect, "); Debug.Write(shareHandle.Handle == IntPtr.Zero ? "not shared... " : String.Format("shared with ({0})... ", shareHandle)); - - lock (API.Lock) - { + + lock (API.Lock) + { XVisualInfo info = window.VisualInfo; // Cannot pass a Property by reference. context = Glx.CreateContext(window.Display, ref info, shareHandle.Handle, direct); @@ -115,7 +115,7 @@ namespace OpenTK.Platform.X11 Debug.Print("done! (id: {0})", context); return; } - } + } Debug.Print("failed."); throw new GraphicsModeException("Failed to create OpenGL context. Glx.CreateContext call returned 0."); @@ -202,10 +202,10 @@ namespace OpenTK.Platform.X11 set { if (vsync_supported) - { + { int error_code = Glx.Sgi.SwapInterval(value ? 1 : 0); if (error_code != 0) - throw new GraphicsException(String.Format("Could not set vsync, error code: {0}", error_code)); + throw new GraphicsException(String.Format("Could not set vsync, error code: {0}", error_code)); vsync_interval = value ? 1 : 0; } } @@ -234,11 +234,6 @@ namespace OpenTK.Platform.X11 throw new NotSupportedException("Use OpenTK.GraphicsContext instead."); } - public IEnumerable GetDisplayModes() - { - throw new Exception("The method or operation is not implemented."); - } - #endregion #region --- IGLContextInternal Members --- @@ -294,7 +289,7 @@ namespace OpenTK.Platform.X11 #region static ContextHandle GetCurrentContext() static ContextHandle GetCurrentContext() - { + { return (ContextHandle)Glx.GetCurrentContext(); } @@ -313,20 +308,20 @@ namespace OpenTK.Platform.X11 private void Dispose(bool manuallyCalled) { if (!disposed) - { + { // Clean unmanaged resources: - try - { + try + { Functions.XLockDisplay(currentWindow.Display); Glx.MakeCurrent(currentWindow.Display, IntPtr.Zero, IntPtr.Zero); - Glx.DestroyContext(currentWindow.Display, context); - //Functions.XFree(visual); - } - finally - { - Functions.XUnlockDisplay(currentWindow.Display); + Glx.DestroyContext(currentWindow.Display, context); + //Functions.XFree(visual); } - + finally + { + Functions.XUnlockDisplay(currentWindow.Display); + } + if (manuallyCalled) { }