Jonathan Dunlap
Jonathan Dunlap

Reputation: 2631

C++11 friendly graphics library

After several years of developing in other languages, I'm getting back into C++ because of some of the nice features being introduced with ISO C++11. Are there any libraries (DirectX/OpenGL based) that make use of these new features in their public API (shared ptrs, lambda friendly, etc)?

EDIT: The library can be in beta status too as I don't expect any library to be commercially-ready on a spec that isn't fully released yet.

Upvotes: 8

Views: 3792

Answers (5)

dharmatech
dharmatech

Reputation: 9537

From the README:

Magnum is 2D/3D graphics engine written in C++11/C++14 and modern OpenGL. Its goal is to simplify low-level graphics development and interaction with OpenGL using recent C++11/C++14 features and to abstract away platform-specific issues.

Upvotes: 4

Ed Swangren
Ed Swangren

Reputation: 124790

Well, no on OpenGL because it is a C compatible API.

As far as DirectX goes, they certainly aren't going to go and change the API all over the place just to include neat language features like lambdas when it isn't necessary. C++11 compilers are still not in common use compared to previous revisions of the standard, so it would be very silly to create an API that only a small portion of developers can use.

There are broad implications to changing your API when thousands/millions of people use it. It would be hugely irresponsible of them to add lambdas to API functions just because they're neat and shiny. On top of that, it's not like you can just go around breaking your API with each new version if you care about people actually using it.

EJDIT:

I misunderstood the question at first. C++11 is so new that there are likely no API changes to existing libraries as of yet because it would severely limit their userbase (there is no fully featured C++11 compiler out at this time as far as I am aware, and even if there were most of us wouldn't be using it yet).

As some of the commenters rightly pointed out, I was too narrow in my initial response. You added that a beta version would be acceptable. I am still unaware of any libraries which have drastically modified their API's to include new features in C++11, and my previous point still stands.

Changing API function signatures is dangerous because you break backward compatibility. If/when these changes do arrive I would expect them to be additions to the API, not modifications. Perhaps someone around here knows of very recent changes to existing libraries that I am unaware of.

Upvotes: 0

SigTerm
SigTerm

Reputation: 26439

As far as I know, there's still no complete C++11 compiler. G++ is pretty close but isn't there yet. I'd suggest to wait. It makes sense to study the language (even if it isn't available), but I think it'll take few years for dust to settle down.

As far as I know, there's little place to use any "advanced" language features (that even includes everything that was present in c++03) in any graphic library. Trying to fully utilize hardware resources isn't the place where it makes sense to use "programming kung-fu" - you'll end up being worried about other things, and KISS principle takes priority. Its either that or you end up diving into some kind of very specific mind-destroying trigonometric nightmare, where KISS principle takes priority once again.

As far as I know, changing graphical API because of single language is not worth it, because availability in multiple languages is more important. That's especially true about OpenGL, but even DirectX had some "fan-made" bindings.

At the moment you're free to use whatever features you want while developing custom frameworks that operate on top of existing 3d API. Shared/weak pointers are useful in resource managment. However, there's no reason to utilize C++11 for that, because functionality is available in boost.

--EDIT--

Qt 5 is said to have C++11 support. It is technically a graphical library that uses OpenGL...

Upvotes: 1

Konrad Rudolph
Konrad Rudolph

Reputation: 546073

The closest to what you want is probably SFML which is a quite clean object wrapper around OpenGL that uses modern C++ idioms more or less throughout.

It’s not using C++11, however, and it’s much too large to be just ported over (it includes sound, networking and lots more in addition to graphics).

I think it could serve as a good basis for an incremental API update to C++11 however.

Upvotes: 1

Alexandre C.
Alexandre C.

Reputation: 56986

Nothing prevents you from using eg. lambdas, auto and initializer lists in any code.

Gtkmm and relatives (you may enjoy Cairo C++ bindings) have clean C++ interfaces, which allow you to use lambdas and autos when you see fit. It is quite useful to be able to use a lambda as a signal handler, and to use auto when initializing a variable from a Gtk smart pointer.

Also, graphical code is often a quite minor part of an application, and for the other parts, you can use proper C++ with its full blown standard library.

Other than that, support for C++11 is not quite there (Visual studio is far behind, g++'s support is not yet complete), and thus libraries designed for C++11 are not yet here.

Nothing prevents you from trying and making your own :)

Upvotes: 1

Related Questions