Quote:Originally posted by Geometrian
Can you make display lists with names? I plan to have a lot of display lists. I would rather call them by name rather than by number.
To the best of my knowledge, no, although I stand to be corrected.
Bear in mind, however, that you should be able to use glGenLists to create multiple consecutive list identifiers, and it should return the first of those. So, if I recall correctly, if a call to glGenLists(4) returns, say, 8, you can then create lists with the identifiers 8, 9, 10 and 11.
I think that you should be able to solve your naming problem by storing your display list identifiers in usefully-named variables, such as plane, ground, etc. If you have a series of list identifiers to store, just use an array.
Thus perhaps create a variable named ground, assign an identifier to it with glGenLists rather than hardcoding a number, and then use it as the parameter to glCallList.
Thus you might have something like:
#"ground" is a variable available to both the initialisation and the# drawing code#initialisationground = glGenLists(1) #generate 1 available display list identifier # and store that value in "ground"glNewList(ground, GL_COMPILE)...#draw codeglCallList(ground)
if you have a series of objects (such as, say, five different kinds of tree), then I'd suggest something like this:
#"num_tree_types" and "tree_lists" are variables available to both the initialisation# and drawing code#I am presuming that all tree objects have a numeric identifier to indicate# the type of tree, called "type", that the identifiers run from 0# to num_tree_types-1, that the trees are stored in an array called "trees",# and that the array has num_trees elements at any given time.#initialisationnum_tree_types = 5tree_lists = glGenLists(num_tree_types) #generate a set of num_tree_types # consecutive display list identifiers, # starting at the value returned by # glGenListsfor i = 0 to numtrees #create the display lists for your various types of tree { glNewList(tree_lists+i, GL_COMPILE) #load/generate tree geometry and textures glEndList() }#draw codefor i = 0 to num_trees { glCallLists(treelists + trees->type) #call the appropriate list for that # type of tree }
Note that I have excluded transformation code simply for clarity.
It also occurs to me that you might be having problems with one of those display lists because the number that you are hard-coding is not actually available, although this is just speculation.
If I'm misunderstanding the problem then I apologise.