Enhanced SetClsColor

BlitzMax Forums/BlitzMax Programming/Enhanced SetClsColor

Jake L.(Posted 2007) [#1]
SetClsColor with alpha: (should be fixed now)




degac(Posted 2007) [#2]
This is interesting and useful...thanks!


tonyg(Posted 2007) [#3]
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.


Brucey(Posted 2007) [#4]
Shouldn't it be
(alpha & 255)

?


ziggy(Posted 2007) [#5]
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.


tonyg(Posted 2007) [#6]
How do I get this to work then and can somebody provide an example of its usefulness?


Jake L.(Posted 2007) [#7]
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.


tonyg(Posted 2007) [#8]
I'm being very dense but what is it used for and how does it differ from the normal setclscolor?


Brucey(Posted 2007) [#9]
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.


tonyg(Posted 2007) [#10]
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.


Jake L.(Posted 2007) [#11]
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: