mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-25 16:21:04 +00:00
This commit is contained in:
parent
24c3a6b290
commit
22f6a0533c
97
Source/OpenGL/OpenGL/DisplayList.cs
Normal file
97
Source/OpenGL/OpenGL/DisplayList.cs
Normal file
|
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides methods to create and render a display list.
|
||||||
|
/// </summary>
|
||||||
|
public class DisplayList : IDisposable
|
||||||
|
{
|
||||||
|
#region --- Private variables ---
|
||||||
|
|
||||||
|
private int id = -1;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region --- Public properties ---
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the display list number.
|
||||||
|
/// </summary>
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get { return id; }
|
||||||
|
private set { id = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region --- Constructors ---
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allocates a new DisplayList.
|
||||||
|
/// </summary>
|
||||||
|
public DisplayList()
|
||||||
|
{
|
||||||
|
Id = GL.GenLists(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region --- Public functions ---
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts recording elements into the display list.
|
||||||
|
/// </summary>
|
||||||
|
public void Begin()
|
||||||
|
{
|
||||||
|
GL.NewList(Id, 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>
|
||||||
|
public void Begin(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (Id > 0)
|
||||||
|
GL.DeleteLists(Id, 1);
|
||||||
|
Id = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue