Do we have to worry about byte orders in the process of programming a game? Do game consoles use different byte orders?
|
|
If you're writing networking code, this often is something you have to deal with, yes. Also it's possible that the byte ordering in a file format is not what your platform uses, so sometimes it matters there too. |
|||
|
|
|
Do you have to worry about it? Likely not. A vast majority of game programming is going to be at such a level that the endianness is abstracted away. Even in networking, you're almost certainly going to be using a library for networking protocols. It's good that you're aware of it, but I doubt you'd run into an issue with it. |
|||
|
|
|
It depends on the platforms you're targetting. For example, I believe that the PS3 is big-endien so if that's one of your targets then it's something you need to be aware of, yes. In the home computer space the "Big 3" (Windows, Linux, Mac) are all exclusively, or all but excelusively, on Intel x86/x64 architectures these days, so endienness concerns are no longer relevant. |
|||
|
|
|
Most of the time, no. Endianess is usually abstracted away in the high level modules of a game engine, and you don't have to worry about it on a daily basis. If it isn't abstracted, then the engine has a serious issue and should be fixed, because this isn't the kind of details you should be worrying about when making a game. However if you're working on some low-level parts of a C/C++ multi-platform engine, you might have to deal with it. All three current-gen consoles use a PowerPC architecture, which is big-endian, whereas the x86 architecture used on PC is little-endian. So if you're working on some code that reads raw bytes from somewhere to put them in data structures (binary serialization, networking...), yes you will have to deal with it. For instance, in C/C++, it's common to see this kind of byte swapping in action (not tested, welcoming corrections):
Once again, this is OK in low-level code, but this shouldn't be something used everywhere. |
|||
|
|
