PDA

View Full Version : 2D user interface



Murray
08-14-2004, 05:25 AM
Hi

I am trying to write a 2d user interface for the simple game engine I am coding.
I am wanting to reprisent each element of the UI ( buttons menus etc) as simple bitmaps.

What is the best way to draw these 2D elements in opengl?

Using glDrawPixels seems to be painfully slow and if I draw them as a textured quad the size of the texture is limited to 2^n x 2^n which increases the size of my files hugely.

Why is glDrawPixels so slow? it seems very strange that it is faster to transform, texturemap and draw a quad than to blit the pixels straight ot the frame-buffer.

Can anyone offer advice on what is the best way to render these 2D elements.

Many Thanks
Murray

08-14-2004, 07:01 AM
Alas, to have decent speed with drawpixels, you have to pay for a professional card (ie quadro for nvidia).
Consumer cards are optimized for quake3, Doom3...
So you have to go with textured quads. About the size of textures, don't worry too much about it : You can still have a non-power of two image file, that you put on the higher left corner of a power of two texture (it can be rectanble, ie 16x64). Let the remaining parts as black, and use ajusted texture coordinates.

I think you can find existing lib for GUIs running on top of opengl, maybe GLUI.

Obli
08-14-2004, 07:03 AM
Originally posted by Murray:
What is the best way to draw these 2D elements in opengl?I also raccomand a bunch of vertices and a texture. It's what our UI manager is doing.

Originally posted by Murray:
Why is glDrawPixels so slow? it seems very strange that it is faster to transform, texturemap and draw a quad than to blit the pixels straight ot the frame-buffer.It's because DrawPixels transfers the whole thing over the bus while the texture is in persistent server-side memory.