Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/intern/blf.c6
-rw-r--r--source/blender/blenfont/intern/blf_font.c8
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c30
3 files changed, 12 insertions, 32 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 8e705616c41..30919f1acda 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -579,9 +579,9 @@ static void blf_draw_gl__start(FontBLF *font)
#ifndef BLF_STANDALONE
Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
+ unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ unsigned int texCoord = GWN_vertformat_attr_add(format, "tex", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
+ unsigned int color = GWN_vertformat_attr_add(format, "col", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
BLI_assert(pos == BLF_POS_ID);
BLI_assert(texCoord == BLF_COORD_ID);
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 5846f7a29e4..fe94270f530 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -188,7 +188,7 @@ static unsigned int verts_needed(const FontBLF *font, const char *str, size_t le
quad_ct += 25; /* 5x5 kernel */
}
- return length * quad_ct * 6;
+ return length * quad_ct; /* Only one vert per quad */
}
static void blf_font_draw_ex(
@@ -211,7 +211,7 @@ static void blf_font_draw_ex(
blf_font_ensure_ascii_table(font);
- immBeginAtMost(GWN_PRIM_TRIS, verts_needed(font, str, len));
+ immBeginAtMost(GWN_PRIM_POINTS, verts_needed(font, str, len));
/* at most because some glyphs might be clipped & not drawn */
while ((i < len) && str[i]) {
@@ -258,7 +258,7 @@ static void blf_font_draw_ascii_ex(
blf_font_ensure_ascii_table(font);
- immBeginAtMost(GWN_PRIM_TRIS, verts_needed(font, str, len));
+ immBeginAtMost(GWN_PRIM_POINTS, verts_needed(font, str, len));
while ((c = *(str++)) && len--) {
BLI_assert(c < 128);
@@ -298,7 +298,7 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
blf_font_ensure_ascii_table(font);
- immBeginAtMost(GWN_PRIM_TRIS, verts_needed(font, str, len));
+ immBeginAtMost(GWN_PRIM_POINTS, verts_needed(font, str, len));
while ((i < len) && str[i]) {
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 1f31a2dbd0a..5e1debf1501 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -318,31 +318,11 @@ void blf_glyph_free(GlyphBLF *g)
static void blf_texture_draw(const unsigned char color[4], float uv[2][2], float dx, float y1, float dx1, float y2)
{
- /* First triangle. */
- immAttrib2f(BLF_COORD_ID, uv[0][0], uv[0][1]);
- immSkipAttrib(BLF_COLOR_ID); /* skip color of most vertices */
- immVertex2f(BLF_POS_ID, dx, y1);
-
- immAttrib2f(BLF_COORD_ID, uv[0][0], uv[1][1]);
- immSkipAttrib(BLF_COLOR_ID);
- immVertex2f(BLF_POS_ID, dx, y2);
-
- immAttrib2f(BLF_COORD_ID, uv[1][0], uv[1][1]);
- immAttrib4ubv(BLF_COLOR_ID, color); /* set color of provoking vertex */
- immVertex2f(BLF_POS_ID, dx1, y2);
-
- /* Second triangle. */
- immAttrib2f(BLF_COORD_ID, uv[0][0], uv[0][1]);
- immSkipAttrib(BLF_COLOR_ID); /* skip color of most vertices */
- immVertex2f(BLF_POS_ID, dx, y1);
-
- immAttrib2f(BLF_COORD_ID, uv[1][0], uv[1][1]);
- immSkipAttrib(BLF_COLOR_ID);
- immVertex2f(BLF_POS_ID, dx1, y2);
-
- immAttrib2f(BLF_COORD_ID, uv[1][0], uv[0][1]);
- immAttrib4ubv(BLF_COLOR_ID, color); /* set color of provoking vertex */
- immVertex2f(BLF_POS_ID, dx1, y1);
+ /* Only one vertex per glyph, geometry shader expand it into a quad. */
+ /* TODO Get rid of Geom Shader because it's not optimal AT ALL for the GPU */
+ immAttrib4ubv(BLF_COLOR_ID, color);
+ immAttrib4fv(BLF_COORD_ID, (float *)uv);
+ immVertex4f(BLF_POS_ID, dx, y1, dx1, y2);
}
static void blf_texture5_draw(const unsigned char color_in[4], float uv[2][2], float x1, float y1, float x2, float y2)