Ogre::Canvas, a 2D API for Ogre3D

June 20th, 2010 by Henri Leave a reply »

In my previous post I have announced Ogre::Canvas but It wasn’t available for download.
Now I have released the source code of Ogre::Canvas and some demo.

What is Ogre::Canvas ?

It is a new 2D API for Ogre3D that is based on the Html5 Canvas specifications. I have chosen this API because it is easy to understand, has a lot of cool demos, and it’s easy to prototype in browser using javascript. But you could be asking: what the point of having fast prototyping in a web browser if you’ll have to translate everything in C++ ? This is why I have also implemented Ogre::CanvasV8: a javascript binding for Ogre::Canvas using V8 the javascript engine of Google Chrome. That means that your prototype written in javascript for a browser will run in Ogre::CanvasV8 (with minor tweaks). The three Canvas demos belows are all working using Ogre::CanvasV8, grab OgreCanvasDemos1.zip and try yourself !

Tutorials from MDC Clocks Canvascape

What could I do with Ogre::Canvas ?

Well, it’s a 2D API, so you get a context on which you can execute drawing calls:

  • Transformation: scale, rotate, …
  • Image drawing: drawImage
  • Line styles: lineWidth, lineCap, …
  • Colors, styles and shadows: strokeStyle, fillStyle, …
  • Paths: moveTo, lineTo, arc, …
  • Text: fillText, strokeText, …
  • If you need a full overview of the Html5 Canvas API, grab the excellent Cheat Sheet.

You could create really complex UI element using Canvas. If you need an example of what you could create using this, take a look at the timeline I have created for a multitouch prototype. In fact it is because I got poor performance using Awesomium that I have decided to create this library. Awesomium is really a good product but integrating a full web page is overkill if you are only interested by a 2D Canvas tag…

What is the development status ?

It is not really “production ready”, I still have some issues with drawing images with alpha channels… You’ll get all information about license (MIT), svn repository and documentation on the Ogre::Canvas page.


Leave a Reply