Advertisement

Loading a Background Image of Unusual Size

Started by July 06, 2001 11:19 AM
5 comments, last by tesanders 23 years, 7 months ago
Hello. I''m trying to load an 800x600 image for use as a background. From what I gather, I''ll need to actually save this as a 1024x1024 image and load it in that way. (Or write a function that loads the 800x600 image in, converts it to 1024 square, and then calls glTexImage2D) However, this seems somewhat inelegant. Is my understanding of this correct, or is there some other way to do it? Thanks, Thomas
Try using a 512x512 image/texture.. it''ll be a little blurred but you won''t notice that...

1024x1024 is overkill.

btw. You can use gluScale(..) to scale the image.
Advertisement
Yeah, I think that''ll work out just fine for some of the backgrounds; in fact, blurring is preferred in some instances. In others, I''m trying to get a crisp image, such that every pixel is displayed. As you say, 1024 is overkill; while 512x512 is too small for some cases, I''d hate to store all that extra info for 1024x1024 when all I need is 800x600.

- Thomas
I know you can load textures of size 16n by 16m if you use mipmapping(at least in Windoz). (I use 3 mipmap levels, maybe number of levels is also important). I am not sure whether it will work in big images or not but you can use 800x608 (608 = 16*38) image and say if you use 3 levels of mipmapping you need 800*608*(1+1/4+1/16+1/32) =~ 4/3*800*608, which is not a bad price to pay for desired resolution.
tesanders, you can of course use more images but I don't think it's worth it because that 512x512 image will look just as fine.



Edited by - Richardve on July 7, 2001 4:29:01 AM
If you want to preserve the quality of your image--and you should--this is what you need to do:

Break up the image into tiles at run-time:
- load your image into a buffer (an array)
- determine the maximum texture size using glGetInteger
- create as many buffers are necessary to break up the image into a series of squares sized at the maximum texture size
- make separate textures out of each one of the squares

To display the image, just draw all of the tiles in the proper order. With most new cards, there''ll be no need to break up the image at all, so make sure you deal with that possibility. Otherwise, people with Voodoos are stuck with the 256x256 limit, which is why you must break up the image into multiple textures.

Now, you may not need that much quality, but if you do, that''s how to do it in a way that will work on all machines since it makes no assumptions.
Advertisement
Makes perfect sense; thanks!

- Thomas

This topic is closed to new replies.

Advertisement