Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Lesson 13 ( fonts ) question

This topic is 6716 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a question about this procedure: GLvoid glPrint(const char *fmt, ...) // Custom GL "Print" Routine { char text[256]; // Holds Our String va_list ap; // Pointer To List Of Arguments if (fmt == NULL) // If There''s No Text return; // Do Nothing va_start(ap, fmt); // Parses The String For Variables vsprintf(text, fmt, ap); // And Converts Symbols To Actual Numbers va_end(ap); // Results Are Stored In Text glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits glListBase(base - 32); // Sets The Base Character to 32 glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text glPopAttrib(); // Pops The Display List Bits } where do va_list , va_start, va_end come from???

Share this post

Link to post
Share on other sites
Well can't tell you if they did something special and non-standard in OpenGL or DirectX with va_list but this is what va_list is all about in standard C/C++.

va_list is used to declare a local state variable which is used to traverse parameters.

So, what does that mean. Well, for example if I have a function that could take in x number of variables like say printf. With printf we use it like

printf("hello %s, how are you on this fine $s morn?\n", name,

/* See, the number of variable is not really limited.
So, the prototype of the function would look something like : */

int printf(char *strin, ...);

/* And the definition would look like : */

int printf(char * strin, ...)
va_list ap;

va_start(ap, strin);

So, finally, to step through the argument list we use the va_arg macro. This is not the best description of va_lists that I have given cause I am not a writer. Best thing you can do is take a look at any GOOD C/C++ book for va_list or va_args.

Edited by - Neuro on June 27, 2000 8:14:00 AM

Share this post

Link to post
Share on other sites
By the way, va_start sets the internal pointer in ap to point to the first argument passed into the function and its from this point that va_arg steps to the next.

va_end does some clear-up (housekeeping) when you reach the end of the arg list with va_arg steps.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!