glCallLists()
is a convenient function for rendering a series of display lists, especially for things like text rendering. I'm curious -- is it actually more efficient to call glCallLists()
, or is it merely a convenience function? For example, which of these two snippets is likely to be faster?
const char *str = "this is a test";
// suppose the display lists numbered [displayListBase..displayListBase+255] have
// been initialized with display lists to render each ASCII character
// snippet 1:
glListBase(displayListBase);
glCallLists(strlen(str), GL_UNSIGNED_BYTE, str);
// snippet 2:
const char *s;
for(s = str; *s; s++)
glCallList(displayListBase + (unsigned char)*s);
I'm not trying to prematurely optimize, I'm just merely curious as to whether glCallLists
provides any significant advantages over the manual approach. If not, then why does it exist? OpenGL tends to be very minimalistic, in that there are very few convenience functions that aren't strictly necessary; the convenience functions that do exist are generally under the glu
namespace (GL utilities), e.g. gluOrtho2D()
, which provides a wrapper around glOrtho()
.
I haven't tried profiling the two snippets yet, although I would guess that profiling may be complicated by CPU-GPU interaction, especially over such a short timeframe. The runtime may also be significantly affected by the sizes of the display lists involved, and the number of display lists executed.