fullscreen FX

Blitz3D Forums/Blitz3D Programming/fullscreen FX

b32(Posted 2006) [#1]
Hello,

Great site! Lots of info!
I would like to make a fullscreen FX for Blitz3D, but I don't know what method to choose.

The thing I would like to try is to write a fullscreen FX.
I would like to apply a blur to pixels above a certain treshold, so the lighter a pixels is, the more blur I want to apply to it. It is an effect used in some videoclips and some commercials.

Ofcourse I am concidering using LockBuffer() and Readpixelfast, but I am also familiair with Delphi and I was wondering if writing a DLL for this might be more fast ? And if so, how could I pass a Buffer or an Image to the .DLL ?


ErikT(Posted 2006) [#2]
Maybe this is useful:
http://blitzbasic.com/codearcs/codearcs.php?code=921


b32(Posted 2006) [#3]
This is certainly a nice .lib! However, I would like to write something myself. I try to write the FX as a form of practice. The thing I want to learn is how to sort or less directly access the B3D buffers/images in a fast way @ the current graphics resolution.

I saw an example today of a C++ DLL that accesses a Buffer. So with a littlebit of work I can translate that to Delphi. But would it be fast enough ?

Today, I also tried the following code:
f$ = "test.bmp"

ff = ReadFile(f$)

bank = CreateBank(FileSize(f$) + 1)

For i = 0 To FileSize(ff)
PokeByte bank, i, ReadByte (ff)
Next

CloseFile ff

DrawImage bank, 0, 0

Print "ok"

WaitKey()

End

So I tried to draw a bank instead of an image, but that couldn't fool Blitz. However I would like to write somethink like this.

Is it possible to declare to variables at the same memory location of to directly acces the bitmap information ?
On my configuration using ReadPixelFast goes actually a bit slow, so I'm not too fond of it.

Or maybe ASM ? Is there some form of inline assembler in Blitz ?


jfk EO-11110(Posted 2006) [#4]
first use ReadByteS to read a bulk of bytes from a file to a bank.

Then there's a hack that allows to use an image as a bank, see code archives/ userlibs/ image as bank or something.

Now that the bank handle points to the an image, it's also possible to write data to this "bank" for a DLL, using a userlib DELCS file.

Blitz will then call a function that is declared in the decls file, using the bank name as a parameter, where this must be declared as "value*" in the decls file, see some example decls files. The dll will then be capable of writing data to that bank. If this fails for some reason, or if you need to hand over a pointer to a pointer for some reason or something, you can always determine the physical aress of a banks data segment by checking the 32 sigint that is located at adress bankhandle+4. You need to use RTLMoveMemory to read that int (see also the image as bank example).

Please note: C++ compiler seem to be only about 1.5 times faster than Blitz compiled code. Well, that's an average benchmark for things like FOR loops etc.
ReadPixelFast and WritePixelFast are kind of limited in speed due to the fact that access of VRam or Ram located image objects requires some special steps, compared to say simply moving 24 bits to a given adress.

No inline Asm in Blitz3D.

BTW, your filter question:

bram32 if you're taling about those trashy shiny blending white areas stuff seen in teethpaste and elections republicans ads, it may be a glow filter. You're lucky, glow filters can be implented using the power of your 3D chips:

http://www.blitzbasic.com/codearcs/codearcs.php?code=1351
Beaker made an other one, but I cannot find it right now.


b32(Posted 2006) [#5]
Thank you very much! I found the code you mentioned:
http://www.blitzbasic.com/codearcs/codearcs.php?code=1518


ZJP(Posted 2006) [#6]
Take a look here. Updated
http://www.blitzbasic.com/Community/posts.php?topic=34301

JP