ofTexture problem

I’m using ofTexture trying to map a square pic on a cube but it turns out the texture is always smaller then the face of the cube

width = 600  
        glVertex3f(width,+width, -width);  
        glVertex3f(width, -width, -width);  
        glVertex3f(-width, -width, -width);  

any idea why this happy?

Yup - its because with OpenGL you need to have a texture as a power of 2.

ie width and height need to be something like 64, 128, 256, 512, 1024, 2048 etc

When you load an image into ofTexture say an image that is 640 by 480 we figure out what the next power of 2 would be for that size - so you actually are using a texture that is 1024 by 512. We then modify the texture coordinates so that you don’t see that extra black pixels which are not being used.

Of course when you map the texture directly with glTexCoord you can’t just put in 1.0 for the edge of the texture you need to figure out what the value is for the size you loaded.

For an image that is 600 by 600 for example - you are getting a texture that is 1024 by 1024 so the far right in x and the bottom in y would have tex coord values of 600.0/1024.0

Of course the easy option is to just load the texture in at 512 by 512 or 1024 by 1024 then you will have no changes to make to your code.

Also in ofTexture we allow for using the ARB extension ARB_TEXTURE_RECTANGLE. This basically loads the texture without needing power of 2 sizes - but the major difference is that your texCoords need to be specified in pixels not 0.0-1.0 range.

So glTexCoord2f(0,1.0); would become glTexCoord2f(0,600.0);

Hope that helps!

Yep, figured out myself too.
Thanx anyway