Web lists-archives.com

Re: Sharing data between GdkGLContexts of GtkGLAreas?




Hi;

On 24 October 2015 at 21:01, Rudolf Walter Kiss Szakacs
<rudolf.wg@xxxxxxxxx> wrote:

> I read that I can tweak context creation in a handler of the
> "create-context" signal of GtkGLArea. GdkGLContext does have the
> "shared-context" construct-only property. However, I also read that I
> need to call the gdk_window_create_gl_context function to create a
> context for a widget (or rather, the gdk window of the widget). Using
> that, there is no way for me to specify that I want the context to
> share data with an existing one.

Correct; the shared context is meant to be used internally by GTK+ to
ensure that the GL context you create shares resources with the paint
context created by GDK. GDK cannot really let you override this
behaviour, otherwise the GL drawing may break — as you can't create a
GL context that shares resources with more than one context.

Instead of creating a new context for all GtkGLArea widgets you can
reuse the same context for all of them — when the first GtkGLArea
widget is created, take its GdkGLContext and store it in some global
state object; then, for every new GtkGLArea widget, override the
create_context() vfunc (either by connecting to the
GtkGLArea::create-context signal or by subclassing GtkGLArea itself)
return the global GdkGLContext instead of creating a new instance.

Ciao,
 Emmanuele.

-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list