+ Windows now have a default icon

~ Changed CVector.Set(params float[]) to CVector.SetRaw(params float[])
~ I hope, the text rendering is now fixed.
~ Mouse2D.InWorld(Camera) now uses Camera.CalculatedWorldScale.
This commit is contained in:
Michel Fedde 2021-04-22 17:49:42 +02:00
parent a921eb827e
commit 51f8dfd522
14 changed files with 78 additions and 24 deletions

View file

@ -3,8 +3,10 @@ using System.Collections.Generic;
using System.Diagnostics;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using SM.Base.Animation;
using SM.Base.Controls;
using SM.Base.Drawing;
using SM.Base.Drawing.Text;
using SM.Base.Time;
using SM.Base.Window;
@ -27,16 +29,54 @@ namespace SM_TEST
{
Font font = new Font(@"C:\Windows\Fonts\Arial.ttf")
{
FontSize = 20,
CharSet = new List<char>(){'H', 'i', 'I', ','}
FontSize = 30,
};
font.RegenerateTexture();
window = new GLWindow(1280, 720, "0ms", WindowFlags.Window, VSyncMode.Off);
window.ApplySetup(new Window2DSetup());
window.SetScene(scene = new Scene());
scene.Background.Color = Color4.Blue;
scene.Camera = new Camera()
{
RequestedWorldScale = new Vector2(0, 10)
};
ItemCollection col = new ItemCollection();
DrawObject2D textTex = new DrawObject2D()
{
Texture = font,
Material = {Blending = true}
};
float aspect = font.Height / (float) font.Width;
textTex.Transform.Size.Set(font.Width * aspect, font.Height * aspect);
textTex.Transform.Position.Set(textTex.Transform.Size.X / 2, 0);
Vector2 fontSize = new Vector2(font.Width * aspect, font.Height * aspect);
Material uvMaterial = new Material()
{
Tint = new Color4(1f, 0, 0, .5f),
Blending = true
};
col.Transform.Size.Set(1);
DrawText test = new DrawText(font, "Level Completed")
{
Material = uvMaterial,
Font = font
};
test.Transform.Size.Set(aspect);
test.Transform.Position.Set(0, 2);
col.Add(test, textTex);
scene.Objects.Add(col);
window.UpdateFrame += WindowOnUpdateFrame;
window.RenderFrame += Window_RenderFrame;