Jump to content
  • Advertisement
Sign in to follow this  
aewarnick

OpenGL Save memory but preserve image quality

This topic is 4907 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

I guess alot of times people will create an opengl texture by shrinking an image inproportionalately thus destroying the original quality. How can I use blocks of textures to keep the original image and save memory at the same time? Can I use 12x12 textures or something and pad the right and bottom textures if need be? Then when I draw those textures, somehow specify to not draw the whole texture?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Can I use 12x12 textures or something and pad the right and bottom textures if need be?

I'm not exactly sure what you mean, but without using extensions you can't use a 12x12 texture, the dimensions need to be powers of two.
Quote:
Then when I draw those textures, somehow specify to not draw the whole texture?

Just use texture coordinates to specify the rectangular shape of the texture you want to draw (ie: [0, 0.5] instead of [0,1] for half the texture).

Now, with all that said it seems like you are trying way too hard to conserve memory. And splitting a texture up into separate texture blocks and padding the unused parts (assuming that's what you were thinking of doing, I'm not sure) would use up more memory anyway. Just look into texture compression. You will save a great deal of texture memory, not have to worry about splitting up textures or using weird texture coordinates, and the loss of detail due to the compression is very minimal, probably unnoticable unless you are specifically looking for it.

Share this post


Link to post
Share on other sites
I just saw an example called Masking and Ortho Mode.
It is a 3-D example with brick walls and a crosshair drawn in Ortho Mode.
What is interesting is that the images are 320x240 and I don't think either of them are powers of 2. Does this mean that I can draw textures of any size with opengl?

Share this post


Link to post
Share on other sites
Quote:
Original post by aewarnick
Does this mean that I can draw textures of any size with opengl?


Yes. As I said in my other post, you can with extensions. The extensions that let you use non-power-of-two (NPOT) textures are GL_ARB_texture_rectangle and GL_ARB_texture_non_power_of_two.

That tutorial probably uses gluBuild2DMipmaps() to make the textures, which resizes the image to a power of two before sending it to OpenGL so there is no need for extensions.

Share this post


Link to post
Share on other sites
Sign in to follow this  

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