Re: Alphablending



På Fri, 28 Apr 2006 19:14:51 +0200, skrev jukka@xxxxxxxxxxxx <jukka@xxxxxxxxxxxx>:

where is the
#include ...

www.liimatta.org


Does this use hardware akseleration? Or GDI?

It does not use hardware acceleration. The drawing is done to offscreen
surface (the "screen" object in the sourcecode). The
"fusion::core::framebuffer" object is the interface to platform
specific framebuffer implementation, in the case of Windows it uses
DirectDraw (but not hardware accelerated, it mainly locks the primary
surface and does a memory copy (including color conversion when
needed)).

I just use systemmemory.

It is 32k, and ALL SOURCE are included in the EXE.
How well does this work with versioning systems like CVS or Perforce?

:) I dont even know what that is. What do I need it for?

A file which is both ascii -and- binary sounds like a hack in this
regard, imagine how you would resolve conflicts, and I assume there
will be a large number of them if more than one person is concurrently
working on the same file.

:)) RosAsm is team work. Theres nothing preventing from sharing code.
They just share a title, and any assoiated resources. I know because I
did this when we updated the UnusedSymbols dialog. I wrote the changes
in a day or two, and Betov updated RosAsm with the new title in a day or so.

It draws to a memory buffer, and it uses GDI for outputting the result.
Instead of moving the leaf around, in a cricle, you can just use your mouse
to move it around. On my PC this looks even smoother.

That's great!

I never did any such programming before, and it sure is fun.

Ok. So it uses GDI then.

No, it doesn't. I mean that I wrote the MMX innerloops in late 1990's,
which makes the code fairly old. Hardware acceleration of such trivial
features made the code obsolete for any serious use. I'd use DirectX or
OpenGL for any serious non-toy application.

Ok. I understand. I read that the alpha is more or less free then, (no need for locking, I heard) but I still value a lot knowing how to do it, manually, under GDI. For instance, I now updated that pe, so that the hittesting works on the transparent parts of the Leaf bitmap, and this took only a few minutes because I know how the databuffers are organized. I just did the rect hittesting, and then I calculated the pixel of the actuall hit, read that dword and rejected if it is equal to the transparent color.


this is about all it took.

push ecx ebx
if D$Left.Clip <> 0
add ecx D$Left.Off
end_if
if D$Top.Clip <> 0
add ebx D$Top.Off
end_if

sub ecx D$edx+Rect.Left
sub ebx D$edx+Rect.Top
mov edx D$edi+Sprite.Bitmaps
or edx edx | je L8>
mov eax D$edx
or eax eax | je L8>

push ecx ebx
mov edx D$edx+eax*4
lea edx D$edx+Bitmap.Info
mov eax D$edx+HBitmap.bmWidthBytes
mov edx D$edx+HBitmap.bmBits
push edx
imul ebx
shl ecx 2
add eax ecx
pop edx | add edx eax
pop ebx ecx
mov ebx D$edi+Section.CV
mov eax D$ebx+SectionCV.TransparentColor
pop ebx ecx
cmp D$edx eax | je L8>
mov D$LastGoodSectionHit edi


There might be cases, even with a 3D blitter, that you need to do some
handywork.

Maybe, but that's not really interesting.

Not to you maybe, who has allready done it, and seems to be well versed in graphics programming.
But I think its very fun. Its imo good education for later doing more graphics. And important to understand how to do stuff, like the hittesting above.

Its still states in the DirectX docs that
the organixation of the applications database (culling, clipping) is more
important then advantages in hardware.

Depends on what you are rendering. If you are doing some simple 2D
drawing I'd be more concerned with having large rendering batches with
single draw call than manually clipping/culling a few primitives that
might be trivially rejected.

Ok. To me all this is new, except for reading about it, even if everybody else has done it thousands of times :))


I'd be more concerned about updating the *texture* that is used for
refreshing the canvas, unnecessary client draw requests will just load
the CPU with unnecessary work, and also burn bandwidth for updating the
textures.

Yes. I am working on doing this better.

.



Relevant Pages