mirror of https://github.com/fltk/fltk
Remove use of static global var gl_fontsize inside virtual member Fl_Gl_Window_Driver::alpha_mask_for_string()
This commit is contained in:
parent
3c37cd033b
commit
32f926c360
|
@ -96,7 +96,8 @@ public:
|
|||
virtual int overlay_color(Fl_Color i) {return 0;} // support for gl_color() with HAVE_GL_OVERLAY
|
||||
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);
|
||||
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,8 @@ 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 char *alpha_mask_for_string(const char *str, int n, int w, int h);
|
||||
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);
|
||||
};
|
||||
|
||||
|
@ -219,14 +220,18 @@ 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. */
|
||||
|
||||
char *Fl_Cocoa_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, int w, int h)
|
||||
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
|
||||
Fl_Image_Surface *surf = new Fl_Image_Surface(w, h);
|
||||
Fl_Font f=fl_font(); Fl_Fontsize s=fl_size();
|
||||
Fl_Font f=fl_font();
|
||||
Fl_Surface_Device::push_current(surf);
|
||||
fl_color(FL_WHITE);
|
||||
fl_font(f, s * gl_scale);
|
||||
fl_font(f, fs);
|
||||
fl_draw(str, n, 0, fl_height() - fl_descent());
|
||||
// get the alpha channel only of the bitmap
|
||||
char *alpha_buf = new char[w*h], *r = alpha_buf, *q;
|
||||
|
|
|
@ -412,7 +412,8 @@ int gl_texture_fifo::compute_texture(const char* str, int n)
|
|||
|
||||
fifo[current].scale = Fl_Gl_Window_Driver::gl_scale;
|
||||
fifo[current].fdesc = gl_fontsize;
|
||||
char *alpha_buf = Fl_Gl_Window_Driver::global()->alpha_mask_for_string(str, n, w, h);
|
||||
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
|
||||
GLint row_length, alignment;
|
||||
|
@ -496,8 +497,11 @@ 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)
|
||||
char *Fl_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, int w, int h, Fl_Fontsize fs)
|
||||
{
|
||||
// write str to a bitmap that is just big enough
|
||||
// create an Fl_Image_Surface object
|
||||
|
@ -511,7 +515,7 @@ char *Fl_Gl_Window_Driver::alpha_mask_for_string(const char *str, int n, int w,
|
|||
// set up the text colour as white, which we will interpret as opaque
|
||||
fl_color(255,255,255);
|
||||
// Fix the font scaling
|
||||
fl_font (fnt, gl_fontsize->size); // resize "fltk" font to current GL view scaling
|
||||
fl_font (fnt, fs); // resize "fltk" font to current GL view scaling
|
||||
int desc = fl_descent();
|
||||
// Render the text to the buffer
|
||||
fl_draw(str, n, 0, h - desc);
|
||||
|
|
Loading…
Reference in New Issue