Jump to content

  • Log In with Google      Sign In   
  • Create Account


Need to support OGL 1.4 retrospectively... (NPOT Problem)


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
5 replies to this topic

#1 FlyingSolo   Members   -  Reputation: 114

Like
0Likes
Like

Posted 17 May 2012 - 08:41 AM

Hi all, please excuse this confused ogl newbie.

Having written an app which happily runs on all the hardware it was meant to, all of which support OGL 2.1 or better, I had used a great many NPOT image files for my textures.

I now need to add support for a wretched ASUS EeeeeeePC which only supports OGL 1.4 and has none of the hoped for rectangle extensions at all. Thanks Intel, love ya.

Is there a way I can munge my images on load to get around this? I'm sure I'm not the first person to fall foul of a situation like this but Googling hasn't helped me in any constructive way.

Converting the images (and the code that uses them) to be POT compatible is out of the question.

Thanks :)

Sponsor:

#2 Tachikoma   Members   -  Reputation: 548

Like
1Likes
Like

Posted 17 May 2012 - 09:33 AM

Converting the images (and the code that uses them) to be POT compatible is out of the question.


While reading the NPOT textures from file, you could resample them to the nearest POT dimensions in software. If you don't want to lose detail, you might want to resample up only, rather than nearest.

After buffering the resulting POT textures to GL, use a texture matrix to scale the bound textures to the correct aspect ratio on the geometry.

Edited by Tachikoma, 17 May 2012 - 09:34 AM.

Latest project: Sideways Racing on the iPad

#3 szecs   Members   -  Reputation: 2095

Like
1Likes
Like

Posted 17 May 2012 - 09:57 AM

Converting the images (and the code that uses them) to be POT compatible is out of the question.


While reading the NPOT textures from file, you could resample them to the nearest POT dimensions in software. If you don't want to lose detail, you might want to resample up only, rather than nearest.

After buffering the resulting POT textures to GL, use a texture matrix to scale the bound textures to the correct aspect ratio on the geometry.


Resampling AND altering the texture coordinates at the same time will screw the rendering. Either resampling or modifying the texture coordinates.

#4 mhagain   Crossbones+   -  Reputation: 7436

Like
1Likes
Like

Posted 17 May 2012 - 11:54 AM

The old gluBuild2DMipmaps will do the resize automatically for you, in exchange for you losing all control over how the resizing is done. You'll likely want to replace this with your own resample function for production/release, but it remains a means of finding out how well (or not so well) this is going to work out, and that doesn't require a huge amount of code work on your part.

It's actually slower than just resizing and loading yourself, so be aware of that up-front and don't be put off by the fact that your textures now take X times as long to load as they previously used to.

An alternative, for images that don't need to repeat, is to pad the image to the nearest powers of two, then do the texture matrix trick mentioned above.

Edited by mhagain, 17 May 2012 - 11:55 AM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#5 slicer4ever   Crossbones+   -  Reputation: 3205

Like
0Likes
Like

Posted 18 May 2012 - 10:07 PM

I'd recommend modifying the texture matrix as the best solution, this means no loss in detail, although large textures might give you quite a bit of overhead(i.e a 1025x1025 would result in a 2048x2048 padded texture).
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#6 FlyingSolo   Members   -  Reputation: 114

Like
0Likes
Like

Posted 23 May 2012 - 03:03 PM

Apologies for the tardy catch-up.. life gets in the way sometimes!

Thanks for the helpful pointers, I'll have a memory-refresh from the Red Book and try your suggestions.

Cheers :)




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