Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++11 friendly graphics library

Tags:

c++

c++11

directx

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.

like image 666
Jonathan Dunlap Avatar asked Apr 26 '12 22:04

Jonathan Dunlap


People also ask

Is there a graphics library for C++?

h library − The graphic. h library is used to add graphics to your C++ program. For graphic programming, it is a must include library as it contains all required methods.

Where can I find C++ libraries?

Usually, there is '/lib' folder on Windows or '/usr/lib' folder on Linux that contains all the libraries. Once the library is installed, the compiler and the linker know the path of the library to use, and the library is ready for use.

Which library is used for graphics?

A graphics library is a program library designed to aid in rendering computer graphics to a monitor. This typically involves providing optimized versions of functions that handle common rendering tasks.

Is OpenGL a graphics library?

OpenGL (Open Graphics Library) is the computer industry's standard application program interface ( API ) for defining 2-D and 3-D graphic images.


4 Answers

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.

like image 121
dharmatech Avatar answered Oct 26 '22 19:10

dharmatech


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...

like image 35
SigTerm Avatar answered Oct 26 '22 20:10

SigTerm


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 :)

like image 45
Alexandre C. Avatar answered Oct 26 '22 20:10

Alexandre C.


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.

like image 44
Konrad Rudolph Avatar answered Oct 26 '22 20:10

Konrad Rudolph