Re: [GtkGLExt] Re: Drawing Each Frame



Thanks this worked however, my CPU usage is now around 70%. When I did this program using the SDL library the CPU usage was about 30%. Is there anything I can do to decrease CPU usage without affecting the performance?

On 11/11/05, Luca Cappa <luca cappa i-medlab com> wrote:
Hello flood,

you should use connect to a timeout or the idle event an handler which
does somethig similar to the following code. IMO, the idle event is the
better method if you want to burn all the cpu cycle letting you app
goin' to the max speed.


static gboolean timeout (GtkWidget *widget)
{
   /* Invalidate the whole window. */
   gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);

   /* Update synchronously. */
   gdk_window_process_updates (widget->window, FALSE);

   return TRUE;
}


Look at here to see how it is implemented:
http://cvs.sourceforge.net/viewcvs.py/gtkglext/gtkglext/examples/logo.c?rev=HEAD&content-type=text/vnd.viewcvs-markup


Greetings,
Luca

flood wrote:
> BTW, it also updates if I resize the window.
>
> On 11/10/05, *flood* <subflood gmail com <mailto:subflood gmail com>> wrote:
>
>     Hello, I'm making a particle system using gtkglext but I have ran
>     into a problem. Whenever I run my program it only updates the scene
>     when the window is not in focus. Meaning once a few particles are
>     drawn it stops updating the window. I have click on another window
>     and drag it and only than do I see the scene being updated.
>
>     My setup is simple:
>
>         /* Initialize, Resize, and Render */
>           g_signal_connect_after (G_OBJECT (gtkinit->drawing_area),
>     "realize",
>                                 G_CALLBACK (InitGL), NULL);
>
>         g_signal_connect (G_OBJECT (gtkinit->drawing_area),
>     "configure_event",
>                           G_CALLBACK (ResizeWin), NULL);
>
>         g_signal_connect (G_OBJECT (gtkinit->drawing_area), "expose_event",
>                           G_CALLBACK (DrawScene), NULL);
>
>
>
>         /* Show the Program */
>         gtk_container_add(GTK_CONTAINER(winInit.window),
>     winInit.drawing_area);
>         gtk_widget_show ( winInit.drawing_area);
>         gtk_widget_show (winInit.window);
>
>         gtk_main();
>
>
>     During expose_event I call two functions which update the particles.
>
>     --
>     ~flood
>
>
>
>
> --
> ~flood
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> gtkglext-list mailing list
> gtkglext-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkglext-list

_______________________________________________
gtkglext-list mailing list
gtkglext-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkglext-list



--
~flood

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