0
\$\begingroup\$

I'm trying to fit a texture on a curved plane made from some triangles with GL_CLAMP, because GL_CLAMP_TO_EDGE is not available in my OpenGL version, but the texture (512 x 512 pixels) appears so small when render:

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); // If the u,v coordinates overflow the range 0,1 the image is repeated
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // The magnification function ("linear" produces better results)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //The minifying function

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE,  GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); 
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

enter image description here

I load the texture like this:

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECR );    
glTexImage2D(GL_TEXTURE_2D, 0, 4, infoheader.biWidth, infoheader.biHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, l_texture);
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, infoheader.biWidth, infoheader.biHeight, GL_RGBA, GL_UNSIGNED_BYTE, l_texture);
\$\endgroup\$
2
  • \$\begingroup\$ It's not clear to me from this image what the problem is. Can you show us what the input texture and UV unwrap for the mesh look like, and give us an idea of what should be different in this image when it's working the way you want it to? \$\endgroup\$ – DMGregory Apr 18 at 20:50
  • \$\begingroup\$ The texture is a face that fills a BMP of size 512x512. The mesh is created by code from a Bezier curve with normals. The UVs are auto generated from the code above. I want the texture to wrap the whole plane mesh with one repeat. If I put GL_REPEAT instead of GL_CLAMP it fills the entire mesh but repeating the texture many times. Since the mesh are many triangles, is it posible repaeat only once with GL_CLAMP?. Notice that i can generated UV's by code, but it not easy when the mesh twits like this plane, so I woud like to do that job with OPENGL automatic GL_CLAMP \$\endgroup\$ – Luis ALberto Apr 19 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.