Sunday, December 1, 2013

Revisit OpenGL with GLUT on Linux

Remember in year 2002, the time I begin my game programming journey. The first thing I learn to program OpenGL during that time is Win32, and because I'm running on Windows machine, Win32 is the perfect option I started with Windows programming. Today, I'm revisit the OpenGL code on Linux, unfortunately Win32 is not runnable on Linux. What am I suppose to do next?

I discover that it's still doable with GLUT library. One thing that impress me is the code has nearly chop off 70% LOC just on the windows creation. Code snippet below showing the basic code framework done on GLUT:
int main(int argc, char **argv)
 glutInit(&argc, argv);
 //Simple buffer
 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB );
 glutCreateWindow("Green window");
Comparing with the code done on Win32, it is bloody disaster. I didn't show the code in this post because it is bloody long, it is reachable at NeHe's link. There are variation on the GLUT setup, Windows and Linux. On Linux, the require files are reachable through the Linux repository of my choice, and the header files always located at /usr/header, and library files located at /usr/lib.

Whereas on Windows, there is a litter tricky, and very dependent on compiler choice. I have try 3 of the compilers which there are Cygwin, MinGW, and VS 2012 Express. I failed to make it run on Cygwin and MinGW due to proprietary DLL file was missing during run-time. Luckily it is workable on VS 2012 Express. I got a bad news initially when working on VS where the Microsoft SDK doesn't come with GLUT library, it has to be download separately. I was so lucky that I found this link that drive me all the from setup till running the program. One thing to note is that I'm running Windows8 machine, putting the glut32.dll under C:\windows\system32 will not going to work, it has to be put under C:\windows\SysWOW64.

In conclusion, Linux is always the best choice for developer because it is a development box at the beginning with header and library files ready set aside on the path.

No comments: