Is this useful?

BlitzMax Forums/BlitzMax Beginners Area/Is this useful?

Chroma(Posted 2005) [#1]
GL Colors range from 0 to 1. Hey, this let's me be lazy. And yes I'm taking baby steps here. :(

Print GLColor(200)

Function GLColor:Float(RGB:Int)
	Return RGB / 255.0
End Function



Grey Alien(Posted 2005) [#2]
well not useful for anything fast ;-)


Chroma(Posted 2005) [#3]
It wouldn't be called every cycle of course. Just wondering how people are getting the colors they want by using the 0 to 1 values. Is there a built in converter or are you guys just guessing?


TomToad(Posted 2005) [#4]
This is where an "Inline" option would be handy. When the overhead of calling a function is more than the function itself, then the compiler would just replace the call with the function. So.
Inline Function AddNumbers:Int(Number1:Int,Number2:Int)
 Return Number1 + Number2
End Function

Print AddNumbers(10,15)

Would actually compile down to
Print 10+15



Ferminho(Posted 2005) [#5]
True, true.
Would love to see this someday


Chroma(Posted 2005) [#6]
The function works perfectly here. But I see what you're saying. It wouldn't be optimal in a realtime situation.

Instead of calling the glColor function it'd be faster to just do the math ie:

glColor3f( 100.0/255.0, 200.0/255.0, 245.0/255.0 )


Warpy(Posted 2005) [#7]
or do it in your head... you can make a pretty good guess about what fraction of 256 something is quite easily


Grey Alien(Posted 2005) [#8]
yeah but if you type this glColor3f( 100.0/255.0, 200.0/255.0, 245.0/255.0 )

the compile should calc the values at compile time into a single constant, it shouldn't be doing the divisions at runtime so you are OK unless you replace one of the values with a variable.


Hotcakes(Posted 2005) [#9]
Would actually compile down to

Print 10+15

Which would in turn compile down to a lazy 'Print 25' because constants were used =]