Lines appearing next to a texture

Started by KLMNT, August 04, 2018, 20:53:37

Previous topic - Next topic

KLMNT

So I tried to basically render an image/texture in 2D mode just like in the LWJGL tutorials, but some lines show up right next and under the image. IÃ,´ve tried using a different png image without transparency and it doesnÃ,´t happen.
I tried another png image with transparency and the lines show up again.
I saw a guy mentioning i need to use:

glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);      
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

after

glEnable(GL_TEXTURE_2D);

but its not recognizing GL_CLAMP_TO_EDGE so I canÃ,´t try that.
Any help?

KaiHH

Quote from: KLMNT on August 04, 2018, 20:53:37
but its not recognizing GL_CLAMP_TO_EDGE so I canÃ,´t try that.
This static field is declared in org.lwjgl.opengl.GL13, so you can use it like so:
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, org.lwjgl.opengl.GL13.GL_CLAMP_TO_EDGE);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, org.lwjgl.opengl.GL13.GL_CLAMP_TO_EDGE);

Or add a static import to that field, just like you apparently did it for GL_TEXTURE_2D and the other static fields from GL11, too.

KLMNT

You were right! I had only imported GL11, tho, GL_CLAMP_TO_EDGE is from GL12, not GL13.
But still, the problem persists, IÃ,´ve tried just clamp, clamp to border, to edge and nothing.
Although, after trying with an image from the internet, it didnÃ,´t show up those lines, whereas with my handmade images it does.
Is there a magic trick in the way you export the file to a PNG so the lines donÃ,´t show up that IÃ,´m unaware?

Cornix

It has probably nothing to do with the image itself (unless you actually have those lines IN your image but I guess you dont) but with the way the texels are rasterized. Clamping only works if the area of the texture that you are drawing is equal to the entire size of the texture. If you are using a texture atlas and only drawing a portion of it clamping will not help. In this case you need to either change the filters to a nearest neighbour filter or add a transparent border around each part of the texture atlas.

KLMNT

Quote from: Cornix on August 05, 2018, 19:52:47
It has probably nothing to do with the image itself (unless you actually have those lines IN your image but I guess you dont) but with the way the texels are rasterized. Clamping only works if the area of the texture that you are drawing is equal to the entire size of the texture. If you are using a texture atlas and only drawing a portion of it clamping will not help. In this case you need to either change the filters to a nearest neighbour filter or add a transparent border around each part of the texture atlas.
Ok, let me see I actually understood that as a newbie that I am.
The problem is not from the image but from how openGL is interpreting the image and translating its data into actual pixel to the screen.By using a texture atlas I donÃ,´t really know what you mean, but IÃ,´d say IÃ,´m not. I have 2 methods defined for drawing images, one that allows me to define the actual size I want to draw the image at, and the other one uses the actual image size, but both seem to make the lines appear (btw, IÃ,´m trying to keep this royect with a high level of abstraction, so IÃ,´m using slickÃ,´s resource loader to load the image and whatnot).
So please, could you detail a bit more the infor you just gave me, because didnÃ,´t really caught the second part.
Also, I donÃ,´t know if this:

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

is setting the filter to nearest neighbor as you sugested, but it still doesnÃ,´t work :(