wxGLCanvas with opengl text (to glut or not to glut)
Posted: Tue Dec 16, 2014 11:47 pm
Hi
wxWidgets version: 3.0.2
platform/OS: Windows 7 64 bit
compiler: mingw32-gcc
I have a wxWidgets frame based project, with a panel for opengl derived from wxGLCanvas. I can draw nice shapes, background, etc, even track the mouse, but now I want to draw text and I'm not sure where to start. I might want to stay away from glut (or should I not?) because while I got glut library to compile with mingw32 and link to my project (statically), it crashes on "glutBitmapCharacter" in the following snippet (assume that the arguments are valid):
and the error is:
The application was unable to start correctly (0xc0000142). Click OK to close the application.
the error does not show up if I comment out the line with glutBitmapCharacter. The str variable is populated with valid text.
I can draw some text with the non-opengl context after the call to SwapBuffers but the graphic flickers, and it's not pretty nor efficient if I want to draw lots of text (because the regular context has no display list) and so I'd rather draw the text in opengl context. How can I do that? (Can I get away without glut and only using wxwidgets classes and regular call to opengl functions?)
wxWidgets version: 3.0.2
platform/OS: Windows 7 64 bit
compiler: mingw32-gcc
I have a wxWidgets frame based project, with a panel for opengl derived from wxGLCanvas. I can draw nice shapes, background, etc, even track the mouse, but now I want to draw text and I'm not sure where to start. I might want to stay away from glut (or should I not?) because while I got glut library to compile with mingw32 and link to my project (statically), it crashes on "glutBitmapCharacter" in the following snippet (assume that the arguments are valid):
Code: Select all
void DrawTextFunction(double x, double y, char* str)
{
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glRasterPos2f(x, y);
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[0]);
glDisable(GL_TEXTURE_2D);
}
The application was unable to start correctly (0xc0000142). Click OK to close the application.
the error does not show up if I comment out the line with glutBitmapCharacter. The str variable is populated with valid text.
I can draw some text with the non-opengl context after the call to SwapBuffers but the graphic flickers, and it's not pretty nor efficient if I want to draw lots of text (because the regular context has no display list) and so I'd rather draw the text in opengl context. How can I do that? (Can I get away without glut and only using wxwidgets classes and regular call to opengl functions?)