Hello!
I've been wrestling with this code for a little bit now. The reason is it creates a weird "artifact" on the image. See this:
Weird Artifact by
naters4lad, on Flickr
Notice the red arrows pointing to strange gray lines that are only below the image and extend to approximately 1/5 to 1/4 of the image width. I used the basic code I got from (hat-tip)
NinjaCave.com because it does exactly the same thing in their code as it does mine. Also this happens in different images I created, not just this one. It's severely messing-up my sprites and HUD. The image was created in Gimp 2.6.11 on Windows 7 64bits.
Here is the Ninjacave.com code to map the image to the quad to produce this effect:
Code:
Color.white.bind();
texture.bind(); // or GL11.glBind(texture.getTextureID());
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0,0);GL11.glVertex2f(100,100);
GL11.glTexCoord2f(1,0);GL11.glVertex2f(100+texture.getTextureWidth(),100);
GL11.glTexCoord2f(1,1);GL11.glVertex2f(100+texture.getTextureWidth(),100+texture.getTextureHeight());
GL11.glTexCoord2f(0,1);GL11.glVertex2f(100,100+texture.getTextureHeight());
GL11.glEnd();
This is the change in the code I made to "get rid" of the lines:
Code:
Color.white.bind();
texture.bind(); // or GL11.glBind(texture.getTextureID());
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0,0);GL11.glVertex2f(100,100);
GL11.glTexCoord2f(1,0);GL11.glVertex2f(100+texture.getTextureWidth(),100);
GL11.glTexCoord2f(1,1);GL11.glVertex2f(100+texture.getTextureWidth(),100+texture.getTextureHeight());
GL11.glTexCoord2f(0,[b].98f[/b]);GL11.glVertex2f(100,100+texture.getTextureHeight());
GL11.glEnd();
Now I realize this is only "stretching" the mapping on the bottom-left corner but this was the only way I could get rid of this weird line. Again, I have attempted to use different images created in Gimp with different colors and different image dimensions and shapes. Any idea? Or at least has anyone else had this issue? Any input would be greatly appreciated!
~~ Nate