Hi, I’m having some problems trying to draw a bitmap to screen. This is probably really stupid, but I’m really new to OpenGL and I wasn’t even able to google for an appropiate answer to my problems.
I’m trying to draw a xbm image containing a simple font to screen. I just want the simplest and smaller way of using a pixelated font. I made a simplified version of the image just to test the drawing functions:
#define pong_font_width 4
#define pong_font_height 4
static unsigned char pong_font_bits[] = {
0x09, 0x00, 0x00, 0x01 };
That should draw to something like
X__X
____
____
X___
Where “X” is black and “_” is white.
The closer I got to properly rendering the image was with glBitmap, but
the result is inverted vertically, and glPixelZoom doesn’t make any effect in making the image bigger or inverting it.
glRasterPos2f((MI_WIDTH(mi)-pong_font_width*8)/2, MI_HEIGHT(mi)*8/10);
glBitmap( pong_font_width, pong_font_height,
0, 0, 0, 0,
pong_font_bits );
The proper method if I want to be in control of the zoom factor is probably glDrawPixels, but I can’t find the combination of parameters to properly render it.
This code renders nothing, and the closer I got to something useful was drawing some multicolor random garbage (I don’t remember with wich parameters).
glPixelStorei(GL_UNPACK_LSB_FIRST, 1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glEnable(GL_COLOR_TABLE);
static unsigned char colors[] = { 0x01, 0x00, 0x00, 0x00 };
glColorTable(GL_COLOR_TABLE, GL_RGB8, 1, GL_RGB, GL_UNSIGNED_BYTE, colors);
glRasterPos2f( (MI_WIDTH(mi)-pong_font_width*8)/2, MI_HEIGHT(mi)*8/10 );
glPixelZoom( 8.0, 8.0 );
glDrawPixels( pong_font_width,
pong_font_height,
GL_COLOR_INDEX,
GL_BITMAP,
pong_font_bits2 );
Could anybody help me out? I’m pretty sure I’m not understanding some basic concept about OpenGL rendering here.