Jump to content
  • Advertisement

Archived

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

DanG

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


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

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!