Archived

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

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

Recommended Posts

Hi, this problem is driving me crazy, and it keeps cropping up again all the time. I would like to simplify the following: ---------start----------- void function ( void ) { glCallList ( list0 ); glCallList ( list1 ); glCallList ( list2 ); glCallList ( list3 ); glCallList ( list4 ); } ---------end----------- To something like this: ---------start----------- void function ( int num ) { for ( int i = 0; i < num; i++ ) glCallList ( list"i" ); } ---------end----------- I know there must be a simple C++ trick for this but I cant find it. Thanks for your help.

Share on other sites
void glCallLists(GLsizei n, GLenum type, const GLvoid * lists);
=]
Try looking this one up, it simply calls all the lists in the array passed as the lists parameter.
Hope this helps.

Share on other sites
Thanks, I didnt know even know that function existed. I will certainly use it. My question had a wider scope, however. What I want to be able to do its not necessarilly call several display lists at once, but write out commands that have been compiled as strings. For example, instead of:

glCallList ( list0 );
glCallList ( list1 );
glCallList ( list2 );
glCallList ( list3 );
glCallList ( list4 );

to write someting like:

for ( int j = 0; j < 5; j++ ) glCallList ( "list%i", j );

With emphasis on that last "%i" part. How can I replace a part of a command using string-type functions?

Share on other sites
oh I took list0 etc just to be your variable names not actuall strings.
Well I still think the best thing to be would be to make an array.
Otherwise I guess you''d prolly have to do some super pre-processor stuff that I wouldnt have a clue about =]

Share on other sites
I knpow its out there somewhere because I saw it once, but its difficult searching for something when you don't know what its called. What I want to do looks somthing like this, except that the printf function would print out to my code instead of to the screen:

for ( int j = 0; j < 5; j++ )
{
printf ( "glCallList ( list%i );", j );
}

Edited by - Keermalec on December 28, 2001 11:31:48 AM

Share on other sites
char List[5][5] = {"list0","list1","list2", "list3", "list4"}

for (int i = 0; i < 5; i ++) glCallList ( List );

I''ve not tried the code but tell me if it''s work.

========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/

Share on other sites
Sorry, I''ve made a mistake :

for (int i = 0; i < 5; i ++) glCallList ( List );

========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/

Share on other sites
The forum doesn''t accepted ""List""

========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/

Share on other sites
I''ve tested and it''s doesn''t work. Sorry

========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/

Share on other sites
Keermalec: I don''t think you can do what you want to do because C/C++ is a compiled language. I believe that would stop you from being able to do what your talking about. If you put those variables in an array then you could do it easily.

Example instead of the following variables:
list0,list1,list2,list3,list4 you had an array like

List[5]. Then you could just do:

for(int i = 0;i < 5;i++){     glCallList(list);}[CODE]That void glCallLists(GLsizei n, GLenum type, const GLvoid * lists); function seems to let you do the same thing but I don''t use OpenGL so I don''t know...

Jesus Freak,
Jesus Loves you. He is the Alpha and Omega the Beginning and the End.

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
17

• 9
• 12
• 9
• 12
• 37
• Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×