Magnum — C++11 and OpenGL graphics engine

Mag­num is 2D/3D graph­ics en­gine writ­ten in C++11/C++14 and mod­ern OpenGL. Its goal is to sim­pli­fy low-lev­el graph­ics de­vel­op­ment and in­ter­ac­tion with OpenGL us­ing re­cent C++11 fea­tures and to ab­stract away plat­form-spe­cif­ic is­sues.

Design goals

  • 2D is not an ug­ly stepchild. Many en­gines out there were cre­at­ed as pure 2D or 3D and the al­ter­na­tive is usu­al­ly just an af­ter­thought, if it is present at all. If you want to do your next project in 2D on­ly, you have to ei­ther re­learn an­oth­er en­gine from scratch or em­u­late it in 3D, leav­ing many things over­ly com­pli­cat­ed. Mag­num treats 2D equiv­a­lent­ly to 3D so you can re­use what you al­ready learned for 3D and even com­bine 2D and 3D in one project.
  • For­ward com­pat­i­bil­i­ty. If new­er tech­nol­o­gy makes things faster, sim­pler or more in­tu­itive, it is the way to go. Mag­num by de­fault re­lies on de­cent C++11 sup­port and mod­ern OpenGL fea­tures and if some fea­ture isn’t avail­able, it tries to em­u­late it us­ing old­er func­tion­al­i­ty. How­ev­er, you are not re­strict­ed to use the old­er func­tion­al­i­ty di­rect­ly, if you re­al­ly want to.
  • In­tu­itive, but not re­stric­tive API. Script­ing lan­guages are of­ten pre­ferred to C/C++ be­cause they are de­signed to have less com­pli­cat­ed APIs and less boil­er­plate code. Mag­num is de­signed with in­tu­itiv­i­ty in mind, but al­so with speed and stat­ic checks that strong­ly-typed na­tive code of­fers. It wraps OpenGL in­to less ver­bose and more type-safe API, which is eas­i­er to use. Usu­al­ly the most com­mon way is the most sim­ple, but if you need full con­trol, you can have it.
  • Ex­ten­si­ble and re­place­able com­po­nents. If you want to use dif­fer­ent math­e­mat­i­cal li­brary for spe­cif­ic pur­pos­es, that new win­dow­ing tool­kit, your own file for­mats or an­oth­er physics li­brary, you can. Con­ver­sion of math struc­tures be­tween dif­fer­ent li­braries can be done on top of pre-made skele­ton class­es, sup­port for file for­mats is done us­ing plug­ins and plat­form sup­port is done by writ­ing sim­ple wrap­per class.

Supported platforms

Graph­ics APIs:

  • OpenGL 2.1 through 4.5, core pro­file func­tion­al­i­ty and mod­ern ex­ten­sions
  • OpenGL ES 2.0, 3.0, 3.1 and ex­ten­sions to match desk­top OpenGL func­tion­al­i­ty
  • We­bGL 1.0 and ex­ten­sions to match desk­top OpenGL func­tion­al­i­ty

Plat­forms:

  • Lin­ux and em­bed­ded Lin­ux (na­tive­ly us­ing GLX/EGL and Xlib or through GLUT or SDL2 tool­kit)
  • Win­dows (through GLUT or SDL2 tool­kit)
  • OS X (through SDL2 tool­kit, thanks to Miguel Mar­tin and oth­ers)
  • Google Chrome (through Na­tive Client, both newlib and glibc toolchains are sup­port­ed)
  • HTM­L5/JavaScript (through Em­scripten)
  • An­droid

Features

  • Vec­tor and ma­trix li­brary with im­ple­men­ta­tion of com­plex num­bers, quater­nions and their du­al coun­ter­parts for rep­re­sent­ing trans­for­ma­tions.
  • Class­es wrap­ping OpenGL us­ing RAII prin­ci­ple and sim­pli­fy­ing its us­age with di­rect state ac­cess and au­to­mat­ic fall­back for un­avail­able fea­tures.
  • Ex­ten­si­ble scene graph which can be mod­i­fied for each spe­cif­ic us­age.
  • Plug­in-based da­ta ex­change frame­work, tools for ma­nip­u­lat­ing mesh­es, tex­tures and im­ages.
  • Pre-made shaders, prim­i­tives and oth­er tools for easy pro­to­typ­ing and de­bug­ging.

See com­plete fea­ture list for more in­for­ma­tion. You might want to read al­so of­fi­cial project an­nounce­ment or notes from lat­est May 2015 re­lease.

Showcase

Mag­num is cur­rent­ly used in two small games (one of which is still unan­nounced) and the func­tion­al­i­ty is demon­strat­ed in var­i­ous ex­am­ples. See show­case page for im­ages and live ap­pli­ca­tions.

Getting started

Doc­u­men­ta­tion is avail­able for online viewing, you can al­so gen­er­ate it di­rect­ly from the source code, see above down­load in­struc­tions for more in­for­ma­tion. The doc­u­men­ta­tion has a thor­ough guide how to start us­ing Mag­num in your project.

License

Mag­num is li­censed un­der MIT/Ex­pat li­cense:

Copy­right © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Vladimír Von­druš <mosra@cen­trum.cz>

Per­mis­sion is here­by grant­ed, free of charge, to any per­son ob­tain­ing a copy of this soft­ware and as­so­ci­at­ed doc­u­men­ta­tion files (the “Soft­ware”), to deal in the Soft­ware with­out re­stric­tion, in­clud­ing with­out lim­i­ta­tion the rights to use, copy, mod­i­fy, merge, pub­lish, dis­trib­ute, sub­li­cense, and/or sell copies of the Soft­ware, and to per­mit per­sons to whom the Soft­ware is fur­nished to do so, sub­ject to the fol­low­ing con­di­tions:

The above copy­right no­tice and this per­mis­sion no­tice shall be in­clud­ed in all copies or sub­stan­tial por­tions of the Soft­ware.

THE SOFT­WARE IS PRO­VID­ED “AS IS”, WITH­OUT WAR­RAN­TY OF ANY KIND, EX­PRESS OR IM­PLIED, IN­CLUD­ING BUT NOT LIM­IT­ED TO THE WAR­RANTIES OF MER­CHANTABIL­I­TY, FIT­NESS FOR A PAR­TIC­U­LAR PUR­POSE AND NON­IN­FRINGE­MENT. IN NO EVENT SHALL THE AU­THORS OR COPY­RIGHT HOLD­ERS BE LI­ABLE FOR ANY CLAIM, DAM­AGES OR OTH­ER LI­A­BIL­I­TY, WHETHER IN AN AC­TION OF CON­TRACT, TORT OR OTH­ER­WISE, ARIS­ING FROM, OUT OF OR IN CON­NEC­TION WITH THE SOFT­WARE OR THE USE OR OTH­ER DEAL­INGS IN THE SOFT­WARE.