[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

slow OpenGl or RunLoop misunderstanding ?

From: Xavier Glattard
Subject: slow OpenGl or RunLoop misunderstanding ?
Date: Sun, 14 Jan 2007 18:02:33 +0000 (UTC)
User-agent: Loom/3.14 (


I'm playing with NSOpenGLView and trying to port glxgears to gnustep. 
I reuse as code from glxgears as possible.

With glxgears I get 2225 FPS
With gnustep-gears I get 380 FPS !

Even when I draw nothing in my window (drawRect = flushBuffer) i only 
get 480 FPS.

I think of 2 point :
- NSOpenGL* classes are very CPU intensive
- my frame loop is bad

I use [RunLoop-performSelecto:...] to loop. The documentation says the 
selector is perform before the next runloop iteration.

- (void) nextAnimationFrame: (id) gl_view
  NSTimeInterval thisFrame = [NSDate timeIntervalSinceReferenceDate];
  NSTimeInterval sinceLastFrame = (thisFrame - _lastFrame);
  _lastFrame = thisFrame;
  [_scene nextFrameWithStep: sinceLastFrame];
  [gl_view setNeedsDisplay: YES];
  if(YES == _running)
    if (!_rl_modes)
      _rl_modes = [[NSArray alloc] initWithObjects: NSDefaultRunLoopMode,
                               NSEventTrackingRunLoopMode, nil];
    [[NSRunLoop currentRunLoop]
         performSelector: @selector(nextAnimationFrame:)
                  target: self
                argument: gl_view
                   order: 10
                   modes: _rl_modes];

Does the RunLoop iteration timed ? I hope it runs as fast as possible...

Any comment will be welcome !  :-)

Thanks in advance


reply via email to

[Prev in Thread] Current Thread [Next in Thread]