PDA

View Full Version : How do I change variable on the fly?



hcrogma
08-29-2003, 02:53 AM
I have written a program and I now want to make changes to different constant without quit the program. Could you please tell me what to do. If you a sample code please send it to me at hcrogma@uark.edu.

Thank you

Jan
08-29-2003, 03:12 AM
Just use a variable instead of a constant!

This is neither an advanced, nor a beginner OpenGL question. Itīs a beginner C++ question.

Jan.

jwatte
08-29-2003, 07:45 AM
There's some number of ways of doing it.

Easy: make the "constant" be a global variable. Stop the program. Change the value of the global in the debugger. Start the program again. Voila! But the change is not persistent.

Medium: make the program able to read values into the globals (or member variables, or whatever) from a script or text file. Add a single command to reload all data files. Start program. Change text/data/script file. Execute command (magic key; whatever). Presto! Changes are already saved on disk because they went into the script.

Hard: add a UI to your program which gives you sliders/buttons/etc for all the data values. Make the program read data out of a database on start-up, and write changes back to the database when you manipulate the UI. Aw-yeah!

This is all, of course, a question about software engineering, and not at all about OpenGL. I suggest the sweng-gamedev mailing list for questions like this.