mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 20:06:02 +02:00
allow the bad triangles to render
This commit is contained in:
parent
e5a31bc174
commit
b5d1ae1a36
1 changed files with 11 additions and 18 deletions
|
@ -107,7 +107,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() {
|
||||||
|
|
||||||
void VoxelSystem::copyWrittenDataToReadArrays() {
|
void VoxelSystem::copyWrittenDataToReadArrays() {
|
||||||
// lock on the buffer write lock so we can't modify the data when the GPU is reading it
|
// lock on the buffer write lock so we can't modify the data when the GPU is reading it
|
||||||
pthread_mutex_lock(&bufferWriteLock);
|
|
||||||
// store a pointer to the current end so it doesn't change during copy
|
// store a pointer to the current end so it doesn't change during copy
|
||||||
GLfloat *endOfCurrentVerticesData = writeVerticesEndPointer;
|
GLfloat *endOfCurrentVerticesData = writeVerticesEndPointer;
|
||||||
// copy the vertices and colors
|
// copy the vertices and colors
|
||||||
|
@ -116,7 +116,6 @@ void VoxelSystem::copyWrittenDataToReadArrays() {
|
||||||
|
|
||||||
// set the read vertices end pointer to the correct spot so the GPU knows how much to pull
|
// set the read vertices end pointer to the correct spot so the GPU knows how much to pull
|
||||||
readVerticesEndPointer = readVerticesArray + (endOfCurrentVerticesData - writeVerticesArray);
|
readVerticesEndPointer = readVerticesArray + (endOfCurrentVerticesData - writeVerticesArray);
|
||||||
pthread_mutex_unlock(&bufferWriteLock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoxelSystem::treeToArrays(VoxelNode *currentNode, float nodePosition[3]) {
|
int VoxelSystem::treeToArrays(VoxelNode *currentNode, float nodePosition[3]) {
|
||||||
|
@ -233,22 +232,16 @@ void VoxelSystem::render() {
|
||||||
|
|
||||||
|
|
||||||
if (readVerticesEndPointer != readVerticesArray) {
|
if (readVerticesEndPointer != readVerticesArray) {
|
||||||
// try to lock on the buffer write
|
|
||||||
// just avoid pulling new data if it is currently being written
|
glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID);
|
||||||
if (pthread_mutex_trylock(&bufferWriteLock) == 0) {
|
glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW);
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLfloat), readVerticesArray);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vboVerticesID);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW);
|
glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLfloat), readVerticesArray);
|
glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLubyte) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW);
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLubyte), readColorsArray);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vboColorsID);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLubyte) * MAX_VOXELS_PER_SYSTEM, NULL, GL_DYNAMIC_DRAW);
|
readVerticesEndPointer = readVerticesArray;
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, (readVerticesEndPointer - readVerticesArray) * sizeof(GLubyte), readColorsArray);
|
|
||||||
|
|
||||||
readVerticesEndPointer = readVerticesArray;
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&bufferWriteLock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// tell OpenGL where to find vertex and color information
|
// tell OpenGL where to find vertex and color information
|
||||||
|
|
Loading…
Reference in a new issue