I'm messing around with a simple game using GLFW with freeglut to render text. I noticed that it was using far more CPU than I would have expected, and after commenting out various bits of code I realised it was the (minimal) GUI that was causing the problem.
Every frame, the game writes about half a dozen strings to the screen ("SCORE: 3000", "LIVES: 5", that kind of thing). If I disable this overlay, the CPU usage drops to about 2-5%. If I re-enable it, CPU usage skyrockets to about 40-50% and the game visibly slows down.
This is the code I'm using to render text:
void draw_string(int x, int y, string output) {
glRasterPos2i(x, y);
glutBitmapString(GLUT_BITMAP_HELVETICA_12, (const unsigned char*)output.c_str());
}
Am I doing something really stupid here without realising it? I cannot understand why I can render thousands of primitives per frame and OpenGL doesn't even blink, but as soon as I try to render a handful of lines of text my processor begins to buckle under the strain (and it's a 3.4GHz quad, it's not like it's a netbook or whatever).
Why is doing something that appears to be fairly simple causing such massive demands of my CPU?
Thanks in advance for any responses