WritePixelFast for out-of-screen coordinates?

BlitzPlus Forums/BlitzPlus Programming/WritePixelFast for out-of-screen coordinates?

A22(Posted 2013) [#1]
I have a question about the "ReadPixelFast" and "WritePixelFast" commands.
I'm considering using them to create full screen "fade to black" and "fade from black" effects.

I think I already know how to do this, but I'm a little bit afraid of using these commands, because in the BlitzPlus manual it says this:

---------------------------------------------
Also, you must make sure that the coordinates that you are writing to are valid, otherwise you will end up overwriting other areas of memory.

WARNING:

By not following the above advice, you may cause your computer to crash.

---------------------------------------------

So, everything should go fine as long as the "coordinates are valid"...

But then it came into my mind, that what if the user moves the game window partially out of screen?
And then my program would try to do ReadPixelFast/WritePixelFast to coordinates that are located outside of the visible screen area?
Could it then possibly cause a crash, or would everything still be OK?

If anyone knows the answer, then tell me. :)


Yasha(Posted 2013) [#2]
The coordinates in question are referring to the game window or image buffer, not to your desktop or actual monitor. It doesn't matter where the window is or whether the user has dragged it offscreen - this is taken care of at a lower level: WritePixelFast writes to a block of memory that the OS then grabs and uses to draw the game window on your display; if the window is off screen, the OS is used to handling it in the same way it would draw any partially offscreen window - but by that time it's already copied your block of "pixel" memory into its compositing system and you no longer need to think about that.

It is however still important that you target this fixed block of pixel memory correctly in the first place, which is why you need to make sure not to go out of the buffer's bounds. But they don't change if the window moves, for the aforementioned reason that the game itself has no idea about things like the position of the window and runs independently of that information.


...unrelated to that part: be warned that WritePixelFast is really, really slow. On most machines it is nowhere near fast enough for fullscreen effects - what you're hoping to use it for may not necessarily be possible.


A22(Posted 2013) [#3]
Ok, thanks for the info.

I'll experiment with these commands to see if they're fast enough.


Kryzon(Posted 2013) [#4]
If these commands don't prove to be fast enough, there are other alternatives:

bOGL-2, with Draw2D addon
3D engine for BlitzPlus that overrides the native graphics commands to give you 3D functionality. With the 2D addon you can draw a semi transparent rectangle over the screen with alpha blending, doing your fade effects.

Extended B2D DLL
An userlib that overrides BlitzPlus's native graphics to give you more options. Includes alpha transparency - which is what you need to perform the fade effects - among other things such as pixel-perfect collision etc.