Monday, January 11, 2016

OpenGL and Arduino, will it blend?

I was working with Arduino recently and I thought: can this small ATMega328 run some 3D graphics? I realized that there are some projects about that, some of them are really good actually, and that was enough to get me inspired to try my own micro-project. So I thought, why not port OpenGL for Arduino? Let's see what a 16 Mhz 8-bit micro-controller can do.

And this is the result:

Cubes are easy!

STL models don't look so nice...

By the way, you got it right, that's the same display used on the old Nokias! As you can see, I didn't have a fancy LCD colour display, but for this demo that one is good enough!

It is not hard to see that most of OpenGL's features are missing. It has no backface culling, no frustum culling, no colours, no depth/z buffer,  no textures, no lighting, no shading, no shaders, etc...

Although limited, you can use this Arduino library to port some really basic 2D and 3D OpenGL programs to Arduino. You could even try to build a small game! But don't get too excited, you only have 32kb of program memory and 2kb of RAM (most of that already used by the library itself). You'll probably only be able to fit one low poly 3D model and nothing else.

Still want to try it? GitHub


2 comments:

  1. In your opinion, could this code be made to run on other displays, eg ILI9341?

    ReplyDelete
  2. Yes, definitely. All you need to do to make it work is to implement another class similar to the "PCD8544" class. i.e. to implement a class that has a method that receives a bitmap generated by an instance of the "Canvas" class and that is able to render that bitmap on your display.

    ReplyDelete