So I have been playing around to create a 3d shape addon on for OF. I have been going over examples in the red book.

What I have is very very basic. Just teapots and cubes. It gets tricky with light color and shading.

I want to also build a simple way to load shader files and acess them. Figure I would post what I have and see what people can add.



Cool! This will definitely be useful for people to get started with 3D shapes in openFrameworks.

A couple of suggestions:
Make lights a class - this way people can create multiple lights. You could have a base light class that has a lot of features and then have some simple light classes that inherit from that that have some default settings. Or just have 1 light class but have some #defines for different settings. ie DIRECTION_LIGHT, SOFT_LIGHT etc

ofLightsOn(); might be better outside of the drawing commands - as people might want to draw shapes without lighting.

Another thing to look into if you are doing 3D is display lists - they are good to use for complex shapes that stay the same during your app or shapes that get used a lot.

You might want to check out josh nimoy’s objLoader addon in the soon to be released 005 which lets you load 3D obj files into openFrameworks.


nice thanks theo working on it. Question about shaders. Do you know of any lib for loading and using shaders. I would love to try and compile one in OF or just start building one from scratch.

Hey Todd,

There is some example of shader code here:

And some more info here:

Hope that helps!

Hey guys. This might be kind of a ridiculous question, but I’m trying to throw lighting into a program i’m working on and i just cant seem to figure it out.

I tried out putting in this of3d code and using it to turn lights on and off, and apply them to vertex shapes that I’m drawing, but it doesnt seem to work. here’s what my draw func looks like:


the lighting is applied to the teapot and cube properly, but the quad shape that I draw doesnt reflect light at all. I assume this is some kind of materials problem, but i dont know how to fix it :confused:

can anyone help out?



In order to light stuff in opengl you need to calculate the normals of the polygon faces you are drawing. The library function calls such as the teapot and square already do this for you, but if you make your own shapes you have to calculate the normals yourself.

An example for lighting a cube (without using the library function call):


and the opengl red book:

more stuff out there if you google a little…

haha. wow this is pretty epic.

looks fun