   displaying images randomly
  Hey guys am new to opengl and am using it with borland c++.i need to display 5 different images randomly one after the other . what can i do? just advice me   
  1) Load Images ( and create textures, perhaps ).2) Assign each image a number in with a certain range (e.g. 0->4)3) Randomly choose a number in the range.4) Display image. (In OpenGL, you could do this via glDrawPixels(...) or using OpenGL texturing functionality. )Hope that helps.   ;  Ok, but what i want is i wrote 5 diffrent functions, which can create diffrent polygons like circle,square,etc, under the same file. Now i need to call these functions randomly so that images will be created. Once after i run the program these images should be displayed one by one (ex. firs square, after 1 minute circle, etc, randomly). can you say something?,thanks.   ;  if ya wanna keep with the function thing, you could create an array of function pointers and randomly choose an index into that array to call your functions.   ;  ok, when i do that it displays only the first image and will not back to the second function cause of mainloop()(as i think).And the othre thing is what time function can i use for a delay.   ;  If you're looking for something fast and easy to use, you can use GetTickCount()// Start of loopStartTime = GetTickCount()if TimePassed > Delay   FunctionPointers[Rand(0,MaxArray)].Draw()// End of loopEndTime = GetTickCount()TimePassed = EndTime - StartTime   ;  Thanks too much, i got your idea of ticking time. But i tried to call these functions in the main function. i.e:displayfun1(){}reshapefun1(){}displayfun2(){}reshapefun2(){}int main(...){glutCreateWindow (...);   for(i=0<;i<=2;i++)    {   if(i==0){    glutDisplayFunc (displayfun1);glutReshapeFunc (reshapefun1);    glutMainLoop ();  return 0;   } else{ glutDisplayFunc (displayfun2);glutReshapeFunc (reshapefun2);    glutMainLoop ();  return 0;}When i=0 it displays the first image after that it will enter to the MainLoop() and won't come to check the second condition. what can i do ? just advice. Thanks.   ;Quote:Original post by entoneThanks too much, i got your idea of ticking time. But i tried to call these functions in the main function. i.e:When i=0 it displays the first image after that it will enter to the MainLoop() and won't come to check the second condition. what can i do ? just advice. Thanks.Don't 'return' from inside the loop. That bails out from the entire function.   ;  what do u mean?(say only what you have to say)   ;return 0;Ends the whole function.Let's say you haveint myFunc(){ ImportantFunction1(); return 0; // read as : JUMP TO END OF PROGRAM ImportantFunction2(); // this will never be executed  return 0;// END OF PROGRAM}Also, you should consider using switch instead of multiple if statementsswitch(variable){case 1: some_code_here; break;case 2: some_code_here2; break;..case n: some_code_here3; break;default : default_code_if_none_of_the_above_worked; break}Why there is a 'break' at the end of each line? Because if you won't break, it will proceed to check the next value, and you don't want that.Hope this helped.   