Allow the user to code his own ITextPrinterImplementation.

This commit is contained in:
the_fiddler 2008-05-24 07:47:30 +00:00
parent 43aaa02745
commit 6ce200cdae
2 changed files with 36 additions and 8 deletions

View file

@ -15,10 +15,31 @@ namespace OpenTK.Graphics
/// <summary> /// <summary>
/// Defines the interface for TextPrinter implementations. /// Defines the interface for TextPrinter implementations.
/// </summary> /// </summary>
interface ITextPrinterImplementation public interface ITextPrinterImplementation
{ {
TextHandle Load(Vector2[] vertices, ushort[] indices, int index_count); /// <summary>
/// Caches a text fragment for future use.
/// </summary>
/// <param name="vertices">The vertex array for the text fragment.</param>
/// <param name="indices">The index array for the text fragment. Please use the indexCount parameter
/// instead of indices.Count, as the indices array may be larger than necessary for performance reasons.</param>
/// <param name="indexCount">The actual number of indices in the text fragment.</param>
/// <returns>A TextHandle that can be used to draw the text fragment.</returns>
TextHandle Load(Vector2[] vertices, ushort[] indices, int indexCount);
/// <summary>
/// Draws the specified cached text fragment.
/// </summary>
/// <param name="handle">The TextHandle corresponding to the desired text fragment.</param>
void Draw(TextHandle handle); void Draw(TextHandle handle);
void Draw(Vector2[] vertices, ushort[] indices, int index_count);
/// <summary>
/// Draws a text fragment, without caching.
/// </summary>
/// <param name="vertices">The vertex array for the text fragment.</param>
/// <param name="indices">The index array for the text fragment. Please use the indexCount parameter
/// instead of indices.Count, as the indices array may be larger than necessary for performance reasons.</param>
/// <param name="indexCount">The actual number of indices in the text fragment.</param>
void Draw(Vector2[] vertices, ushort[] indices, int indexCount);
} }
} }

View file

@ -38,13 +38,20 @@ namespace OpenTK.Graphics
Vector2[] vertices = new Vector2[8 * 8]; Vector2[] vertices = new Vector2[8 * 8];
ushort[] indices = new ushort[6 * 8]; ushort[] indices = new ushort[6 * 8];
#region --- Constructor --- #region --- Constructors ---
/// <summary> /// <summary>
/// Constructs a new TextPrinter object. /// Constructs a new TextPrinter object.
/// </summary> /// </summary>
public TextPrinter() { } public TextPrinter() { }
public TextPrinter(ITextPrinterImplementation implementation)
{
if (implementation == null)
throw new ArgumentNullException("implementation");
printer = implementation;
}
#endregion #endregion
#region --- Private Members --- #region --- Private Members ---