Hello Guest

Strange Artifact when rendering a list and moving the screen

  • 5 Replies
  • 7161 Views
*

Offline @

  • *
  • 41
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.
« Last Edit: April 02, 2014, 17:53:04 by @ »

*

Offline Cornix

  • *****
  • 488
Re: Strange Artifact when rendering a list and moving the screen
« Reply #1 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?

*

Offline @

  • *
  • 41
Re: Strange Artifact when rendering a list and moving the screen
« Reply #2 on: April 02, 2014, 19:17:54 »
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?

*

Offline Cornix

  • *****
  • 488
Re: Strange Artifact when rendering a list and moving the screen
« Reply #3 on: April 02, 2014, 19:38:02 »
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.

*

Offline quew8

  • *****
  • 569
  • Because Square Eyes Look More Real
Re: Strange Artifact when rendering a list and moving the screen
« Reply #4 on: April 02, 2014, 23:19:37 »
Have you forgotten to clear the colour buffer? Ie have you called glClear(GL_COLOR_BUFFER_BIT) at the start of the game loop?

*

Offline @

  • *
  • 41
Re: Strange Artifact when rendering a list and moving the screen
« Reply #5 on: April 03, 2014, 09:04:06 »
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
Code: [Select]
if (!fullscreen) {
    Display.setDisplayMode(new DisplayMode(width, height));
    updateScreen();//Explained below
    return;
    }

updateScreen()
Code: [Select]
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()
Code: [Select]
public void scaleScreen(float scale) {
this.scale = scale;
updateScreen(); //Same method as described above.
}
« Last Edit: April 03, 2014, 09:05:44 by @ »