Advertisement

.exe size due to display lists

Started by June 14, 2002 04:23 PM
9 comments, last by penetrator 22 years, 8 months ago
i''m working on a flight simulator, and since i''m featuring more and more aircrafts using precompiled display lists, the .exe size is growing bigger and bigger. With 3 aircrafts is about 8mb, but with 6 aircrafts already 13mb. I''m not much of a programmer, but do you know if it is possible to find a solution to this ? For example compile the display lists in separate files (.dll ?). In that way i could build a dynamic application, and let people download only the aircrafts they want to fly. Thanks ! glHorizon_Project

www.web-discovery.net

AFAIK, it is not possible to precompile a display list (it is compiled at runtime, by the driver). Still, this would imply that you''re generating your planes in code. Why that? It sounds like a very cumbersome way of working. Instead, model the plane in a modelling packageand load it directly. NeHe has several tutorials on model loading.

Kippesoep
Advertisement
the problem is that i can''t release .3ds or other sort of files ...

glHorizon_Project



www.web-discovery.net


Why can''t you distribute model files? It would be the ''cleanest'' solution to your problem (at least IMO).

If you absolutely must generate your models at runtime, you could simply create a function that generates a display list and put that function into its own DLL. Then you dynamically load all the model-DLLs found at runtime (i.e. use LoadLibrary/GetProcAddress to get the function from the DLL, call the function and use the display list it returns).
This is completely feasible. Simply create a DLL that exports a single function for building a display list. The function doesn''t need to take arguments, but alternately you could pass the DC and RC for a wglMakeCurrent (if you weren''t sharing display lists and used multiply RC''s). Make sure that the function within the DLL has all the code to compile the display list...

Stick all the DLL''s in some directory that the .exe can determine, loop through at run time finding all the DLL''s in that directory. Then simply GetProcAddress on the function after loading the module. Call the function using the pointer from GetProcAddress, and save the return as your display list ID. (Making sure to gen lists accordingly for however many you plan to load.)

Using this method would allow you to easily add more display lists without recompiling the .exe by simply building more DLL files and sticking them in the appropriate folder.

Some pseudocode:

UINT YourClassName::LoadDisplayList(char *YOUR_DISPLAY_LIST_DLL){	// Function prototypes	typedef UINT (*DISP_LIST_MODULE_FUNC)(VOID);	// Function pointers	DISP_LIST_MODULE_FUNC pCreateList = NULL;	// Module handle	HINSTANCE hInst = NULL;	hInst = LoadLibrary(YOUR_DISPLAY_LIST_DLL);	if(hInst)	{                // Based on whatever you call your function exported by the DLL, use it in place of the string here		pCreateList = (DISP_LIST_MODULE_FUNC)GetProcAddress(hInst, "DisplayListFuncExported";                                // If you get a valid pointer to the function, use it		if(pCreateList)		{                        // Call the function and store the display list ID                        UINT dispListID = pCreateList();                        FreeLibrary(hInst);                        return dispListID;		}		else // some error occured                {                     // Message the error however you like, free the library                     FreeLibrary(hInst);                     return NULL;	}	// If the module failed to load, message the error however you like	else	{	     // Message the error or return NULL or whatever             return NULL;	}} 


Doh. I''m not signed on, so I can''t view if this code looks right, but that''s essentially it. Make sure the right RC is active in this case, and that the DLL properly exports the function.

You''ll have a display list built from a DLL. (Alternately, you could have all the models in one DLL with different function exports, or maybe a parameter that determines which model is loaded, but you get the idea.)
I don''t know about not being allowed to released .3ds files, but you can export to .x or .md3 or something and you certainly can distribute those with your game.

---
Make it work.
Make it fast.

"Commmmpuuuuterrrr.." --Scotty Star Trek IV:The Voyage Home
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
Advertisement
Why not same the data into txt or binary files then load the arrays for say level then compile them at startup. or no experience with writing binary files? you can customize a file format as long as the job gets done
Game Core
BGCJR, i have no experience in writing and then loading binary files ... i really would need an example or tutorial

glHorizon_Project



www.web-discovery.net


How long have you got to work on this project?
I have exams right now.... but within the next couple of weeks there will be a 5(ish) part tutorial series on creating an exporter for 3dsmax4. That way you can make your own model format.

I have the code done for all parts, and its really just writing the tutorials that needs to be done, after which you should have everything ya need to write a model exporter. Check www.gametutorials.com for it over the next couple of weeks.
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
Doesn''t OGL have some kind of precomiled display list functionality? I seem to remember seeing references to it. Like .c files or something... From what I remember, they are deprecated though.

Loading your own file formats is realy easy though. It is even easier if you use a C++ mind set and work on streams. Then file access is just like any other i/o stream.

ifstream fileName("model.foo");int x, y, z;fileName >> x >> y >> z; 


Make any sense at all?


Landsknecht
My sig used to be, "God was my co-pilot but we crashed in the mountains and I had to eat him..."
But folks whinned and I had to change it.

This topic is closed to new replies.

Advertisement