I've already worked with display lists and I always saw that they are boosts my SDL-OpenGL applications. But... now, I've started a new project. When I draw my scene without any display list, I get an FPS of around 1300 or 1400, but with display lists it slows down to 300 or 400 fps. In principle it's enough, but I think that's can't be normal.
My code to initialize SDL and OpeGL is the following:
SDL_Init(SDL_INIT_VIDEO); SDL_Init(SDL_INIT_VIDEO); screen = SDL_SetVideoMode(r.w, r.h, r.bpp, SDL_OPENGL|SDL_HWSURFACE|SDL_GL_DOUBLEBUFFER|SDL_INIT_NOPARACHUTE|SDL_INIT_EVENTTHREAD); displayList = glGenLists(1); glEnable(GL_BLEND); glEnable(GL_ALPHA_TEST); glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDepthMask(GL_TRUE); glDepthFunc(GL_LEQUAL); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glAlphaFunc(GL_GREATER, 0.1); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glClearColor(0, 0, 0, 0); glClearDepth(1); glViewport(0, 0, r.w, r.h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, r.w, r.h, 0, 0, -100);
My render loop looks like this:
glNewList(displayList, GL_COMPILE); displayFunction(); glEndList(); glCallList(displayList);
... where displayFunction() calls all textures which should be drawn. The source for drawing textures is this:
glBindTexture(GL_TEXTURE_2D, textureId); glBegin(GL_QUADS); glTexCoord2i(0, 0); glVertex3i(position.x, position.y, zPos); glTexCoord2i(1, 0); glVertex3i(position.x + textureSize.w, position.y, zPos); glTexCoord2i(1, 1); glVertex3i(position.x + textureSize.w, position.y + textureSize.h, zPos); glTexCoord2i(0, 1); glVertex3i(position.x, position.y + textureSize.h, zPos); glEnd();
I think I've forgotten anything to initialize or similar mistake. I hope anyone can help me to solve the problem.