Is it not possible to use structures in the opencl patch in quartz composer?
 e.g. the code below causes me to either get "error building program source" or 
"error passing kernel arguments" if I remove all the source code.

I know this kernel works because it's the same kernel I use at 
http://memo.tv/opencl_in_openframeworks_example_1_milion_particles
perhaps QC has some limits?


#define DAMP2                   0.95f
#define MOUSE_FORCE             300.0f
#define CENTER_FORCE2   0.007
#define BOUNCE2                 -0.9f
#define MIN_SPEED2              0.0000001f
#define MAX_SPEED2              100.0f

#define MIN_DIST                50
#define MIN_DIST_SQ             MIN_DIST*MIN_DIST
#define REPULSION_FORCE 0.1f


typedef struct {
        float4 col;
        float2 pos;
        float2 homePos;
        float2 vel;
        float mass;
        float dummy2;
} Particle;



__kernel void update(__global struct Particle* particles, const float2 
mousePos, const float2 dimensions){
        int id = get_global_id(0);
        __global struct Particle        *p = &particles[id];
        
        float2 pos = p->pos;
        
        float2 diff = mousePos - pos;
        float invDistSQ = 1.0f / dot(diff, diff);
        diff *= MOUSE_FORCE * invDistSQ;

        float2 vel = p->vel + (p->homePos * dimensions - pos) * CENTER_FORCE2 - 
diff * p->mass;
        pos += vel;
        vel *= DAMP2;
        
        float speed2 = dot(vel, vel);
        if(speed2<MIN_SPEED2) pos = mousePos + diff * (1 + p->mass);
        
        p->vel = vel;
        
        p->pos = pos;
}



        
MSA Visuals Ltd.
Unit 107 Netil Studios
1-7 Westgate St.
London E8 3RL, UK
+44 20 8123 9986
www.msavisuals.com

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to