"Animation" problems


I created a program that performs a simulation and I want to display the
results graphically every N time steps. However, I notice that the
interval between the updates of the display is not very unregular even
though the duration of the time steps is approximately equal. Somehow
there are delays of about a second after which many updates in a very
short time are performed and then nothing happens during the next second
and so on. 

Here is the code that I use for the updates (its in gtk-- but should be
readable for everyone who knows gtk+):

    rect.x = 0; rect.y = 0; rect.width = 640; rect.height = 480;
    Gdk_GC gc = drawingArea->get_style()->get_white_gc();
    pixmap->draw_rectangle(gc, true, rect.x, rect.x, rect.width,
    gc = drawingArea->get_style()->get_black_gc();
    for (int i = 1; i <= N; ++i)
        pixmap->draw_line(gc, 320 + (int)(x[i-1] * 10.), (i-1) * 640 / N,
                          320 + (int)(x[i] * 10.), i * 640 / N);
    win->draw_pixmap(gc, *pixmap, 0, 0, 
                     rect.x, rect.y, rect.width, rect.height);

Am I doing something wrong or is this problem unavoidable?



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