mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-26 05:31:03 +00:00
Deprecate TextPrinter.Begin()/End(). These are only left for backwards compatibility. New code should set the desired projection and modelview matrices manually.
This commit is contained in:
parent
5135a25828
commit
1502fc27b7
|
@ -28,6 +28,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenTK.Math;
|
using OpenTK.Math;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace OpenTK.Graphics.Text
|
namespace OpenTK.Graphics.Text
|
||||||
{
|
{
|
||||||
|
@ -39,6 +40,7 @@ namespace OpenTK.Graphics.Text
|
||||||
Dictionary<Texture2D, List<Vector2>> active_lists = new Dictionary<Texture2D, List<Vector2>>();
|
Dictionary<Texture2D, List<Vector2>> active_lists = new Dictionary<Texture2D, List<Vector2>>();
|
||||||
Queue<List<Vector2>> inactive_lists = new Queue<List<Vector2>>();
|
Queue<List<Vector2>> inactive_lists = new Queue<List<Vector2>>();
|
||||||
float[] viewport = new float[4];
|
float[] viewport = new float[4];
|
||||||
|
bool legacy_mode = false;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -57,6 +59,19 @@ namespace OpenTK.Graphics.Text
|
||||||
|
|
||||||
public void Print(TextBlock block, PointF location, Color color, IGlyphRasterizer rasterizer, GlyphCache cache)
|
public void Print(TextBlock block, PointF location, Color color, IGlyphRasterizer rasterizer, GlyphCache cache)
|
||||||
{
|
{
|
||||||
|
GL.PushAttrib(AttribMask.TextureBit | AttribMask.EnableBit | AttribMask.ColorBufferBit | AttribMask.DepthBufferBit);
|
||||||
|
|
||||||
|
GL.Enable(EnableCap.Texture2D);
|
||||||
|
GL.Enable(EnableCap.Blend);
|
||||||
|
GL.BlendFunc(BlendingFactorSrc.ConstantColorExt, BlendingFactorDest.OneMinusSrcColor); // For subpixel with color
|
||||||
|
|
||||||
|
GL.Disable(EnableCap.DepthTest);
|
||||||
|
|
||||||
|
//GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Modulate);
|
||||||
|
//GL.Enable(EnableCap.ColorMaterial);
|
||||||
|
//GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); // For grayscale
|
||||||
|
//GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcColor); // For subpixel
|
||||||
|
|
||||||
using (TextExtents extents = rasterizer.MeasureText(block, location))
|
using (TextExtents extents = rasterizer.MeasureText(block, location))
|
||||||
{
|
{
|
||||||
// Build layout
|
// Build layout
|
||||||
|
@ -109,6 +124,11 @@ namespace OpenTK.Graphics.Text
|
||||||
key.Bind();
|
key.Bind();
|
||||||
|
|
||||||
GL.Translate(location.X, location.Y, 0);
|
GL.Translate(location.X, location.Y, 0);
|
||||||
|
if (!legacy_mode)
|
||||||
|
{
|
||||||
|
GL.Scale(2.0 / (viewport[2] - viewport[0]), -2.0 / (viewport[3] - viewport[1]), 1);
|
||||||
|
}
|
||||||
|
GL.BlendColor(color);
|
||||||
|
|
||||||
GL.Begin(BeginMode.Triangles);
|
GL.Begin(BeginMode.Triangles);
|
||||||
|
|
||||||
|
@ -129,16 +149,20 @@ namespace OpenTK.Graphics.Text
|
||||||
}
|
}
|
||||||
|
|
||||||
active_lists.Clear();
|
active_lists.Clear();
|
||||||
|
|
||||||
|
GL.PopAttrib();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Begin
|
#region Begin
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
public void Begin()
|
public void Begin()
|
||||||
{
|
{
|
||||||
if (GraphicsContext.CurrentContext == null)
|
GraphicsContext.Assert();
|
||||||
throw new GraphicsContextException("No GraphicsContext is current in the calling thread.");
|
|
||||||
|
legacy_mode = true;
|
||||||
|
|
||||||
GL.GetFloat(GetPName.Viewport, viewport);
|
GL.GetFloat(GetPName.Viewport, viewport);
|
||||||
|
|
||||||
|
@ -154,29 +178,18 @@ namespace OpenTK.Graphics.Text
|
||||||
GL.MatrixMode(MatrixMode.Modelview);
|
GL.MatrixMode(MatrixMode.Modelview);
|
||||||
GL.PushMatrix();
|
GL.PushMatrix();
|
||||||
GL.LoadIdentity();
|
GL.LoadIdentity();
|
||||||
|
|
||||||
GL.PushAttrib(AttribMask.TextureBit | AttribMask.EnableBit | AttribMask.ColorBufferBit);
|
|
||||||
|
|
||||||
//GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Modulate);
|
|
||||||
|
|
||||||
//GL.Enable(EnableCap.ColorMaterial);
|
|
||||||
GL.Enable(EnableCap.Texture2D);
|
|
||||||
GL.Enable(EnableCap.Blend);
|
|
||||||
//GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); // For grayscale
|
|
||||||
GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcColor); // For subpixel
|
|
||||||
//GL.BlendFunc(BlendingFactorSrc.ConstantColorExt, BlendingFactorDest.OneMinusSrcColor); // For subpixel with color
|
|
||||||
|
|
||||||
|
|
||||||
GL.Disable(EnableCap.DepthTest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region End
|
#region End
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
public void End()
|
public void End()
|
||||||
{
|
{
|
||||||
GL.PopAttrib();
|
GraphicsContext.Assert();
|
||||||
|
|
||||||
|
legacy_mode = false;
|
||||||
|
|
||||||
GL.MatrixMode(MatrixMode.Modelview);
|
GL.MatrixMode(MatrixMode.Modelview);
|
||||||
GL.PopMatrix();
|
GL.PopMatrix();
|
||||||
|
|
|
@ -109,9 +109,9 @@ namespace OpenTK.Graphics
|
||||||
if (font == null)
|
if (font == null)
|
||||||
throw new ArgumentNullException("font");
|
throw new ArgumentNullException("font");
|
||||||
|
|
||||||
text_output.Begin();
|
//text_output.Begin();
|
||||||
text_output.Print(new TextBlock(text, font, options, layoutRectangle.Size), layoutRectangle.Location, color, glyph_rasterizer, glyph_cache);
|
text_output.Print(new TextBlock(text, font, options, layoutRectangle.Size), layoutRectangle.Location, color, glyph_rasterizer, glyph_cache);
|
||||||
text_output.End();
|
//text_output.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue