[SOLVED]LWGJL - Black bars on textures

Hi everyone, I new here :slight_smile:

I have some problem with textures.
Here is the image of the problem :
http://pokit.org/get/?e7209a7120098536a3b15dd5a5d15f56.png

As you can see the texture isn’t spread over the plane. The texture has 4K resolution, so that isn’t a problem.

Anyone know how to solve this ?

Thanks in advanced :slight_smile:

https://open.gl/textures

Try changing the 'Wrapping parameter to [icode]GL12.GL_CLAMP_TO_EDGE[/icode]

// Tell the texture to wrap around the border
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE)

glBindTexture(GL11.GL_TEXTURE_2D, myTexture);

I don’t think clamping is the effect he wants.

OP: Can you post the code related to drawing this texture. I think that you may be using the wrong texture coordinates.

This is how I load my textures

public Texture loadTexture(String format, String filename)
	{
		try{
		return TextureLoader.getTexture(format, ResourceLoader.getResourceAsStream(filename));
		} catch (FileNotFoundException e) {
	         e.printStackTrace();
		} catch( IOException e)
		{
			e.printStackTrace();
		}return null;
		
	}
	public void loadTextures()
	{
		wood = loadTexture("PNG", "res/tex1.png");
	}

and this is the plane

public Plane( Vector3 position, float size, Texture texture){
		//.glLoadIdentity();
		
		glPushMatrix();
		glEnable(GL_TEXTURE_2D);
		texture.bind();
		
		glTranslatef(position.x, position.y, position.z);
		
		glBegin(GL_QUADS);
		
		glNormal3f(0, 0, 0);
		glTexCoord2f(0, 0);glVertex3f(-size/2, -size/2, size/2);
		glTexCoord2f(1.0f, 0);glVertex3f(size/2, -size/2, size/2);
		glTexCoord2f(1.0f, 1.0f);glVertex3f(size/2, size/2, size/2);
		glTexCoord2f(0, 1.0f);glVertex3f(-size/2, size/2, size/2);
	
		glEnd();
		//glDisable(GL_TEXTURE_2D);
		glPopMatrix();
	}

Hi,

I’m pretty sure you’re using the slick2d texture loader ? If your texture is not square, it forces it to be (it creates a square texture with yours inside + black areas). So hardcoding your texture coordinates with 0, 1 … will not work. From what I remember there should be a way to get the correct texture coordinates from the Texture class, just have a look at its methods, the name should be obvious :wink:

texture.getWidth(); and texture.getHeight();

Can we have a copy of the exact texture? Just upload it to http://www.imgur.com/ and give us a link. :wink:

Because what may be the problem is the texture’s resolution isn’t the same ratio in size as your ‘plane’. It also may be because the texture isn’t a s2 (s^2). The width and hight have to be a power of two. Like 256x16, 32x64, or 16x16.

Here is the image, res is 3072x2048

http://www.geek-envy.com/wp-content/uploads/2014/06/Brickwall_01_-.jpg

Try this:

http://pokit.org/get/?18c6c230e82905a3c8ef5046958d1a52.png
Works like a charm :smiley:

So what was the trick to make it as square or ?

Putting a texture larger than the plane you’re drawing it on is acceptable as long as it is proportional to the plane. Like the texture being 256x256 and the plane being 900x900. A 1024x256 texture will only fit in a space that’s a multiple of 2x1. Or else it will try in down-size/stretch it into the correct locations, and it won’t look very good.

Thank you very much :slight_smile:

Anyway to say “Thanks” here on forum, like +1 or something like that ?

Yeah, they’re called medals. They’re the things that ruin your life when you have too little of them.

I currently have 8 and one of them was an accident…