[vtkusers] question for opengl experts

Jeff Lee jeff at cdnorthamerica.com
Fri Mar 19 17:49:21 EST 2004


Yes, you can do it, but be prepared for a performance hit.  Just check 
your hardware for the extension string "GL_ARB_texture_non_power_of_two" 
and if it's there you can use a non power of 2 texture just like you 
would a normal texture.  You would have to modify vtkOpenGLTexture.cxx 
to do this (take out the resample logic).  I would not recommend it, 
though, the reason to keep it to powers of 2 is efficiency - multiplying 
with powers of 2 is done with bitshifts which are an order of magnitute 
faster than real multiplication.  Even with resampling (padding out to 
the next-biggest power-of-2) it is still typically faster - especially 
since you only resample on load.
-Jeff

Leila Baghdadi wrote:

>Hi Jeff
>
>Thanks for the quick reply. The reason I asked that question is because I 
>had a discussion with someone who had some opengl experience and he told 
>me, he did not think this whole powers of 2 dimension is true!
>
>So I am just trying to make sure I understand things properly,
>do you know opengl and if yes can you please give me some hints as in why 
>this is the case in opengl.
>
>Thanks
>
>Leila
>
>
>On Fri, 19 Mar 2004, Jeff Lee wrote:
>
>  
>
>>Leila,
>>It happens in vtkOpenGLTexture.cxx.  When the texture loads, it checks 
>>the dimensions and resamples if either dimension is not a power of 2.  
>>It also resamples if either dimension is greater than OpenGL can handle.
>>-Jeff
>>
>>Leila Baghdadi wrote:
>>
>>    
>>
>>>Hi everyone
>>>
>>>I was reading the vtk user's guide, using texture page 54, and there is a 
>>>note there talking about graphics hardware/libraries only accept powers 
>>>of two in dimension,
>>>does it mean 2,4,8...
>>>or how does that work and where is the code that deals with this to 
>>>generate a power of two dimension.
>>>
>>>
>>>Thanks
>>>
>>>
>>>Leila
>>>
>>> 
>>>
>>>      
>>>
>>    
>>
>
>  
>

-- 
Jeff Lee
Senior Software Engineer
Computational Dynamics North America Ltd
21 Lafayette Street, Suite 230
Lebanon NH 03766 USA
fax:   603 643 9994
phone: 603 643 9993 x109
http://www.cd-adapco.com




More information about the vtkusers mailing list