#### Archived

This topic is now archived and is closed to further replies.

# whats needed for true platform independent?

This topic is 5885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Will a console application using GLUT and OpenGL in MSVC++6 be able to run, un-changed and not recompiled, on a different system than Windows? If not, than what is needed to do this?

##### Share on other sites
Hmmm, your program must be recompiled for the different
platforms. You can''t avoid that.

My GLUT programs can compile with no modification
on Windows, Linux, and Solaris. And yes, they run identically
on all 3 platforms (appearance, not performance).

The only thing I need is this:

#ifdef WIN32#include <windows.h>#endif#include <GL/gl.h>#include <GL/glut.h>

That and the sleep function. I use Sleep
for Windows and nanosleep for Linux/Solaris.

Kami no Itte ga ore ni zettai naru!

##### Share on other sites
That''s tight, my game is so platform dependent it makes me sick Unless you consider the XBox another platform, then its portable lol

Mindgamez Entertainment

##### Share on other sites
How do you set your compiler for the multiple systems? Can it be done easily in MSVC?

##### Share on other sites
Either go to the other platform and compile it on a native compiler, or use a cross-compiler. I believe you can''t do this with MSVC.

##### Share on other sites
I''d have tried to make a platform independent engine but I''m using DirectX so no dice lol

Mindgamez Entertainment

##### Share on other sites
I recently discussed this actually, and one thing I didn''t think of is that you have to take endian-ness into account. Make sure that you convert to the right endian for the OS, otherwise your program will be garbage ( thinking about loading files from disk now ). There are functions to convert "network endian" into native OS endian though, which you will most likely need to use. I forget the names.

Death of one is a tragedy, death of a million is just a statistic.

##### Share on other sites
"How do you set your compiler for the multiple systems? Can it be done easily in MSVC"

no

Why would microsoft want to make a compiler that works for non-ms operating systems?

##### Share on other sites
quote:
Original post by neurokaotix
That''s tight, my game is so platform dependent it makes me sick Unless you consider the XBox another platform, then its portable lol

Mindgamez Entertainment

wow... the last i heard they were just making theorys on how to make apps for the xbox! although that was about 3 months ago... -PmanC

##### Share on other sites
My engine (Avangion) is platform-independant (Works on Windows and Unix based systems). The matter concerning little and big endian is annoying but can be resolved quite easily. First, find out what system your engine is compiled on by using #ifdef. Windows works with little endian while Linux works with big endian. Then, simply #define some macros that automatically convert the data if it is necessary. Here is some pseudo-code:

#ifdef LITTLE_ENDIAN
#define SWAP16LE(x) (x)
#define SWAP32LE(x) (x)
#define SWAP16BE(x) Swap16(x)
#define SWAP32BE(x) Swap32(x)
#endif

#ifdef BIG_ENDIAN
#define SWAP16LE(x) Swap16(x)
#define SWAP32LE(x) Swap32(x)
#define SWAP16BE(x) (x)
#define SWAP32BE(x) (x)
#endif

The Swap16 & Swap32 functions simply switch the high order byte(s) with the low order one(s) using bitwise ops.

Hope that helps!

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
13

• 9
• 14
• 10
• 25
• 9
• ### Forum Statistics

• Total Topics
632645
• Total Posts
3007627
• ### Who's Online (See full list)

There are no registered users currently online

×