Login  Register

GLCLInteroperabilityDemo and float4

Posted by paolofuse on Mar 03, 2016; 6:10pm
URL: https://forum.jogamp.org/GLCLInteroperabilityDemo-and-float4-tp4036419.html

Hi all,
I'm running correctly GLCLInteroperabilityDemo. But I want to understand why it's using a float4 vertex and not a float3 vertex.
Why I cannot use this kernel:

kernel void sineWave(global float3 * vertex, int size, float time) {

    unsigned int x = get_global_id(0);
    unsigned int y = get_global_id(1);

    // calculate uv coordinates
    float u = x / (float) size;
    float v = y / (float) size;

    u = u*2.0f - 1.0f;
    v = v*2.0f - 1.0f;

    // calculate simple sine wave pattern
    float freq = 4.0f;
    float w = sin(u*freq + time) * cos(v*freq + time) * 0.5f;

    // write output vertex
    vertex[y*size + x] = (float3)(u*10.0f, w*10.0f, v*10.0f);
}

and in display method:

gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, glObjects[VERTICES]);
gl.glVertexPointer(3, GL2.GL_FLOAT, 0, 0);
gl.glColor3f(1, 1, 1);
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
gl.glDrawArrays(GL2.GL_POINTS, 0, MESH_SIZE * MESH_SIZE);
gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);

This doesn't work. There's an explanation?
Thanks