I have a 3d engine going now, and am getting
172 frames per second ( hooray! ).
I wrote some code to draw non transparent
2d pixmaps ( gui dialogs ) over the whole thing and the fps drops to 14 fps.
Surely 2d bitmaps are the most basic function
going. Why am I getting such a performance hit.
The draw method for my bitmap class follows.
void draw( int x,int y,int z )
{
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
gluOrtho2D( 0,640,0,480);
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();
glRasterPos2i( x,
460-y- BitmapInfo.bmiHeader.biHeight>>1) );
if ( !_transparent )
{
glDisable( GL_BLEND);
glDrawPixels( _BitmapInfo.bmiHeader.biWidth,
_BitmapInfo.bmiHeader.biHeight,
GL_BGR_EXT,GL_UNSIGNED_BYTE,_BitmapBits );
}
else
{
glBlendFunc( GL_SRC_ALPHA,
GL_ONE_MINUS_SRC_ALPHA);
glEnable( GL_BLEND);
glDrawPixels( _BitmapInfo.bmiHeader.biWidth,
_BitmapInfo.bmiHeader.biHeight,
GL_RGBA,GL_UNSIGNED_BYTE,_BitmapBits );
glDisable( GL_BLEND);
}
glPopMatrix();
glMatrixMode( GL_PROJECTION );
glPopMatrix();
glMatrixMode( GL_MODELVIEW );
}
I apologise for the formatting…
Basically, if the bitmap is transparent,
blending is enabled and disable if not transparent.
The biggest hit, is for a 128x64 non transparent bitmap
dd