GDI can be fast!
- From: o//annabee <fack@xxxxxxxxxxxxxx>
- Date: Thu, 30 Mar 2006 01:46:23 +0200
This is a test I am running.
I use a sprite that is moving across the screen, horizontally.
This sprite is a bitmap of size 143x40 pixels. The bitmap has been given a keycolor (1, 0, 255), and is not rectangular.
each time the sprite move, it is redrawn, with transparency. E.g. every pixel is written seperatly, and tested if it is the transparent color, and if so, it is skipped.
Also, each time it moves, the background are redrawn under it, and behind it.
And any other sprites below it will also redraw.
I was not expecting this to be fast enough for a game, but it is quite fast. Considering that there is every way of making it even faster, take a look at the numbers below.
When I moved the sprite one pixel at a time, it moved much to fast to be useful.
So I had to subdivide that pixel, and even dividing by 10000 was to fast.
in order to get the sprite to move at a speed where it floats a cross the screen taking about a second for the full travel, I had to update the counter 100000 times before advancing the sprite a single pixel.
And it make little diffrence if placing about 10 other sprites on top of each other in the path of the animating sprite.
I say this is very promising. Doing all this to move the sprite is faster than using the scrolling APIs :))) *MUCH* faster. And its not even fully properly clipped yet. All the sprites are 100% redrawn if any part of the DELTA movement happens inside that sprites rectangle, even if the sprite is invisible, and should be culled because of it, it is redrawn in full, when the moving sprite enters its rectangle, each single time the moving sprite moves.
[fraction: 0]
ThisApp.GameLoop:
test D$ThisApp.States ThisAppState_Animate | jz L0>
mov edi D$LastSprite
inc D$fraction
cmp D$fraction 100000 | jb L1>
mov D$fraction 0
mov ecx 1, ebx 0 | call Section.Move
lea eax D$edi+Section.ClientRect
mov ecx D$esi+Window.Width
test D$eax+Rect.Left ForNegative32bit | jnz L1>
cmp D$eax+Rect.Left ecx | jb L1>
neg ecx | mov ebx 0 | call Section.Move
L1:
L0:
ret
.
- Follow-Ups:
- Re: GDI can be fast!
- From: Donkey
- Re: GDI can be fast!
- From: hutch--
- Re: GDI can be fast!
- Prev by Date: Re: Why use assembly?
- Next by Date: Re: RosAsm User Interface
- Previous by thread: RosAsm User Interface
- Next by thread: Re: GDI can be fast!
- Index(es):
Relevant Pages
|