RadekH
06-05-2012, 02:13 AM
I need to display text in an OpenGL window. I have tried FTGL but I got GP fault immediately in font->FaceSize(size). I am using Debian and wxWidgets.
- the OpenGL window is a part of a frame window (a "control"). This should work. I have written more such OpenGL apps and they work.
- the crashing code:
void MyCanvas::InitGL()
{
int argc = 0;
bool bb;
fnt = new FTGLPixmapFont("/usr/share/fonts/truetype/ttf-liberation/LiberationSans-Regular");
glutInit(&argc,NULL);
glClearColor(0.0,0.0,0.0,1.0);
bb = fnt->FaceSize(72); // crash
}
- InitGL() is called from the OnPaint handler of the OpenGL window. The code above is the first touch to OpenGL and FTGL in the app. It is known that in wxWidgets, the first OpenGL call must be made from this handler. You get a GP fault otherwise.
- OpenGL Device Context is set.
- Creating the font passes, the debugger shows a non-NULL pointer. In fact, the font may be created in the MyCanvas ctor.
- GLUT: I have noted that FTGL examples search for GLUT so I tried glutInit() but it solves nothing.
- fnt->FaceSize() causes GP fault. The debugger states that the fault is in FTSize::CharSize() of FTGL. The end.
If I comment out the crashing statement, I get a GP fault in fnt->Render(). Something is wrong with my coding, I was able to compile and run FTGL examples on my comp - but they are GLUT apps which use GLUT window and GLUT controlling of the app, I cannot use this.
What might be wrong?
- the OpenGL window is a part of a frame window (a "control"). This should work. I have written more such OpenGL apps and they work.
- the crashing code:
void MyCanvas::InitGL()
{
int argc = 0;
bool bb;
fnt = new FTGLPixmapFont("/usr/share/fonts/truetype/ttf-liberation/LiberationSans-Regular");
glutInit(&argc,NULL);
glClearColor(0.0,0.0,0.0,1.0);
bb = fnt->FaceSize(72); // crash
}
- InitGL() is called from the OnPaint handler of the OpenGL window. The code above is the first touch to OpenGL and FTGL in the app. It is known that in wxWidgets, the first OpenGL call must be made from this handler. You get a GP fault otherwise.
- OpenGL Device Context is set.
- Creating the font passes, the debugger shows a non-NULL pointer. In fact, the font may be created in the MyCanvas ctor.
- GLUT: I have noted that FTGL examples search for GLUT so I tried glutInit() but it solves nothing.
- fnt->FaceSize() causes GP fault. The debugger states that the fault is in FTSize::CharSize() of FTGL. The end.
If I comment out the crashing statement, I get a GP fault in fnt->Render(). Something is wrong with my coding, I was able to compile and run FTGL examples on my comp - but they are GLUT apps which use GLUT window and GLUT controlling of the app, I cannot use this.
What might be wrong?