Drawpoly
BlitzMax Forums/BlitzMax Beginners Area/Drawpoly
| ||
Does anybody know how I can avoid the black corners on the my_poly image in this example but keep the shadeblendSetGraphicsDriver 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. |
| ||
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. |
| ||
... 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). |
| ||
Its up to you. You could have separate images for each mode. Or if you prefer your shade-and-mask modification, go with it. |
| ||
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. |