Jump to content
  • Advertisement
Sign in to follow this  
Kaze

OpenGL GL 2d drawing

This topic is 4872 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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();

}


Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
When you load your textures, try using GL_CLAMP_TO_EDGE, thats what always fixes that problem for me.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!