OSX and PC
This article is going to give a brief comparison of OSX and Windows 7 in relation to OpenGL programming, and programming in general. I am in no way wanting to start a flame war, but feel free to fight amongst yourselves in the comments section. I will admit it sounds like I’m bashing Windows and praising OSX, but in relation to OpenGL, this is the truth.
If any of you have taken a real good look at the tutorials on the site, you may notice that some of them have screenshots from Windows and others have screenshots from OSX, the newer tutorials being from OSX. This is because I first started programming on Windows many years ago, and whilst I still program on Windows when I have to, a majority of my work is now done on OSX. Don’t get yourselves thinking that I automatically have some money behind me, just because I own a Mac, doesn’t automatically translate to “He’s got a Mac, how the heck did he afford that?! …Must be some rich guy.” I’m a uni student, who spent half a year saving for it, and these days it’s my most valuable asset.
Anyway, I started my OpenGL programming back on Windows XP and as Windows Vista and Windows 7 were released, I migrated from one to the other. The downside to being an OpenGL programmer in a Windows environment, is that while you can get everything setup easily, you still have to go through that setting up stage every time you format, reinstall or upgrade your operating system, as Windows is primarily meant for DirectX, and while you still need the DirectX SDK to develop on your operating system, you can generally run your previous programs no worries.
Well after quite a few years, I finally grew up and was able to come to University, where I was given a good rundown of Ubuntu and I started doing some research in one of the labs which also used Ubuntu. From then on, I spent about a year and a half developing with OpenGL on Ubuntu and it was all fairly straight forward after you had the correct packages installed, although it was a little confusing as to which OpenGL packages I had to install, and I still am unsure about what they all are.
Finally, I met a guy at the University who suggested I borrow one of the Macbooks and start porting my stuff onto it in an attempt to get me to the WWDC on a scholarship, as one person had recently left the lab I was in, and his old Macbook was floating around with no one to use it. This was a 2004 model Macbook, but it was running OSX 10.5 at the time.
I ported some of my better demos to OSX and to my excitement, I was accepted to go over to the WWDC in 2009. While at the WWDC, it was a little funny to see such hardcore Apple fans, I think I was the only person with a PC laptop and a Nokia phone, while everyone else had an iPhone and a Macbook. But as the conference went on, I was intrigued as to some of the upcoming features in OSX 10.6. More importantly OpenCL, which still isn’t really supported on PC’s unless you get the drivers from GPU manufacturers, and the fact that OSX is powered by OpenGL and they have so much support for it.
OSX loves OpenGL
One thing to learn when developing with OpenGL on OSX, is that OSX will forever love you and be nice to you. Once you have XCode installed, which is the preferred IDE for developing on OSX and the iPhone, you will find that all you have to do is create a new command line project, and import the OpenGL and GLUT frameworks into your project. You don’t have to worry about dll files in the correct directory, or having to download the library and header files and put them in the right location. You just add the frameworks and go. This is because OSX uses OpenGL for it’s entire GUI, everything you see on the screen. This is awesome to wrap your head around as an OpenGL developer, because it shows you a new side to Computer Graphics. It isn’t just 3D games and visualizations which was what I was familiar with, it has now extended to entire User Interfaces.
Apple have also done some amazing things in terms of OpenGL debugging. Yes, you can in fact debug an OpenGL application on OSX, there is a tool for that! Or if you have an iPhone and are doing iPhone development, I’ll use the pun “There’s an app for that!”. The OpenGL debugger shows you how much time you are spending on different calls, just like a regular debugger, but my favourite part, is that you can pause your application and view all your current buffers, your depth buffers and your colour buffers, at any time. So you can make sure your application is running as expected, which saves a lot of time compared to not knowing what is going on in the GPU.
If you are on Windows and you have tried my GLSL tutorials, and you haven’t read the comments section, you may run into an error when you try executing any of the tutorials. This is because I have not included a line to glewInit() that is essential on Windows. It’s just one of those things you have to do, to make sure you have access to your extensions when using the GLEW library. Well on OSX there is no GLEW library, OSX has full support for all OpenGL extensions right off the bat and you don’t have to worry about declaring what extensions are available. It’s little things like this all over the place that make developing for OpenGL on OSX so nice.
Windows loves DirectX
Starting off with OpenGL, I have come to love it extensively, but there is no denying it is not the be all and end all of computer graphics. Microsoft DirectX has it’s Direct3D API which can do everything that OpenGL can do, just in it’s own way (well eventually, often OpenGL is just that tiny step ahead). While OSX has a GUI powered completely by OpenGL, the GUI for Windows now uses DirectX to offload everything on the GPU and speed it up. I remember watching videos of codename Longhorn, now known as Windows Vista, and it was thought of as quite an achievement to have a GUI that runs on the GPU. I even remember stories at the time, that suggested Microsoft didn’t want to support OpenGL at all in Windows, and that if they did, it was going to be a bunch of Direct3D calls underneath the OpenGL calls which would slow down your program dramatically. Luckily they never went along with this and OpenGL is natively supported still on Windows. Could you imagine the backlash they would have suffered, when for example, games by iD software, including the Quake and Doom series, rely on OpenGL!
But while you can get the DirectX SDK and various SDK’s from GPU manufacturers, there is no “it just works” approach to computer graphics programming in Windows like there is on OSX. The only advantage to Windows is that it runs both DirectX and OpenGL whilst OSX only runs OpenGL (which is not their fault). You have to install your editor, just as you do on OSX, but then you also have to install the SDK’s, correct drivers and there are no Direct3D debuggers that I am aware of. This isn’t too much hassle if you know what you are doing but for beginners, can cause some initial headaches.
When it comes to debugging Direct3D, you can enable debugging information, but I am yet to see anything that offers the functionality that the OpenGL debuggers provide.