Enhanced SetClsColor
BlitzMax Forums/BlitzMax Programming/Enhanced SetClsColor
| ||
SetClsColor with alpha: (should be fixed now) |
| ||
This is interesting and useful...thanks! |
| ||
Hi Jake, I must be doing something wrong as I get Bitwise Operator can only be used with integers .I did have to add an End Function and brackets. I changed to If TD3D7Max2DDriver(_max2dDriver) TD3D7Max2DDriver(_max2dDriver).clscolor=Int((alpha And 255) Shl 24) |(red Shl 16)|(green Shl 8)|blue Else glClearColor red/255.0,green/255.0,blue/255.0,alpha EndIf which seems to work. |
| ||
Shouldn't it be(alpha & 255) ? |
| ||
Yes it should be & instead of And. see this example: Print 12345 And 6789 Print 12345 & 6789 The output is different becouse "And" is optimized for logical operations, and "&" is the regular boolean operator. |
| ||
How do I get this to work then and can somebody provide an example of its usefulness? |
| ||
Damn, I forgot about two golden rules. 1.) Never post code before you got your first morning coffee 2.) Never do quick changes to posted code before test compiling it. I rearranged my code while posting, so this errors. Sorry for that, should be fine now. |
| ||
I'm being very dense but what is it used for and how does it differ from the normal setclscolor? |
| ||
It appears to add an Alpha value, as well as RGB. And the comment in the code posted also says "Useful if you want to save images with alpha using GrabPixmap.", which I believe is not how it currently works. |
| ||
Yep, thanks for that. This is where I am being dense. I can read the code and the comments but I would really like to see an example of it being used. |
| ||
Hm, seems like I tested this only with OpenGL. DX-Alpha got ignored somehow. Here's the line from d3d7max2d:clscolor=$ff000000|(red Shl 16)|(green Shl 8)|blue Changing $ff000000 to something different doesn't make a difference. Here's an example that, using the OpenGL driver, works: |