PDA

View Full Version : texture black border when changing scale



Tiresias
02-20-2010, 04:04 AM
Hello
i am using openg for 2d only textures.l
my texture are png files.
I noticed at some scale there i a small black line located at the bottom border of the png (it seems to blink). it is not a big problem but is a bit ugly. with no scale no issue. Most of the scales are ok, only some value are messing opengl.

here is my code for the texture.

creation:

glBindTexture(GL_TEXTURE_2D, work->textureID);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL _CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL _CLAMP_TO_EDGE);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, work->w, work->h , 0, GL_RGBA, GL_UNSIGNED_BYTE, work->data);

and then during blitting there is a translate(), a scale() if new dim are not the same than original png dim, and a simple begin() end() with vertex stuff.

Mattan360
05-08-2011, 01:12 AM
Hi!

(Sorry for posting on such an old post)

Try set the texture to this instead:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

And most of the artifacts will be gone.
Also try and make your surfaces, and textures to the power of two!

Edit:
Also found this: http://www.opengl.org/wiki/Common_Mistakes#Creating_a_Texture