Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > MacOS X - Darwin - Opengl/Md2 Models - Programming weirdnes

MacOS X - Darwin - Opengl/Md2 Models - Programming weirdnes
Thread Tools
Syphor
Junior Member
Join Date: Jul 2002
Location: Australia
Status: Offline
Reply With Quote
May 30, 2003, 09:00 AM
 
I have made a program which will tell me the version number of the MD2 file called "tris.md2", I have compiled this on linux and freebsd though the very same program doesn't work on darwin/macos x....

it comes up with diff outputs:
FreeBSD: Version is 8
Linux: Version is 8
Mac OS X: Version is 134217728

http://syphor.homeip.net/MD2

download md2.c, md2.h, tris.md2 and then type "cc -o run md2.c" then "./run"


Any help would be very very very appriciated
     
proton
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
May 30, 2003, 10:18 AM
 
Originally posted by Syphor:
I have made a program which will tell me the version number of the MD2 file called "tris.md2", I have compiled this on linux and freebsd though the very same program doesn't work on darwin/macos x....

it comes up with diff outputs:
FreeBSD: Version is 8
Linux: Version is 8
Mac OS X: Version is 134217728

http://syphor.homeip.net/MD2

download md2.c, md2.h, tris.md2 and then type "cc -o run md2.c" then "./run"


Any help would be very very very appriciated
To actually connect to the site, use http://syphor.homeip.net/MD2/ folks.

And on to the problem...

The problem is that the file stores data on disk in little endian byte format, whereas Macs use a big endian byte format. Here's what happens:

The version is stored as a 32 bit number as this is the size of ints on most computers today. On a little endian machine, 8 when extended out to be 32 bits is stored as:

0x08 0x00 0x00 0x00

On a PowerPC machine (big endian), 8 is represented as:

0x00 0x00 0x00 0x08

Hence when you read that top number in, it is, in big endian format actually 134217728.

You'll need to come up with a way convert from little endian to big endian to read it on any big endian machine, such as SPARC, PowerPC, Motorola 680x0, or basically anything but i386/VAX/IA-64.

- proton
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 06:24 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,