Page 1 of 1

[Implemented] Float command

Posted: Mon May 23, 2005 7:23 pm
by Polo
Yes, we have an Int command, I think we should have a Float one.
Why ? Because some OpenGL function requires the use of float (for example, the command won't work if you type 1 instead of 1.0). For me a Float command would be helpful to be sure we're passing a float.

Well, I'm not sure i'm clear in my explaination, here's an example :
You have one color :
color.l=RGB(255,255,255)
You wanna use the command glColor3f_()
here's an example of what will not work :
glColor3f_(Red(color)/255,Green(color/255),Blue(color)/255)
Why ? Just because "Red(color)/255" will be considered as a long value instead of a float.
I know we can use a temporary value, but it's not a good way to code...

Posted: Mon May 23, 2005 8:16 pm
by Blade
Perhaps

Code: Select all

glColor3f_(Red(color)/255.0,Green(color/255.0),Blue(color)/255.0)
?

Posted: Mon May 23, 2005 8:19 pm
by Polo
Don't know, perhaps, but a float command would be great as well ;)

Posted: Tue May 24, 2005 12:57 am
by jack
I know you don't want work-arounds :wink: but here it is.

Code: Select all

Procedure Float(x.f)
  ProcedureReturn x
EndProcedure
it works because PB automatically converts int to float. :)

Posted: Tue May 24, 2005 8:55 am
by blueznl
shouldn't that be procedure.f?

Posted: Tue May 24, 2005 10:10 am
by jack
blueznl wrote:shouldn't that be procedure.f?
yes

Posted: Tue May 24, 2005 10:58 am
by Fred
Another way would be to specify which OS command needs floats as input so all the conversion will be done automatically.

Posted: Tue May 24, 2005 12:19 pm
by jack
Fred wrote:Another way would be to specify which OS command needs floats as input so all the conversion will be done automatically.
that would be very handy, perhaps like this:

Code: Select all

Declare Extern glColor3f_(x.f,y.f,z.f)

Posted: Tue May 31, 2005 1:38 pm
by Dummy
My Idea(Stolen from C(++)):

You can secify the type of a (Return-, Constant-,...)value so it is Typecasted to that one:

Code: Select all

glColor3f_(Red(color).f/255.0,Green(color.f/255.0),Blue(color).f/255.0)
I hope you understand what I mean!

Posted: Tue May 31, 2005 5:36 pm
by Polo
Not a bad idea since it would avoid the call of a function, and so speed up the program :)