Removed obsolete GetDisplayModes() function.

This commit is contained in:
the_fiddler 2008-04-04 21:08:09 +00:00
parent 224f917a49
commit 84f117b3d3
4 changed files with 37 additions and 66 deletions

View file

@ -83,10 +83,10 @@ namespace OpenTK.Graphics
implementation = new OpenTK.Platform.X11.X11GLContext(mode, window, shareContext, DirectRendering); implementation = new OpenTK.Platform.X11.X11GLContext(mode, window, shareContext, DirectRendering);
else else
throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information."); 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(); //(implementation as IGraphicsContextInternal).LoadAll();
} }
@ -121,8 +121,8 @@ namespace OpenTK.Graphics
public static GraphicsContext CurrentContext public static GraphicsContext CurrentContext
{ {
get get
{ {
lock (context_lock) lock (context_lock)
{ {
if (available_contexts.Count > 0) if (available_contexts.Count > 0)
{ {
@ -130,7 +130,7 @@ namespace OpenTK.Graphics
if (handle.Handle != IntPtr.Zero) if (handle.Handle != IntPtr.Zero)
return (GraphicsContext)available_contexts[handle].Target; return (GraphicsContext)available_contexts[handle].Target;
} }
return null; return null;
} }
} }
//set //set
@ -205,10 +205,10 @@ namespace OpenTK.Graphics
void CreateContext(bool direct, IGraphicsContext source) void CreateContext(bool direct, IGraphicsContext source)
{ {
this.Destroy += ContextDestroyed; this.Destroy += ContextDestroyed;
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));
} }
//OpenTK.Graphics.OpenGL.GL.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit); //OpenTK.Graphics.OpenGL.GL.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit);
@ -333,15 +333,6 @@ namespace OpenTK.Graphics
dispose_queue.Clear(); dispose_queue.Clear();
} }
/// <summary>
/// Returns the display modes supported by the current opengl context.
/// </summary>
/// <returns>An IEnumerable containing all supported display modes.</returns>
IEnumerable<DisplayMode> IGraphicsContextInternal.GetDisplayModes()
{
return (implementation as IGraphicsContextInternal).GetDisplayModes();
}
/// <summary> /// <summary>
/// Gets the address of an OpenGL extension function. /// Gets the address of an OpenGL extension function.
/// </summary> /// </summary>
@ -372,12 +363,12 @@ namespace OpenTK.Graphics
void Dispose(bool manual) void Dispose(bool manual)
{ {
if (!disposed) if (!disposed)
{ {
Debug.WriteLine("Disposing context {0}.", (this as IGraphicsContextInternal).Context.ToString()); Debug.WriteLine("Disposing context {0}.", (this as IGraphicsContextInternal).Context.ToString());
lock (context_lock) lock (context_lock)
{ {
available_contexts.Remove((this as IGraphicsContextInternal).Context); available_contexts.Remove((this as IGraphicsContextInternal).Context);
} }
if (manual) if (manual)
{ {
@ -409,4 +400,4 @@ namespace OpenTK.Graphics
} }
#endregion #endregion
} }

View file

@ -105,12 +105,6 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
void DisposeResources(); void DisposeResources();
/// <summary>
/// Returns the display modes supported by the current opengl context.
/// </summary>
/// <returns>An IEnumerable containing all supported display modes.</returns>
IEnumerable<DisplayMode> GetDisplayModes();
/// <summary> /// <summary>
/// Gets the address of an OpenGL extension function. /// Gets the address of an OpenGL extension function.
/// </summary> /// </summary>

View file

@ -253,15 +253,6 @@ namespace OpenTK.Platform.Windows
#endregion #endregion
#region public DisplayMode[] GetDisplayModes()
public IEnumerable<DisplayMode> GetDisplayModes()
{
throw new NotSupportedException("See OpenTK.Graphics.DisplayDevice.AvailableModes instead.");
}
#endregion
#region void IGLContextInternal.RegisterForDisposal(IDisposable resource) #region void IGLContextInternal.RegisterForDisposal(IDisposable resource)
void IGraphicsContextInternal.RegisterForDisposal(IDisposable resource) void IGraphicsContextInternal.RegisterForDisposal(IDisposable resource)

View file

@ -63,17 +63,17 @@ namespace OpenTK.Platform.X11
XVisualInfo info = new XVisualInfo(); XVisualInfo info = new XVisualInfo();
info.visualid = (IntPtr)mode.Index; info.visualid = (IntPtr)mode.Index;
info.screen = currentWindow.Screen; info.screen = currentWindow.Screen;
int items; int items;
lock (API.Lock) lock (API.Lock)
{ {
IntPtr vs = Functions.XGetVisualInfo(currentWindow.Display, XVisualInfoMask.ID | XVisualInfoMask.Screen, ref info, out items); IntPtr vs = Functions.XGetVisualInfo(currentWindow.Display, XVisualInfoMask.ID | XVisualInfoMask.Screen, ref info, out items);
if (items == 0) if (items == 0)
throw new GraphicsModeException(String.Format("Invalid GraphicsMode specified ({0}).", mode)); throw new GraphicsModeException(String.Format("Invalid GraphicsMode specified ({0}).", mode));
info = (XVisualInfo)Marshal.PtrToStructure(vs, typeof(XVisualInfo)); info = (XVisualInfo)Marshal.PtrToStructure(vs, typeof(XVisualInfo));
Functions.XFree(vs); Functions.XFree(vs);
} }
return info; return info;
} }
@ -93,9 +93,9 @@ namespace OpenTK.Platform.X11
Debug.Write(direct ? "direct, " : "indirect, "); Debug.Write(direct ? "direct, " : "indirect, ");
Debug.Write(shareHandle.Handle == IntPtr.Zero ? "not shared... " : Debug.Write(shareHandle.Handle == IntPtr.Zero ? "not shared... " :
String.Format("shared with ({0})... ", shareHandle)); String.Format("shared with ({0})... ", shareHandle));
lock (API.Lock) lock (API.Lock)
{ {
XVisualInfo info = window.VisualInfo; // Cannot pass a Property by reference. XVisualInfo info = window.VisualInfo; // Cannot pass a Property by reference.
context = Glx.CreateContext(window.Display, ref info, shareHandle.Handle, direct); context = Glx.CreateContext(window.Display, ref info, shareHandle.Handle, direct);
@ -115,7 +115,7 @@ namespace OpenTK.Platform.X11
Debug.Print("done! (id: {0})", context); Debug.Print("done! (id: {0})", context);
return; return;
} }
} }
Debug.Print("failed."); Debug.Print("failed.");
throw new GraphicsModeException("Failed to create OpenGL context. Glx.CreateContext call returned 0."); throw new GraphicsModeException("Failed to create OpenGL context. Glx.CreateContext call returned 0.");
@ -202,10 +202,10 @@ namespace OpenTK.Platform.X11
set set
{ {
if (vsync_supported) if (vsync_supported)
{ {
int error_code = Glx.Sgi.SwapInterval(value ? 1 : 0); int error_code = Glx.Sgi.SwapInterval(value ? 1 : 0);
if (error_code != 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; vsync_interval = value ? 1 : 0;
} }
} }
@ -234,11 +234,6 @@ namespace OpenTK.Platform.X11
throw new NotSupportedException("Use OpenTK.GraphicsContext instead."); throw new NotSupportedException("Use OpenTK.GraphicsContext instead.");
} }
public IEnumerable<DisplayMode> GetDisplayModes()
{
throw new Exception("The method or operation is not implemented.");
}
#endregion #endregion
#region --- IGLContextInternal Members --- #region --- IGLContextInternal Members ---
@ -294,7 +289,7 @@ namespace OpenTK.Platform.X11
#region static ContextHandle GetCurrentContext() #region static ContextHandle GetCurrentContext()
static ContextHandle GetCurrentContext() static ContextHandle GetCurrentContext()
{ {
return (ContextHandle)Glx.GetCurrentContext(); return (ContextHandle)Glx.GetCurrentContext();
} }
@ -313,20 +308,20 @@ namespace OpenTK.Platform.X11
private void Dispose(bool manuallyCalled) private void Dispose(bool manuallyCalled)
{ {
if (!disposed) if (!disposed)
{ {
// Clean unmanaged resources: // Clean unmanaged resources:
try try
{ {
Functions.XLockDisplay(currentWindow.Display); Functions.XLockDisplay(currentWindow.Display);
Glx.MakeCurrent(currentWindow.Display, IntPtr.Zero, IntPtr.Zero); Glx.MakeCurrent(currentWindow.Display, IntPtr.Zero, IntPtr.Zero);
Glx.DestroyContext(currentWindow.Display, context); Glx.DestroyContext(currentWindow.Display, context);
//Functions.XFree(visual); //Functions.XFree(visual);
}
finally
{
Functions.XUnlockDisplay(currentWindow.Display);
} }
finally
{
Functions.XUnlockDisplay(currentWindow.Display);
}
if (manuallyCalled) if (manuallyCalled)
{ {
} }