writing display lists to file

I was wondering if it were possible to write display lists directly to file. This would make engines and/or CAD program VERY efficient if all tehy had to open was a display list consisting of no more than 500 operations. Is there an OpenGL function that I dont know about that can write them to file, and maybe an accompanying function to read them back, or could i use a basic c algorithm to write it into a block of memory then take that memory and write it to a file. The only part of that that i dont see would work is that I cant figure out a way to load the display list back into OpenGL. Thanx for any help…

No, OpenGL doesn’t know about files at all.

What you’re asking for amounts to a model
description file format, more or less. Thus,
use any of the popular model file formats
out there, and write your own code to read/
write that file format with your program.

The format of display lists depends on the driver’s implementation of them so it is not possible to access them like that. Even if you could do a major hack and find the memory that corresponds to a display list it is going to be specific to your implementation and may contain pointers and stuff that is dependant on the state of the driver so it wont work at all.

Very interesting Trouvist,

Most applications do not require loading of display lists from file because they just include it into the source code. But I do see that there could be a need for such a thing. If you wanted to create modular GL code that could be loaded by the program dynamicly, such as a GUI plugin.

The format of the data file could be very simple: an opcode followed by the parameter set. Each OpenGL function would have an opcode associated with it. You could even write a parser that would take GL source and compile into your new custom format.


Yes, now you understand waht i was trying to do… I’m tryng to be able to put the display list, in a compiled form, if not semi-compiled, so that I could easily change the output of the specific item it loads. Such would work very well in a GUI if you wanted to have different selection type controls, etc. This would also be very nice if I needed to implement new hardware because then i could just add a new display list file to teh order that I load the drivers and you could view the properties dynamically. This could potentially turn linux into a 3D os, the very first 3D os. And also, a display list that is partially compiled would save time not only in being softcoded, but display lists are MUCH faster.

Thanx for the input guys…