mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 17:03:11 +02:00
only allow VBO re-transfer every 5 seconds for test
This commit is contained in:
parent
ebe11151f4
commit
793ac841f2
2 changed files with 11 additions and 5 deletions
|
@ -40,6 +40,8 @@ VoxelSystem::VoxelSystem() {
|
|||
voxelsRendered = 0;
|
||||
tree = new VoxelTree();
|
||||
pthread_mutex_init(&bufferWriteLock, NULL);
|
||||
lastBufferCopy.tv_sec = 0;
|
||||
lastBufferCopy.tv_usec = 0;
|
||||
}
|
||||
|
||||
VoxelSystem::~VoxelSystem() {
|
||||
|
@ -185,11 +187,11 @@ VoxelSystem* VoxelSystem::clone() const {
|
|||
|
||||
void VoxelSystem::init() {
|
||||
// prep the data structures for incoming voxel data
|
||||
writeVerticesArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
|
||||
readVerticesArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
|
||||
writeVerticesEndPointer = writeVerticesArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
|
||||
readVerticesEndPointer = readVerticesArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
|
||||
writeColorsArray = new GLubyte[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
|
||||
readColorsArray = new GLubyte[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
|
||||
|
||||
|
||||
GLuint *indicesArray = new GLuint[INDICES_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
|
||||
|
||||
// populate the indicesArray
|
||||
|
@ -231,8 +233,9 @@ void VoxelSystem::render() {
|
|||
|
||||
glPushMatrix();
|
||||
|
||||
|
||||
if (readVerticesEndPointer != readVerticesArray) {
|
||||
double timeSinceLastDraw = usecTimestampNow() - usecTimestamp(&lastBufferCopy);
|
||||
if (readVerticesEndPointer != readVerticesArray && timeSinceLastDraw >= 5000 * 1000) {
|
||||
printf("The time since the last draw was %f\n", timeSinceLastDraw);
|
||||
// try to lock on the buffer write
|
||||
// just avoid pulling new data if it is currently being written
|
||||
if (pthread_mutex_trylock(&bufferWriteLock) == 0) {
|
||||
|
@ -249,6 +252,8 @@ void VoxelSystem::render() {
|
|||
|
||||
pthread_mutex_unlock(&bufferWriteLock);
|
||||
}
|
||||
|
||||
gettimeofday(&lastBufferCopy, NULL);
|
||||
}
|
||||
|
||||
// tell OpenGL where to find vertex and color information
|
||||
|
|
|
@ -51,6 +51,7 @@ private:
|
|||
GLuint vboColorsID;
|
||||
GLuint vboIndicesID;
|
||||
pthread_mutex_t bufferWriteLock;
|
||||
timeval lastBufferCopy;
|
||||
|
||||
int treeToArrays(VoxelNode *currentNode, float nodePosition[3]);
|
||||
void setupNewVoxelsForDrawing();
|
||||
|
|
Loading…
Reference in a new issue