Eduardo Cavazos
2009-02-07 00:23:59 UTC
Hello,
Example using 'gl':
(glColor4d 1 1 1 1)
Of course, this produces an error since the 'glColor4d' expects double
arguments.
However, it's no fun to litter the code with 'exact->inexact'. Another
approach I take is to do (+ 0.0 n).
So my question is, in the future, will the ffi work such that numeric
conversions such as these happen automatically? If not, then I suppose
the solution is a "higher level" library which does things like:
(define (gl-color r g b a)
(glColor4d (exact->inexact r)
(exact->inexact g)
(exact->inexact b)
(exact->inexact a)))
will be in order.
It seems like integer->float conversions seem conservative while the
reverse isn't prudent.
Ed
Example using 'gl':
(glColor4d 1 1 1 1)
Of course, this produces an error since the 'glColor4d' expects double
arguments.
However, it's no fun to litter the code with 'exact->inexact'. Another
approach I take is to do (+ 0.0 n).
So my question is, in the future, will the ffi work such that numeric
conversions such as these happen automatically? If not, then I suppose
the solution is a "higher level" library which does things like:
(define (gl-color r g b a)
(glColor4d (exact->inexact r)
(exact->inexact g)
(exact->inexact b)
(exact->inexact a)))
will be in order.
It seems like integer->float conversions seem conservative while the
reverse isn't prudent.
Ed