Log in

View Full Version : Bacground tearing



blackvoid
24-04-2004, 10:23 AM
We are developing a 2D strategy game with DDraw. The DDraw is a window and not full screen. While scrolling we have a bad tearing effect near the top of the screen.
With vsync off, we have tearing all over the place.
Any ideas would be appreciated how to avoid this.

I am posting the scroll part of the code here. The code is located in the DXTimer procedure. We tried setting different timers, but that did not help.

And another question: when scrolling is there a better solution to move the sprites than the one below? Now all sprites are in an array and are moved one by one.

BlackVoid


if (isUp in DXInput.States) or scrollup then begin
if Background.Y+ScrollSpeed <= 0 then begin
Background.Y := Background.Y + ScrollSpeed;
AlapY:=AlapY-ScrollSpeed;
for i:=1 to AktSpriteSzam do SpriteTomb[i].Y:=SpriteTomb[i].Y+ScrollSpeed;
// szel beallas
if 0 - Background.Y < ScrollSpeed then begin
for i:=1 to AktSpriteSzam do SpriteTomb[i].Y:=SpriteTomb[i].Y+(0 - Background.Y);
Background.Y:=0;
AlapY:=0;
end;
end;
end;
///*** scroll up end ***///
DXSpriteEngine.Move(1);
DXSpriteEngine.Draw;
DXDraw.Flip;

TheLion
25-04-2004, 10:06 AM
Haven't looked into that stuff for quite some time, but did you check the Isometric demo from Dominique Louis or this one:

http://www.savagesoftware.com.au/DelphiGamer/dodownload.php?link=http://www.SavageSoftware.com.au/delphi/download/DelphiXIsoDemo.zip&ID=2

The scrolling method I used to use for my little rectangular map engine was quite easy and based on Dominiques version, basically what I did was When the users mouse would reach the side, I would move the coords where the drawing of the map started either +Scrollspeed or -Scrollspeed (depending on where the mouse was). Then I just drew the map starting at those new positions, that way I prevented jumpy scrolling, since I would now also draw parts of the tiles... :) I improved it later on by only drawing the parts of the map that where visible! :)

I've uploaded a simple implementation of what I just explained, it does the scrolling to a single picture, however applying it to a single image or to multiple tiles is almost the same. :) (There are a lot of buttons in the demo, but only the mouse scrolling works). :)

http://lionprod.f2o.org/stuff/dxscroll.zip

blackvoid
02-05-2004, 01:49 PM
Thanks for the response.
We have tried out your code and ran into the same tearing problem.
Strangely, it only happens if you use a larger DXDraw window.
Try to enlarge your DXDraw surface to about 700 by 700 pixels, use a much larger picture (like 3000x2000) and you will see.

Is this a DelphiX bug?