mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-27 08:35:32 +00:00
989be84c96
Made example source code visible for all examples in example browser. Updated Prebuild.exe to newest SVN version (resolves issues with resources). Added .rtf and .resx files to Examples project in Prebuild.xml.
51 lines
3.2 KiB
Plaintext
51 lines
3.2 KiB
Plaintext
{\rtf1\ansi\ansicpg1253\deff0\deflang1032{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fswiss\fcharset0 Arial;}{\f2\fswiss\fcharset161{\*\fname Arial;}Arial Greek;}{\f3\fswiss\fprq2\fcharset161{\*\fname Arial;}Arial Greek;}{\f4\fmodern\fprq1\fcharset0 Consolas;}}
|
||
{\colortbl ;\red0\green0\blue255;\red43\green145\blue175;}
|
||
{\*\generator Msftedit 5.41.21.2508;}\viewkind4\uc1\pard\qc\lang1033\b\f0\fs32 Font rendering\par
|
||
\b0\f1\fs20\par
|
||
\lang1032\f2\par
|
||
\pard\lang1033\b\f1\fs24 Overview\par
|
||
\par
|
||
\b0\fs22 This sample demonstrates the basic capabilities of the font renderer, which can be used to render high-quality, 2d text on a color buffer.\par
|
||
\par
|
||
\par
|
||
\b\fs24 Requirements\b0\fs22\par
|
||
\par
|
||
The font renderer depends on OpenGL 1.1, but takes advantage of higher OpenGL versions to improve quality and/or speed.\par
|
||
\par
|
||
\par
|
||
\b\f0\fs24 Usage\par
|
||
\par
|
||
\b0\f1\fs22 To use the font renderer, create and store a \b TextPrinter \b0 instance.\par
|
||
\par
|
||
The \b Print \b0 method renders a System.String using the specified System.Drawing.Font and System.Drawing.Color. You can optionally specify a layout rectangle, one or more layout flags (e.g. right-to-left or vertical) and one or more TextPrinterFlags (e.g. no cache).\par
|
||
\lang1032\f2\par
|
||
\lang1033\f1 The \b Measure \b0 method measures the bounding box of each character (also called 'glyph extents') and the bounding box of the whole string. It can be used to get accurate data for laying out GUI elements or rendering a caret.\par
|
||
\par
|
||
The \b Begin \b0 and \b End \b0 methods can be used to setup and restore a pixel-perfect, resolution dependent, orthographic projection matrix on the current OpenGL context. This matrix matches the typical 2d coordinate system of the native font rendering libraries (origin on the top-left corner of the screen) and ensures that text drawn through OpenTK will look identical to native text.\par
|
||
\par
|
||
A typical usage scenario looks like this:\par
|
||
\par
|
||
\cf1\lang1032\f3 using\lang1033\f0 \cf0 System;\par
|
||
\cf1\lang1032\f3 using\lang1033\f0 \cf0 System.Drawing;\par
|
||
\cf1\lang1032\f3 using\lang1033\f0 \cf0 OpenTK.Graphics;\par
|
||
...\par
|
||
\cf2\lang1032\f3 Font\lang1033\f0 \cf0 font = new \cf2\lang1032\f3 Font\cf0\lang1033\f0 (\cf2\lang1032\f3 FontFamily\cf0\lang1033\f0 .GenericSansSerif, 16.0);\par
|
||
\cf2\lang1032\f3 ITextPrinter\lang1033\f0 \cf0 printer = new TextPrinter();\par
|
||
...\par
|
||
printer.Begin();\par
|
||
printer.Print(frames_per_second.ToString(), font, \cf2\lang1032\f3 Color\cf0\lang1033\f0 .SpringGreen);\par
|
||
printer.End();\f4\par
|
||
\f1\par
|
||
If you wish to specify a \b custom projection matrix\b0 , do not call TextPrinter.Begin or TextPrinter.End and scale the text by the inverse of your viewport Width and Height, multiplied by two. For example:\par
|
||
\par
|
||
\cf2\lang1032\f3 GL\cf0 .MatrixMode(\cf2 MatrixMode\cf0 .Projection);\par
|
||
\cf2 GL\cf0 .LoadIdentity();\par
|
||
\cf2 GL\cf0 .Ortho(\lang1033\f0 -1, 1, -1, 1\lang1032\f3 , -1, 1);\par
|
||
\cf2 GL\cf0 .MatrixMode(\cf2 MatrixMode\cf0 .Modelview);\par
|
||
\cf2 GL\cf0 .LoadIdentity();\lang1033\f1\par
|
||
\cf2\lang1032\f3 GL\cf0\lang1033\f1 .Scale(2.0 / Width, 2.0 / Height, 1.0);\par
|
||
\par
|
||
printer.Print(\f0 frames_per_second.ToString(), font, \cf2\lang1032\f3 Color\cf0\lang1033\f0 .SpringGreen);\f1\par
|
||
\lang1032\f2\par
|
||
}
|
||
|