my original thread is here: http://www.gamedev.net/community/forums/topic.asp?topic_id=402259
The issue is that pink lines appear above and below one texture for some odd reason. Clamping got rid of the line on the bottom, but I don’t know what to do on the top.
Copied and pasted information:
The problem is that when I move an image, for some reason it flashes pink lines on the bottom and top of the image. Any idea whats causing this?
Heres the app so you can see it for yourself.
http://files.filefront.com/OGLSpaceShooterzip/;5224896;;/fileinfo.html
Draw code:
bool Image::Draw(float X, float Y){
glBindTexture(GL_TEXTURE_2D, (*iIndex));
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0.0f,(float)iHeight/(float)iFullHeight);
glVertex2f(X, Y);
glTexCoord2f((float)iWidth/(float)iFullWidth, (float)iHeight/(float)iFullHeight);
glVertex2f(X + (float)iWidth, Y);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(X, Y + (float)iHeight);
glTexCoord2f((float)iWidth/(float)iFullWidth,0.0f);
glVertex2f(X + (float)iWidth, Y + (float)iHeight);
glEnd();
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
return true;
}
class Image
{
public:
Image(GLuint *Index, int Width, int Height, int iFullWidth, int iFullHeight, char *File);
bool Draw(int X, int Y, int Width, int Height);
bool Draw(float X, float Y);
private:
char *iFile;
int iHeight, iWidth, iFullHeight, iFullWidth;
GLuint *iIndex;
};
Image::Image(GLuint *Index, int Width, int Height, int FullWidth, int FullHeight, char *File){
iFile = File;
iIndex = Index;
iHeight = Height;
iWidth = Width;
iFullHeight = FullHeight;
iFullWidth = FullWidth;
}
bool Image::Draw(float X, float Y){
glBindTexture(GL_TEXTURE_2D, (*iIndex));
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0.0f,(float)iHeight/(float)iFullHeight);
glVertex2f(X, Y);
glTexCoord2f((float)iWidth/(float)iFullWidth, (float)iHeight/(float)iFullHeight);
glVertex2f(X + (float)iWidth, Y);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(X, Y + (float)iHeight);
glTexCoord2f((float)iWidth/(float)iFullWidth,0.0f);
glVertex2f(X + (float)iWidth, Y + (float)iHeight);
glEnd();
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
return true;
}
//in the init game function
ImageIndex = 0;
ilInit();
ilEnable(IL_ORIGIN_SET);
ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
glGenTextures(MAXIMAGES, texture);
oglLoadTexture("Images/Backgrounds/BG0_space_1.png");
oglLoadTexture("Images/Backgrounds/BG1_planet_big_1.png");
oglLoadTexture("Images/Backgrounds/BG1_planet_small_1.png");
oglLoadTexture("Images/Enemies/SPRITE_small_1.png");
oglLoadTexture("Images/Backgrounds/BG1_planet_big_1.png");
//thats the relevant code
//yes I realize I somewhat suck at coding.
void GraphicsSystem::oglLoadTexture(char *filename){
glBindTexture(GL_TEXTURE_2D, texture[ImageIndex]);
ilLoadImage(filename);
ILuint img;
ilGenImages(1, &img);
ilBindImage(img);
ilLoadImage(filename);
int RealWidth, RealHeight;
RealWidth = ilGetInteger(IL_IMAGE_WIDTH);
RealHeight = ilGetInteger(IL_IMAGE_HEIGHT);
if (ilGetInteger(IL_IMAGE_FORMAT) == IL_RGBA){
PadImage(4);
} else
if (ilGetInteger(IL_IMAGE_FORMAT) == IL_RGB){
PadImage(3);
}
glBindTexture(GL_TEXTURE_2D, texture[ImageIndex]);
if (ilGetInteger(IL_IMAGE_FORMAT) == IL_RGBA){
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE, ilGetData());
} else
if (ilGetInteger(IL_IMAGE_FORMAT) == IL_RGB){
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE, ilGetData());
}
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glEnable(GL_TEXTURE_2D);
// GameImages[ImageIndex] = new Image(&texture[ImageIndex], RealWidth, RealHeight, ilGetInteger(IL_IMAGE_HEIGHT),
// ilGetInteger(IL_IMAGE_WIDTH), filename);
GameImages.push_back(Image(&texture[ImageIndex], RealWidth, RealHeight, ilGetInteger(IL_IMAGE_HEIGHT),
ilGetInteger(IL_IMAGE_WIDTH), filename));
ilDeleteImages(1, &img);
ImageIndex++;
}
bool PadImage(int bpp){
int ImgWidth,ImgHeight,NewImgWidth,NewImgHeight;
ImgWidth = ilGetInteger(IL_IMAGE_WIDTH);
ImgHeight = ilGetInteger(IL_IMAGE_HEIGHT);
NewImgWidth = roundUpToPow2(ImgWidth);
NewImgHeight = roundUpToPow2(ImgHeight);
ILubyte *data = ilGetData();
if (NewImgWidth != ImgWidth || NewImgHeight != ImgHeight){
char* tempdata = new char[((NewImgWidth*bpp)*NewImgHeight)];
memset(tempdata, 255, (NewImgWidth*bpp)*NewImgHeight);
for (int y = 0; y < ImgHeight; y++){
for (int x = 0; x < ImgWidth*bpp; x++){
tempdata[x+(y*NewImgWidth*bpp)] = (char)data[x+(y*ImgWidth*bpp)];
}
}
ilTexImage(NewImgWidth,NewImgHeight,1,bpp,ilGetInteger(IL_IMAGE_FORMAT),ilGetInteger(IL_IMAGE_TYPE),tempdata);
delete[] tempdata;
}
return true;
}
so I have this: std::vector<Image> GameImages;
Whatever happens the be the second image thats push_back'd into it tends to have the pink lines. My question is why?