0

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?

1
  • Nobody uses display lists in new code these days. Just too cumbersome to use efficiently. You just experienced one of the particular problems. Commented Apr 25, 2011 at 19:34

2 Answers 2

3

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!

Sign up to request clarification or add additional context in comments.

Comments

0

That won't work. Be sure to read both the specification and the FAQ carefully, in particular:

The GL may be instructed to process a particular display list (possibly repeatedly) by providing a number that uniquely specifies it. Doing so causes the commands within the list to be executed just as if they were given normally. The only exception pertains to commands that rely upon client state. When such a command is accumulated into the display list (that is, when issued, not when executed), the client state in effect at that time applies to the command.

16.010 Why does a display list take up so much memory? An OpenGL display list must make a copy of all data it requires to recreate the call sequence that created it.

In other words, if you plan to change the texture's data store later, it will make no difference, because OpenGL keeps its own copy to ensure that it can exactly reproduce whatever was the current state.

The only way to get some kind of variability into display lists is via the nested display trick, but as Matias Valdenegro already suggested, you should not use display lists at all if you can help it. Other functionality (e.g. VBO) is more flexible and has the same or better performance.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.