Advertisement

Preloading display lists at run-time

Started by April 22, 2003 11:25 AM
3 comments, last by penetrator 21 years, 10 months ago
I''m building a flight simulator ( www.web-discovery.net ). After creating an aircraft model, i use 3dexplorer to convert it into a .cpp display list. After that i merge the display list into my program and i can use that aircraft too. The problem is that i have now something like 20 aircrafts, which means 20 display lists merged into the program, and the executable size starts to be quite large, among with loading time. So here is the question: how can i pre-compile a display list in a separate file, and load it (or not) at runtime ? There is a way to do that ?
Why not convert it into another loadable model format instead and load it at runtime? You don''t HAVE to use display lists. I don''t know much about model formats, but perhaps you could try converting your models to a different format supported by 3dexplorer and then head on over to google and look up methods for loading and rendering that model format.

--- Alex Broadwin
--- Domini Nocti Games
- [email=atronic@gamebox.net]Alex Broadwin[/email]- Adroit Creations- My Journal- The All-Knowing One
Advertisement
I cant do that because i cant release models in a 3ds or max format, they must be encrypted or smt like that.

Well, a more common method, would be to store a list of the vertices (x,y,z coordinates). Then, you would need a list that holds which vertices make up triangles.


  //A 3d locationstruct Vertex_S{ float x,y,z;};//Used to store 3 points of a trianglestruct Face_S{ unsigned long i1, i2, i3; //Index 1,2,3};//Our Model Classclass Model_C{private: unsigned long Num_Verts; unsigned long Num_Faces; Vertex_S *Verts; Face_S *Faces;public: Model_C(void); void Draw(void); void Unload(void); ~Model_C(void);};//Our constructor initializes everything to 0.Model_C::Model_C(void){//Initialize everything to 0! Num_Verts=0; Num_Faces=0; Verts=0; Faces=0;}//This is to draw our modelvoid Model_C::Draw(void){ unsigned long ctr; glBegin(GL_TRIANGLES); for (ctr=0;ctr!=Num_Faces;++ctr) {  glVertex3fv(&Verts[Faces[ctr].i1].x);  glVertex3fv(&Verts[Faces[ctr].i2].x);  glVertex3fv(&Verts[Faces[ctr].i3].x); } glEnd();}//Unload our modelvoid Model_C::Unload(void){ if (Verts)  delete Verts; if (Faces)  delete Faces; Num_Verts=0; Num_Faces=0; Verts=0; Faces=0;}//Our destructor, simply call Unload()Model_C::~Model_C(void){ Unload(); //Make sure we unload it afterwards!}  



You would also have to create a Load function that would load your model, depending on what model format you''re loading will determine how this function will work. If you need help writing that, I can help. Also, a more efficient method would be to use glDrawElements, instead of using primitives with glBegin. Again, if you need specific help, contact me .

Messenger names:
aim = crazyguy4eva
msn = ready4dis_1@hotmail.com

Email:
Ready4Dis@aol.com
Ready4Dis@piqsoftware.com
By the way, I could probably take those source files that are generated, and format them into a raw binary format (just something that stores vertices + indexes), that way you aren't infringing on anybodies format. Just contact me, and let me know.

--- Edit ---
Just took a look at the page, I didn't realize it was textured also, but that isn't to difficult to also implement. Either way, I can help you out if you need, just contact me .

[edited by - Ready4Dis on April 22, 2003 12:56:39 PM]

This topic is closed to new replies.

Advertisement