Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm trying to load a Texture in an OpenGL context using corona library. OpenGL requires a texture to be of power of two!!

1. Why not other texture dimensions? Why it requires only textures of power two?

2. How to convert a texture to power of two?

Thanks and Regards,
GPUToaster.
Posted
Updated 7-Jun-10 22:57pm
v2

1 solution

GPUToaster wrote:
1. Why not other texture dimensions? Why it requires only textures of power two?


I think it does that for optimization reasons. Not really sure why. As far as I know, loading a texture which is has not a size of power of two will work on certain computers but not on other computers (in which case, a white rectangle will be displayed instead).


GPUToaster wrote:
2. How to convert a texture to power of two?


Converting it is easy: simply open the picture in a drawing program (e.g. paint) and increase the size of the picture so that its width and height are a power of two (16, 32, 64, 128, ...) and then save it. You will have some white space on the right and bottom.

Now, when you want to draw your texture, you have to draw only the part which is actually containing your texture, without the 'unused' space. If you want, you can have a look at my second article on the OpenGL series, there's an example on how to do it there.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900