Opentk/Source/OpenTK/OpenGL/DisplayList.cs

99 lines
2.2 KiB
C#
Raw Normal View History

#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenTK.OpenGL
{
/// <summary>
/// Provides methods to create and render a display list.
/// </summary>
[Obsolete("Use OpenGL methods directly, instead.")]
public class DisplayList : IDisposable
{
#region --- Private variables ---
private int id = -1;
#endregion
#region --- Constructors ---
/// <summary>
/// Allocates a new DisplayList.
/// </summary>
public DisplayList()
{
Id = GL.GenLists(1);
}
#endregion
#region --- Public properties ---
/// <summary>
/// Gets the display list number.
/// </summary>
public int Id
{
get { return id; }
private set { id = value; }
}
#endregion
#region --- Public methods ---
/// <summary>
/// Starts recording elements into the display list.
/// </summary>
public void Begin()
{
2007-08-01 09:30:14 +00:00
GL.NewList(Id, GL.Enums.ListMode.COMPILE);
}
/// <summary>
/// Starts recording elements into the display list.
/// </summary>
/// <param name="listMode">Sets if the list is to be compiled or compiled and executed immediately.</param>
2007-08-01 09:30:14 +00:00
public void Begin(GL.Enums.ListMode listMode)
{
GL.NewList(Id, listMode);
}
/// <summary>
/// Stops recording elements into the display list.
/// </summary>
public void End()
{
GL.EndList();
}
/// <summary>
/// Renders the display list elements.
/// </summary>
public void Render()
{
GL.CallList(Id);
}
#endregion
#region --- IDisposable Members ---
public void Dispose()
{
if (Id > 0)
GL.DeleteLists(Id, 1);
Id = -1;
}
#endregion
}
}