mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 16:25:37 +00:00
Allow the user to code his own ITextPrinterImplementation.
This commit is contained in:
parent
43aaa02745
commit
6ce200cdae
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,23 +28,30 @@ namespace OpenTK.Graphics
|
||||||
public class TextPrinter : ITextPrinter
|
public class TextPrinter : ITextPrinter
|
||||||
{
|
{
|
||||||
//static Regex break_point = new Regex("[ .,/*-+?\\!=]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
//static Regex break_point = new Regex("[ .,/*-+?\\!=]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
//static char[] split_chars = new char[]
|
//static char[] split_chars = new char[]
|
||||||
//{
|
//{
|
||||||
// ' ', '\n', '\t', ',', '.', '/', '?', '!', ';', '\\', '-', '+', '*', '='
|
// ' ', '\n', '\t', ',', '.', '/', '?', '!', ';', '\\', '-', '+', '*', '='
|
||||||
//};
|
//};
|
||||||
static ITextPrinterImplementation printer;
|
static ITextPrinterImplementation printer;
|
||||||
float[] viewport = new float[4];
|
float[] viewport = new float[4];
|
||||||
// Interleaved, vertex, texcoord, vertex, etc... Starts with 8 chars, will expand as needed.
|
// Interleaved, vertex, texcoord, vertex, etc... Starts with 8 chars, will expand as needed.
|
||||||
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 ---
|
||||||
|
|
Loading…
Reference in a new issue