Advertisement

Linux

Started by November 22, 2001 03:41 PM
5 comments, last by XzenoX 23 years ago
On linux: i know opengl seems to work fine and i know directx stuff doesn''t work at all, so to render a 2d plane must i use strickly OpenGL or just declaring the window will make it work on all OSes? I''m sorta new programming and me and a few friends were thinking doing a game and i was wondering if i should be better of starting to program using Linux to ensure compatibility, the other programmers all have win98/2k. I know i can get a compiler fine with linux but will all the code work fine with all OSs if i program Linux or it will end up working only on that(which we don''t want to) Tnx ^_^
Resistance is futile: prepare to be assimilated !
If you want to have 100% of your code work in both Windows and Linux take a look at SDL. Otherwise you''ll have to use GLX and XLib (the equivelants of WGL and the Win32 API, respectively).

[Resist Windows XP''s Invasive Production Activation Technology!]
Advertisement
try SDL, its got some nice 2D bit blitting stuff and is OS independant for the most part, using linux does not guarantee compatibility, its the api''s you use and the way you code that does, the code should compile on all compilers that are standards compliant, though there are issues but mostly it shouldn''t concern you.
XWindow programming is different from Windows programming.

The function calls you use to create a window (and such stuff) in Windows won''t work to create a window in X, and vice versa. That''s why GLUT has been developped. If you''re using it to handle the windowing, input and stuff, you should be fine.

As far as files & stuff are concerned, standard C and C++ functions are the same unless you have a faulty install.

Oh, and Microsoft claims that Windows is POSIX compliant (-insert laughter here-)...

Your code will only be as portable as you make it be. Stay away from compiler-specific code or learn to use preprocessor conditionals, like

  #ifdef linux// linux specific code#endif#ifdef WIN32// windows specific code#endif  
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
quote: Original post by Fruny
Stay away from compiler-specific code...

Very true . If you''re using C++, MSVC has quarks with exception throwing (the only prominent one is that the new operator won''t throw an exception by default). Nothing big, a couple preprocessor blocks takes care of it.

[Resist Windows XP''s Invasive Production Activation Technology!]
Tnx, basicaly, when using C++ to work with all, or as much OSs, stay away from compiler specific code and just by using SDL and i should try GLUT, O.K

That was great help tnx ^_^
Resistance is futile: prepare to be assimilated !
Advertisement
Well, since everyone is ragging on MSVC allow me to point out the failings of GCC...

1.) With regards to exceptions, you can''t do this:
try{  ...  throw new exception("Error here");  // bombs here  ...}catch(exception &e){  cout << e.what();} 

2.) GCC does not properly implement the ctype class - behavior clearly specified in the standard (and in examples by Bjarne and others) fail:
ctype()->toupper(str.begin(), str.end()); // fails 


In the final analysis, all compilers have quirks. GCC is an excellent choice if you want to write cross platform code because it runs on so damn many platforms. However, once we move away from the compiler itself we come to more complex issues like wrapping/encapsulate APIs and so forth. Those are major decisions, and a good strategy is a necessity for a successful development cycle.

Then there''s the question of your experience level. If you''re not familiar with Linux, mid-development is not a good time to jump in. Other than that, good luck!

This topic is closed to new replies.

Advertisement