History

only allow VBO re-transfer every 5 seconds for test

Stephen Birarda committed 13 years ago

Commit 793ac841 parent ebe11152 files · +11 −5Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 2 files). Show all

Unified · Split

interface/src/VoxelSystem.cpp+10−5
@@ -40,6 +40,8 @@ VoxelSystem::VoxelSystem() { · 39 unmodified lines
40 voxelsRendered = 0;40 voxelsRendered = 0;
41 tree = new VoxelTree();41 tree = new VoxelTree();
42 pthread_mutex_init(&bufferWriteLock, NULL);42 pthread_mutex_init(&bufferWriteLock, NULL);
43 lastBufferCopy.tv_sec = 0;
44 lastBufferCopy.tv_usec = 0;
43}45}
44 46
45VoxelSystem::~VoxelSystem() { 47VoxelSystem::~VoxelSystem() {
@@ -185,11 +187,11 @@ VoxelSystem* VoxelSystem::clone() const { · 139 unmodified lines
185 187
186void VoxelSystem::init() {188void VoxelSystem::init() {
187 // prep the data structures for incoming voxel data189 // prep the data structures for incoming voxel data
188 writeVerticesArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];190 writeVerticesEndPointer = writeVerticesArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
189 readVerticesArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];191 readVerticesEndPointer = readVerticesArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
190 writeColorsArray = new GLubyte[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];192 writeColorsArray = new GLubyte[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
191 readColorsArray = new GLubyte[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];193 readColorsArray = new GLubyte[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
192 194
193 GLuint *indicesArray = new GLuint[INDICES_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];195 GLuint *indicesArray = new GLuint[INDICES_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
194 196
195 // populate the indicesArray197 // populate the indicesArray
@@ -231,8 +233,9 @@ void VoxelSystem::render() { · 35 unmodified lines
231 233
232 glPushMatrix();234 glPushMatrix();
233 235
234 236 double timeSinceLastDraw = usecTimestampNow() - usecTimestamp(&lastBufferCopy);
235 if (readVerticesEndPointer != readVerticesArray) {237 if (readVerticesEndPointer != readVerticesArray && timeSinceLastDraw >= 5000 * 1000) {
238 printf("The time since the last draw was %f\n", timeSinceLastDraw);
236 // try to lock on the buffer write239 // try to lock on the buffer write
237 // just avoid pulling new data if it is currently being written240 // just avoid pulling new data if it is currently being written
238 if (pthread_mutex_trylock(&bufferWriteLock) == 0) {241 if (pthread_mutex_trylock(&bufferWriteLock) == 0) {
@@ -249,6 +252,8 @@ void VoxelSystem::render() { · 10 unmodified lines
249 252
250 pthread_mutex_unlock(&bufferWriteLock);253 pthread_mutex_unlock(&bufferWriteLock);
251 }254 }
255
256 gettimeofday(&lastBufferCopy, NULL);
252 }257 }
253 258
254 // tell OpenGL where to find vertex and color information259 // tell OpenGL where to find vertex and color information