mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-04-17 01:01:52 +00:00
Added documentation.
This commit is contained in:
parent
f52e61b1a8
commit
bfcfe107b2
|
@ -15,9 +15,13 @@ using OpenTK.Fonts;
|
|||
using OpenTK.OpenGL;
|
||||
using OpenTK.Input;
|
||||
using OpenTK.OpenGL.Enums;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Examples.Tutorial
|
||||
{
|
||||
/// <summary>
|
||||
/// Shows how to render and scroll large amounts of text.
|
||||
/// </summary>
|
||||
public class Text : GameWindow, IExample
|
||||
{
|
||||
TextureFont serif = new TextureFont(new Font(FontFamily.GenericSerif, 24.0f));
|
||||
|
@ -25,11 +29,9 @@ namespace Examples.Tutorial
|
|||
ITextPrinter text = new TextPrinter();
|
||||
|
||||
public Text() : base(new DisplayMode(800, 600), String.Format("OpenTK | Tutorial {0}: Text", order))
|
||||
{ VSync = VSyncMode.Off; }
|
||||
{ }
|
||||
|
||||
// Read some text to print. It's a good idea to ensure line-endings are all in the \n
|
||||
// form and not \r\n or \n\r.
|
||||
string poem = new StreamReader("Data/Poem.txt").ReadToEnd().Replace('\r', ' ');
|
||||
string poem = new StreamReader("Data/Poem.txt").ReadToEnd();
|
||||
int lines; // How many lines the poem contains.
|
||||
|
||||
float scroll_speed;
|
||||
|
@ -42,12 +44,16 @@ namespace Examples.Tutorial
|
|||
public override void OnLoad(EventArgs e)
|
||||
{
|
||||
GL.ClearColor(Color.SteelBlue);
|
||||
|
||||
|
||||
current_position = initial_position;
|
||||
scroll_speed = -1.0f;
|
||||
|
||||
text.Prepare(poem, serif, out poem_handle);
|
||||
|
||||
// Count the amount of lines in the text, to find out the correct
|
||||
// warparound position. We want the text to scroll until the last
|
||||
// line moves outside the screen, then warp it around from the
|
||||
// other side of the screen.
|
||||
foreach (char c in poem)
|
||||
if (c == '\n')
|
||||
lines++;
|
||||
|
@ -58,6 +64,16 @@ namespace Examples.Tutorial
|
|||
|
||||
#endregion
|
||||
|
||||
#region OnUnload
|
||||
|
||||
public override void OnUnload(EventArgs e)
|
||||
{
|
||||
poem_handle.Dispose();
|
||||
serif.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnResize
|
||||
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
|
|
Loading…
Reference in a new issue