History

Revert "allow the bad triangles to render"

This reverts commit b5d1ae1a36b9451f64358558eb3db0a02b3d0831.

Stephen Birarda committed 13 years ago

Commit 2de86bf1 parent 4589cee1 file · +18 −11Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+18−11
@@ -107,7 +107,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() { · 106 unmodified lines
107107
108108 void VoxelSystem::copyWrittenDataToReadArrays() {
109109 // lock on the buffer write lock so we can't modify the data when the GPU is reading it
110−
110+ pthread_mutex_lock(&bufferWriteLock);
111111 // store a pointer to the current end so it doesn't change during copy
112112 GLfloat *endOfCurrentVerticesData = writeVerticesEndPointer;
113113 // copy the vertices and colors
@@ -116,6 +116,7 @@ void VoxelSystem::copyWrittenDataToReadArrays() { · 2 unmodified lines
116116
117117 // set the read vertices end pointer to the correct spot so the GPU knows how much to pull
118118 readVerticesEndPointer = readVerticesArray + (endOfCurrentVerticesData - writeVerticesArray);
119+ pthread_mutex_unlock(&bufferWriteLock);
119120 }
120121
121122 int VoxelSystem::treeToArrays(VoxelNode *currentNode, float nodePosition[3]) {
@@ -232,16 +233,22 @@ void VoxelSystem::render() { · 110 unmodified lines
232233
233234
234235 if (readVerticesEndPointer != readVerticesArray) {
235−
236− glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID);
237− glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW);
238− glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLfloat), readVerticesArray);
239−
240− glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);
241− glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLubyte) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW);
242− glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLubyte), readColorsArray);
243−
244− readVerticesEndPointer = readVerticesArray;
236+ // try to lock on the buffer write
237+ // just avoid pulling new data if it is currently being written
238+ if (pthread_mutex_trylock(&bufferWriteLock) == 0) {
239+
240+ glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID);
241+ glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW);
242+ glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLfloat), readVerticesArray);
243+
244+ glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);
245+ glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLubyte) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW);
246+ glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLubyte), readColorsArray);
247+
248+ readVerticesEndPointer = readVerticesArray;
249+
250+ pthread_mutex_unlock(&bufferWriteLock);
251+ }
245252 }
246253
247254 // tell OpenGL where to find vertex and color information

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t