help-gnustep
[Top][All Lists]
Advanced

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

Re: slow OpenGl or RunLoop misunderstanding ?


From: xavier . glattard
Subject: Re: slow OpenGl or RunLoop misunderstanding ?
Date: Mon, 15 Jan 2007 21:25:32 +0100
User-agent: Internet Messaging Program (IMP) 3.2.5

Selon Richard Frith-Macdonald <richard@tiptree.demon.co.uk>:

(...)
>
> Well, the selector is performed before the next run loop
> iteration ... but then the run loop will wait for events, so I guess
> the next time the selector is performed is after some event occurs,
> and perhaps waiting for the event is delaying things.
>
> The performselector API is relatively expensive as it requires
> allocation and deallocation of memory as you create/destroy the
> objects managing this in each loop iteration, so that might be an
> issue ... if so, perhaps setting up a repeating timer to trigger the
> nextAnimationFrame: method might be faster.
>
> However, those are really just a vague guesses ... I suppose your
> problem could be anywhere.
>

If i comment out the "setNeedsDisplay" line, the program doesnt
loop until i move the mouse or anything : you're right, RunLoop
waits for an event. But i think "setNeedsDisplay" does post the
needed event, so it loops.

Here is my [GearsGLView-drawRect] :

- (void) drawRect: (NSRect) aRect
{
  NSOpenGLContext *ctx;

  {
    ctx = [self openGLContext];
    if(ctx == nil) return;
    if( ctx != [NSOpenGLContext currentContext] )
    {
      NS_DURING
        [ctx makeCurrentContext];
        [self reshape];
      NS_HANDLER
        NSLog(@"Exception");
        NS_VOIDRETURN;
      NS_ENDHANDLER
    }
  }

  if (NO == _gl_initialized)
    [self prepareOpenGL];

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  [_scene glDrawFrame];

  [[self openGLContext] flushBuffer];
}

I've tried to comment out the 3 last lines :
- when all 3 lines disabled I get 3040 FPS ! (yes, 3 thousands)
- when i left any of the lines I get 380-480 FPS... (4 hundreds)

It looks like my opengl is so slow... (not accelerated ? why ?!)
and RunLoop has no responsability (no "wait state").

Xavier

PS: Richard, do you know you dont reply to the list ?




reply via email to

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