tags:

views:

52

answers:

3

Any time I embark on a project that requires some rendering of primitive shapes and lines, I usually turn to Java because it's just so easy. For my latest project, I decided I might like to learn another API similar to but not Java Graphics2D. I would preferably like something that will work with C++ on Linux. Does anybody have any good recommendations for me? Thanks!

+3  A: 

Anti-Grain geometry gives high quality 2D rendering from path and font primitives, is a good example of idiomatic use of templates in C++, and looks fantastic. It has more documentation on the algorithms than on the API, so be prepared to look at the examples for how to use it. It requires some OS specific code to take the in-memory bitmap and blit it onto the screen. The other disadvantage is that when you next look at Java 2D or GDI+ applications you'll think Ewww as they're so badly rendered.

Pete Kirkham
That does look great. Thanks!
just_wes
+2  A: 

Cairo graphics is a 2D library that's cross-platform. It is written in C, though a C++ wrapper exists (cairomm). It's under a LGPL license.

Jeff Foster
+2  A: 

I suspect that you aren't goning to use raw X11 for windows and input, so my suggestion would depend on the GUI toolkit you plan to use.

Qt has its own painting engine. You can paint directly on to windows or widgets, or you can paint onto a QPicture, which allows you to both display, print and save the result easily. For more complex scenes, you can turn to QGraphicsScene.

With gtk, it's more common to use cairo, already mentioned by Jeff Foster

gnud
Even better in Qt, if you use a QPainter on a QGLWidget it can benefit from your graphics card's anti-aliasing/multi-sampling capabilities (if enabled) and it can look stunning.
timday
Unless you multi-sample 768 times, it won't be as good antialiasing as pixel-coverage based antialiasing, which is what anti-grain uses
Pete Kirkham