Jump to content
  • Advertisement
Sign in to follow this  
Dougie

OpenGL SDL/OpenGL/PNGs and Linux (and Mac)

This topic is 5055 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

Ok, I'm a windows programmer, but I'm trying to make my games quick and easy to compile on other OS's (Linux and Mac mainly). I use SDL and OpenGL and avoid all windows only functions. I'm also trying to use the pnglib and the other files that go with it to read png files. Now, I've have friends on other Linux and Mac complain about several thing, and I need some info: Firstly, is gl.h, glu.h, and OpenGL32.lib universal or windows only? Secondly, what are makefiles and how do I make them? And thirdly, do makefiles work for both Mac and Linux? Thanks for your time

Share this post


Link to post
Share on other sites
Advertisement
Oh, and I forgot; is there something similar to the __asm keyboard for other compilers (I use VC++ 6.0)?

I would also like to avoid glut as I've heard its slow

Share this post


Link to post
Share on other sites
As far as I know...


The asm keyword (or variation of said keyword) is standard C, I think.

makefile = ascii text file that is parsed by nmake, gmake, make (and so on) that (to put it simlpy) defines dependancies of source files and compiler/linker options.

Think of a makefile as a different way to define your project. Typically more fuss to get it working but more flexability. Usually, you can make it do exactly what you want.


I believe gl libraries are usually under <GL/gl.h> (etc) in nix like setups

As for OpenGL32.lib, that is (I think) windows specific, You'll probably find OpenGL as GL and GLU which symlink to the current version installed.

Or in short, you'll either need a crossplatform makefile, or a project/makefile per OS.

HTH

Share this post


Link to post
Share on other sites
If you don't use any of the GLUT functions in your code, you don't have to use it. SDL provides all the necessary window handling functionality.

Often, it's worth checking for yourself. Often someone could have made an incorrect claim about something, and people accept and repeat it as if it is true.

Java is a good example. Bits of it, admittedly could do with being a bit faster (Swing), the bits you are more likely to use in a game are pretty fast. Java's got considerably faster than it was originally. Indeed applications running under a modern JIT compiling JVM can beat the same application compiled directly to native code.

Share this post


Link to post
Share on other sites
GL/gl.h and GL/glu.h are universal. Note that the GL is capital, and that you use a forward slash. This is mandatory in order for the code to be portable.

OpenGL32.lib is windows specific. You can either configure it in the VS project settings, or use:

#ifdef WIN32
#pragma comment(lib, "opengl32.lib")
#endif

For other platforms, you can configure the project settings (Xcode, for example) or you can set it in the Makefile (Linux).

Share this post


Link to post
Share on other sites
Just some clarification:

while the __asm keyword is part of the c standard, the asm code is different for many types of processor, for instance, Macs use PowerPC architecture chips, and Intel style asm doesn't run on PowerPCs (totaly different instruction set), so you should avoid asm if at all possible for portable code.

while GL/gl.h works for linux and windows, the mac stores GL at:

#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>
// and glut is at:
#include <GLUT/glut.h>


But SDL has a neat header, SDL/SDL_opengl.h that will find you OpenGL on any platform, so it is best to use this instead.

Glut has not been noticeably slower in my use than SDL, or indeed any windowing library, but I dislike that glut forces you to surrender control of the run loop, I must be a control freak ;)

Hope this helps,

SwiftCoder

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!