LWJGL Nearest Neighbor filter has artifacts without scaling?

So, I’m trying to build my own gaming library, and I am writing my own TiledMap class. Problem is, whenever I load in any sprite and apply a nearest neighbor filter like…

	public void render()
	{
		texture.bind();
		
		// Filter code
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
		
		// Mins and maxes for which parts of the image to select
		float minX = srcX / (float)texture.getTextureWidth();
		float minY = srcY / (float)texture.getTextureHeight();
		float maxX = srcX2 / (float)texture.getTextureWidth();
		float maxY = srcY2 / (float)texture.getTextureHeight();
				
		// Begins drawing a quad
		GL11.glBegin(GL11.GL_QUADS);
		   GL11.glTexCoord2f(minX, minY);
		   GL11.glVertex2f(0, 0);
		   GL11.glTexCoord2f(maxX, minY);
		   GL11.glVertex2f(srcX2 - srcX, 0);
		   GL11.glTexCoord2f(maxX, maxY);		//
		   GL11.glVertex2f(srcX2 - srcX, srcY2 - srcY);
		   GL11.glTexCoord2f(minX, maxY);		//
		   GL11.glVertex2f(0, srcY2 - srcY);
		GL11.glEnd();
	}

the edges of the texture look kinda wavy, almost like some pixels are slightly ahead of each other sometimes. I have not scaled anything, and the camera’s coordinates are changing, but rounded. I really don’t know why there would be visual artifacts like this.

The code

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

should have handled the nearest neighbor filtering for me, and it DOES prevent LWJGL from rendering a particular texture in a smooth manner when scaling, but it shouldn’t be jagged when the coordinates are rounded! Any clues?

Pics or it didn’t happen. :wink:

It’s kinda hard to tell when the image is not moving.

Well, it’s easier to tell with the text. The textures are just so jagged, and I KNOW I haven’t done any scaling… The font class is my own as well, just fyi. I am using SlickUtil to load textures. Is there a particular way I need to be loading textures? Perhaps I specify a filter upon creating the texture?

I am the dumb stupid… I set Display’s window size to 600x400, but I left glOrtho as…


GL11.glOrtho(0, 640, 480, 0, 1, -1);

Ouch… That’s what I get for copying code snippets, I guess…