View Full Version : Texture Mapping not working

02-03-2016, 09:54 AM

I'm tryin' to display a texture on a square. It does somehow but not in the right way for any reason. (colors are correct somehow) I thought the problem would be the shaders (asked for that in a recent post). but that seemed to be a different issue. searched the web again and found almost the same examples with squares using the same uv mapping.

it makes no difference, wether i use glActiveTexture(GL_TEXTURE0) after calling glGenTexture, glBindTexture or not. (cause that was missing in my code). the file is 24 bit .bmp (R8, G8, B8). Switching order of RGB for glTexImage2D with GL_RGB to GL_BGR wouldn't make any difference as well.

Generally: Does the order of uv mapping matter, as long you stick to the order of vertex positions initialization? (cause that's the only difference in different tutorials -> starting for e.g. with left bottom instead of left top.)

I uploaded everything on GitHub (https://github.com/Rawocar/engine_test)

The functions which initialize the square are CModel_3D::set_texture_square and CModel_3D::create_square in en_3d_mdl.cpp (src directory).

Any ideas? I appreciate your help

02-08-2016, 03:34 AM

I now wrote a bmp function by myself to test if that would solve my problem. But I get the same results as for SOIL. I am using a 2px x 2px bitmap to keep things simple. But only pixel left down, and left up are displayed. Changing texture coordinates wouldn't change that in any way. ('though it should, right?) So what is wrong in CModel_3D::set_texture_square? (en_3d_mdl.cpp)

I updated the project on GitHub (https://github.com/Rawocar/engine_test.git). I'm tryin' to load "textures/test.bmp" and display it on a square, which is ppModel[3], loaded in gm_init.cpp and being displayed in gm_draw.cpp. The square is made with 4 vertexes using GL_TRIANGLE_STRIP.

Any help please. Tryin' to fix it for days now.

02-11-2016, 02:19 PM

I made it. I forgot to send the uv data to the shaders. so I created another class vbo for texture coords only and sent them to the GPU.