Various tricks to overcome common building and rendering issues.
If your project suddenly stops building after Magnum upgrade, check these things:
- If the building fails on CMake step, be sure that you have up-to-date
FindMagnum.cmakeand other CMake modules in your project (
FindSDL2.cmake). They are contained in
modules/directory of Magnum sources (and sources of other projects) also are installed into
- In some cases when the changes done to build system are too drastic, recreating the build dir or clearing CMake cache is needed, but this is a very rare occasion.
- The library is constantly evolving, thus some API might get deprecated over time (and later removed). Either build the libraries with
BUILD_DEPRECATEDor switch to non-deprecated features. See Downloading and building for more information.
If you are experiencing so-called "black screen of death", weird behavior or crashes on GL calls, you might want to try these things:
- Verify that no OpenGL error was emitted.
- Check that you use only extensions that are available on your system.
- Check that you didn't exceed any implementation-defined limit (see Magnum GL Info output for list of all of them).
- Enable debug output to see more detailed errors, warnings and performance hints.
- If using framebuffer objects, check that they are complete.
- Change framebuffer clear color to something else than black to verify that at least something is drawn.
- If nothing is drawn, use GL::
PrimitiveQuery to check that at least some primitives were generated. Use GL:: SampleQuery to check whether fragments were drawn.
- Verify that the mesh is properly set up — nonzero vertex/index count, matching type in buffer and vertex specification, properly set up index buffer and index count for indexed mesh. If you specified index range, be sure that all indices fall into it, otherwise you would get undefined behavior.
- Try disabling depth test, face culling and other renderer features that might affect the fragments.
- Verify that your projection and transformation matrix is properly set up — try drawing points instead of triangles, to see if they are at least at proper places.
- Validate the shader, check that all used uniforms and attributes have proper locations. Try reducing it until it is able to draw something, possibly also with some simpler mesh.
- Magnum tracks the OpenGL state to improve performance, but the tracker can get confused if you or any other library are doing OpenGL calls outside of Magnum. You can use GL::
Context:: resetState() to reset the internal state tracker. The other library also needs to be aware of this fact (either setting all state explicitly every time or having similar ability to reset its state tracker), otherwise you may need to save and restore GL state manually for that library to work.
- Enable debug output to see additional performance hints and implementation-dependent information.
- Use GL::
TimeQuery to find hot spots in the rendering code.
- Mark relevant parts of code to find them easier in the debugger.
- Use ApiTrace to trace the program call by call, verify buffer and texture contents, vertex binding and count of generated primitives, rendered fragments and time spent in various calls.