2007-07-23 02:15:18 +02:00
|
|
|
|
#region --- License ---
|
2008-02-28 14:57:07 +01:00
|
|
|
|
/* 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.
|
2007-07-23 02:15:18 +02:00
|
|
|
|
*/
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2008-02-28 14:57:07 +01:00
|
|
|
|
using OpenTK.Platform;
|
|
|
|
|
|
|
|
|
|
namespace OpenTK.Graphics
|
2007-07-23 02:15:18 +02:00
|
|
|
|
{
|
2007-09-09 17:10:21 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Provides methods for creating and interacting with an OpenGL context.
|
|
|
|
|
/// </summary>
|
2008-01-31 14:17:42 +01:00
|
|
|
|
public interface IGraphicsContext : IDisposable
|
2007-07-23 02:15:18 +02:00
|
|
|
|
{
|
2008-01-31 14:15:17 +01:00
|
|
|
|
/// <summary>Swaps buffers, presenting the rendered scene to the user.</summary>
|
2007-07-23 02:15:18 +02:00
|
|
|
|
void SwapBuffers();
|
|
|
|
|
|
2008-01-31 14:15:17 +01:00
|
|
|
|
/// <summary>Makes the GraphicsContext current in the calling thread.</summary>
|
2008-03-03 13:44:56 +01:00
|
|
|
|
/// <param name="window">An OpenTK.Platform.IWindowInfo structure that points to a valid window.</param>
|
2008-01-31 14:15:17 +01:00
|
|
|
|
/// <remarks>
|
|
|
|
|
/// <para>OpenGL commands in one thread, affect the GraphicsContext which is current in that thread.</para>
|
|
|
|
|
/// <para>It is an error to issue an OpenGL command in a thread without a current GraphicsContext.</para>
|
|
|
|
|
/// </remarks>
|
2008-03-03 13:44:56 +01:00
|
|
|
|
void MakeCurrent(IWindowInfo window);
|
2007-07-23 02:15:18 +02:00
|
|
|
|
|
2007-12-09 19:15:51 +01:00
|
|
|
|
/// <summary>
|
2008-01-31 14:15:17 +01:00
|
|
|
|
/// Gets or sets a System.Boolean indicating whether the GraphicsContext is current in the calling thread.
|
2007-12-09 19:15:51 +01:00
|
|
|
|
/// </summary>
|
2008-03-03 13:44:56 +01:00
|
|
|
|
bool IsCurrent { get; /*set;*/ }
|
2007-12-09 19:15:51 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2008-01-11 21:22:46 +01:00
|
|
|
|
/// Raised when a Context is destroyed.
|
2007-12-09 19:15:51 +01:00
|
|
|
|
/// </summary>
|
2008-01-31 14:17:42 +01:00
|
|
|
|
event DestroyEvent<IGraphicsContext> Destroy;
|
2007-12-09 19:15:51 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2008-01-11 21:22:46 +01:00
|
|
|
|
/// Gets or sets a value indicating whether VSyncing is enabled.
|
2007-12-09 19:15:51 +01:00
|
|
|
|
/// </summary>
|
2008-01-11 21:22:46 +01:00
|
|
|
|
bool VSync { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public delegate void DestroyEvent<T>(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.
|
2008-03-01 14:15:31 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Provides methods to create new GraphicsContexts. Should only be used for extending OpenTK.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface IGraphicsContextInternal
|
2008-01-11 21:22:46 +01:00
|
|
|
|
{
|
2008-03-24 14:24:32 +01:00
|
|
|
|
///// <summary>
|
|
|
|
|
///// Creates an OpenGL context with the specified direct/indirect rendering mode and sharing state with the
|
|
|
|
|
///// specified IGraphicsContext.
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="direct">Set to true for direct rendering or false otherwise.</param>
|
|
|
|
|
///// <param name="source">The source IGraphicsContext to share state from.</param>.
|
|
|
|
|
///// <seealso cref="CreateContext(bool)"/>
|
2008-03-01 14:15:31 +01:00
|
|
|
|
//void CreateContext(bool direct, IGraphicsContext source);
|
|
|
|
|
|
|
|
|
|
/// <summary>Prepares the entry points for OpenGL.</summary>
|
|
|
|
|
void LoadAll();
|
|
|
|
|
|
2007-07-23 02:15:18 +02:00
|
|
|
|
/// <summary>
|
2008-01-11 21:22:46 +01:00
|
|
|
|
/// Gets a handle to the OpenGL rendering context.
|
2007-07-23 02:15:18 +02:00
|
|
|
|
/// </summary>
|
2008-01-11 21:22:46 +01:00
|
|
|
|
ContextHandle Context { get; }
|
2007-07-23 02:15:18 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2008-01-11 21:22:46 +01:00
|
|
|
|
/// Gets the IWindowInfo describing the window associated with this context.
|
2007-07-23 02:15:18 +02:00
|
|
|
|
/// </summary>
|
2008-03-03 13:44:56 +01:00
|
|
|
|
//IWindowInfo Info { get; }
|
2007-09-29 17:24:55 +02:00
|
|
|
|
|
2008-02-28 16:28:40 +01:00
|
|
|
|
/// <summary>Gets the GraphicsMode of the context.</summary>
|
|
|
|
|
GraphicsMode GraphicsMode { get; }
|
2008-01-11 21:22:46 +01:00
|
|
|
|
|
2008-01-31 14:15:17 +01:00
|
|
|
|
///// <summary>
|
|
|
|
|
///// 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.
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <returns>A System.IntPtr that holds the handle to the current OpenGL context.</returns>
|
|
|
|
|
//ContextHandle GetCurrentContext();
|
2007-12-09 19:15:51 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Registers an OpenGL resource for disposal.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="resource">The OpenGL resource to dispose.</param>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// 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.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
void RegisterForDisposal(IDisposable resource);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Disposes all registered OpenGL resources.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void DisposeResources();
|
|
|
|
|
|
2008-01-11 21:22:46 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the address of an OpenGL extension function.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="function">The name of the OpenGL function (e.g. "glGetString")</param>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// A pointer to the specified function or IntPtr.Zero if the function isn't
|
|
|
|
|
/// available in the current opengl context.
|
|
|
|
|
/// </returns>
|
2008-01-23 00:58:50 +01:00
|
|
|
|
// /// <see cref="Marshal.GetDelegateForFunctionPointer"/>
|
2008-01-11 21:22:46 +01:00
|
|
|
|
IntPtr GetAddress(string function);
|
|
|
|
|
}
|
2007-07-23 02:15:18 +02:00
|
|
|
|
}
|