Quantcast
Channel: Question and Answer » uv-mapping
Viewing all articles
Browse latest Browse all 11

Why are my OpenGL textures warped?

$
0
0

I am writing a graphical program using OpenGL for rendering, Assimp for mesh loading and SDL for window etc, but also image loading.

enter image description here

As can be seen in the image, the white outlines at the left of the screen should actually be textures with text content in them. The surface should a grid-like texture, but it seems to only use the main colour in the image. The vehicle is loaded in with a texture that fully covers it, but it seems to duplicate the texture along every face of the mesh.

I can confirm using CodeXL that the textures get send to the GPU correctly and are not warped in anyway, so I believe my issue may be with how my code is using the UV coordinates for meshes.

The shader program I am using is simply a texture only shader, it takes vertex positions and multiplies them by the projection matrix. It also takes the tex coordinates, passes them to the fragment shader which sets the fragment colour to the texture sample and coordinates.

Before I draw each object, I call:

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureID);

The following is my model loading code:

enter image description here

The UV coordinates that should be stored in the vehicle’s mesh look correct in Blender:

enter image description here

Can someone advise where my texture rendering might be going wrong?


Viewing all articles
Browse latest Browse all 11

Trending Articles