Basic font rendering working.
This commit is contained in:
Binary file not shown.
@@ -10,6 +10,7 @@
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<AssemblyVersion>1.0.0.0</AssemblyVersion>
|
||||
<Description>A tool to help with developing a game using SlatedGameToolkit.</Description>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -1,14 +1,18 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using SDL2;
|
||||
using SlatedGameToolkit.Commons.Loaders;
|
||||
using SlatedGameToolkit.Framework.Graphics.Render;
|
||||
using SlatedGameToolkit.Framework.Graphics.Text;
|
||||
using SlatedGameToolkit.Framework.Graphics.Textures;
|
||||
using SlatedGameToolkit.Framework.Graphics.Window;
|
||||
using SlatedGameToolkit.Framework.Input.Devices;
|
||||
using SlatedGameToolkit.Framework.StateSystem;
|
||||
using SlatedGameToolkit.Framework.StateSystem.States;
|
||||
using StbTrueTypeSharp;
|
||||
|
||||
namespace SlatedGameToolkit.Tools.Utilities.Playground
|
||||
{
|
||||
@@ -17,6 +21,7 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
|
||||
private WindowContext window;
|
||||
private Camera2D camera;
|
||||
private MeshBatch renderer;
|
||||
private BitmapFont font;
|
||||
private Texture logoTexture, fillerTexture;
|
||||
private RectangleMesh logo, textureTester, untextured;
|
||||
|
||||
@@ -36,6 +41,7 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
|
||||
{
|
||||
logoTexture.Dispose();
|
||||
fillerTexture.Dispose();
|
||||
font.Dispose();
|
||||
renderer.Dispose();
|
||||
window.Dispose();
|
||||
}
|
||||
@@ -45,13 +51,13 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
|
||||
return "main state";
|
||||
}
|
||||
|
||||
public void Initialize(StateManager manager)
|
||||
public unsafe void Initialize(StateManager manager)
|
||||
{
|
||||
window = new WindowContext("SlatedGameToolkit Playground");
|
||||
camera = new Camera2D(2, 2);
|
||||
renderer = new MeshBatch(camera);
|
||||
|
||||
logoTexture = TextureLoader.Load2DTexture("Resources/Playground/yhdnbgnc.png", null);
|
||||
logoTexture = TextureLoader.Load2DTexture("Resources/Playground/yhdnbgnc.png");
|
||||
logo = new RectangleMesh(logoTexture, Color.White);
|
||||
logo.Width = 0.5f;
|
||||
logo.Height = 0.5f;
|
||||
@@ -59,7 +65,7 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
|
||||
logo.Y = -0.25f;
|
||||
|
||||
|
||||
fillerTexture = TextureLoader.Load2DTexture("Resources/Playground/filler.png", null);
|
||||
fillerTexture = TextureLoader.Load2DTexture("Resources/Playground/filler.png");
|
||||
textureTester = new RectangleMesh(fillerTexture, Color.White);
|
||||
textureTester.Width = 0.15f;
|
||||
textureTester.Height = 0.15f;
|
||||
@@ -70,6 +76,8 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
|
||||
untextured.Height = 0.1f;
|
||||
untextured.X = 0.25f;
|
||||
untextured.Y = - 0.15f;
|
||||
|
||||
font = new BitmapFont("Resources/Playground/earwig_factory_rg.ttf");
|
||||
}
|
||||
|
||||
public void Render(double delta)
|
||||
@@ -78,6 +86,7 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
|
||||
renderer.Draw(logo);
|
||||
renderer.Draw(textureTester);
|
||||
renderer.Draw(untextured);
|
||||
font.Draw(renderer, delta, 0.25f, -0.25f, "123", Color.White);
|
||||
renderer.End();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user