Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  ByteOrder issue  (Read 1557 times)
0 Members and 1 Guest are viewing this topic.
Offline Evil-Devil

Senior Devvie


Medals: 2


Fir Tree Master


« Posted 2005-12-20 18:45:11 »

Hi,
as it came up to export the data of models like *.obj to the one my engine uses, i ask me the question "what about the byteorder issue with various platforms?".

As on Windows there is Heighest Bit first i write my datafiles with these byteorder. But how does i have to handle it with other platforms? Is it enough to tell my fileloader (uses NIO bytebuffers) to take all byte with heighest bit regardless the filesystem uses Lowest Bit?
Is that enough or have swap every byte from high to low and back to make my files compatible on most platforms?

Evil
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2005-12-20 18:55:42 »

Take a look at the java.nio.Buffer and ist sub classes. You can set the endianess.

Be aware that there (at least was) a bug in the duplicate() and slice() functions where it loses the endianess setting in the new copy so you need to reset it.

JK

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Evil-Devil

Senior Devvie


Medals: 2


Fir Tree Master


« Reply #2 - Posted 2005-12-20 19:39:49 »

I know that i can set the endian by myself via the byteOrder() function, but does i have to switch from heighest to lowest or can i just write and read with heighest even on a lowest bit system? (sounds confusing?)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #3 - Posted 2005-12-20 20:55:12 »

Java has a standard byte order of its own that is cross paltform.

If all you need to do is read and write to/from java programs just use the normal DataInput/OutputStreams and dont worry about it.

(Buffers also default to Java byte order.)


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #4 - Posted 2005-12-20 21:38:27 »

Java has a standard byte order of its own that is cross paltform.

More precisely, Java uses the "standard" byte order known as "Network Byte Order". Network byte order was developed to ensure that [TCP|UDP|*]/IP packets could be understood by all machines that used the Internet. Since Java is a cross-platform language in the Internet era, Network Byte Order made a lot of sense.

It would be nice if all I/O libraries observed network byte order. Sadly, most default to machine byte order, so you have to be careful when you're reading a file written by a non-Java program. I've been bitten by poor endianess on Intel more than once.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Evil-Devil

Senior Devvie


Medals: 2


Fir Tree Master


« Reply #5 - Posted 2005-12-23 11:00:32 »

Ok, that means i dont have to provide the "byteOrder()" function while i create a bytebuffer to store my data, right?
If so, thanks for the help Smiley

Evil
Offline Jeff

JGO Coder




Got any cats?


« Reply #6 - Posted 2005-12-23 18:58:08 »

Right it defeaults to the Java Standard.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #7 - Posted 2005-12-24 00:58:56 »

It would be nice if all I/O libraries observed network byte order. Sadly, most default to machine byte order, so you have to be careful when you're reading a file written by a non-Java program. I've been bitten by poor endianess on Intel more than once.

Motorola and PowerPC processors are sane enough to use the correct ("network" or "big endian") byte order.  Sadly there aren't many of those superior processors around.. now that Apple has gone to Intel.    I don't think we should hold our breath for Intel to make a processor with a decent architecture... perhaps if they didn't base their current processors on being backward compatible with a calculator chip from the 70s... so sad...  Too bad IBM couldn't work out their issues with getting the PowerPC up to speed.

What byte order does a Sparc processor use?  I would assume that it is also the correct byte order, after all "the network is the computer" Smiley

One of my "high hopes" for Java was that it would free Intel to break with the backwards compatibility since Java applications wouldn't even need to be recompiled.  Once you have the core OS and a JRE ported/recompiled all the existing apps should "just work".   But we all know it is far from that simple.  And so we have better achitectures like PPC being emulated on Intel in the new Macs, when it should be the other way around.  Somehow I am sure this is all Microsofts fault Smiley

Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #8 - Posted 2005-12-24 01:18:17 »

What byte order does a Sparc processor use?  I would assume that it is also the correct byte order, after all "the network is the computer" Smiley

SPARC is a naturally Big Endian architecture. Most RISC processors were. The little endian processors included x86, ARM, and Alpha. (All high performance processors. Coincidence? Probably.)

Quote
One of my "high hopes" for Java was that it would free Intel to break with the backwards compatibility since Java applications wouldn't even need to be recompiled.  Once you have the core OS and a JRE ported/recompiled all the existing apps should "just work".   But we all know it is far from that simple.  And so we have better achitectures like PPC being emulated on Intel in the new Macs, when it should be the other way around.  Somehow I am sure this is all Microsofts fault Smiley

It's not hard to make a case for Microsoft's fault in the situation. After all, they DID have the best JVM available back in the 1.1 days. They also had a kick-ass IDE in the form of J++. If they hadn't screwed the market over with their incompatible extensions, we'd all be using Java desktop applications today.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Jeff

JGO Coder




Got any cats?


« Reply #9 - Posted 2005-12-24 05:16:36 »

It would be nice if all I/O libraries observed network byte order. Sadly, most default to machine byte order, so you have to be careful when you're reading a file written by a non-Java program. I've been bitten by poor endianess on Intel more than once.

Motorola and PowerPC processors are sane enough to use the correct ("network" or "big endian") byte order.  Sadly there aren't many of those superior processors around.. now that Apple has gone to Intel.   

Gonna be a lot of em around soon in consoles....  all the next gen consoles are PPC.

IBM calls their strategy "Power Everywhere" and is very serious about getting PPC into every computing device possible.

Ironically, this is reportedly part of  what pushed Apple away from PPC.  When noone else muchw as using PPC they had "favoured nation status" and rather abused it by all accounts.  Once IBM/Motorola had other larger customers, that status went away and Apple no longer was accord the defference they felt they deserved....

Quote
I don't think we should hold our breath for Intel to make a processor with a decent architecture... perhaps if they didn't base their current processors on being backward compatible with a calculator chip from the 70s... so sad...  Too bad IBM couldn't work out their issues with getting the PowerPC up to speed.

After the Itanium disaster it will take a brave exec at Intel to suggest moving away from their power bsae again.

Quote
What byte order does a Sparc processor use?  I would assume that it is also the correct byte order, after all "the network is the computer" Smiley

What I rememerb from my C days... is that Sparc is the same byte order as the Motorola 68000 family, but there are subtle byte packing differences.  Again AIR 68000 aligngend everything on word boundaries whereas Sparc aligns on type-boundaries.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #10 - Posted 2005-12-24 19:00:08 »

IBM calls their strategy "Power Everywhere" and is very serious about getting PPC into every computing device possible.

Except the desktop.  Meaning I no longer can get a PPC based home computer.  I have an old BeBox sitting around here somewhere, but I was never able to get it to boot up properly Sad

Quote
Ironically, this is reportedly part of  what pushed Apple away from PPC.  When noone else muchw as using PPC they had "favoured nation status" and rather abused it by all accounts.  Once IBM/Motorola had other larger customers, that status went away and Apple no longer was accord the defference they felt they deserved....

If it was I think it was a small part.  The speed problems seemed to be the big thing.  Though it's funny how all of Apple's performance information shows their high-end PPC based systems beating Intel systems with faster clocks... and yet now that's exactly where they are headed Smiley   The power of marketing.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (37 views)
2014-12-15 09:26:44

Mr.CodeIt (31 views)
2014-12-14 19:50:38

BurntPizza (62 views)
2014-12-09 22:41:13

BurntPizza (99 views)
2014-12-08 04:46:31

JscottyBieshaar (60 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (77 views)
2014-11-29 21:32:03

toopeicgaming1999 (138 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (38 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!