behavior of 3ds2mgf

Hello all,

I have two 64bit machines here running und Gentoo Linux. When compiling the latest HEAD everything works just fine, all executables are built.
After running a few tests I discovered, that 3ds2mgf seems to be broken. This is the content of rmake:

#!/bin/sh
exec make "SPECIAL=" \
        "OPT=-O2" \
        "MACH=-Dlinux -D_FILE_OFFSET_BITS=64 -L/usr/X11R6/lib -I/usr/include/X11 -DNOSTEREO" \
        ARCH=IBMPC "COMPAT=erf.o" \
        INSTDIR=/opt/ray/bin \
        LIBDIR=/opt/ray/lib \
        ESUFFIX= \
        CC=gcc "$@" -f Rmakefile

"3ds2mgf file.3ds" only produces "file.mgf" with this content:

c R =
        cxy 0.640 0.330
c G =
        cxy 0.290 0.600
c B =
        cxy 0.150 0.060

i file.inc

and "file.inc" is empty. Can anyone reproduce this or maybe even better has a hint as to where I can start debugging this problem?
It seems all 32bit versions (older compiles) run fine on the same systems, i.e. they produce the expected output.

Thanks in advance,
Erwin

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

Sorry, Erwin. I tried. It isn't easy for me to debug something using a compiler I don't have on a machine I don't have.

-Greg

···

From: "Erwin Zierler" <[email protected]>
Date: October 7, 2008 9:56:34 PM PDT

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

Dont worry, I will figure it out eventually :wink:
Thanks,
Erwin

···

-------- Original Message --------
Subject: [Radiance-dev] Re: behavior of 3ds2mgf (08-Okt-2008 8:18)
From: Gregory J. Ward <[email protected]>
To: [email protected]

Sorry, Erwin. I tried. It isn't easy for me to debug something
using a compiler I don't have on a machine I don't have.

-Greg

> From: "Erwin Zierler" <[email protected]>
> Date: October 7, 2008 9:56:34 PM PDT
>
> 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

_______________________________________________
Radiance-dev mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-dev

Dear Erwin,

I don't know if the gcc is really the problem - but if yes, see below an
instruction how to build an older gcc version with a newer one. I use
that for compiling esp-r- which also has trouble with gcc4.xx.

Then you have two gcc versions in parallel. Be careful while installing:
you have to use the /make bootstrap /otherwise you can destroy your
system (if you install it as root it replaces the existing libraries -
I once destroyed my system with that....)
Before using programs compiled under gcc3.x, you have to set the library
path to the related lib-path ( export LD_LIBRARYPATH=/opt/gcc33/lib or
similar).

Good luck!

Jan

------------- Instruction to build an gcc 3.3.6, using gcc4.xx

···

---------------------------

Get gcc-core from from GCC Mirrors Page

Compiling GCC-3.3.6:

Untar the source then configure with:
./configure --prefix=/opt/gcc33 --program-suffix=-3.3
WARNING: Do NOT configure it with the default prefix! It is recommended
to compile it with this prefix else you can damage your system!
Now compile it with make bootstrap and after that install it with make
install.

Gregory J. Ward wrote:

Sorry, Erwin. I tried. It isn't easy for me to debug something using
a compiler I don't have on a machine I don't have.

-Greg

From: "Erwin Zierler" <[email protected]>
Date: October 7, 2008 9:56:34 PM PDT

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

_______________________________________________
Radiance-dev mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-dev

--
Dipl.-Ing. Jan Wienold
Project Manager
Fraunhofer-Institut für Solare Energiesysteme
Thermal Systems and Buildings, Lighting and Daylighting
Heidenhofstr. 2, 79110 Freiburg, Germany
Phone: +49(0)761 4588 5133 Fax:+49(0)761 4588 9133
[email protected]

In office:
Mo,Tue: 8:30-18:00
We,Thu: 8:30-16:00
Fr: 8:30-15:30