Beginning OpenGL Development: Abstracting Shaders

In my last post, I showed how we can draw a triangle with a single giant file of C++ and OpenGL code. As I’ve said this gets unweidly and hard to refactor. This post will mark the start of a series that shows how I abstracted different parts of the code from the previous post with the end goal of being able to only focus on the code that matter to what we want to render, without being bogged down by setup and details.

The general overview of what I do here is basically to move the shader code to their own files, and then load them when we need to compile them and attach them to our GL program.

Continue reading…

Beginning OpenGL Development on OS X

For a while now, I’ve been meaning to get into some video game development. I’m also interested in OpenGL, and so I figured why not dive headfirst into OpenGL and make a video game? I have a few game ideas I want to explore, but baby steps first right?

My original plan was to build:

  1. a Pong clone vs. AI
  2. a Geometry Wars clone
  3. Start going crazy with my own ideas

However, I recently stumbled upon Game Mechanic Explorer when browsing HackerNews. It’s a really cool site made by John Watson where he has created a bunch of different game mechanics using the Phaser game framework. He’s got each of them in a dedicated page, with a playable sample as well as code and explanations. It’s an amazing site and I highly urge everyone to spend a few minutes to check it out.

After seeing that site, I’ve decided to replace #1 in my original plan to recreating his samples but in OpenGL. I think it’s much more ambitious than creating a Pong clone, but I think it’s still in reach.

I’ve found a few resources to help me get started with OpenGL development. I’ll list them here for reference, but I won’t go into detail on any of them since that is not within the scope of this post.

However, the one thing I will say about The OpenGL SuperBible (since it’s the one I purchased) is that the main complaint others have had with the book rings true with me: the authors abstracted much of the code into a library for the book. This makes things difficult to understand and track down for newcomers to OpenGL. It does make things easier to code if you follow along in the book, but you won’t understand what the library is doing and you’ll be lost without the library and the book.

In the rest of this post, I’ll explore how to get set up to start developing with OpenGL on Mac OS X as well as show to to render a simple triangle.

Continue reading…