Author Topic: FreeGlut  (Read 6698 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Re: FreeGlut
« Reply #15 on: June 09, 2012, 10:20:02 AM »
Yes I agree Kent. Your strategy for static initialisation, involving a glut function is the correct way to do it.

Statics are assigned values at the start of the program (zero or null by default). And it is not safe to make a Glut call at this stage, before Glut is set up.

So a one-shot block is required:

Code: OxygenBasic
  1.  
  2.         'statics always initialised to zero at start of prog
  3.        '
  4.        static sys lastTime,loops,once
  5.         static GLfloat fps
  6.         '
  7.        'one shot initialisation
  8.        '
  9.        if not once then
  10.           ' this is assigned once
  11.           lastTime = glutGet GLUT_ELAPSED_TIME
  12.           once=1 'no repeat
  13.        end if
  14.  


Charles


kryton9

  • Guest
Re: FreeGlut
« Reply #16 on: June 09, 2012, 10:44:17 AM »
I like having the once flag near the routine instead of as a global as I had it. Good idea and thanks!