Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Bucket_Head

Overcoming OpenGL's Insidious Texture Limitations

This topic is 6308 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

One of the only things that I don''t like about OpenGL is that annoying power-of-two, 256x256 texture limitation...What gives with that, anyhow? Why exactly is there such a limitation? I imagine it has something to do with efficiency of texture memory storage and/or transfer...But it still seems somewhat rediculous. The main issue I''d like to understand how to address is that of overcoming these limitations. How does one do this? When left to my own imagination, I considered some sort of funky routine that involves breaking a large or non-uniform image up into chunks, and peicing those image chunks appropriately onto the geometry as you wish them to appear...Though the idea of trying to figure out such an algorithm gives me a headache. Is there a much easier way? Possibly even one built into OpenGL? A coder friend of mine seems to be loading in a 1024x768 image without even knowing how he''s doing it, and the idea that he accidentally stumbled on a solution astonishes me. Maybe he got some bitmap loading routine from somewhere that automatically solves this problem, I don''t know... Anyways, this would clear up a large stumbling block, and allow me (and anyone else reading this who''s wondering) to make everything look so much better with high-resolution textures. That, and I wouldn''t have to re-size textures for some md2 files to load in my program, heh...I always thought that was annoying... So please help me! How do I overcome...OpenGL''s Insidious Texture Limitations?!? Thank you for your time. - Bucket - Hai, watashi no chichi no kuruma ga oishikatta desu! ...or, in other words, "Yes, my dad''s car was deliscious!"

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
OpenGL does NOT limit texture size to 256x256 (if something limits, then it must be your graphics card).
Use the OpenGL glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize); call to determine maximum texture for a specific OpenGL implementation on a specific graphics card.
And texture maps aren''t limited to power-of-two either.


-t33

Share this post


Link to post
Share on other sites
Anonymous poster is right.

AFAIK power of two limitation in hardware is to avoid page break and reduce computations for texture mapping.


-* So many things to do, so little time to spend. *-

Share this post


Link to post
Share on other sites
You can use any size, but some cards don''t support that. You should stick with powers of two for compatibility.

The resons powers of two are used are so that a pixel can be found quickly by using bitshifting, ie, a pixel in a 32 bit 256x256 texture can be found with x<<2+y<<10 and the next 4 bytes are the colour. Bitshifting is faster than multiplying.

Share this post


Link to post
Share on other sites
You can load a non-power of 2 texture into a "best fit" power of 2 surface and then use modified texture coordinates to reference only the image portion. You can also load multiple images into a texture surface and use modified texture coordinates to reference the various subregions as needed. Instead of using 4 256x256 texture and requiring 4 texture changes, use 1 1024x1024 texture with no texture changes.


"That ones free, the next one is gonna cost ya"

Share this post


Link to post
Share on other sites
only the voodoo1/2/3 and some other early noname cards have this limitation my vanta(tnt2) can handle 2048x2048 textures. either as ppl have said break the texture up or rescale the image. u can use gluBuildMipmaps(..) to do this

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
Better yet, why not just put your say 47x256 texture in a 256x256 one, then when it comes to texture mapping your objects, use the desired texture co-ords which define the position of the 47x256 texture in the 256x256 one?

Share this post


Link to post
Share on other sites
There is a trick that I use sometimes if I have a specific sized texture that I want to map to a specific sized quad.

Lets take a splash screen for example. I create a splash screen at 1024x768. Now I want to map it to a fullscreen quad.

First I load it in PhotoShop and change the Image Size to 512x512. This makes it look all scrunched up. But when I map it to a quad that takes up the full screen, it stretches it back out and it looks right again And it will look right on any standard resolution.

I lose a little bit of precision but PhotoShop does an excellent job of making it unnoticable.

Seeya
Krippy

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!