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:
authorTon Roosendaal <ton@blender.org>2009-04-10 18:27:29 +0400
committerTon Roosendaal <ton@blender.org>2009-04-10 18:27:29 +0400
commit61249337817d3699ca961c9e4007cb0cdb232051 (patch)
tree67efe8fd93e3c368c97008210a1e3211964bf0aa
parentd2cc19dcc65e2684894ba5b1e413b4b69cb09742 (diff)
2.5
Nicer implementation of blurred font draw, moved to blenfont module. Set it with BLF_blur(value). Current kernels implemented are 3 and 5 only. Blenfont module can extend this once.
-rw-r--r--source/blender/blenfont/BLF_api.h2
-rw-r--r--source/blender/blenfont/intern/blf.c9
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c84
-rw-r--r--source/blender/blenfont/intern/blf_internal_types.h5
-rw-r--r--source/blender/editors/interface/interface_style.c55
5 files changed, 94 insertions, 61 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index d6f0cf38558..adf9742cc9f 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -68,6 +68,8 @@ float BLF_height(char *str);
*/
void BLF_rotation(float angle);
void BLF_clipping(float xmin, float ymin, float xmax, float ymax);
+void BLF_blur(int size);
+
void BLF_enable(int option);
void BLF_disable(int option);
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 686e54e4986..e5c1e675294 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -280,6 +280,15 @@ void BLF_size(int size, int dpi)
(*font->size_set)(font, size, dpi);
}
+void BLF_blur(int size)
+{
+ FontBLF *font;
+
+ font= global_font[global_font_cur];
+ if (font)
+ font->blur= size;
+}
+
void BLF_draw(char *str)
{
FontBLF *font;
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 628e5f3e6af..063093efb1d 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -433,6 +433,69 @@ void blf_glyph_free(GlyphBLF *g)
MEM_freeN(g);
}
+static void blf_glyph_texture_draw(float uv[2][2], float dx, float y1, float dx1, float y2)
+{
+
+ glBegin(GL_QUADS);
+ glTexCoord2f(uv[0][0], uv[0][1]);
+ glVertex2f(dx, y1);
+
+ glTexCoord2f(uv[0][0], uv[1][1]);
+ glVertex2f(dx, y2);
+
+ glTexCoord2f(uv[1][0], uv[1][1]);
+ glVertex2f(dx1, y2);
+
+ glTexCoord2f(uv[1][0], uv[0][1]);
+ glVertex2f(dx1, y1);
+ glEnd();
+
+}
+
+static void blf_glyph_texture5_draw(float uv[2][2], float x1, float y1, float x2, float y2)
+{
+ float soft[25]= {
+ 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f,
+ 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f,
+ 2/60.0f, 5/60.0f, 8/60.0f, 5/60.0f, 2/60.0f,
+ 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f,
+ 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f};
+
+ float color[4], *fp= soft;
+ int dx, dy;
+
+ glGetFloatv(GL_CURRENT_COLOR, color);
+
+ for(dx=-2; dx<3; dx++) {
+ for(dy=-2; dy<3; dy++, fp++) {
+ glColor4f(color[0], color[1], color[2], fp[0]*color[3]);
+ blf_glyph_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy);
+ }
+ }
+
+ glColor4fv(color);
+}
+
+static void blf_glyph_texture3_draw(float uv[2][2], float x1, float y1, float x2, float y2)
+{
+ float soft[9]= {1/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 4/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 1/16.0f};
+ float color[4], *fp= soft;
+ int dx, dy;
+
+ glGetFloatv(GL_CURRENT_COLOR, color);
+
+ for(dx=-1; dx<2; dx++) {
+ for(dy=-1; dy<2; dy++, fp++) {
+ glColor4f(color[0], color[1], color[2], fp[0]*color[3]);
+ blf_glyph_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy);
+ }
+ }
+
+ glColor4fv(color);
+}
+
+
+
int blf_glyph_texture_render(FontBLF *font, GlyphBLF *g, float x, float y)
{
GlyphTextureBLF *gt;
@@ -461,20 +524,13 @@ int blf_glyph_texture_render(FontBLF *font, GlyphBLF *g, float x, float y)
if (cur_tex != gt->tex)
glBindTexture(GL_TEXTURE_2D, gt->tex);
- glBegin(GL_QUADS);
- glTexCoord2f(gt->uv[0][0], gt->uv[0][1]);
- glVertex2f(dx, y1);
-
- glTexCoord2f(gt->uv[0][0], gt->uv[1][1]);
- glVertex2f(dx, y2);
-
- glTexCoord2f(gt->uv[1][0], gt->uv[1][1]);
- glVertex2f(dx1, y2);
-
- glTexCoord2f(gt->uv[1][0], gt->uv[0][1]);
- glVertex2f(dx1, y1);
- glEnd();
-
+ if (font->blur==3)
+ blf_glyph_texture3_draw(gt->uv, dx, y1, dx1, y2);
+ else if (font->blur==5)
+ blf_glyph_texture5_draw(gt->uv, dx, y1, dx1, y2);
+ else
+ blf_glyph_texture_draw(gt->uv, dx, y1, dx1, y2);
+
return(1);
}
diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h
index e176eb2040b..cf42dc69f77 100644
--- a/source/blender/blenfont/intern/blf_internal_types.h
+++ b/source/blender/blenfont/intern/blf_internal_types.h
@@ -157,7 +157,10 @@ typedef struct FontBLF {
/* angle in degrees. */
float angle;
-
+
+ /* blur: 3 or 5 large kernel */
+ int blur;
+
/* this is the matrix that we load before rotate/scale/translate. */
float mat[4][4];
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index e66fef2ee59..82ff20b2495 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -134,53 +134,18 @@ static uiFont *uifont_to_blfont(int id)
/* *************** draw ************************ */
-
-static void ui_font_shadow5_draw(uiFontStyle *fs, int x, int y, char *str)
-{
- float soft[25]= {
- 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f,
- 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f,
- 2/60.0f, 5/60.0f, 8/60.0f, 5/60.0f, 2/60.0f,
- 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f,
- 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f};
-
- float color[4], *fp= soft;
- int dx, dy;
-
- glGetFloatv(GL_CURRENT_COLOR, color);
-
- x+= fs->shadx;
- y+= fs->shady;
-
- for(dx=-2; dx<3; dx++) {
- for(dy=-2; dy<3; dy++, fp++) {
- glColor4f(fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fp[0]*fs->shadowalpha);
- BLF_position(x+dx, y+dy, 0.0f);
- BLF_draw(str);
- }
- }
-
- glColor4fv(color);
-}
-
-static void ui_font_shadow3_draw(uiFontStyle *fs, int x, int y, char *str)
+static void ui_font_shadow_draw(uiFontStyle *fs, int x, int y, char *str)
{
- float soft[9]= {1/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 4/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 1/16.0f};
- float color[4], *fp= soft;
- int dx, dy;
+ float color[4];
glGetFloatv(GL_CURRENT_COLOR, color);
- x+= fs->shadx;
- y+= fs->shady;
+ glColor4f(fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
- for(dx=-1; dx<2; dx++) {
- for(dy=-1; dy<2; dy++, fp++) {
- glColor4f(fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fp[0]*fs->shadowalpha);
- BLF_position(x+dx, y+dy, 0.0f);
- BLF_draw(str);
- }
- }
+ BLF_blur(fs->shadow);
+ BLF_position(x+fs->shadx, y+fs->shady, 0.0f);
+ BLF_draw(str);
+ BLF_blur(0);
glColor4fv(color);
}
@@ -204,10 +169,8 @@ void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, char *str)
BLF_clipping(rect->xmin-4, rect->ymin-4, rect->xmax+4, rect->ymax+4);
BLF_enable(BLF_CLIPPING);
- if(fs->shadow==3)
- ui_font_shadow3_draw(fs, rect->xmin+xofs, rect->ymin+yofs, str);
- else if(fs->shadow==5)
- ui_font_shadow5_draw(fs, rect->xmin+xofs, rect->ymin+yofs, str);
+ if(fs->shadow)
+ ui_font_shadow_draw(fs, rect->xmin+xofs, rect->ymin+yofs, str);
BLF_position(rect->xmin+xofs, rect->ymin+yofs, 0.0f);
BLF_draw(str);