Working on messenger in portrait mode

This commit is contained in:
Vladislav Khorev committed 2026-06-26 20:04:08 +03:00
1 parent 0b4df8ab2d
commit 8c42179576
10 files changed
+498 -65

No files matched your search

+9 -9
View File
@@ -380,9 +380,11 @@ float TextRenderer::measureTextWidth(const std::string& text, float scale) const
return maxLineWidth;
}
void TextRenderer::drawText(const std::string& text, float x, float y, float scale, bool centered, std::array<float, 4> color)
void TextRenderer::drawText(const std::string& text, float x, float y, float scale, bool centered, std::array<float, 4> color, float projW, float projH)
{
if (!r || text.empty() || !atlasTexture) return;
if (projW <= 0.0f) projW = Environment::projectionWidth;
if (projH <= 0.0f) projH = Environment::projectionHeight;
// формируем ключ кеша
std::string key = text + "|" + std::to_string(scale) + "|" + (centered ? "1" : "0");
@@ -471,16 +473,14 @@ void TextRenderer::drawText(const std::string& text, float x, float y, float sca
// 4. Рендеринг
r->shaderManager.PushShader(shaderName);
// Матрица проекции — используем виртуальные проекционные размеры,
// чтобы координаты текста были независимы от физического разрешения экрана.
float W = Environment::projectionWidth;
float H = Environment::projectionHeight;
// Матрица проекции — используем переданные проекционные размеры.
// Это позволяет корректно рендерить текст как в основной сцене, так и внутри FBO.
Eigen::Matrix4f proj = Eigen::Matrix4f::Identity();
proj(0, 0) = 2.0f / W;
proj(1, 1) = 2.0f / H;
proj(0, 0) = 2.0f / projW;
proj(1, 1) = 2.0f / projH;
// Сдвигаем проекцию так, чтобы локальные координаты меша (pen-origin=0,0) оказались в (tx,ty)
proj(0, 3) = -1.0f + 2.0f * (tx) / W;
proj(1, 3) = -1.0f + 2.0f * (ty) / H;
proj(0, 3) = -1.0f + 2.0f * (tx) / projW;
proj(1, 3) = -1.0f + 2.0f * (ty) / projH;
//cached.mesh.RefreshVBO();
+1 -1
View File
@@ -26,7 +26,7 @@ public:
~TextRenderer();
bool init(Renderer& renderer, const std::string& ttfPath, int pixelSize, const std::string& zipfilename);
void drawText(const std::string& text, float x, float y, float scale, bool centered, std::array<float, 4> color = { 1.f,1.f,1.f,1.f });
void drawText(const std::string& text, float x, float y, float scale, bool centered, std::array<float, 4> color = { 1.f,1.f,1.f,1.f }, float projW = 0.0f, float projH = 0.0f);
float measureTextWidth(const std::string& text, float scale = 1.0f) const;
float getLineHeight(float scale = 1.0f) const { return lineHeight * scale; }