Working on a game, and I was testing out my renderer. It unfortunately only runs at about 4 frames per second. Profiling reveals that surprisingly, only 5% of that runtime belongs to my code, and the remaining 95% of the total run time was spent in nvoglnt.dll.
Only one 256×256 texture is used though, and beyond that, the only openGL code I use outside of a few camera transformations is this following template of code. It is executed only 134217728 times for a total of 33554432 quads.
glTexCoord2f(u, v);
glColor3f(r, g, b);
glVertex3f(x, y, z);
What could I be doing wrong that’s causing OpenGL to become so slow? Are there any common performance techniques I could use to improve it?
Each of those “few” calls makes your system to switch execution context between your program and the OpenGL driver. This is not “few”. Honestly I’d consider this question some fine trolling, because each and every OpenGL tutorial these days will tell you not to use immediate mode for excactly that serious performance hit you observed, which immediate mode causes, i.e. glBegin, glEnd, glVertex and so on.
Use Vertex Arrays or better yet Vertex Buffer Objects.