diff --git a/Source/OpenGL/OpenGL/DisplayList.cs b/Source/OpenGL/OpenGL/DisplayList.cs new file mode 100644 index 00000000..7ff7c375 --- /dev/null +++ b/Source/OpenGL/OpenGL/DisplayList.cs @@ -0,0 +1,97 @@ +#region --- License --- +/* This source file is released under the MIT license. See License.txt for more information. + * Coded by Stephen Apostolopoulos. + */ +#endregion + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenTK.OpenGL +{ + /// + /// Provides methods to create and render a display list. + /// + public class DisplayList : IDisposable + { + #region --- Private variables --- + + private int id = -1; + + #endregion + + #region --- Public properties --- + + /// + /// Gets the display list number. + /// + public int Id + { + get { return id; } + private set { id = value; } + } + + #endregion + + #region --- Constructors --- + + /// + /// Allocates a new DisplayList. + /// + public DisplayList() + { + Id = GL.GenLists(1); + } + + #endregion + + #region --- Public functions --- + + /// + /// Starts recording elements into the display list. + /// + public void Begin() + { + GL.NewList(Id, Enums.ListMode.COMPILE); + } + + /// + /// Starts recording elements into the display list. + /// + /// Sets if the list is to be compiled or compiled and executed immediately. + public void Begin(Enums.ListMode listMode) + { + GL.NewList(Id, listMode); + } + + /// + /// Stops recording elements into the display list. + /// + public void End() + { + GL.EndList(); + } + + /// + /// Renders the display list elements. + /// + public void Render() + { + GL.CallList(Id); + } + + #region IDisposable Members + + public void Dispose() + { + if (Id > 0) + GL.DeleteLists(Id, 1); + Id = -1; + } + + #endregion + + #endregion + } +}