2D Texture issue with redrawing pixels

Started by bosstweed, April 10, 2013, 02:15:29

Previous topic - Next topic

bosstweed

This is my first post and it is about the first game I am making. I have read about some similar issues with "extra" pixels on the borders ( pixels being redrawn from the opposite edge ). But for me, this problem seems to happen most often during or after I have translated the my image.

For example, when my image is at 1098,859, it is being drawn correctly, however at position 1798,329, there are pixels being drawn on the left and bottom from the right and top sides.

All of my images are saved in power of 2.

All of my images inherit from a Shape class which has a Texture pic, so the texture is assigned in any of the child classes, then binded back in Shape. This is the code I am using to bind images:
public void textureStart()
	{
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

		GL11.glEnable(GL11.GL_TEXTURE_2D);
	}

	public void textureVertices()
	{
		
		pic.bind();

		glBegin(GL_QUADS);
		glTexCoord2f(0, 0);
		glVertex2d(this.x, this.y);
		glTexCoord2f(this.pic.getWidth(), 0);
		glVertex2d(this.x + this.pic.getTextureWidth(), this.y);
		glTexCoord2f(this.pic.getWidth(), this.pic.getHeight());
		glVertex2d(this.x + this.pic.getTextureWidth(), this.y + this.pic.getTextureHeight());
		glTexCoord2f(0, this.pic.getHeight());
		glVertex2d(this.x, this.y + this.pic.getTextureHeight());
		glEnd();
		GL11.glDisable(GL11.GL_TEXTURE_2D);

		
	}



This is just to explain where 'pic' comes from.  When the code runs it will call a draw() function on any of the child classes, an example of one is this:
public void draw()
	{
		textureStart();

		pic = GameShell.news;

		textureVertices();
	}


I'm not sure if i'm allowed to post videos here so I won't for now, but i think that would be the best way for me to show the problem that I am having.

Also, I am not sure if this is a related problem or not, but when i translate images sometimes they appear to be wavy, i dont know if this is just my computer though as I am developing from a low spec MacBook Pro.

Thank you for all and any help.

Fool Running

A video or even just an image of what you are trying to explain would help (since I have no idea what you are saying :P).

The wavy images might be caused by not enabling V-sync.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

bosstweed

http://www.youtube.com/watch?v=KyhYmYOJR8I

heres a video of what goes on, i hope it is easy enough to see and clears things up a little.

When the character is on the bottom of the screen and not translating, the image is fine, however while translating on the bottom, or on the way to the top and while standing still on the top, the pixels show up.

Also I am unfamilar with V-sync or how to enable it. So I'll look into that.

Elviz

Have you tried setting the wrap parameters for your character texture to GL_CLAMP_TO_EDGE?

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

bosstweed

Quote from: Elviz on April 10, 2013, 23:32:56
Have you tried setting the wrap parameters for your character texture to GL_CLAMP_TO_EDGE?

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


this works like a charm, I had to use GL_CLAMP, instead of GL_CLAMP_TO_EDGE, im not sure what the difference is but it didnt look like GL_CLAMP_EDGE could be imported in my project.

Thank you so much for your help.

bosstweed

Quote from: Fool Running on April 10, 2013, 12:55:03

The wavy images might be caused by not enabling V-sync.

You guys are good...  :)

V-sync stopped the waviness.

Thank you so much for your time and help.