On Fri, 5 Aug 2005, Tim Blechmann wrote:
In general, the question of scheduling graphics updates is hard, especially now that (arrays can contain (lists that contain (arrays of scalars))), etc. Having "garrays" separate from the "real" data structure mechanism was always a temporary measure, and now I'm glad it's gone. But what this means is that now we need a more general way of updating changes to data. If I can think of a good one I'll get it into 0.39 (it's prety high on the dolist at the moment...)
before i'm starting to work on an implementation on my own ... have you been thinking about this?
I propose something like this:
typedef void (*t_garray_observer)(t_garray*,int start,int length); void garray_add_observer(t_garray*,t_garray_observer); void garray_del_observer(t_garray*,t_garray_observer); void garray_notify(t_garray*self,int start,int length) { self->observer(self,start,length); }
such that the add and del functions maintain a list of observers to notify when a change is being applied.
the garray objects call garray_notify method just _after_ every change they make to the data, to indicate the span of data that has been modified: that is, the start index, and the number of entries that have been modified.
any piece of code that is external to a garray but modifies its data directly instead of through the object's method, must now call garray_notify as if it were the garray object itself. that's the difficult part because it means incompatibility with the objects that may have modified the data silently.
does that make sense?
I'd like a more general mechanism than that, which may apply to all pd objects, such as:
typedef void (*t_pd_observer)(t_pd*); void pd_add_observer(t_pd*,t_pd_observer); void pd_del_observer(t_pd*,t_pd_observer); void pd_notify(t_pd*,...);
This is something being suggested by the IMPD paper presented last year at PdConvention04:
http://artengine.ca/matju/graz/ImpureData_PdConvention04.pdf
In section 1.1; it's just that the one above is more flexible, as it can apply to parts of objects instead of just wholes.
However I'll have to think some more about how the "..." part would work, because varargs in C/C++ are a bit clumsy to use...
____________________________________________________________________ Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju Freelance Digital Arts Engineer, Montréal QC Canada