Quick Clipping question...

Started by
5 comments, last by Rappler 23 years, 11 months ago
Would it be faster to: Check whether an object is on the screen, and if not, don''t call Blt. - OR - Just Blting it and letting DD decide if it should draw it. "But then the stupider students would be in here complaining, furrowing their brows in a vain attempt to understand the situation..."
"The Gates of Pearl have turned to gold, it seems you've lost your way."
Advertisement
Let Blt() do it. Blt already does checking like that to clip your images, so you''re going to end up checking everything twice when you display an image.

Unless of course, your ''objects'' are bigger than one image. If you have some sort of construction that takes 20 blits to draw to the screen, then it might be a good idea to see whether you can eliminate the entire thing before trying to draw any of it.
I try both ways and i found it is much faster not to do the blit at all ....
when my routine eliminates blits form been done...my game is much faster then if i let the clipper do the same stuff...

but i still let the clipper do it on margins...
i only eliminate blits if its a long distance from screen limits (a safety border)

Hope this helps...

Bogdan
obysoft
Let me clarify the use...

It is being used in a 2d 8-way scrolling tile engine. I need to check whether or not each tile is drawn, and if it is do so. Later I''ll be bliting stuff onto the maps, characters and such. If I check every one, it could get really slow as the maps get larger.
"The Gates of Pearl have turned to gold, it seems you've lost your way."
I guess I should be a little bit more specific too. If you are doing a tile engine, make sure that you are just drawing the range of tiles that have some chance of being onscreen and not running through your entire map and checking each tile. For example, if the upper left corner of the screen is going to be tile (10,10), then there is no need to look at any tiles in the first 10 rows or columns of the map array. Hopefully, what I mean is pretty clear.

Now, if you''re drawing characters and objects too, it depends on how you store their information. For example, if a character is associated with a specific tile of the map, then you can eliminate drawing them along with the tile when the tile is off the screen. However, if you''re using world coordinates to track your objects and players and they aren''t connected to a specific ''square'' of the map, then you will probably have to check each and everyone to decide if it should be drawn.

My original response was referring to things like tiles or objects that are borderline. That is, something that might be JUST off the screen. In this case, just let Blt do the clipping.

I hope I cleared myself up a little.
Let me clarify also

What i wanted to say was for 2D sprites... dont let them blt when they are away off screen

Tiles...wow... I NEVER draw any one more then needed....maybe one extra on the margins and thats all...very easy to test in a 2D tile engine...

Bogdan
obysoft
Hi

If your Objects aren''t tilebound, you could use Sectors to store them. You then only need to look which sectors are visible, and only draw Objects in those sectors.
The disadvantage is that you need to update your sectors on each move of an Object, or at least check, if an update is necessary.

Lars
--------> http://www.larswolter.de <---------

This topic is closed to new replies.

Advertisement