Displaying bitmaps NOT using textured quads

Started by
10 comments, last by griffenjam 22 years, 7 months ago
I want to display bitmaps, but all the info I find on doing it says to use either textured quads or glDrawPixels(). I don''t like textured quads be it requires that all bitmaps have sizes in powers of 2 (I think) and I head that glDrawPixels is slow (true?). So if YOU were writing a 2D game in OpenGl what would YOU do? Jason Mickela ICQ : 873518 E-Mail: jmickela@pacbell.net ------------------------------ "Evil attacks from all sides but the greatest evil attacks from within." Me ------------------------------
"The paths of glory lead but to the grave." - Thomas GrayMy Stupid BlogMy Online Photo Gallery
Advertisement
example
create a 256x128 sized texture

draw a 200x100 sized image in the bottom left corner

glBegin( GL_QUADS)
glTexCoord(0,0) glVertex3fv(corner1);
glTexCoord(0,100.0/128.0) glVertex3fv(corner2);
glTexCoord(200.0/256.0,100.0/128.0) glVertex3fv(corner3);
glTexCoord(200.0/256.0,0) glVertex3fv(corner4);
glEnd();

get the idea?
Hi,
I believe OpenGL has a function to display just standard bitmaps, but I''m not sure how it works...
However, the Windows API has a function to display a bitmap...BitBlt ;-) However, that''s really slow.

I would use textured quads in a 2D game...Powers of 2 texture sizes isn''t much of a restriction. If you don''t have images that are powers of 2, simply resize the image''s canvas and don''t use the blank space...
I think I explained that clear enough... ^-^

--nairb
Yes, glDrawPixels is generally slow (on consumer PC hardware, on old SGI systems it was pretty speedy).

The best way to do it is to use textured quads. The best way to use textured quads is to write a bitmap manager that will take care of the details once and reuse this all over.
Some of the things the bitmap manager can do, if it is designed and programmed well:

Load multiple smaller sprites onto single larger power-of-2 textures (sort of like sprite managers that load multiple sprites onto one big DirectDraw surface). This helps reduce video memory wastage. Then you can use the texture matrix and uv mapping to only display part of the larger texture on specific quads.

Handle very large bitmaps by splitting them up into multiple textures. The bitmap manager should always heed the maximum texture size for the current card (which can be as little as 256 for 3dfx cards). If the bitmap is too large for one texture, it should split the bitmap into N textures and then either use a multitexture/multipass method on a single quad the size of the bitmap, or (usually the better choice) draw multiple quads, each mapped with part of the large bitmap.



Anyway, that's what I would do. All in all I agree that its quite silly that there isn't a better/faster OpenGL 2D interface. D3D/DD do a pretty decent job of working together (or did, before Microsoft dropped DD in DX8). There's slowdown involved because of stalls when doing 2D operations, but its nowhere near the insanely slow performance that is common when using the OpenGL glDrawPixels interface.


Edited by - gmcbay on August 8, 2001 1:00:42 PM
quote:Original post by griffenjam
So if YOU were writing a 2D game in OpenGl what would YOU do?


I wouldn''t write a 2D game in OpenGL.
Now thats helpfull advice
"The paths of glory lead but to the grave." - Thomas GrayMy Stupid BlogMy Online Photo Gallery
You''re bitmaps don''t have to always be a power of 2, if you make the texture a mipmapped texture you can get around that restriction.
yes they do
gluBuildMipMaps(..) calls gluScaleImage which resizes your image to powers of 2.
note with geforces + perhaps other new cards ''radeon?'' u can use non power ofd2 sized images but there are restrictions eg no mipmaps (though for a 2d game this aint important)
quote:
I wouldn''t write a 2D game in OpenGL.


why not?
Why don''t you want to use "powers of 2" sprites? It may simplify collision detection...

It is a bit strange, but PC hardware is faster with 3D than 2D...

This topic is closed to new replies.

Advertisement