Displaying bitmaps NOT using textured quads,
Members - Reputation: 193
Posted 07 August 2001 - 12:14 PM
Members - Reputation: 528
Posted 07 August 2001 - 02:49 PM
create a 256x128 sized texture
draw a 200x100 sized image in the bottom left corner
get the idea?
Members - Reputation: 756
Posted 08 August 2001 - 05:12 AM
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... ^-^
Members - Reputation: 130
Posted 08 August 2001 - 05:58 AM
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
Members - Reputation: 528
Posted 25 August 2001 - 08:04 PM
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)
Posted 25 August 2001 - 11:27 PM
It is a bit strange, but PC hardware is faster with 3D than 2D...
Members - Reputation: 560
Posted 29 August 2001 - 08:12 PM
Do you ever watch the History channel, where the camera pans across an old photograph or something? SURPRISE! That photograph is actually a real life 3d object displayed as a 2d image on the television. Same concept.
Members - Reputation: 140
Posted 31 August 2001 - 10:50 AM
Here''s a technique that will draw any size sprite on an opengl screen.
1) Determine the size of the sprite. (30pixels x 40pixels)
2) Find the closest ^2 that the sprite will fit into. for the 30x40 example it would be 32x64.
3) Make a texture the size of the ^2(32x64) and paint the sprite(30x40) onto the corner.
4) Draw a quad with the texture, but the the texture coordanites set correctly.
You can also use one giant 1024x1024 texture with all your sprites on it and use the appropriate texture coordanites.
You''d really be better of using an API that will allow you direct access to blitting and pixels like DirectDraw, or if your using LINUX or another real OS Allegro or SDL.
The only reason you should stick to opengl is if your going to be doing heavy alpha blending or antialiasing or rotations.