Я пытаюсь представить текстовый рендеринг в моем игровом двигателе, сделанный в OpenGL. Я использовал Freetype, и все работало отлично. До сегодняшнего дня. Я только что запускаю программу, и некоторые буквы отсутствуют. < /P>
Если я устанавливаю ft_set_pixel_sizes (лицо, 0, 48) < /code>, то не хватает только pqygj.Font::Font(std::string_view filePath)
{
FT_Library ft;
TOMATO_ASSERT(!FT_Init_FreeType(&ft), "ERROR::FREETYPE: Could not init FreeType Library");
FT_Face face;
TOMATO_ASSERT(!FT_New_Face(ft, filePath.data(), 0, &face), "ERROR::FREETYPE: Failed to load font");
FT_Set_Pixel_Sizes(face, 0, 48);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // disable byte-alignment restriction
for (unsigned char c = 0; c < 128; c++)
{
// load character glyph
if (FT_Load_Char(face, c, FT_LOAD_RENDER))
{
TOMATO_ERROR("ERROR::FREETYTPE: Failed to load Glyph");
continue;
}
// generate texture
m_Chars[c].Texture = std::make_shared(face->glyph->bitmap.width, face->glyph->bitmap.rows, face->glyph->bitmap.buffer, GL_RED);
// now store character for later use
m_Chars[c].Size = UInt2(face->glyph->bitmap.width, face->glyph->bitmap.rows);
m_Chars[c].Bearing = UInt2(face->glyph->bitmap_left, face->glyph->bitmap_top);
m_Chars[c].Advance = face->glyph->advance.x;
}
FT_Done_Face(face);
FT_Done_FreeType(ft);
}
< /code>
Я использую пакетный рендеринг. < /p>
void Renderer::DrawText(std::string_view text, const Font& font, const Mat4& transform)
{
auto& ins = s_Instance;
// activate corresponding render state
ins->m_Shader->Use();
ins->m_VertexArray->Bind();
Float scale = 0.1f;
// iterate through all characters
Float x = 0.0f;
for (const auto& c : text)
{
auto& ch = font[c];
Float xpos = x + ch.Bearing.x * scale;
Float ypos = - (ch.Size.y - ch.Bearing.y) * scale;
Float w = ch.Size.x * scale;
Float h = ch.Size.y * scale;
auto color = Float4(1.0f, 1.0f, 1.0f, 1.0f);
auto texIndex = GetTextureIndex(ch.Texture);
if (RendererData::VertexCounter + 6 >= RendererData::MaxVertexNumber)
Flush();
std::array coords;
coords[0] = Float4(xpos, ypos + h, 0.0f, 1.0f);
coords[1] = Float4(xpos, ypos, 0.0f, 1.0f);
coords[2] = Float4(xpos + w, ypos, 0.0f, 1.0f);
coords[3] = Float4(xpos, ypos + h, 0.0f, 1.0f);
coords[4] = Float4(xpos + w, ypos, 0.0f, 1.0f);
coords[5] = Float4(xpos + w, ypos + h, 0.0f, 1.0f);
RendererData::Vertices[RendererData::VertexCounter++] = Vertex((transform * coords[0]).xyz, color, texIndex, Float2(0.0f, 0.0f), 1.0f);
RendererData::Vertices[RendererData::VertexCounter++] = Vertex((transform * coords[1]).xyz, color, texIndex, Float2(0.0f, 1.0f), 1.0f);
RendererData::Vertices[RendererData::VertexCounter++] = Vertex((transform * coords[2]).xyz, color, texIndex, Float2(1.0f, 1.0f), 1.0f);
RendererData::Vertices[RendererData::VertexCounter++] = Vertex((transform * coords[3]).xyz, color, texIndex, Float2(0.0f, 0.0f), 1.0f);
RendererData::Vertices[RendererData::VertexCounter++] = Vertex((transform * coords[4]).xyz, color, texIndex, Float2(1.0f, 1.0f), 1.0f);
RendererData::Vertices[RendererData::VertexCounter++] = Vertex((transform * coords[5]).xyz, color, texIndex, Float2(1.0f, 0.0f), 1.0f);
x += (ch.Advance >> 6) * scale;
}
VertexArray::Unbind();
}
Подробнее здесь: https://stackoverflow.com/questions/735 ... re-missing
Freetype, некоторые буквы отсутствуют ⇐ C++
Программы на C++. Форум разработчиков
1758018479
Anonymous
Я пытаюсь представить текстовый рендеринг в моем игровом двигателе, сделанный в OpenGL. Я использовал Freetype, и все работало отлично. До сегодняшнего дня. Я только что запускаю программу, и некоторые буквы отсутствуют. < /P>
Если я устанавливаю ft_set_pixel_sizes (лицо, 0, 48) < /code>, то не хватает только pqygj.Font::Font(std::string_view filePath)
{
FT_Library ft;
TOMATO_ASSERT(!FT_Init_FreeType(&ft), "ERROR::FREETYPE: Could not init FreeType Library");
FT_Face face;
TOMATO_ASSERT(!FT_New_Face(ft, filePath.data(), 0, &face), "ERROR::FREETYPE: Failed to load font");
FT_Set_Pixel_Sizes(face, 0, 48);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // disable byte-alignment restriction
for (unsigned char c = 0; c < 128; c++)
{
// load character glyph
if (FT_Load_Char(face, c, FT_LOAD_RENDER))
{
TOMATO_ERROR("ERROR::FREETYTPE: Failed to load Glyph");
continue;
}
// generate texture
m_Chars[c].Texture = std::make_shared(face->glyph->bitmap.width, face->glyph->bitmap.rows, face->glyph->bitmap.buffer, GL_RED);
// now store character for later use
m_Chars[c].Size = UInt2(face->glyph->bitmap.width, face->glyph->bitmap.rows);
m_Chars[c].Bearing = UInt2(face->glyph->bitmap_left, face->glyph->bitmap_top);
m_Chars[c].Advance = face->glyph->advance.x;
}
FT_Done_Face(face);
FT_Done_FreeType(ft);
}
< /code>
Я использую пакетный рендеринг. < /p>
void Renderer::DrawText(std::string_view text, const Font& font, const Mat4& transform)
{
auto& ins = s_Instance;
// activate corresponding render state
ins->m_Shader->Use();
ins->m_VertexArray->Bind();
Float scale = 0.1f;
// iterate through all characters
Float x = 0.0f;
for (const auto& c : text)
{
auto& ch = font[c];
Float xpos = x + ch.Bearing.x * scale;
Float ypos = - (ch.Size.y - ch.Bearing.y) * scale;
Float w = ch.Size.x * scale;
Float h = ch.Size.y * scale;
auto color = Float4(1.0f, 1.0f, 1.0f, 1.0f);
auto texIndex = GetTextureIndex(ch.Texture);
if (RendererData::VertexCounter + 6 >= RendererData::MaxVertexNumber)
Flush();
std::array coords;
coords[0] = Float4(xpos, ypos + h, 0.0f, 1.0f);
coords[1] = Float4(xpos, ypos, 0.0f, 1.0f);
coords[2] = Float4(xpos + w, ypos, 0.0f, 1.0f);
coords[3] = Float4(xpos, ypos + h, 0.0f, 1.0f);
coords[4] = Float4(xpos + w, ypos, 0.0f, 1.0f);
coords[5] = Float4(xpos + w, ypos + h, 0.0f, 1.0f);
RendererData::Vertices[RendererData::VertexCounter++] = Vertex((transform * coords[0]).xyz, color, texIndex, Float2(0.0f, 0.0f), 1.0f);
RendererData::Vertices[RendererData::VertexCounter++] = Vertex((transform * coords[1]).xyz, color, texIndex, Float2(0.0f, 1.0f), 1.0f);
RendererData::Vertices[RendererData::VertexCounter++] = Vertex((transform * coords[2]).xyz, color, texIndex, Float2(1.0f, 1.0f), 1.0f);
RendererData::Vertices[RendererData::VertexCounter++] = Vertex((transform * coords[3]).xyz, color, texIndex, Float2(0.0f, 0.0f), 1.0f);
RendererData::Vertices[RendererData::VertexCounter++] = Vertex((transform * coords[4]).xyz, color, texIndex, Float2(1.0f, 1.0f), 1.0f);
RendererData::Vertices[RendererData::VertexCounter++] = Vertex((transform * coords[5]).xyz, color, texIndex, Float2(1.0f, 0.0f), 1.0f);
x += (ch.Advance >> 6) * scale;
}
VertexArray::Unbind();
}
Подробнее здесь: [url]https://stackoverflow.com/questions/73540922/freetype-some-letters-are-missing[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия