mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-06-20 22:07:54 +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.OpenGL;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using OpenTK.OpenGL.Enums;
|
using OpenTK.OpenGL.Enums;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Examples.Tutorial
|
namespace Examples.Tutorial
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Shows how to render and scroll large amounts of text.
|
||||||
|
/// </summary>
|
||||||
public class Text : GameWindow, IExample
|
public class Text : GameWindow, IExample
|
||||||
{
|
{
|
||||||
TextureFont serif = new TextureFont(new Font(FontFamily.GenericSerif, 24.0f));
|
TextureFont serif = new TextureFont(new Font(FontFamily.GenericSerif, 24.0f));
|
||||||
|
@ -25,11 +29,9 @@ namespace Examples.Tutorial
|
||||||
ITextPrinter text = new TextPrinter();
|
ITextPrinter text = new TextPrinter();
|
||||||
|
|
||||||
public Text() : base(new DisplayMode(800, 600), String.Format("OpenTK | Tutorial {0}: Text", order))
|
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
|
string poem = new StreamReader("Data/Poem.txt").ReadToEnd();
|
||||||
// form and not \r\n or \n\r.
|
|
||||||
string poem = new StreamReader("Data/Poem.txt").ReadToEnd().Replace('\r', ' ');
|
|
||||||
int lines; // How many lines the poem contains.
|
int lines; // How many lines the poem contains.
|
||||||
|
|
||||||
float scroll_speed;
|
float scroll_speed;
|
||||||
|
@ -42,12 +44,16 @@ namespace Examples.Tutorial
|
||||||
public override void OnLoad(EventArgs e)
|
public override void OnLoad(EventArgs e)
|
||||||
{
|
{
|
||||||
GL.ClearColor(Color.SteelBlue);
|
GL.ClearColor(Color.SteelBlue);
|
||||||
|
|
||||||
current_position = initial_position;
|
current_position = initial_position;
|
||||||
scroll_speed = -1.0f;
|
scroll_speed = -1.0f;
|
||||||
|
|
||||||
text.Prepare(poem, serif, out poem_handle);
|
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)
|
foreach (char c in poem)
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
lines++;
|
lines++;
|
||||||
|
@ -58,6 +64,16 @@ namespace Examples.Tutorial
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region OnUnload
|
||||||
|
|
||||||
|
public override void OnUnload(EventArgs e)
|
||||||
|
{
|
||||||
|
poem_handle.Dispose();
|
||||||
|
serif.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region OnResize
|
#region OnResize
|
||||||
|
|
||||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||||
|
|
Loading…
Reference in a new issue