This commit is contained in:
MihailRis
2024-11-12 06:01:53 +03:00
parent edbd851d11
commit 7734d403ea
+8 -25
View File
@@ -52,8 +52,7 @@ static inline void draw_glyph(
uint c, uint c,
const glm::vec3& right, const glm::vec3& right,
const glm::vec3& up, const glm::vec3& up,
float glyphInterval, float glyphInterval
float lineHeight
) { ) {
batch.sprite( batch.sprite(
pos.x + offset.x * right.x, pos.x + offset.x * right.x,
@@ -73,8 +72,7 @@ static inline void draw_glyph(
uint c, uint c,
const glm::vec3& right, const glm::vec3& right,
const glm::vec3& up, const glm::vec3& up,
float glyphInterval, float glyphInterval
float lineHeight
) { ) {
batch.sprite( batch.sprite(
pos + right * offset.x + up * offset.y, pos + right * offset.x + up * offset.y,
@@ -95,8 +93,7 @@ static inline void draw_text(
const glm::vec3& pos, const glm::vec3& pos,
const glm::vec3& right, const glm::vec3& right,
const glm::vec3& up, const glm::vec3& up,
float glyphInterval, float glyphInterval
float lineHeight
) { ) {
uint page = 0; uint page = 0;
uint next = MAX_CODEPAGES; uint next = MAX_CODEPAGES;
@@ -112,14 +109,7 @@ static inline void draw_text(
if (charpage == page){ if (charpage == page){
batch.texture(font.getPage(charpage)); batch.texture(font.getPage(charpage));
draw_glyph( draw_glyph(
batch, batch, pos, glm::vec2(x, y), c, right, up, glyphInterval
pos,
glm::vec2(x, y),
c,
right,
up,
glyphInterval,
lineHeight
); );
} }
else if (charpage > page && charpage < next){ else if (charpage > page && charpage < next){
@@ -148,14 +138,11 @@ void Font::draw(
Batch2D& batch, std::wstring_view text, int x, int y, float scale Batch2D& batch, std::wstring_view text, int x, int y, float scale
) const { ) const {
draw_text( draw_text(
*this, *this, batch, text,
batch,
text,
glm::vec3(x, y, 0), glm::vec3(x, y, 0),
glm::vec3(glyphInterval*scale, 0, 0), glm::vec3(glyphInterval*scale, 0, 0),
glm::vec3(0, lineHeight*scale, 0), glm::vec3(0, lineHeight*scale, 0),
glyphInterval/static_cast<float>(lineHeight), glyphInterval/static_cast<float>(lineHeight)
lineHeight
); );
} }
@@ -167,13 +154,9 @@ void Font::draw(
const glm::vec3& up const glm::vec3& up
) const { ) const {
draw_text( draw_text(
*this, *this, batch, text, pos,
batch,
text,
pos,
right * static_cast<float>(glyphInterval), right * static_cast<float>(glyphInterval),
up * static_cast<float>(lineHeight), up * static_cast<float>(lineHeight),
glyphInterval/static_cast<float>(lineHeight), glyphInterval/static_cast<float>(lineHeight)
lineHeight
); );
} }