cemulate
cemulate

Reputation: 2333

Best general cross-platform solution for drawing (primitives, lines, etc) in C++?

I've had much experience writing in Java, python, C#, and C, mostly for hobby. In all of the applications I've coded that involve displays (simulations, graphers, etc.), I've always just used the stock "Canvas" class of whatever framework I'm using (Swing Canvas, .NET Canvas, pygame once for python).

The downside of this is that all of these have slightly different paradigms in drawing.

I'm starting a project in C++ and was wondering what the best solution is for cross-platform drawing. OpenGL is obviously very low level, but some sort of library on top of OpenGL would be good. I've heard of/read about things like Cairo, SDL, etc., but don't yet know what to go with. I'm already using wxWidgets for interface, but would prefer to use something more standard instead of just a wxWidgets canvas. Obviously, the ability to draw lines and shapes is important, not just display pictures or whatnot.

Thanks for any direction!

Upvotes: 0

Views: 1325

Answers (3)

xmoex
xmoex

Reputation: 2702

Open Frameworks is very easy to use and comes with a lot of examples...
it's platform independent and somehow reminds me of

Upvotes: 0

wkl
wkl

Reputation: 79903

SDL is SimpleMedia Direct Layer, which is basically a common interface to interface with the framebuffer and audio devices. If you wanted to create windows and such, it doesn't have general purpose constructs that work cross-platform.

Cairo is for drawing graphics, but still operates at a level that's lower than what WxWidgets provides.

C++ doesn't provide anything standard, so either you go with some platform specific, or you use a cross platform library like Qt (already mentioned by Basile) or stick with wxWidgets. Both are popular and widely used, though Qt is probably much more well-known and used (though that is just opinion). I've used Qt for work and it is very much cross platform and pretty easy to use (but very extensive, so prepare to read a lot of documentation). Luckily it also has a lot of documentation and many examples available.

Plus, both wxWidgets and Qt have bindings in many languages, so you could take the knowledge with either and use it with many other languages.

Upvotes: 1

I would consider using Qt, and notably its Graphics View framework. (Qt works on Linux, Windows, MacOSX).

Upvotes: 2

Related Questions