开发者

glBitmap questions

I'm working with a legacy piece of code in some stuff for work which uses glBitmap() calls to draw bitmap icons. My issue is that it's rather slow once you get to drawing about 1000 icons at once. It slows down to about a 1- to 2-second refresh rate, and I'd like to see if I can make it faster than that.

First I should probably describe how the current code works. The bitmap icons are 32x32 images with one bit per pixel, pre-loaded into memory. For each icon being drawn, the code does:

glNewList glRasterPos2f glBitmap glEndList

and then glCallList() is cal开发者_开发技巧led on the display list. I know that calling glCallList() repeatedly like this for each icon can be really slow, but some overlying architecture in the code makes changing that pretty difficult.

Are there any other ways I can speed this up without rearchitecting the whole thing? I have pretty much free reign to do that kind of thing, but I have to be able to justify it to management. Would changing from glBitmap() to using something like texture-mapped quads be any faster? Can I stick multiple calls to glBitmap() in a single display list and just call glCallList() once for all of the icons?

I've done a bit of GL stuff in the past but it's been a while. I'm pretty rusty but I can figure most of it out.


Textured quads all the way. I used that for rendering text (axis numbers for graphs) and got 60 FPS with several hundred digits on-screen, with Intel integrated video (a couple years ago, so it was GMA945 generation).

Put all the icon content into a single texture too, and just call glTexCoord to pick out the part you want, then you avoid switching textures.

BTW since your icons are monochrome (and for grayscale as well), store them in the texture's alpha channel and then you can choose the actual color when you output the quads.


Agreed : use screen-aligned quads. Set up your modelview matrix to identity and your projection matric to gluOrtho(0,0, 800, 600, 1,-1). Draw your quads at (x,y,0). (beware of their orientation)

Never use display list, they are a nightmare to maintain for drivers developpers and may not be stable

Never use glBitmap or any other function that directly access the framebuffer (glGetPixels & co )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜