|
|
About the present texture-based Mac OS implementation
of text drawing in OpenGL windows.
There was a bug in the Mac OS 1.3 version where gl_draw() would fail
after an Fl_Gl_Window was deleted and recreated. The pre-computed
texture was re-used to draw in the new window, and this would fail.
I have implemented in r. 8536 a fix that invalidates the pile
of pre-computed textures when any Fl_Gl_Window is deleted.
This fixes the bug.
But, isn't there a better and less drastic solution ?
This short program displays the bug (before r.8536):
// run, then press 'd'
// - expected behaviour: the string is unchanged after pressing d
// - observed behaviour: the string is replaced by a rectangle
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Tile.H>
#include <FL/Fl_Gl_Window.H>
#include <FL/gl.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif
class openglWindow : public Fl_Gl_Window{
public:
openglWindow(int x, int y, int w, int h) : Fl_Gl_Window(x, y, w, h){}
void draw()
{
glClearColor(0.5, 0.3, 0.8, 0.);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glRasterPos2d(0, 0);
gl_font(0,20);
gl_draw("A string");
}
};
Fl_Tile *tile;
int shortcuts(int event)
{
if(Fl::test_shortcut('d')){
tile->clear();
openglWindow *gl = new openglWindow(0, 0, 400, 400);
gl->end();
gl->mode(FL_RGB | FL_DEPTH | FL_DOUBLE);
tile->add(gl);
gl->show();
}
return 1;
}
int main(int argc, char **argv)
{
Fl_Window *win = new Fl_Window(0, 0, 400, 400);
tile = new Fl_Tile(0, 0, 400, 400);
openglWindow *gl = new openglWindow(0, 0, 400, 400);
gl->end();
gl->mode(FL_RGB | FL_DEPTH | FL_DOUBLE);
tile->end();
win->end();
win->show(argc, argv);
Fl::add_handler(shortcuts);
Fl::run();
}
[ Direct Link to Message ] | |
|
| |