rougier/freetype-gl — pull request #8 by cforfang (2013-11-07 22:16:13+00:00)
Title: Use a VAO internally to support core profile contexts out-of-the-box

If you don't mind the extra dependency on VAOs, feel free to pull this which changes vertex-buffer to use a VAO to store attribute- and element-buffer-state.

Note that this continues the behaviour of querying and caching the currently bound shader's attribute-locations on first draw, and using them for all subsequent draw calls -- which might not always be the wanted behaviour (e.g. if using the buffer with different shaders). There's probably many ways one could go about handling this if one wanted to (e.g. a function to invalidate / pulling out querying and instead have the user provide explicit indexes / separating the buffers from draw-calls entirely etc.), but here I just maintain the status quo.

Some informal benchmarks using demo-benchmark.c on my Radeon HD6950:
- Generation+Rendering:
-- Without VAO: ~1141 fps
-- With VAO: ~1211 fps

- Rendering only:
-- Without VAO: ~10097 fps
-- With VAO: ~10101 fps

Note that it is in no way a given that one will see any performance improvements for using VAOs at all, as it depends on the driver. My Nvidia NVS 4200 runs quite a bit slower with VAOs for instance, and for all I know this might be the norm.

One advantage however is that since a core profile context requires the use of VAOs anyway (even just a globally bound one), this commit takes away the user's responsibility to make sure one is bound before calling freetype-gl if using the core profile (see rougier/freetype-gl#7), and any nasty surprises regarding their own VAOs being corrupted by freetype-gl if they forget to unbind them (even if not using core).