Re-2: [Radiance-dev] behavior of 3ds2mgf

Erwin Zierler radiance at rendigo.com
Tue Oct 7 21:56:34 PDT 2008


I have tried your patch but it didn't change things really. Out of curiosity I compiled the current head on a 32bit machine (also under Linux) and I get the exact same behavior (using the original 3ds2mgf.c). 
So I finally tried an older binary of 3ds2mgf (Radiance 3.6a) on the same system and this one works just fine. Unfortunatly I dont have the sources anymore to see what happens if I compile them 
Somehow I get a feeling it might have to do with the gcc version I am using on all these systems nowadays: 

# gcc --version
gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.1)

For all older compilations I am pretty sure I was still using gcc 3.*. 
Just in case that helps. 
 Erwin

-------- Original Message --------
Subject: Re: [Radiance-dev] behavior of 3ds2mgf (07-Okt-2008 18:40)
From:    Gregory J. Ward <gregoryjward at gmail.com>
To:      radiance at rendigo.com

> Hi Erwin,
> 
> I'm pretty sure the problem is in 3ds2mgf.c:
> 
> float read_float()
> {
>      dword data;
> 
>      data = read_dword();
> 
>      return *(float *)&data;
> }
> 
> which assumes that "unsigned long" is 4-bytes long.  This bit of code  
> would actually work on a BigEndian system (I think), but not on  
> Intel.  This is not my code, so I'm not 100% confident on this fix,  
> but try it:
> 
> float read_float()
> {
>      union { dword i; char c[8]; } u;
>      dword data;
> 
>      data = read_dword();
> 
>      if (sizeof(dword) == sizeof(float))
>          return *(float *)&data;
> 
>      u.i = 1;
>      if (u.c[0] == 0)
>          return *(float *)&data; /* assume big-endian */
> 
>      if (sizeof(dword) != 2*sizeof(float)) {
>          fputs("Unsupported word length\n", stderr);
>          exit(1);
>      }
>      u.i = data;
>      return *(float *)&u.c[4];
> }
> 
> -Greg
> 
> _______________________________________________
> Radiance-dev mailing list
> Radiance-dev at radiance-online.org
> http://www.radiance-online.org/mailman/listinfo/radiance-dev





More information about the Radiance-dev mailing list