[osg-users] Background image texture rescaling problem

Eric Sokolowsky eric.sokolowsky at nasa.gov
Mon Sep 17 08:11:03 PDT 2007


Robert Osfield wrote:
> Hi John,
> 
> On 9/15/07, John Steinbis <jsteinbis at gmail.com> wrote:
>> Thanks Robert,
>> I have this working now without rescaling the image. My solution was
>> to pad the image with zeros making it a power of two and then specify
>> the correct percentage of the image to use as 2D texture. Not sure if
>> this is the best solution but it works and is fast enough for me.
> 
> This is not an elegant way to tackle the problem, workable yes, but
> I'd recommend spending a little time - readying up about
> TextureRectangle or just disabling the resize of non power of two
> textures, you'll end up with a more efficient and elegant solution.

I've used two of these methods to avoid the resizing penalty. The first 
was to use John's solution to create power-of-two images and only fill 
it with a subimage that is actually used. I then use the texture matrix 
to change the texture coordinates so no recoding is necessary. This has 
worked very well for my application. The second method was to use the 
TextureRectangle solution, but there are a few drawbacks to this method: 
it may not be hardware-accelerated, especially on older cards; you lose 
the ability to generate mipmapped textures; and your texture coordinates 
become non-normalized, so that you have to know the size of the image 
when you set up your scene if you do anything fancy.

Texture Rectangles are useful but are not the ultimate solution to all 
problems.

Eric



More information about the osg-users mailing list