Search code examples
opengltexturing

OpenGL - Texturing, unwanted skewing and rotating


I'm trying to map several texture atlases onto various quads on a car object. I am coming across a problem where some textures are skewed and rotated rather than mapping directly onto a quad. The problem is shown below, I've used a smiley face for a clearer example of what's going on. Skewed/rotated Image

I've tried to make the texture atlases' widths powers of 2, that does not work. I also heard from a friend that this is due to the texture atlases not being an even width, which didn't resolve the problem for all cases. The fact that changing the width managed to solve the problem in some cases leads me to believe that texture width may be the cause.

I'm using my own shaders to perform texture co-ordinate manipulation for the texture atlases, if this is relevant. Does anyody have any clues as to the cause of this problem?


Solution

  • Looking at your left image I see some out-of-place black pixels. That kind of things happen when you load image wrongly (part of images header goes to RGBA data).

    Another possible reason is wrong width of image in header and in data (could caused by wrongful header usage or padding in images data).

    Without code and image format it's harder to be more specific.