Re: Passing floats/doubles to C

new topic     » goto parent     » topic index » view thread      » older message » newer message

Todd:

   Take a look at my MIXEDLIB.E in the recent contributors
   It might make your job easier for handling structures
   and converting things from "C".
   Below are examples:
   This code will work without worrying about pokes and offsets.

Bernie



include mixedlib.e

constant -- structure is created and initialized as all zeros
MATERIAL = struc(" diffuse_r  : double : 1 "&
   " diffuse_g  : double : 1 "&
   " diffuse_b  : double : 1 "&
   " diffuse_a  : double : 1 "&
   " ambient_r  : double : 1 "&
   " ambient_g  : double : 1 "&
   " ambient_b  : double : 1 "&
   " ambient_a  : double : 1 "&
   " specular_r : double : 1 "&
   " specular_g : double : 1 "&
   " specular_b : double : 1 "&
   " specular_a : double : 1 "&
   " emissive_r : double : 1 "&
   " emissive_g : double : 1 "&
   " emissive_b : double : 1 "&
   " emissive_a : double : 1 "&
   " power      : double : 1 ",HIGH)

-- declare a "C" type variable
double adubval

-- To set a structure value
Sets(MATERIAL, "ambient_r", 1.783)

-- To read a structure value
adubval = Gets(MATERIAL,  "ambient_r")

-- print it
printf(1,"%f", adubval)

-- or print like this
printf(1,"%f", Gets(MATERIAL,  "ambient_r"))

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu