Features » Extra Functionality

The fol­low­ing li­braries pro­vide ad­di­tion­al func­tion­al­i­ty on top of core Mag­num APIs. They com­ple­ment each oth­er for a well-bal­anced ex­pe­ri­ence, how­ev­er none of them are strict­ly re­quired and it’s pos­si­ble to use any sub­set that match­es your par­tic­u­lar use case.

Plug­in man­age­ment

Used ex­ten­sive­ly by var­i­ous oth­er parts of Mag­num, pro­vides a way to ex­tend func­tion­al­i­ty at run­time, im­ple­ment hot code reload­ing or al­ter be­hav­ior of al­ready de­ployed ap­pli­ca­tions with­out need­ing to mod­i­fy the bi­na­ries them­selves.

  • Plug­in man­ag­er han­dling de­pen­den­cies, in­her­i­tance and alias­es through the same API on all plat­forms
  • Ver­sion­ing plug­in API and ABI for grace­ful han­dling of run­time er­rors
  • Both dy­nam­i­cal­ly and stat­i­cal­ly load­ed plug­ins

Sig­nals and slots

In­spired by Qt’s sig­nals and slots API, pro­vides an easy-to-use de­sign pat­tern to con­nect lis­ten­ers to events. Macro-less syn­tax us­ing C++11 vari­adic tem­plates, with full type safe­ty and no need for any pre­pro­ces­sor.

  • Light­weight im­ple­men­ta­tion with fo­cus on de­bug per­for­mance and trans­paren­cy
  • Sig­nals are mem­ber func­tions, slots can be mem­bers, free func­tions or lamb­das
  • Abil­i­ty to equip third-par­ty class­es with sig­nal/slot func­tion­al­i­ty us­ing mul­ti­ple in­her­i­tance

Test­ing and bench­mark­ing

Bor­row­ing ini­tial ideas from Qt’s QTest, gives the us­er a clear API for cre­at­ing au­to­mat­ed unit tests, in­te­gra­tion tests and bench­marks with min­i­mal use of macros and no opaque mag­ic be­hind the scenes.

  • Fo­cus on clar­i­ty of test out­put and di­ag­nos­tics with col­ors, pret­ty print­ers and rich com­mand-line op­tions for test white/black­list­ing, re­peat­ing and shuf­fling
  • Equiv­a­lent work­flow on desk­top, iOS/An­droid and web plat­forms, mak­ing au­to­mat­ed test­ing a no-brain­er
  • Ex­ten­si­ble with com­para­tors for spe­cial da­ta types, bench­mark­ing of cus­tom mea­sured da­ta

An­i­ma­tion frame­work

Lay­ered ar­chi­tec­ture ex­pos­ing ev­ery­thing from di­rect val­ue in­ter­po­la­tion over keyframe struc­tures up to high-lev­el an­i­ma­tion-driv­en be­hav­ior and play­back di­rect­ly from load­ed scene da­ta.

  • De­faults to easy-to-use high-lev­el APIs but al­lows for fine-tun­ing of all pa­ram­e­ters in­clud­ing in­ter­po­la­tor func­tions and ex­trap­o­la­tion be­hav­ior
  • De­signed for cache-ef­fi­cient mem­o­ry ac­cess
  • Abil­i­ty to use dif­fer­ent types for an­i­ma­tion in­put and out­put (for spline in­ter­po­la­tion or on-the-fly keyframe da­ta de­com­pres­sion)
  • Abil­i­ty to use dif­fer­ent glob­al time type and an­i­ma­tion track time type

OpenGL wrap­ping lay­er

Ab­stracts away plat­form dif­fer­ences and ex­ten­sions, re­sult­ing in a sin­gle API cov­er­ing desk­top OpenGL, OpenGL ES and We­bGL. De­pend­ing on the GPU driv­er, the back­end se­lects the most suit­able fea­ture im­ple­men­ta­tion, giv­ing pri­or­i­ty to re­cent ex­ten­sions.

  • OpenGL 2.1 to 4.6, OpenGL ES 2.0, 3.0–3.2, We­bGL 1 / 2 + ex­ten­sions
  • DSA-like API with state track­ing, elim­i­na­tion of re­dun­dant GL calls, fea­ture em­u­la­tion on old­er driv­ers
  • Can co-ex­ist with oth­er ren­der­ers shar­ing the same OpenGL con­text, ex­change live OpenGL ob­jects with third-par­ty code

Vulkan wrap­ping lay­er

Com­ing soon. Sub­scribe to mosra/mag­num#234 for up­dates.

Plat­form in­te­gra­tion

Wraps plat­form-spe­cif­ic or gener­ic win­dow­ing tool­kits in a thin lay­er to pro­vide con­sis­tent ac­cess to OpenGL con­text and in­put events across var­i­ous sys­tems, util­i­ties for plat­form ca­pa­bil­i­ty in­tro­spec­tion.

  • In­te­grates SDL2, GLFW, Xlib, An­droid na­tive ac­tiv­i­ties and more
  • Ab­strac­tion lay­er to pro­vide OpenGL con­text to com­mand-line tools in a cross-plat­form way
  • Com­plete­ly opt-in lay­er, you can in­stead hook Mag­num di­rect­ly in­to your own win­dow, con­text and event han­dling

Mesh, tex­ture and shad­er tools

Col­lec­tion of es­sen­tial mesh, tex­ture and im­age al­go­rithms. Sim­ple in­put/out­put func­tions work­ing on plain da­ta types for easy in­te­gra­tion in­to ex­ist­ing pipe­lines.

  • Mesh op­ti­miza­tion, in­dexed mesh han­dling, ver­tex trans­for­ma­tions, nor­mal, sub­di­vi­sion al­go­rithms and at­tribute (de)in­ter­leav­ing
  • Tex­ture at­las pack­ing
  • Dis­tance field cal­cu­la­tion, avail­able al­so through a com­mand-line util­i­ty

Shad­er tools are com­ing soon. Sub­scribe to mosra/mag­num#234 for up­dates.

As­set man­age­ment

De­fines da­ta types and in­ter­faces for im­port of gener­ic scene for­mats and han­dling of un­com­pressed and com­pressed im­ages.

  • Scene hi­er­ar­chy, mesh da­ta, ma­te­ri­al, cam­era, light and tex­ture prop­er­ties
  • Com­mand-line util­i­ty for im­age con­ver­sion, com­pres­sion and de­com­pres­sion
  • Not re­quired to be used when im­ple­ment­ing your own as­set load­ing, pro­vides just a ready-to-use API for the gen­er­al case

De­bug­ging and pro­to­typ­ing

Go-to tool­box for when you are play­ing around, ex­plor­ing new tech­niques, pro­to­typ­ing a game, de­bug­ging a glitch or mea­sur­ing your app per­for­mance.

  • Set of builtin prim­i­tives for place­hold­er ob­jects, ma­te­ri­al test­ing or de­bug wire­frames
  • Shaders to give your ob­ject a ba­sic look or to vi­su­al­ize par­tic­u­lar mesh prop­er­ties
  • Pro­fil­ing, vi­su­al­iza­tion and au­to­mat­ic test­ing aids

Scene graph func­tion­al­i­ty

Ar­ranges scene da­ta in a tree with au­to­mat­ic ob­ject life­time man­age­ment, trans­for­ma­tion in­her­i­tance and abil­i­ty to at­tach any num­ber of fea­tures to scene ob­jects.

  • Choice of dif­fer­ent trans­for­ma­tion im­ple­men­ta­tions de­pend­ing on de­sired flex­i­bil­i­ty and speed/ac­cu­ra­cy trade­off
  • Cam­era ob­ject im­ple­men­ta­tion with con­ve­nient han­dling of pro­jec­tion and cam­era ma­tri­ces
  • Col­lec­tion of col­li­sion shapes for ba­sic physics or ob­ject pick­ing

Text and UI

GPU-cen­tered text ren­der­ing us­ing a pre-pop­u­lat­ed glyph cache tex­ture with abil­i­ty to use ar­bi­trary third-par­ty text lay­outers for kern­ing and oth­er ad­vanced text shap­ing and lay­out­ing sup­port.

  • Ren­der­ing from ei­ther pix­el-per­fect or dis­tance field glyph cache
  • Ex­per­i­men­tal UI li­brary fo­cused on ef­fi­cient ren­der­ing, min­i­mal foot­print and fast it­er­a­tion times
  • La­bel, but­ton, in­put wid­gets, modal­i­ty sup­port


Wraps Ope­nAL in a fash­ion sim­i­lar to the OpenGL wrap­ping lay­er; de­fines da­ta types and in­ter­faces for au­dio da­ta im­port.

  • Full sup­port of stock Ope­nAL 1.1 API with var­i­ous ex­ten­sions
  • Play­er and lis­ten­er ob­jects for scene graph in­te­gra­tion
  • Com­mand-line util­i­ty for plat­form ca­pa­bil­i­ty in­tro­spec­tion

In­te­gra­tion li­braries

Con­ve­nience util­i­ties, wrap­per types, da­ta con­ver­sion and in­ter­faces that im­prove in­ter­op­er­abil­i­ty with third-par­ty li­braries.

  • Par­tial or full API wrap­ping de­pend­ing on what’s need­ed for seam­less in­te­gra­tion of giv­en li­brary
  • Bul­let Physics math type con­ver­sion, de­bug ren­der­er im­ple­men­ta­tion and scene graph in­te­gra­tion
  • DART Dy­nam­ics An­i­ma­tion and Ro­bot­ics Tool­kit math type con­ver­sion and ren­der­er for DART worlds
  • Ocu­lus SDK math type con­ver­sion and wrap­per class­es for full Ocu­lus VR sup­port in Mag­num