hi, I read the code of FluidsGL in CUDAsdk, in fluidsGL.cu
//two particle data are prepared:
static cData *mparticles = NULL;
static cData *particles = NULL;
…
//particles is used for generate buffer in main
int main ( int argc, char** argv ) {
....
glGenBuffersARB( 1, &pbuffer );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, pbuffer );
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(cData) * DS, particles, GL_DYNAMIC_DRAW_ARB);
....
}
//but in the display func, the mparticles is used for mapping buffer
advertParticles( mparticles, dvfield, DIM, DIM, DT );
void advectParticles( cData *p, cData *v, int dx, intdy, float dt ) {
....
cudaGLMapBufferObject((void*)&p, pbuffer );
....
}
Here I change the parameter of advertParticle:
advertParticles( particles, dvfield, DIM, DIM, DT );
then it also works well, I dont know why two particle data are used?