Basicallly POC, but still somethign wrong with u_FontQuadParts

This commit is contained in:
2023-06-04 10:05:42 -07:00
parent 6a61255aee
commit bbd442b191
7 changed files with 45 additions and 21 deletions

View File

@ -12,7 +12,7 @@ namespace Dawn {
};
#pragma pack(push, 1)
struct __attribute__ ((packed)) Color {
struct Color {
float_t r, g, b, a;
struct Color operator * (const float_t &x) {

View File

@ -51,7 +51,7 @@ void Dawn::_newTrueTypePlaceholder(
charStore[c] = info;
// Buffer the pixels, oh dear GOD there has to be a more efficient way.
for(int32_t i = 0; i < face->glyph->bitmap.rows; i++) {
for(uint32_t i = 0; i < face->glyph->bitmap.rows; i++) {
memoryCopy(
(void *)(face->glyph->bitmap.buffer + (i * face->glyph->bitmap.width)),
(void *)(buffer + offset),

View File

@ -34,14 +34,15 @@ void _uiLabelBake(
h += face->glyph->bitmap.rows;
}
assertTrue(w > 0);
assertTrue(h > 0);
// Now buffer pixels to the texture
float_t y = 0;
// I'd love to just buffer straight to the GPU, but it seems that is a bit
// unstable right now.
uint8_t *buffer = (uint8_t *)memoryAllocate(w * h * sizeof(uint8_t));
memorySet(buffer, 0x00, sizeof(uint8_t) * w * h);
uint8_t *buffer = (uint8_t *)memoryFillWithZero(w * h * sizeof(uint8_t));
size_t offset = 0;
for(c = NEW_LABEL_CHAR_BEGIN; c < NEW_LABEL_CHAR_END; c++) {
@ -67,6 +68,7 @@ void _uiLabelBake(
face->glyph->bitmap.width * sizeof(uint8_t)
);
offset += w * sizeof(uint8_t);
assertTrue(offset <= (w * h * sizeof(uint8_t)));
}
y += face->glyph->bitmap.rows;
}
@ -129,7 +131,8 @@ void UILabelNew::onStart() {
if(FT_New_Face(
getGame()->renderManager.getFontManager()->fontLibrary,
"/usr/share/fonts/TTF/arial.ttf",
// "/usr/share/fonts/TTF/arial.ttf",
"C:\\Windows\\Fonts\\arial.ttf",
0,
&face
)) {
@ -140,7 +143,8 @@ void UILabelNew::onStart() {
if(FT_New_Face(
getGame()->renderManager.getFontManager()->fontLibrary,
"/usr/share/fonts/TTF/arialbd.ttf",
// "/usr/share/fonts/TTF/arialbd.ttf",
"C:\\Windows\\Fonts\\arialbd.ttf",
0,
&faceBold
)) {
@ -151,7 +155,8 @@ void UILabelNew::onStart() {
if(FT_New_Face(
getGame()->renderManager.getFontManager()->fontLibrary,
"/usr/share/fonts/TTF/ariali.ttf",
// "/usr/share/fonts/TTF/ariali.ttf",
"C:\\Windows\\Fonts\\ariali.ttf",
0,
&faceItalics
)) {
@ -161,11 +166,11 @@ void UILabelNew::onStart() {
struct FontShaderBufferData fontData;
glm::vec2 position = glm::vec2(0, defFace.fontSize);
glm::vec2 position = glm::vec2(32, 32);
testMesh.createBuffers(QUAD_VERTICE_COUNT * 96, QUAD_INDICE_COUNT * 96);
auto x = _uiLabelQuad(
"Hello",
"Hello ",
&this->testMesh,
fontData,
defFace,
@ -183,7 +188,7 @@ void UILabelNew::onStart() {
1
);
fontData.fontParts[0].color = COLOR_BLUE;
fontData.fontParts[0].color = COLOR_MAGENTA;
fontData.fontParts[0].texture = 0;
fontData.fontParts[1].color = COLOR_RED;
fontData.fontParts[1].texture = 1;

View File

@ -8,8 +8,8 @@
#include "display/mesh/QuadMesh.hpp"
#define NEW_LABEL_CHAR_BEGIN 0x00
#define NEW_LABEL_CHAR_END 0xFF
#define NEW_LABEL_CHAR_BEGIN 32
#define NEW_LABEL_CHAR_END 192
namespace Dawn {
struct UILabelChar {