Drawimage masking?

BlitzMax Forums/BlitzMax Programming/Drawimage masking?

kronholm(Posted 2008) [#1]
I was wondering if anyone knows of a clever way to draw an image for my particular situation. I guess you could call it masking.



Basically, the balls that approach from the bottom should be hidden from view until they enter the playfield (the black part). Currently in my code, they are also drawn on top of the background, because I draw the balls last. The background is drawn first, and secondly I draw the black level, on top of the background.

I guess this could be solved by every frame taking a "screenshot" from the backbuffer or something and drawing that on top of the balls. But what I'm wondering is if there's some better methods of achieving this, some that are not as cpu taxing. Maybe there's an option of drawing a part of an image or something? Maybe something to do with blending layers?


Brucey(Posted 2008) [#2]
Use a viewport when drawing things that you want drawn only to a set area?


Brucey(Posted 2008) [#3]
SetViewPort(x, y, width, height)

"The current ViewPort defines an area within the back buffer that all drawing is clipped to. Any regions of a DrawCommand that fall outside the current ViewPort are not drawn."


Czar Flavius(Posted 2008) [#4]
Is viewport reliable?


Brucey(Posted 2008) [#5]
I haven't had any problems with it on GLMax2D.


kronholm(Posted 2008) [#6]
JUST what I was looking for, thanks a ton guys :)


Dreamora(Posted 2008) [#7]
as long as you don't use it on crap 2D cards like intel onboard it reliable.


Trader3564(Posted 2008) [#8]
does it clip based on wheter the X Y are inside the viewport yes/no. Or does it actualy not render the pixels that fall out?


GfK(Posted 2008) [#9]
SetViewPort doesn't work on some GeForce cards, either.

as long as you don't use it on crap 2D cards like intel onboard it reliable.
...or to put it another way - its reliable if you want to cut out 50% of your potential market at the drop of a hat.

You can get rid of the rest of your customers by supporting OpenGL and not DX.


Brucey(Posted 2008) [#10]
You can get rid of the rest of your customers by supporting OpenGL and not DX.

Oh well, there go my plans for doing anything on my Mac, which has a crappy intel card and doesn't do DX..

Bugger.


GfK(Posted 2008) [#11]
I'm talking about Windows, obviously.


Brucey(Posted 2008) [#12]
Oh... well cover me in pickle and call me an onion... nevermind then :-)


ImaginaryHuman(Posted 2008) [#13]
I would just draw the balls and then redraw the bottom portion of the part that covers it up.