LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: elias4444 on September 26, 2005, 20:37:42

Title: Drawing a simple static background image
Post by: elias4444 on September 26, 2005, 20:37:42
I want to simply draw a large background image behind everything (something like a nice scenic picture or a snapshot from the game for a menu backdrop). What's the most efficient way to do this? I've thought of the following, but if someone else has a better idea, please let me know:

1. Take a LARGE image (like 1024x1024 pixels or higher) and texture map it to a large rectangle set behind everything.

or

2. Use the GL11 glBitMap function (which I've never used)

or

3. Something better.  :)

Any ideas/help is appreciated.
Title: hmmmmmmm...
Post by: Fool Running on September 27, 2005, 13:10:40
I think the fastest way (i.e. the best  :lol: ) is to do #1.
I think every time you call glBitMap() it transfers the bitmap to the graphics card (someone can correct me) which is slow.
Title: Drawing a simple static background image
Post by: elias4444 on September 27, 2005, 14:15:38
I've been doing some benchmarking, and the texturemap is definitely faster... I'm just worried about using such a large texture.  :?
Title: Drawing a simple static background image
Post by: Matzon on September 27, 2005, 14:38:34
anything above 512 will break on matrox
Title: Drawing a simple static background image
Post by: CaseyB on September 27, 2005, 17:50:54
I've been doing some benchmarking as well with displaying images in OpenGL vs. Java2D and it appears that Java2D is actaully faster!  I can't image why that would be!  It seems to me that Java2D would have the image in main memory and have to transfer that to the video card as in the glBitMap() case so OpenGL should (in the worst case) be as fast as Java2D, but in my tests it's not!
Title: Drawing a simple static background image
Post by: tomb on September 27, 2005, 20:32:39
Java2D uses HW acceleration if you follow some strict rules, or enable non-default pipelines. In wich case it's the same as rendering a texture in OpenGL. Should be roughly the same speed.
Title: Drawing a simple static background image
Post by: WiESi on September 28, 2005, 10:41:37
Quote1. Take a LARGE image (like 1024x1024 pixels or higher) and texture map it to a large rectangle set behind everything.

I would recommend you to use GL_TEXTURE_RECTANGLE_ARB or GL_TEXTURE_RECTANGLE_EXT or GL_TEXTURE_RECTANGLE_NV because it uses less memory and you can choose the size of the image at your own... and it looks better. Maybe using compressed textures would still use less memory but I don't have any experience with that stuff.

WiESi
Title: Drawing a simple static background image
Post by: oNyx on September 28, 2005, 11:49:20
Quote from: "Matzon"anything above 512 will break on matrox

Anything above 256 will break on voodoo :D

Well, there are like a dozen ways to do this. If its say... 1024x768, I would use a 1024x512 texture and a single quad. Or a 1024x512 and a 1024x256 texture and two quads.

Or you could use a 4x3 grid with 256x256 textures. Or a 2x1 grid with 512x512 and a 2x1 grid with 512x256.