"Improved" TextRenderer (︶^︶)
This commit is contained in:
parent
f7dc2e24dc
commit
ff85180750
8 changed files with 247 additions and 126 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#region usings
|
#region usings
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -13,23 +14,18 @@ namespace SM.Base.Drawing.Text
|
||||||
public struct CharParameter
|
public struct CharParameter
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The position on the X-axis.
|
/// The advance on the X-axis.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int X;
|
public int Advance;
|
||||||
|
|
||||||
|
public float BearingX;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The width of the character.
|
/// The width of the character.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Width;
|
public float Width;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The normalized position inside the texture.
|
|
||||||
/// </summary>
|
|
||||||
public float NormalizedX;
|
|
||||||
|
|
||||||
/// <summary>
|
public Matrix3 TextureMatrix;
|
||||||
/// The normalized width inside the texture.
|
|
||||||
/// </summary>
|
|
||||||
public float NormalizedWidth;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,138 +1,92 @@
|
||||||
#region usings
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Text;
|
using System.Drawing.Drawing2D;
|
||||||
using OpenTK.Graphics.OpenGL4;
|
using System.Windows.Forms;
|
||||||
|
using OpenTK;
|
||||||
|
using SharpFont;
|
||||||
using SM.Base.Textures;
|
using SM.Base.Textures;
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace SM.Base.Drawing.Text
|
namespace SM.Base.Drawing.Text
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Represents a font.
|
|
||||||
/// </summary>
|
|
||||||
public class Font : Texture
|
public class Font : Texture
|
||||||
{
|
{
|
||||||
/// <summary>
|
private static Library _lib;
|
||||||
/// The char set for the font.
|
|
||||||
/// <para>Default: <see cref="FontCharStorage.SimpleUTF8" /></para>
|
|
||||||
/// </summary>
|
|
||||||
public ICollection<char> CharSet = FontCharStorage.SimpleUTF8;
|
|
||||||
|
|
||||||
/// <summary>
|
private Face _fontFace;
|
||||||
/// The font family, that is used to find the right font.
|
|
||||||
/// </summary>
|
|
||||||
public FontFamily FontFamily;
|
|
||||||
|
|
||||||
/// <summary>
|
public float SpaceWidth { get; private set; } = 0;
|
||||||
/// The font size.
|
|
||||||
/// <para>Default: 12</para>
|
|
||||||
/// </summary>
|
|
||||||
public float FontSize = 12;
|
|
||||||
|
|
||||||
public float SpaceWidth { get; private set; }
|
public ICollection<char> CharSet { get; set; } = FontCharStorage.SimpleUTF8;
|
||||||
|
|
||||||
/// <summary>
|
public float FontSize { get; set; } = 12;
|
||||||
/// The font style.
|
|
||||||
/// <para>Default: <see cref="System.Drawing.FontStyle.Regular" /></para>
|
|
||||||
/// </summary>
|
|
||||||
public FontStyle FontStyle = FontStyle.Regular;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This contains all information for the different font character.
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<char, CharParameter> Positions = new Dictionary<char, CharParameter>();
|
public Dictionary<char, CharParameter> Positions = new Dictionary<char, CharParameter>();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generates a font from a font family from the specified path.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">The specified path</param>
|
|
||||||
public Font(string path)
|
public Font(string path)
|
||||||
{
|
{
|
||||||
var pfc = new PrivateFontCollection();
|
_lib ??= new Library();
|
||||||
pfc.AddFontFile(path);
|
|
||||||
FontFamily = pfc.Families[0];
|
_fontFace = new Face(_lib, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generates a font from a specified font family.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="font">Font-Family</param>
|
|
||||||
public Font(FontFamily font)
|
|
||||||
{
|
|
||||||
FontFamily = font;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override TextureWrapMode WrapMode { get; set; } = TextureWrapMode.ClampToEdge;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Regenerates the texture.
|
|
||||||
/// </summary>
|
|
||||||
public void RegenerateTexture()
|
public void RegenerateTexture()
|
||||||
{
|
{
|
||||||
Width = 0;
|
Width = Height = 0;
|
||||||
Height = 0;
|
|
||||||
Positions = new Dictionary<char, CharParameter>();
|
Positions = new Dictionary<char, CharParameter>();
|
||||||
|
|
||||||
|
_fontFace.SetCharSize(0, FontSize, 0, 96);
|
||||||
|
|
||||||
var map = new Bitmap(1000, 20);
|
var pos = new Dictionary<char, float[]>();
|
||||||
var charParams = new Dictionary<char, float[]>();
|
foreach (char c in CharSet)
|
||||||
using (var f = new System.Drawing.Font(FontFamily, FontSize, FontStyle))
|
|
||||||
{
|
{
|
||||||
using (var g = Graphics.FromImage(map))
|
_fontFace.LoadChar(c, LoadFlags.Render, LoadTarget.Normal);
|
||||||
|
|
||||||
|
pos.Add(c, new []{(float)_fontFace.Glyph.Bitmap.Width, Width});
|
||||||
|
Width += (int)_fontFace.Glyph.Advance.X + 5;
|
||||||
|
Height = Math.Max(_fontFace.Glyph.Bitmap.Rows, Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
_fontFace.LoadChar('_', LoadFlags.Render, LoadTarget.Normal);
|
||||||
|
SpaceWidth = _fontFace.Glyph.Advance.X.ToSingle();
|
||||||
|
|
||||||
|
float bBoxHeight = (Math.Abs(_fontFace.BBox.Bottom) + _fontFace.BBox.Top);
|
||||||
|
float bBoxTopScale = _fontFace.BBox.Top / bBoxHeight;
|
||||||
|
float baseline = Height * bBoxTopScale;
|
||||||
|
|
||||||
|
Map = new Bitmap(Width, Height);
|
||||||
|
using (Graphics g = Graphics.FromImage(Map))
|
||||||
|
{
|
||||||
|
g.Clear(Color.Transparent);
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var keyvalue in pos)
|
||||||
{
|
{
|
||||||
g.Clear(Color.Transparent);
|
_fontFace.LoadChar(keyvalue.Key, LoadFlags.Render, LoadTarget.Normal);
|
||||||
|
|
||||||
foreach (var c in CharSet)
|
int y = ((int)baseline - (int)_fontFace.Glyph.Metrics.HorizontalBearingY);
|
||||||
|
|
||||||
|
g.DrawImageUnscaled(_fontFace.Glyph.Bitmap.ToGdipBitmap(Color.White), (int)keyvalue.Value[1], y);
|
||||||
|
|
||||||
|
Positions.Add(keyvalue.Key, new CharParameter()
|
||||||
{
|
{
|
||||||
var s = c.ToString();
|
Advance = (int)_fontFace.Glyph.LinearHorizontalAdvance,
|
||||||
var size = g.MeasureString(s, f, 0, StringFormat.GenericTypographic);
|
BearingX = _fontFace.Glyph.BitmapLeft,
|
||||||
try
|
|
||||||
{
|
|
||||||
charParams.Add(c, new[] {size.Width, Width});
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Height < size.Height) Height = (int) size.Height;
|
Width = keyvalue.Value[0],
|
||||||
Width += (int) size.Width;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpaceWidth = g.MeasureString("_", f, 0, StringFormat.GenericTypographic).Width;
|
TextureMatrix = TextureTransformation.CalculateMatrix(new Vector2(keyvalue.Value[1] / Width, 0),
|
||||||
}
|
new Vector2(keyvalue.Value[0] / Width, 1), 0),
|
||||||
|
});
|
||||||
map = new Bitmap(Width, Height);
|
|
||||||
using (var g = Graphics.FromImage(map))
|
|
||||||
{
|
|
||||||
foreach (var keyValuePair in charParams)
|
|
||||||
{
|
|
||||||
var normalizedX = (keyValuePair.Value[1]) / Width;
|
|
||||||
var normalizedWidth = keyValuePair.Value[0] / Width;
|
|
||||||
|
|
||||||
CharParameter parameter;
|
|
||||||
Positions.Add(keyValuePair.Key, parameter = new CharParameter
|
|
||||||
{
|
|
||||||
NormalizedWidth = normalizedWidth,
|
|
||||||
NormalizedX = normalizedX,
|
|
||||||
Width = keyValuePair.Value[0],
|
|
||||||
X = (int) keyValuePair.Value[1]
|
|
||||||
});
|
|
||||||
|
|
||||||
g.DrawString(keyValuePair.Key.ToString(), f, Brushes.White, parameter.X, 0, StringFormat.GenericTypographic);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map = map;
|
Console.WriteLine();
|
||||||
Recompile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override void Compile()
|
public override void Compile()
|
||||||
{
|
{
|
||||||
RegenerateTexture();
|
RegenerateTexture();
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ namespace SM.Base.Drawing.Text
|
||||||
/// The spacing between numbers.
|
/// The spacing between numbers.
|
||||||
/// <para>Default: 1</para>
|
/// <para>Default: 1</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Spacing = 1;
|
public float Spacing = 1f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The font.
|
/// The font.
|
||||||
|
|
@ -112,6 +112,7 @@ namespace SM.Base.Drawing.Text
|
||||||
var _last = new CharParameter();
|
var _last = new CharParameter();
|
||||||
for (var i = 0; i < _text.Length; i++)
|
for (var i = 0; i < _text.Length; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (_text[i] == ' ')
|
if (_text[i] == ' ')
|
||||||
{
|
{
|
||||||
x += Font.SpaceWidth * Spacing;
|
x += Font.SpaceWidth * Spacing;
|
||||||
|
|
@ -136,16 +137,21 @@ namespace SM.Base.Drawing.Text
|
||||||
throw new Exception("Font doesn't contain '" + _text[i] + "'");
|
throw new Exception("Font doesn't contain '" + _text[i] + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
x += parameter.Width / 2;
|
||||||
|
}
|
||||||
|
|
||||||
var matrix = Matrix4.CreateScale(parameter.Width, Font.Height, 1) *
|
var matrix = Matrix4.CreateScale(parameter.Width, Font.Height, 1) *
|
||||||
Matrix4.CreateTranslation(x, -y, 0);
|
Matrix4.CreateTranslation(x, -y, 0);
|
||||||
_instances[i] = new Instance
|
_instances[i] = new Instance
|
||||||
{
|
{
|
||||||
ModelMatrix = matrix,
|
ModelMatrix = matrix,
|
||||||
TextureMatrix = TextureTransformation.CalculateMatrix(new Vector2(parameter.NormalizedX, 0),
|
TextureMatrix = parameter.TextureMatrix
|
||||||
new Vector2(parameter.NormalizedWidth, 1), 0)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
x += parameter.Width * Spacing;
|
x += Math.Max(parameter.Advance, 6);
|
||||||
_last = parameter;
|
_last = parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
144
SMCode/SM.Base/Legacy/Font.cs
Normal file
144
SMCode/SM.Base/Legacy/Font.cs
Normal file
|
|
@ -0,0 +1,144 @@
|
||||||
|
#region usings
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Text;
|
||||||
|
using OpenTK.Graphics.OpenGL4;
|
||||||
|
using SM.Base.Textures;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace SM.Base.Drawing.Text
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a font.
|
||||||
|
/// </summary>
|
||||||
|
public class Font : Texture
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The char set for the font.
|
||||||
|
/// <para>Default: <see cref="FontCharStorage.SimpleUTF8" /></para>
|
||||||
|
/// </summary>
|
||||||
|
public ICollection<char> CharSet = FontCharStorage.SimpleUTF8;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The font family, that is used to find the right font.
|
||||||
|
/// </summary>
|
||||||
|
public FontFamily FontFamily;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The font size.
|
||||||
|
/// <para>Default: 12</para>
|
||||||
|
/// </summary>
|
||||||
|
public float FontSize = 12;
|
||||||
|
|
||||||
|
public float SpaceWidth { get; private set; }
|
||||||
|
|
||||||
|
public float Spacing = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The font style.
|
||||||
|
/// <para>Default: <see cref="System.Drawing.FontStyle.Regular" /></para>
|
||||||
|
/// </summary>
|
||||||
|
public FontStyle FontStyle = FontStyle.Regular;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This contains all information for the different font character.
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<char, CharParameter> Positions = new Dictionary<char, CharParameter>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates a font from a font family from the specified path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The specified path</param>
|
||||||
|
public Font(string path)
|
||||||
|
{
|
||||||
|
var pfc = new PrivateFontCollection();
|
||||||
|
pfc.AddFontFile(path);
|
||||||
|
FontFamily = pfc.Families[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates a font from a specified font family.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="font">Font-Family</param>
|
||||||
|
public Font(FontFamily font)
|
||||||
|
{
|
||||||
|
FontFamily = font;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override TextureWrapMode WrapMode { get; set; } = TextureWrapMode.ClampToEdge;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Regenerates the texture.
|
||||||
|
/// </summary>
|
||||||
|
public void RegenerateTexture()
|
||||||
|
{
|
||||||
|
Width = 0;
|
||||||
|
Height = 0;
|
||||||
|
Positions = new Dictionary<char, CharParameter>();
|
||||||
|
|
||||||
|
|
||||||
|
var map = new Bitmap(1000, 20);
|
||||||
|
var charParams = new Dictionary<char, float[]>();
|
||||||
|
using (var f = new System.Drawing.Font(FontFamily, FontSize, FontStyle))
|
||||||
|
{
|
||||||
|
using (var g = Graphics.FromImage(map))
|
||||||
|
{
|
||||||
|
g.Clear(Color.Transparent);
|
||||||
|
|
||||||
|
foreach (var c in CharSet)
|
||||||
|
{
|
||||||
|
var s = c.ToString();
|
||||||
|
var size = g.MeasureString(s, f, 0, StringFormat.GenericTypographic);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
charParams.Add(c, new[] {size.Width, Width});
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Height < size.Height) Height = (int) size.Height;
|
||||||
|
Width += (int) size.Width + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SpaceWidth = g.MeasureString("_", f, 0, StringFormat.GenericTypographic).Width;
|
||||||
|
}
|
||||||
|
|
||||||
|
map = new Bitmap(Width, Height);
|
||||||
|
using (var g = Graphics.FromImage(map))
|
||||||
|
{
|
||||||
|
foreach (var keyValuePair in charParams)
|
||||||
|
{
|
||||||
|
var normalizedX = (keyValuePair.Value[1]+ 0.00001f) / Width;
|
||||||
|
var normalizedWidth = keyValuePair.Value[0] / Width;
|
||||||
|
|
||||||
|
CharParameter parameter;
|
||||||
|
Positions.Add(keyValuePair.Key, parameter = new CharParameter
|
||||||
|
{
|
||||||
|
NormalizedWidth = normalizedWidth,
|
||||||
|
NormalizedX = normalizedX,
|
||||||
|
Width = keyValuePair.Value[0],
|
||||||
|
X = (int) keyValuePair.Value[1]
|
||||||
|
});
|
||||||
|
|
||||||
|
g.DrawString(keyValuePair.Key.ToString(), f, Brushes.White, parameter.X, 0, StringFormat.GenericTypographic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map = map;
|
||||||
|
Recompile();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void Compile()
|
||||||
|
{
|
||||||
|
RegenerateTexture();
|
||||||
|
base.Compile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -167,7 +167,7 @@ namespace SM.Base.PostEffects
|
||||||
int iter = Iterations * 2;
|
int iter = Iterations * 2;
|
||||||
for (int i = 0; i < iter; i++)
|
for (int i = 0; i < iter; i++)
|
||||||
{
|
{
|
||||||
(hoz ? _bloomBuffer1 : _bloomBuffer2).Activate();
|
(hoz ? _bloomBuffer1 : _bloomBuffer2).Activate(false);
|
||||||
|
|
||||||
_shader.Draw(collection =>
|
_shader.Draw(collection =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\build\SharpFont.props" Condition="Exists('..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\build\SharpFont.props')" />
|
||||||
|
<Import Project="..\..\..\IAmTwo - Kopie\packages\SharpFont.Dependencies.2.6\build\SharpFont.Dependencies.props" Condition="Exists('..\..\..\IAmTwo - Kopie\packages\SharpFont.Dependencies.2.6\build\SharpFont.Dependencies.props')" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
|
@ -12,6 +14,8 @@
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
|
@ -38,6 +42,9 @@
|
||||||
<HintPath>..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
|
<HintPath>..\..\packages\OpenTK.3.3.1\lib\net20\OpenTK.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="PresentationCore" />
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="SharpFont, Version=4.0.1.200, Culture=neutral, PublicKeyToken=48add4c483071cdf, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\lib\net45\SharpFont.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
|
@ -57,6 +64,7 @@
|
||||||
<Compile Include="Drawing\Instance.cs" />
|
<Compile Include="Drawing\Instance.cs" />
|
||||||
<Compile Include="Drawing\ShaderArguments.cs" />
|
<Compile Include="Drawing\ShaderArguments.cs" />
|
||||||
<Compile Include="Drawing\TextureTransformation.cs" />
|
<Compile Include="Drawing\TextureTransformation.cs" />
|
||||||
|
<Compile Include="Drawing\Text\Font.cs" />
|
||||||
<Compile Include="PostEffects\PostProcessUtility.cs" />
|
<Compile Include="PostEffects\PostProcessUtility.cs" />
|
||||||
<Compile Include="Scene\IFixedScriptable.cs" />
|
<Compile Include="Scene\IFixedScriptable.cs" />
|
||||||
<Compile Include="Shaders\MaterialShader.cs" />
|
<Compile Include="Shaders\MaterialShader.cs" />
|
||||||
|
|
@ -91,7 +99,6 @@
|
||||||
<Compile Include="SMRenderer.cs" />
|
<Compile Include="SMRenderer.cs" />
|
||||||
<Compile Include="Textures\Texture.cs" />
|
<Compile Include="Textures\Texture.cs" />
|
||||||
<Compile Include="Drawing\Text\CharParameter.cs" />
|
<Compile Include="Drawing\Text\CharParameter.cs" />
|
||||||
<Compile Include="Drawing\Text\Font.cs" />
|
|
||||||
<Compile Include="Drawing\Text\FontCharStorage.cs" />
|
<Compile Include="Drawing\Text\FontCharStorage.cs" />
|
||||||
<Compile Include="Drawing\Text\TextDrawingBasis.cs" />
|
<Compile Include="Drawing\Text\TextDrawingBasis.cs" />
|
||||||
<Compile Include="Time\Interval.cs" />
|
<Compile Include="Time\Interval.cs" />
|
||||||
|
|
@ -145,4 +152,11 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\..\..\IAmTwo - Kopie\packages\SharpFont.Dependencies.2.6\build\SharpFont.Dependencies.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\IAmTwo - Kopie\packages\SharpFont.Dependencies.2.6\build\SharpFont.Dependencies.props'))" />
|
||||||
|
<Error Condition="!Exists('..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\build\SharpFont.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\IAmTwo - Kopie\packages\SharpFont.4.0.1\build\SharpFont.props'))" />
|
||||||
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="OpenTK" version="3.3.1" targetFramework="net452" />
|
<package id="OpenTK" version="3.3.1" targetFramework="net452" />
|
||||||
|
<package id="SharpFont" version="4.0.1" targetFramework="net452" />
|
||||||
|
<package id="SharpFont.Dependencies" version="2.6" targetFramework="net452" />
|
||||||
</packages>
|
</packages>
|
||||||
|
|
@ -26,12 +26,13 @@ namespace SM.OGL.Framebuffer
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the screen buffer.
|
/// Represents the screen buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Framebuffer Screen = new()
|
public static readonly Framebuffer Screen = new Framebuffer()
|
||||||
{
|
{
|
||||||
_id = 0,
|
_id = 0,
|
||||||
CanCompile = false,
|
CanCompile = false,
|
||||||
_window = ScreenWindow,
|
_window = ScreenWindow,
|
||||||
_windowScale = 1,
|
_windowScale = 1,
|
||||||
|
DefaultApplyViewport = false
|
||||||
};
|
};
|
||||||
|
|
||||||
private IFramebufferWindow _window;
|
private IFramebufferWindow _window;
|
||||||
|
|
@ -45,6 +46,8 @@ namespace SM.OGL.Framebuffer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2 Size { get; private set; }
|
public Vector2 Size { get; private set; }
|
||||||
|
|
||||||
|
public bool DefaultApplyViewport { get; set; } = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains all color attachments.
|
/// Contains all color attachments.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -168,27 +171,27 @@ namespace SM.OGL.Framebuffer
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Activates the framebuffer without clearing the buffer.
|
/// Activates the framebuffer without clearing the buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Activate()
|
public void Activate(bool? applyViewport = null)
|
||||||
{
|
{
|
||||||
Activate(FramebufferTarget.Framebuffer, ClearBufferMask.None);
|
Activate(FramebufferTarget.Framebuffer, ClearBufferMask.None, applyViewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Activates the framebuffer for the specific target framebuffer and without clearing.
|
/// Activates the framebuffer for the specific target framebuffer and without clearing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="target"></param>
|
/// <param name="target"></param>
|
||||||
public void Activate(FramebufferTarget target)
|
public void Activate(FramebufferTarget target, bool? applyViewport = null)
|
||||||
{
|
{
|
||||||
Activate(target, ClearBufferMask.None);
|
Activate(target, ClearBufferMask.None, applyViewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Activates the framebuffer while clearing the specified buffer.
|
/// Activates the framebuffer while clearing the specified buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clearMask"></param>
|
/// <param name="clearMask"></param>
|
||||||
public void Activate(ClearBufferMask clearMask)
|
public void Activate(ClearBufferMask clearMask, bool? applyViewport = null)
|
||||||
{
|
{
|
||||||
Activate(FramebufferTarget.Framebuffer, clearMask);
|
Activate(FramebufferTarget.Framebuffer, clearMask, applyViewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -196,9 +199,10 @@ namespace SM.OGL.Framebuffer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="target"></param>
|
/// <param name="target"></param>
|
||||||
/// <param name="clear"></param>
|
/// <param name="clear"></param>
|
||||||
public void Activate(FramebufferTarget target, ClearBufferMask clear)
|
public void Activate(FramebufferTarget target, ClearBufferMask clear, bool? applyViewport = null)
|
||||||
{
|
{
|
||||||
GL.BindFramebuffer(target, this);
|
GL.BindFramebuffer(target, this);
|
||||||
|
if (applyViewport.GetValueOrDefault(DefaultApplyViewport)) GL.Viewport(0, 0, (int)Size.X, (int)Size.Y);
|
||||||
GL.Clear(clear);
|
GL.Clear(clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,10 +213,11 @@ namespace SM.OGL.Framebuffer
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Framebuffer GetCurrentlyActive(FramebufferTarget target = FramebufferTarget.Framebuffer)
|
public static Framebuffer GetCurrentlyActive(FramebufferTarget target = FramebufferTarget.Framebuffer)
|
||||||
{
|
{
|
||||||
Framebuffer buffer = new()
|
Framebuffer buffer = new Framebuffer()
|
||||||
{
|
{
|
||||||
CanCompile = false,
|
CanCompile = false,
|
||||||
ReportAsNotCompiled = true
|
ReportAsNotCompiled = true,
|
||||||
|
DefaultApplyViewport = false
|
||||||
};
|
};
|
||||||
switch (target)
|
switch (target)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue