openglgraphicsdisplaylist

Passing parameters to OpenGL display lists


I was wondering if there is any way (standard or a clever trick) to pass parameters to an OpenGL display list. Let me show an example to clarify what I mean.

Suppose we have the following code:

GLuint l = glGenLists(1);
glNewList(l, GL_COMPILE);
  // ...some OpenGL function calls
  glBindTexture(GL_TEXTURE_2D, some_texture); // <-- here, I want `some_texture' to be a parameter that I can set when calling the display list
  //...some more stuff...
glEndList();

Is there a way to accomplish what I want?


Solution

  • Well, yes, the bound texture is global state and if you bind a texture and then call a display list, the texture should still be bound when the list executed.

    But it's better to stop using display lists and use VAs/VBOs, i recommend them!