Drawpoly

BlitzMax Forums/BlitzMax Beginners Area/Drawpoly

tonyg(Posted 2005) [#1]
Does anybody know how I can avoid the black corners on the my_poly image in this example but keep the shadeblend
SetGraphicsDriver GLMax2DDriver()
Graphics 800,600,0
image=LoadImage("max.png")
my_poly=CreateImage(100,100)
Local poly#[]=[0.0,50.0,50.0,0.0,100.0,0.0,100.0,50.0,100.0,100.0]
Cls
SetColor 255,0,0
DrawPoly poly
GrabImage (my_poly,0,0)
SetColor 255,255,255
While Not KeyHit(KEY_ESCAPE)
    Cls
    DrawImage image,100,100
	mx=MouseX() ; my=MouseY()
	SetBlend shadeblend
	SetAlpha 0.6
	DrawImage my_poly,mx,my
	SetBlend maskblend
	SetAlpha 1.0
	FlushMem
	Flip
Wend
End

<edit> It seems that Shadeblend turns off maskblend. That's annoying. Is there a way around it?
<edit2> OK, I got it. Edited glMAX2D...
		Case SHADEBLEND
			glEnable GL_BLEND
			glBlendFunc GL_DST_COLOR,GL_ZERO
			glEnable GL_ALPHA_TEST
			glAlphaFunc GL_GEQUAL,.5

Hope it doesn't cause any grief later.


ImaginaryHuman(Posted 2005) [#2]
Technically with shadeblend and lightblend you do not need a mask.

With Shadeblend, make the pixels that you want masked WHITE. Since shadeblend does a multiply, it will multiply the floating-point version of the colors. White will be 1.0 so it wont change the destination. It will appear transparent.

With Lightblend, make the pixels that you want masked BLACK. Since lightblend does an addition, you want to be sure to add nothing to the destination, so any black pixels will show as transparent.

I think.

You shouldn't need to explicitly mask it or have a mask/alpha or modify the module.


tonyg(Posted 2005) [#3]
... but, when I create my images, how do I know whether I'll later use them for shadeblend or lightblend?
What happens if I want to use them for both?
Should I have a white set to draw for shadeblend and a black set for lightblend?
If I say mask colour 0,0,0 is transparent then I want it to be transparent (i.e. ignored).


ImaginaryHuman(Posted 2005) [#4]
Its up to you. You could have separate images for each mode. Or if you prefer your shade-and-mask modification, go with it.


tonyg(Posted 2005) [#5]
I checked the ZombieBlast example and he uses color 0,0,0 with Alphablend for drawing shadows. So that's another option. It just seemed odd that I asked (by default) for masked 0,0,0 but it used them in the shadeblend calculation.