Fri, 20 Aug 2010

# How to use glutBitmapCharacter in Perl

glutBitmapCharacter is an OpenGL function used to display a single character. The C function signature looks like this:

void glutBitmapCharacter(void *font, int character);

Seeing this, it should be clear that you have to call it from Perl with a numeric character value:

glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, ord('J'));

The trick is to use ord to convert the character to the character code. Don't try without or you'll just see the background color and no error message. I just lost nearly an hour over this simple thing, which is not so obvious if you just look at C examples. But 'J' are two very different things in Perl and C.

posted at 11:35 | path: /gl | permanent link to this entry

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.