Jump to content

  • Log In with Google      Sign In   
  • Create Account

Displaying bitmaps NOT using textured quads


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 griffenjam   Members   -  Reputation: 193

Like
Likes
Like

Posted 07 August 2001 - 12:14 PM

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 ------------------------------

Sponsor:

#2 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 07 August 2001 - 02:49 PM

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?

#3 Nairb   Members   -  Reputation: 436

Like
Likes
Like

Posted 08 August 2001 - 05:12 AM

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

#4 gmcbay   Members   -  Reputation: 130

Like
Likes
Like

Posted 08 August 2001 - 05:58 AM

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

#5 wolfman8k   Members   -  Reputation: 140

Like
Likes
Like

Posted 09 August 2001 - 04:58 AM

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.

#6 griffenjam   Members   -  Reputation: 193

Like
Likes
Like

Posted 09 August 2001 - 09:10 AM

Now thats helpfull advice

#7 Nazmir   Members   -  Reputation: 122

Like
Likes
Like

Posted 25 August 2001 - 07:56 PM

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.

#8 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 25 August 2001 - 08:04 PM

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)

#9 Yorvik   Members   -  Reputation: 122

Like
Likes
Like

Posted 25 August 2001 - 10:37 PM

quote:

I wouldn''t write a 2D game in OpenGL.



why not?

#10 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 25 August 2001 - 11:27 PM

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...

#11 smitty1276   Members   -  Reputation: 560

Like
Likes
Like

Posted 29 August 2001 - 08:12 PM

If you''re writing a "2D" game it''s going to be 3D anyway, as far as the hardware is concerned. You''re just going to be texturing flat quads in 3d space.

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.

#12 wolfman8k   Members   -  Reputation: 140

Like
Likes
Like

Posted 31 August 2001 - 10:50 AM

I guess I''ll help you out a bit...

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS