ZFGC
Resources => Coding => Topic started by: MG-Zero on November 12, 2009, 06:21:01 pm
-
I've got some..interesting image tearing problems going with the Harvest Engine. I've ran it on multiple computers and get different results on every one of them (distortion, tiles splitting up).
Are there any articles out there I can look through the deal with this? This is openGL btw.
-
vsync?
-
Edge clamping enabled?
-
vsync?
Tried with vsync on and off, doesn't change anything.
Edge clamping enabled?
uhh...details nao?
-
Screenshots of what you're talking about may help somewhat =P (So would the rendering code but I'm not gonna ask for that because if you didn't give it originally I assume you don't want to ;P)
-
Sorry, took forever to get this up.
As you see, the top of the tree is separated from the bottom when the screen scrolls. The top of the tree is on a separate layer from the bottom. My rendering code looks like this..
for (int i = 0; i < HMD.layerCount; i++)
{
for (int j = 0; j < 2500; j++)
{
//draw the tiles skipping -1s
if (HMD.layers[i].getTileNum(j) != -1)
{
HVSTGFX::createTilePNG(HMD.layers[i].getTileNum(j), tileCoordX[j], tileCoordY[j], HMD.tileSet);
}
}
}
-
You sure the widths and heights of the images are right? If they're like 1 pixel off things can get a bit weird...
-
Yes, tiles are all 16x16. The tearing only occurs when the screen scrolls.
-
Hmm, is the rendering done in a separate thread from the game loop?
And does the top layer move down when scrolling up, left when scrolling right and right when scrolling left.
-
Well, check your second layer rendering. From that screenshot it seems that it only happens on the top part of the tress...
-
If the rendering coordinates are in float point, convert them to integers. I had the same problem a while back, that fixs it :3
-
Hmm, is the rendering done in a separate thread from the game loop?
And does the top layer move down when scrolling up, left when scrolling right and right when scrolling left.
No, it's all the same thread.
And yes, they move in all directions.
If the rendering coordinates are in float point, convert them to integers. I had the same problem a while back, that fixs it :3
Yea, but then the coordinates get all screwed up D=
EDIT: ahh..that's interesting. The tearing occurs on the layer that the player is being rendered on..gonna take a look through the rest of the map creation and see what's going on here.
-
Hmm, is the rendering done in a separate thread from the game loop?
And does the top layer move down when scrolling up, left when scrolling right and right when scrolling left.
No, it's all the same thread.
And yes, they move in all directions.
Ah well, if it was in a different thread, than maybe it would be possible that the viewport gets updated after the bottom layer was rendered. But if it is in the same thread, then I don't think that is the problem.
-
How are you executing your games logic?
You're not doing it all in the same loop are you?
-
How are you executing your games logic?
You're not doing it all in the same loop are you?
You're referring to the main loop, I assume?
-
How are you executing your games logic?
You're not doing it all in the same loop are you?
You're referring to the main loop, I assume?
If I am guessing right, I think Windy means. Do you update one layer, then render it and then go to next layer update that and render it and so on till you get to last layer.
That could explain why the top layer seems to shift in the opposite direction of the scrolling and why the tearing takes place in the layer that Link is on, because the viewport is updated there.
That is how you can make the multithreaded image tear in a single thread. The piece of code you gave suggests you didn't though.
-
The way I'm executing the player code may relate to that. Alright, that shouldn't be too hard to fix. I can just use the player reference I have in the main.cpp to call the player from the proper layer after everything is drawn.