Questions about dealing with non power of two textures

Hi all.
i’m aware that textures in opengl es 1.x need to be POT in size.
Now i’m working on an app where you can load a picture (from user albums) and insert
that pic on a scene with other objs/textures etc. so i need to find a way for dealing with
those images which size i can’t control.
my first thought was that i would have to open the file, adjust its size, annotate the offsets and then load the modified version.
but i have the impression this is brute force. what can we do on a case like this??

Thanks for any suggestions.

You can use subTexLoad to place the image into one corner of a larger map - then adjust your texture coordinates to render only that part of the map.

you mean glTexSubImage2D? i see it says “redefines a contiguous subregion of an existing two-dimensional texture image”.
so i can say that if we get an 260x260 image, then its possible to take the 256x256 part for texturing. is this correct?. what about expand to 512 and prevent cutting (of course this will cause waste of space.)

glTexSubImage2D - yeah, I always forget the name of that darned function!

Anyway - it won’t let you write a 260x260 into a 256x256 map - but it will let you load it into the bottom-left corner of a 512x512 map (and, yes, you’d have a gigantic amount of wasted space). Then, when you use that to texture a polygon, instead of your texture coordinates going from 0…1, they’d have to go from 0 to (260.0/512.0).

Thanks, its more clear now what i can do.

it will be just one pic that is going to pass through this process so i guess i’ll sacrifice that space.

You can also use a texture atlas, you can place several images into a single pot texture using the function Steve mentioned. It might allow you to save some memory, however you’ll need some algorithm to manage possibly various sized images.

Hi, guys, registered to thank you for the great advice provided in here. You’ve saved tones of my nerves and time

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.