mirror of https://github.com/fltk/fltk
Slightly simplify gl_texture_fifo::compute_texture()
The font size is set to the value necessary for the GL scene before computing the string width. Virtual Fl_Gl_Window_Driver::effective_size() becomes unnecessary.
This commit is contained in:
parent
6e70afc811
commit
3bc9017970
|
@ -97,7 +97,6 @@ public:
|
|||
static void draw_string_with_texture(const char* str, int n); // cross-platform
|
||||
// support for gl_draw(). The cross-platform version may be enough.
|
||||
virtual char *alpha_mask_for_string(const char *str, int n, int w, int h, Fl_Fontsize fs);
|
||||
virtual Fl_Fontsize effective_size();
|
||||
virtual int genlistsize() { return 0; } // support for gl_draw()
|
||||
virtual Fl_Font_Descriptor** fontnum_to_fontdescriptor(int fnum);
|
||||
virtual Fl_RGB_Image* capture_gl_rectangle(int x, int y, int w, int h);
|
||||
|
|
|
@ -53,7 +53,6 @@ class Fl_Cocoa_Gl_Window_Driver : public Fl_Gl_Window_Driver {
|
|||
virtual void make_overlay_current();
|
||||
virtual void redraw_overlay();
|
||||
virtual void gl_start();
|
||||
virtual Fl_Fontsize effective_size();
|
||||
virtual char *alpha_mask_for_string(const char *str, int n, int w, int h, Fl_Fontsize fs);
|
||||
virtual Fl_RGB_Image* capture_gl_rectangle(int x, int y, int w, int h);
|
||||
};
|
||||
|
@ -220,10 +219,6 @@ void Fl_Cocoa_Gl_Window_Driver::resize(int is_a_resize, int w, int h) {
|
|||
/* Some old Apple hardware doesn't implement the GL_EXT_texture_rectangle extension.
|
||||
For it, draw_string_legacy_glut() is used to draw text. */
|
||||
|
||||
Fl_Fontsize Fl_Cocoa_Gl_Window_Driver::effective_size() {
|
||||
return (Fl_Fontsize)round(fl_graphics_driver->size() * gl_scale);
|
||||
}
|
||||
|
||||
char *Fl_Cocoa_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, int w, int h, Fl_Fontsize fs)
|
||||
{
|
||||
// write str to a bitmap just big enough
|
||||
|
|
|
@ -405,16 +405,18 @@ int gl_texture_fifo::compute_texture(const char* str, int n)
|
|||
memcpy(fifo[current].utf8, str, n);
|
||||
fifo[current].utf8[n] = 0;
|
||||
fifo[current].str_len = n; // record length of text in utf8
|
||||
fl_graphics_driver->font_descriptor(gl_fontsize);
|
||||
int w, h;
|
||||
w = int(ceil(fl_width(fifo[current].utf8, n) * Fl_Gl_Window_Driver::gl_scale));
|
||||
// Hack - make w be aligned
|
||||
w = (w + 3) & (~3);
|
||||
h = int(ceil(fl_height() * Fl_Gl_Window_Driver::gl_scale));
|
||||
|
||||
Fl_Fontsize fs = fl_size();
|
||||
float s = fl_graphics_driver->scale();
|
||||
fl_graphics_driver->Fl_Graphics_Driver::scale(1); // temporarily remove scaling factor
|
||||
fl_font(fl_font(), fs * Fl_Gl_Window_Driver::gl_scale); // the font size to use in the GL scene
|
||||
int w = (int)ceil( fl_width(fifo[current].utf8, n) );
|
||||
w = ((w + 3) / 4) * 4; // make w a multiple of 4
|
||||
int h = fl_height();
|
||||
fl_graphics_driver->Fl_Graphics_Driver::scale(s); // re-install scaling factor
|
||||
fl_font(fl_font(), fs);
|
||||
fs *= Fl_Gl_Window_Driver::gl_scale;
|
||||
fifo[current].scale = Fl_Gl_Window_Driver::gl_scale;
|
||||
fifo[current].fdesc = gl_fontsize;
|
||||
Fl_Fontsize fs = Fl_Gl_Window_Driver::global()->effective_size();
|
||||
char *alpha_buf = Fl_Gl_Window_Driver::global()->alpha_mask_for_string(str, n, w, h, fs);
|
||||
|
||||
// save GL parameters GL_UNPACK_ROW_LENGTH and GL_UNPACK_ALIGNMENT
|
||||
|
@ -499,9 +501,6 @@ void Fl_Gl_Window_Driver::draw_string_with_texture(const char* str, int n)
|
|||
gl_fifo->display_texture(index);
|
||||
}
|
||||
|
||||
Fl_Fontsize Fl_Gl_Window_Driver::effective_size() {
|
||||
return fl_graphics_driver->font_descriptor()->size;
|
||||
}
|
||||
|
||||
char *Fl_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, int w, int h, Fl_Fontsize fs)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue