GL 2d drawing

Started by
2 comments, last by Sir Sapo 18 years, 4 months ago
on a 2d game im making i use opengl with quads, i have many pictures stored on a single texture and im using the posted code to draw them. the only problem is when i draw tiles or any other image that need to join up with a seporatly draw one i get a line where they join, this is becouse its not cutting it perfectly and i get a edge thats the wrong color becouse it blends with image next to it. How can i stop this and is it becouse im doing something wrong or just that floating point calcilations arnt 100% accurate.

struct Texture{
    GLuint tex;
    int height,width;
};

void GL_drawbit(int X, int Y,int Width,int Height,int sX,int sY,Texture texture){
 glColor3f (1.0f,1.0f, 1.0f);       
glBindTexture(GL_TEXTURE_2D,texture.tex); 
glBegin(GL_QUADS);


glTexCoord2f((float)sX/texture.width        ,(float)sY/texture.height);		
 glVertex2f(X, Y);
glTexCoord2f((float)(sY+Width)/texture.width,(float)sY/texture.height);			
 glVertex2f(X+Width, Y);
glTexCoord2f((float)(sY+Width)/texture.width,(float)(sX+Height)/texture.height);		
  glVertex2f(X+Width,Y+Height);
glTexCoord2f((float)sX/texture.width        ,(float)(sX+Height)/texture.height);		
  glVertex2f(X, Y+Height);
  
glEnd();

}


Advertisement
When you load your textures, try using GL_CLAMP_TO_EDGE, thats what always fixes that problem for me.
thanks, i had to use GL_CLAMP but it worked

on a side note would upgrading my gl header files couse any compatibility issues with older hardware
I'm not sure, but i don't think so. I think they made it a priority to be backwards-compatible, but someone correct me if I am wrong.

BTW, I was the AP, forgot to log in[grin]
My Current Project Angels 22 (4E5)

This topic is closed to new replies.

Advertisement