diff options
| author | Manolo Gouy <Manolo> | 2017-01-10 15:33:14 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2017-01-10 15:33:14 +0000 |
| commit | 723012c2bd2caa9931d2ed0c5c5c0910212eff44 (patch) | |
| tree | a31a8515f9d50f093fa10fe7b8f477a5032625dc /src | |
| parent | 0e22ca28ddacce9e793dd032471df2bb04e9a6b4 (diff) | |
Fl_OpenGL_Graphics_Driver : use gl_font()/gl_draw() to draw text in a GL window.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12162 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H | 3 | ||||
| -rw-r--r-- | src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_font.cxx | 39 |
2 files changed, 41 insertions, 1 deletions
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H index 775253178..f73f046d4 100644 --- a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H +++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver.H @@ -83,7 +83,8 @@ public: void color(Fl_Color c); Fl_Color color() { return color_; } void color(uchar r, uchar g, uchar b); - // --- implementation is in src/fl_font.cxx which includes src/cfg_gfx/xxx_font.cxx + // --- implementation is in Fl_OpenGL_Graphics_Driver_font.cxx + void font(Fl_Font face, Fl_Fontsize fsize); void draw(const char *str, int n, int x, int y); double width(const char *str, int n); void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h); diff --git a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_font.cxx b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_font.cxx index 0b1990df7..25a51f71a 100644 --- a/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_font.cxx +++ b/src/drivers/OpenGL/Fl_OpenGL_Graphics_Driver_font.cxx @@ -93,6 +93,9 @@ static const char *font_data[128] = { }; +void Fl_OpenGL_Graphics_Driver::font(Fl_Font face, Fl_Fontsize fsize) { + Fl_Graphics_Driver::font(face, fsize); +} double Fl_OpenGL_Graphics_Driver::width(const char *str, int n) { return size_*n*0.5; @@ -169,10 +172,46 @@ FL_EXPORT int glutStrokeWidth(void *font, int character); #else +// use gl_font()/gl_draw() to draw GL text + +void Fl_OpenGL_Graphics_Driver::font(Fl_Font face, Fl_Fontsize fsize) { + Fl_Surface_Device::push_current(Fl_Display_Device::display_device()); + gl_font(face, fsize); + Fl_Surface_Device::pop_current(); +} + void Fl_OpenGL_Graphics_Driver::draw(const char* str, int n, int x, int y) { gl_draw(str, n, x, y); } +double Fl_OpenGL_Graphics_Driver::width(const char *str, int n) { + Fl_Surface_Device::push_current(Fl_Display_Device::display_device()); + double w = fl_width(str, n); + Fl_Surface_Device::pop_current(); + return w; +} + +int Fl_OpenGL_Graphics_Driver::descent() { + Fl_Surface_Device::push_current(Fl_Display_Device::display_device()); + int d = fl_descent(); + Fl_Surface_Device::pop_current(); + return d; +} + +int Fl_OpenGL_Graphics_Driver::height() { + Fl_Surface_Device::push_current(Fl_Display_Device::display_device()); + int h = fl_height(); + Fl_Surface_Device::pop_current(); + return h; +} + +void Fl_OpenGL_Graphics_Driver::text_extents(const char *str, int n, int& dx, int& dy, int& w, int& h) +{ + Fl_Surface_Device::push_current(Fl_Display_Device::display_device()); + fl_text_extents(str, n, dx, dy, w, h); + Fl_Surface_Device::pop_current(); +} + #endif |
