MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / setArray

Method setArray

cpp/2_Concepts_and_Techniques/particles/particleSystem.cpp:377–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377void ParticleSystem::setArray(ParticleArray array, const float *data, int start, int count)
378{
379 assert(m_bInitialized);
380
381 switch (array) {
382 default:
383 case POSITION: {
384 if (m_bUseOpenGL) {
385 unregisterGLBufferObject(m_cuda_posvbo_resource);
386 glBindBuffer(GL_ARRAY_BUFFER, m_posVbo);
387 glBufferSubData(GL_ARRAY_BUFFER, start * 4 * sizeof(float), count * 4 * sizeof(float), data);
388 glBindBuffer(GL_ARRAY_BUFFER, 0);
389 registerGLBufferObject(m_posVbo, &m_cuda_posvbo_resource);
390 }
391 else {
392 copyArrayToDevice(m_cudaPosVBO, data, start * 4 * sizeof(float), count * 4 * sizeof(float));
393 }
394 } break;
395
396 case VELOCITY:
397 copyArrayToDevice(m_dVel, data, start * 4 * sizeof(float), count * 4 * sizeof(float));
398 break;
399 }
400}
401
402inline float frand() { return rand() / (float)RAND_MAX; }
403

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected