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??
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).
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.