#region --- License --- /* Licensed under the MIT/X11 license. * Copyright (c) 2006-2008 the OpenTK Team. * This notice may not be removed from any source distribution. * See license.txt for licensing detailed licensing details. */ #endregion using System; using System.Collections.Generic; using System.Text; using OpenTK.Platform; namespace OpenTK.Graphics { /// /// Provides methods for creating and interacting with an OpenGL context. /// public interface IGraphicsContext : IDisposable { /// Swaps buffers, presenting the rendered scene to the user. void SwapBuffers(); /// Makes the GraphicsContext current in the calling thread. /// An OpenTK.Platform.IWindowInfo structure that points to a valid window. /// /// OpenGL commands in one thread, affect the GraphicsContext which is current in that thread. /// It is an error to issue an OpenGL command in a thread without a current GraphicsContext. /// void MakeCurrent(IWindowInfo window); /// /// Gets or sets a System.Boolean indicating whether the GraphicsContext is current in the calling thread. /// bool IsCurrent { get; /*set;*/ } /// /// Raised when a Context is destroyed. /// event DestroyEvent Destroy; /// /// Gets or sets a value indicating whether VSyncing is enabled. /// bool VSync { get; set; } /// /// Updates the graphics context. This must be called when the region the graphics context /// is drawn to is resized. /// /// void Update(IWindowInfo window); /// Gets the GraphicsMode of this instance. GraphicsMode GraphicsMode { get; } /// /// Gets or sets a System.Boolean, indicating whether automatic error checking should be performed. /// Influences the debug version of OpenTK.dll, only. /// bool ErrorChecking { get; set; } } public delegate void DestroyEvent(T sender, EventArgs e); // Functions for internal use by OpenTK. // TODO: RegisterForDisposal/DisposeResources for 0.3.15 (GC & OpenGL) // TODO: Remove or move GetDisplayModes to another class. /// /// Provides methods to create new GraphicsContexts. Should only be used for extending OpenTK. /// public interface IGraphicsContextInternal { IGraphicsContext Implementation { get; } ///// ///// Creates an OpenGL context with the specified direct/indirect rendering mode and sharing state with the ///// specified IGraphicsContext. ///// ///// Set to true for direct rendering or false otherwise. ///// The source IGraphicsContext to share state from.. ///// //void CreateContext(bool direct, IGraphicsContext source); /// Prepares the entry points for OpenGL. void LoadAll(); /// /// Gets a handle to the OpenGL rendering context. /// ContextHandle Context { get; } // // Gets the IWindowInfo describing the window associated with this context. // //IWindowInfo Info { get; } ///// ///// Gets a System.IntPtr containing the handle to the OpenGL context which is current in the ///// calling thread, or IntPtr.Zero if no OpenGL context is current. ///// ///// A System.IntPtr that holds the handle to the current OpenGL context. //ContextHandle GetCurrentContext(); /// /// Registers an OpenGL resource for disposal. /// /// The OpenGL resource to dispose. /// /// You may not destroy OpenGL resources in finalizers, since they run in /// a different thread. To avoid this problem, use this method to register /// a resource for disposal during the finalizer call, and call DisposeResources() /// from the main thread to dispose it. /// void RegisterForDisposal(IDisposable resource); /// /// Disposes all registered OpenGL resources. /// void DisposeResources(); /// /// Gets the address of an OpenGL extension function. /// /// The name of the OpenGL function (e.g. "glGetString") /// /// A pointer to the specified function or IntPtr.Zero if the function isn't /// available in the current opengl context. /// // /// IntPtr GetAddress(string function); } }