Compare commits

...

3 Commits

4 changed files with 36 additions and 9 deletions

View File

@ -78,7 +78,7 @@ namespace Quik.OpenTK
if (!_glDriver.IsInit)
_glDriver.Init();
GL.Clear(GLEnum.GL_COLOR_BUFFER_BIT);
GL.Clear(GLEnum.GL_COLOR_BUFFER_BIT | GLEnum.GL_DEPTH_BUFFER_BIT);
_glDriver.Draw(_vertexEngine.DrawQueue, view);
_window.Context.SwapBuffers();

View File

@ -118,10 +118,10 @@ namespace Quik.OpenGL
foreach (DrawCall call in queue)
{
GL.Scissor(
(int)MathF.Round(call.Bounds.Left),
(int)MathF.Round(view.Bottom - call.Bounds.Bottom),
(int)MathF.Round(call.Bounds.Right),
(int)MathF.Round(view.Bottom - call.Bounds.Top));
(int)MathF.Round(call.Bounds.Min.X),
(int)MathF.Round(size.Y - call.Bounds.Max.Y),
(int)MathF.Round(call.Bounds.Size.X),
(int)MathF.Round(call.Bounds.Size.Y));
QMat4.Translation(out QMat4 modelMatrix, call.Bounds.Min.X, call.Bounds.Min.Y, 0);
QMat4 modelView = viewMatrix * modelMatrix;
GL.UniformMatrix4(m4Transforms, false, in modelView);

View File

@ -21,6 +21,7 @@ namespace Quik.OpenGL
GL_BLEND = 0x0BE2,
GL_COLOR_BUFFER_BIT = 0x00004000,
GL_DEPTH_BUFFER_BIT = 0x00000100,
GL_SRC_ALPHA = 0x0302,
GL_ONE_MINUS_SRC_ALPHA = 0x0303,

View File

@ -2,9 +2,7 @@
using Quik.Media;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Quik.Typography
{
@ -76,10 +74,38 @@ namespace Quik.Typography
}
}
public static void TypesetHorizontalDirect(this CommandList list, string str, QVec2 origin, float size, QFont font)
public static QVec2 MeasureHorizontal(ReadOnlySpan<char> str, float size, QFont font)
{
var enumerator = new LineEnumerator(str);
float width = 0.0f;
float height = 0.0f;
while (enumerator.MoveNext())
{
ReadOnlySpan<char> line = enumerator.Current;
float lineHeight = 0.0f;
foreach (Rune r in line.EnumerateRunes())
{
int codepoint = r.Value;
font.Get(codepoint, size, out FontGlyph glyph);
width += glyph.Metrics.Advance.X;
lineHeight = Math.Max(lineHeight, glyph.Metrics.Size.Y);
}
height += lineHeight;
}
return new QVec2(width, height);
}
public static void TypesetHorizontalDirect(this CommandList list, ReadOnlySpan<char> str, QVec2 origin, float size, QFont font)
{
Dictionary<QImage, FontDrawInfo> drawInfo = new Dictionary<QImage, FontDrawInfo>();
var enumerator = new LineEnumerator(str.AsSpan());
var enumerator = new LineEnumerator(str);
QVec2 pen = origin;
while (enumerator.MoveNext())