PDA

View Full Version : Texturing and Blending



Swiftless
06-30-2005, 10:20 PM
I have a quad set up with:


glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex3f(0,0,0);
glTexCoord2f(0,1);
glVertex3f(0,1,0);
glTexCoord2f(1,1);
glVertex3f(1,1,0);
glTexCoord2f(1,0);
glVertex3f(1,0,0);
glEnd();
I am texturing it like this:


glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glBlendFunc(GL_DST_COLOR, GL_ZERO);
glBindTexture(GL_TEXTURE_2D, smoketexture[1]);
glBlendFunc(GL_ONE, GL_ONE);
glBindTexture(GL_TEXTURE_2D, smoketexture[0]);
Now the problem is that the texture is mapping itself 3 times horizontally and it is leaving a big white rectangle up the top half of the quad. I cannot figure out what is doing this...

In case it may be useful, here is the code I am using when I create the textures:



glGenTextures(1, &texture[0] );

glBindTexture(GL_TEXTURE_2D, texture[0]);

glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

gluBuild2DMipmaps(GL_TEXTURE_2D, 3, width, height, GL_RGB, GL_UNSIGNED_BYTE, data);

T101
06-30-2005, 10:44 PM
You're specifying texture wrapping for the T axis, but not for the S axis. This would allow the texture to repeat in one direction, but not in the other.

That shouldn't make a difference with the texture coordinates you're using though.

Are you sure that the width and height you specify in the gluBuild2DMipmaps call are the same as the actual width and height in the file?
Because if they're not, I can imagine that you're getting a number of the file's lines next to each other in the uploaded texture. And since clamping with a border would result in the rest being white (or the border color in any case), that would explain why part of the quad is just white.

BTW: when you use gluBuildMipmaps, you don't need to also use glTexImage2D.

Swiftless
07-01-2005, 12:00 AM
Did those two little changes you said, but that wasn't it. I did find it though. Nothing to do with my code but with my image formatting. Those images had been encoded differently to the others, in otherwords, it was saving them at 1 thrid of the size :mad: Thanks for your help, I would not have found it if you had not have told me to check the image sizes.