Simple 2D grid

Hey everyone,

I currently have a version of Conway’s Game Of Life I’ve written in C. Since I have no formal training in GL or any of it’s toolkits, I was hoping someone could give me some advice. If you do not know the game of life, it’s a cellular automaton where each cell follows a set of rules to effect the cells around it. (there is more to it, but that’s about it for the sake of this question). It is basically a 2D “grid” of squares. I’ve successfully been able to rig some openGL/GLUT code together to represent each cell as a GL_QUAD.

I’ve seen some versions of this where the drawing of such GL_QUADS or anything really, it SUPER fast. Probably something to do with textures/some advanced GL feature that I am unaware of. Could someone take a look at this and tell me if it’s even possible the “optimize” the performance of the drawing? The quotes are there since I’m not really sure what is possible. I just know that I’m using the most basic drawing idioms and think there is something better out there. The more references people can give me the better; I’m just looking for a solid place to start digging into this stuff.

ps - sorry if this is a duplicate post; I don’t know any keywords to use to lead me to existing posts.

pss - I am aware of technologies such as VSYNC, etc. Basically, I’m pretty experienced with various things, just not GL.

Thanks in advance!

Link to the code -

The code above and its Makefile haven’t been tested in MS Windows.

First thing I noticed is that you’re using immediate mode (glBegin/glEnd) which is the slowest way to send data to the GPU. If you’re still supporting OpenGL 1.1, you can use vertex arrays to send arrays of data to the GPU. Odds are you want to support modern OpenGL which uses vertex buffer objects. This allows you to send you vertex data to the GPU once so you don’t have to send it every frame.

One thing you want to consider doing if you want max speed is learning to use GLSL. All modern GPUs use programmable pipelines and fixed function pipelines are often emulated with programmable pipelines. Programmable pipelines are the fastest way to render (if you use them correctly)

Thanks! I’ll get on this over the next few days and report my progress back incase someone with similar questions comes around. Thanks again man.