I have an OpenGL VBO containing cl_float4 vertices and I'm trying to update the VBO via OpenCL (I'm rendering the VBO contents as GL_POINTS). I pass cl_mem object representing the VBO as a kernel argument (the buffer is set as CL_MEM_READ_WRITE).
Unfortunately I cannot update one vertex's float4 data at once.
Following snippet doesn't work (i.e. the rendered points doesn't move):
__kernel void update(__global float4* particle_positions)
{
int gid = get_global_id(0);
particle_positions[gid] += float4(0.1, 0.1, 0.1, 0.0);
}
Following snippet does work (i.e. the rendered points move):
__kernel void update(__global float4* particle_positions)
{
int gid = get_global_id(0);
particle_positions[gid].x += 0.1;
particle_positions[gid].y += 0.1;
particle_positions[gid].z += 0.1;
}
It is needed to be in paranthesis like
(float4)(1,1,1,1)
to have a float4 type. Or you can use other types too
(float4)((float2)(1,1),(float2)(1,1))
or mixed type
(float4)((float2)(1,1),1,1)
acts like an overloaded function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With