c_vars - need help explaining how they work
I've created a console in opengl. I've got the framework basically all done; the console opens, it has 18 lines of text, and the ability to enter keys and lines, and to move the entered text up the console.
I've looked at the source code for Quake I, and I note something about c-vars. I'm very confused as to how they work and how to parse them. I want to be able to say like "set_speed 9" and it will make a variable named speed equal to 9. Any ideas on how to do this?
-Thanks,
_SkyFire_
Edited by - skyfire360 on 11/22/00 11:55:34 AM
I do real things with imaginary numbers
easiest way to do this depends on how you want to implement. If you have a fixed number of cvars and you know their names before hand (e.g. no user-created ones) like environ variables, you can create a struct containing the name in string form (for matching) and a pointer to the variable. You also may want to have an enumerated type specifying the type of the stored variable (most common would be bool and int). That way you can still maintain type safety.
Brought to you by: O.G.A.P.O.
+----------------------------------------+
| Surgeon General''s Warning - |
| OGAPO can cause serious mental damage |
| if taken in large doses. |
+----------------------------------------+
/* Never underestimate the power of stupid people in large groups */
Brought to you by: O.G.A.P.O.
+----------------------------------------+
| Surgeon General''s Warning - |
| OGAPO can cause serious mental damage |
| if taken in large doses. |
+----------------------------------------+
/* Never underestimate the power of stupid people in large groups */
Brought to you by: [email=ogapo@ithink.net]O.G.A.P.O.[/email] +----------------------------------------+| Surgeon General's Warning - || OGAPO can cause serious mental damage || if taken in large doses. |+----------------------------------------+/* Never underestimate the power of stupid people in large groups */
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement