Strange Artifact when rendering a list and moving the screen

Started by @, April 02, 2014, 17:36:47

Previous topic - Next topic

@

I have a list made of tiles that i can display without any issue. Now, when i change the screen coordinates, a strange thing appears:


Marked in red

In this case if i move again the ortho back to its origin, the thing stays behind the displayed map.

Cornix

Its probably the flying spaghetti monster messing with your computers brain waves...

No, seriously, how should we know until we see your code?

@

Quote from: Cornix on April 02, 2014, 18:23:05
Its probably the flying spaghetti monster messing with your computers brain waves...

No, seriously, how should we know until we see your code?

Because i thought it would be a common issue (I don't know why). If not, i'd have to share the whole thing, which i doubt would solve any problem (or someone would spend his time diving in my project).

It is really not a frequent issue? Has someone faced this same problem before?

Cornix

The most common "issue" is that the programmer did not quite know what his code is doing. Its rarely an issue with hardware or drivers and its probably never an issue of opengl.
What is probable is that in your rendering loop you did a mistake at some point which leads to this visual glitch. But the number of possibilities for such a mistake is near infinity. We could start guessing wildly, but I wonder how long that would take until we can actually help you.
Go through the code of yours that renders the tiles and then show us the relevant parts, that is, all of the OpenGL calls and the control flow and maybe some other parts you deem important for the general understanding.
Then, maybe, we can see what the problem is. And if we dont see it immediately we can try to recreate it and play with it on our own to find a solution.

quew8

Have you forgotten to clear the colour buffer? Ie have you called glClear(GL_COLOR_BUFFER_BIT) at the start of the game loop?

@

I thought about the clearing, but it is not.

After some trials,i came to the conclusion that it only happens when, once the game has started, i resize the window without fullscreen.

The code i use for that task is the one given in lwjgl's webpage examples:

setDisplayMode with no full screen
if (!fullscreen) {							
	    		Display.setDisplayMode(new DisplayMode(width, height));
	    		updateScreen();//Explained below
	    		return;
	    	}


updateScreen()
final int rw = (int) (Display.getWidth() / scale());
		final int rh = (int) (Display.getHeight() / scale());
		
		final float x = vx;  
		final float y = vy;
		final float w = x + rw;
		final float h = y + rh;
		
		glViewport(0, 0, (int)(Display.getWidth()), (int)(Display.getHeight()));
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(x, w, y, h, 1.f, -1.f);
		glMatrixMode(GL_MODELVIEW);


It also happens using normal textures but only if, after resizing the screen, i change its scale to >1< . I suppose this also happens to list, but for some (buggy reason) i cant display a list after resizing and scaling to 1:

scaleScreen()
public void scaleScreen(float scale) {
		this.scale = scale;
		updateScreen(); //Same method as described above.
	}