wxGLCanvas with opengl text (to glut or not to glut)  [SOLVED]

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
mimosa
Knows some wx things
Knows some wx things
Posts: 28
Joined: Mon Sep 08, 2014 6:16 pm

wxGLCanvas with opengl text (to glut or not to glut)

Postby mimosa » 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):

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);
}

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?)

User avatar
doublemax
Moderator
Moderator
Posts: 10923
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxGLCanvas with opengl text (to glut or not to glut)

Postby doublemax » Tue Dec 16, 2014 11:56 pm

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'd guess that the glut32.dll is not found.

Alternatively, try wxGLString:
viewtopic.php?f=20&t=22453
Use the source, Luke!

mimosa
Knows some wx things
Knows some wx things
Posts: 28
Joined: Mon Sep 08, 2014 6:16 pm

Re: wxGLCanvas with opengl text (to glut or not to glut)  [SOLVED]

Postby mimosa » Wed Dec 17, 2014 12:53 am

It appears that while I was able to compile the glut library with mingw32-make, it didn't make a "good" library.. (for the lack of better words). I found a pre-compiled version for glut for Windows platforms (both .a and .h files) and when I link with this pre-compiled version downloaded from a third party link, my program doesn't crash.. I'll have to investigate the reason why glut didn't compile correctly (not giving errors).. this is strange. But lesson learned, test your library when you compile one, before putting it in your projects..


Return to “General Development”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest