mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 18:16:08 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
db7044cf7f
4 changed files with 67 additions and 50 deletions
|
@ -61,7 +61,7 @@ bool SvoViewer::PointRenderAssemblePerVoxel(OctreeElement* node, void* extraData
|
|||
|
||||
void SvoViewer::InitializePointRenderSystem()
|
||||
{
|
||||
DebugPrint("Initializing point render system!\n");
|
||||
qDebug("Initializing point render system!\n");
|
||||
quint64 fstart = usecTimestampNow();
|
||||
_renderFlags.voxelRenderDirty = true;
|
||||
_renderFlags.voxelOptRenderDirty = true;
|
||||
|
@ -93,7 +93,7 @@ void SvoViewer::InitializePointRenderSystem()
|
|||
_renderFlags.ptRenderDirty = false;
|
||||
_ptRenderInitialized = true;
|
||||
float elapsed = (float)(usecTimestampNow() - fstart) / 1000.f;
|
||||
DebugPrint("Point render intialization took %f time for %d nodes\n", elapsed, _nodeCount);
|
||||
qDebug("Point render intialization took %f time for %d nodes\n", elapsed, _nodeCount);
|
||||
}
|
||||
|
||||
void SvoViewer::RenderTreeSystemAsPoints()
|
||||
|
@ -222,7 +222,7 @@ bool SvoViewer::VoxelRenderAssemblePerVoxel(OctreeElement* node, void* extraData
|
|||
|
||||
if (totalNodesProcessedSinceLastFlush >= REASONABLY_LARGE_BUFFER) // Flush data to GL once we have assembled enough of it.
|
||||
{
|
||||
//DebugPrint("committing!\n");
|
||||
//qDebug("committing!\n");
|
||||
PrintGLErrorCode();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, args->vtxID);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, args->lastBufferSegmentStart * sizeof(glm::vec3) * GLOBAL_NORMALS_VERTICES_PER_VOXEL,
|
||||
|
@ -252,7 +252,7 @@ bool SvoViewer::VoxelRenderAssemblePerVoxel(OctreeElement* node, void* extraData
|
|||
|
||||
void SvoViewer::InitializeVoxelRenderSystem()
|
||||
{
|
||||
DebugPrint("Initializing voxel render system.\n");
|
||||
qDebug("Initializing voxel render system.\n");
|
||||
|
||||
FindNumLeavesData data;
|
||||
data.numLeaves = 0;
|
||||
|
@ -330,13 +330,13 @@ void SvoViewer::InitializeVoxelRenderSystem()
|
|||
GLint compiled;
|
||||
glCompileShaderARB(&_vertexShader);
|
||||
glGetShaderInfoLog(_vertexShader, 1000, &shaderLogLength, shaderLog);
|
||||
if (shaderLog[0] != 0) DebugPrint("Shaderlog v :\n %s\n", shaderLog);
|
||||
if (shaderLog[0] != 0) qDebug("Shaderlog v :\n %s\n", shaderLog);
|
||||
glCompileShaderARB(&_geometryShader);
|
||||
glGetShaderInfoLog(_geometryShader, 1000, &shaderLogLength, shaderLog);
|
||||
if (shaderLog[0] != 0) DebugPrint("Shaderlog g :\n %s\n", shaderLog);
|
||||
if (shaderLog[0] != 0) qDebug("Shaderlog g :\n %s\n", shaderLog);
|
||||
glCompileShaderARB(&_pixelShader);
|
||||
glGetShaderInfoLog(_pixelShader, 51000, &shaderLogLength, shaderLog);
|
||||
if (shaderLog[0] != 0) DebugPrint("Shaderlog p :\n %s\n", shaderLog);
|
||||
if (shaderLog[0] != 0) qDebug("Shaderlog p :\n %s\n", shaderLog);
|
||||
|
||||
_linkProgram = glCreateProgram();
|
||||
glAttachShader(_linkProgram, _vertexShader);
|
||||
|
@ -345,7 +345,7 @@ void SvoViewer::InitializeVoxelRenderSystem()
|
|||
glLinkProgram(_linkProgram);
|
||||
GLint linked;
|
||||
glGetProgramiv(_linkProgram, GL_LINK_STATUS, &linked);
|
||||
if (!linked) DebugPrint("Linking failed! %d\n", linked);
|
||||
if (!linked) qDebug("Linking failed! %d\n", linked);
|
||||
|
||||
|
||||
_voxelOptRenderInitialized = true;
|
||||
|
@ -643,11 +643,11 @@ void SvoViewer::InitializeVoxelOptRenderSystem()
|
|||
_segmentNodeReferences[_numSegments] = childNode2ndOrder;
|
||||
_totalPossibleElems += data.numLeaves * NUM_CUBE_FACES * 2;
|
||||
_numSegments++;
|
||||
DebugPrint("child node %d %d has %d leaves and %d children itself\n", i, j, data.numLeaves, childNode2ndOrder->getChildCount());
|
||||
if (_numSegments >= MAX_NUM_OCTREE_PARTITIONS ) { DebugPrint("Out of segment space??? What the?\n"); break; }
|
||||
qDebug("child node %d %d has %d leaves and %d children itself\n", i, j, data.numLeaves, childNode2ndOrder->getChildCount());
|
||||
if (_numSegments >= MAX_NUM_OCTREE_PARTITIONS ) { qDebug("Out of segment space??? What the?\n"); break; }
|
||||
}
|
||||
}
|
||||
if (_numSegments >= MAX_NUM_OCTREE_PARTITIONS ) { DebugPrint("Out of segment space??? What the?\n"); break; }
|
||||
if (_numSegments >= MAX_NUM_OCTREE_PARTITIONS ) { qDebug("Out of segment space??? What the?\n"); break; }
|
||||
}
|
||||
|
||||
|
||||
|
@ -662,7 +662,7 @@ void SvoViewer::InitializeVoxelOptRenderSystem()
|
|||
_systemTree.recurseNodeWithOperation(_segmentNodeReferences[i], &TrackVisibleFaces, &visFaceData, 0);
|
||||
// Now there's a list of all the face centers. Sort it.
|
||||
qsort(faceCenters, visFaceData.count, sizeof(glm::vec3), ptCompFunc);
|
||||
DebugPrint("Creating VBO's. Sorted neighbor list %d\n", i);
|
||||
qDebug("Creating VBO's. Sorted neighbor list %d\n", i);
|
||||
|
||||
_readVertexStructs = new Vertex[GLOBAL_NORMALS_VERTICES_PER_VOXEL * _numChildNodeLeaves[i]];
|
||||
_readIndicesArray = new GLuint[NUM_CUBE_FACES * 2 * 3 * _numChildNodeLeaves[i]];
|
||||
|
@ -683,7 +683,7 @@ void SvoViewer::InitializeVoxelOptRenderSystem()
|
|||
SetupGlVBO(&_vboOVerticesIds[i], args.vtxCount * sizeof(Vertex), GL_ARRAY_BUFFER, GL_STATIC_DRAW, _readVertexStructs);
|
||||
SetupGlVBO(&_vboOIndicesIds[i], args.idxCount * sizeof(GLuint), GL_ARRAY_BUFFER, GL_STATIC_DRAW, _readIndicesArray);
|
||||
|
||||
DebugPrint("Partition %d, vertices %d, indices %d, discarded %d\n", i, args.vtxCount, args.idxCount, args.discardedCount);
|
||||
qDebug("Partition %d, vertices %d, indices %d, discarded %d\n", i, args.vtxCount, args.idxCount, args.discardedCount);
|
||||
|
||||
delete [] _readVertexStructs;
|
||||
delete [] _readIndicesArray;
|
||||
|
|
|
@ -221,11 +221,11 @@ void SvoViewer::InitializeVoxelOpt2RenderSystem()
|
|||
_segmentNodeReferences[_numSegments] = childNode2ndOrder;
|
||||
_totalPossibleElems += data.numLeaves * NUM_CUBE_FACES * 2;
|
||||
_numSegments++;
|
||||
DebugPrint("child node %d %d has %d leaves and %d children itself\n", i, j, data.numLeaves, childNode2ndOrder->getChildCount());
|
||||
if (_numSegments >= MAX_NUM_OCTREE_PARTITIONS ) { DebugPrint("Out of segment space??? What the?\n"); break; }
|
||||
qDebug("child node %d %d has %d leaves and %d children itself\n", i, j, data.numLeaves, childNode2ndOrder->getChildCount());
|
||||
if (_numSegments >= MAX_NUM_OCTREE_PARTITIONS ) { qDebug("Out of segment space??? What the?\n"); break; }
|
||||
}
|
||||
}
|
||||
if (_numSegments >= MAX_NUM_OCTREE_PARTITIONS ) { DebugPrint("Out of segment space??? What the?\n"); break; }
|
||||
if (_numSegments >= MAX_NUM_OCTREE_PARTITIONS ) { qDebug("Out of segment space??? What the?\n"); break; }
|
||||
}
|
||||
|
||||
|
||||
|
@ -240,7 +240,7 @@ void SvoViewer::InitializeVoxelOpt2RenderSystem()
|
|||
_systemTree.recurseNodeWithOperation(_segmentNodeReferences[i], &TrackVisibleFaces, &visFaceData, 0);
|
||||
// Now there's a list of all the face centers. Sort it.
|
||||
qsort(faceCenters, visFaceData.count, sizeof(glm::vec3), ptCompFunc);
|
||||
DebugPrint("Creating VBO's. Sorted neighbor list %d\n", i);
|
||||
qDebug("Creating VBO's. Sorted neighbor list %d\n", i);
|
||||
|
||||
_readVertexStructs = new Vertex[GLOBAL_NORMALS_VERTICES_PER_VOXEL * _numChildNodeLeaves[i]];
|
||||
memset(&_segmentIdxBuffers[i], 0, sizeof(VoxelDimIdxSet)); // Don't do it this way if we ever use a vtable for AABoundingVolumes!
|
||||
|
@ -269,7 +269,7 @@ void SvoViewer::InitializeVoxelOpt2RenderSystem()
|
|||
_segmentIdxBuffers[i].bounds[k].setIsSingleDirection(true, SvoViewerNames::faceNormals[k]);
|
||||
}
|
||||
|
||||
DebugPrint("Partition %d, vertices %d, indices %d, discarded %d\n", i, args.vtxCount, idxCount, args.discardedCount);
|
||||
qDebug("Partition %d, vertices %d, indices %d, discarded %d\n", i, args.vtxCount, idxCount, args.discardedCount);
|
||||
|
||||
delete [] _readVertexStructs;
|
||||
//delete [] _readIndicesArray;
|
||||
|
|
|
@ -77,15 +77,42 @@ SvoViewer::SvoViewer(int& argc, char** argv, QWidget *parent)
|
|||
|
||||
_window->setCentralWidget(_glWidget);
|
||||
|
||||
DebugPrint("Window initialized\n");
|
||||
qDebug("Window initialized\n");
|
||||
|
||||
_window->setVisible(true);
|
||||
_glWidget->setFocusPolicy(Qt::StrongFocus);
|
||||
_glWidget->setFocus();
|
||||
_glWidget->setMouseTracking(true);
|
||||
|
||||
|
||||
_currentShaderModel = RENDER_OPT_CULLED_POLYS; //RENDER_OPT_POLYS;// RENDER_CLASSIC_POLYS; //RENDER_POINTS;//
|
||||
QString svoFileToRead;
|
||||
QString shaderMode;
|
||||
|
||||
QStringList argumentList = arguments();
|
||||
int argumentIndex = 0;
|
||||
|
||||
// check if this domain server should use no authentication or a custom hostname for authentication
|
||||
const QString FILE_NAME = "--file";
|
||||
const QString SHADER_MODE = "--mode";
|
||||
if (argumentList.indexOf(FILE_NAME) != -1) {
|
||||
svoFileToRead = argumentList.value(argumentList.indexOf(FILE_NAME) + 1);
|
||||
qDebug() << "file:" << svoFileToRead;
|
||||
}
|
||||
if (argumentList.indexOf(SHADER_MODE) != -1) {
|
||||
shaderMode = argumentList.value(argumentList.indexOf(SHADER_MODE) + 1);
|
||||
qDebug() << "shaderMode:" << shaderMode;
|
||||
}
|
||||
|
||||
if (shaderMode == "RENDER_OPT_CULLED_POLYS") {
|
||||
_currentShaderModel = RENDER_OPT_CULLED_POLYS;
|
||||
} else if (shaderMode == "RENDER_OPT_POLYS") {
|
||||
_currentShaderModel = RENDER_OPT_POLYS;
|
||||
} else if (shaderMode == "RENDER_CLASSIC_POLYS") {
|
||||
_currentShaderModel = RENDER_CLASSIC_POLYS;
|
||||
} else if (shaderMode == "RENDER_POINTS") {
|
||||
_currentShaderModel = RENDER_POINTS;
|
||||
} else {
|
||||
_currentShaderModel = RENDER_OPT_CULLED_POLYS;
|
||||
}
|
||||
memset(&_renderFlags, 0, sizeof(_renderFlags));
|
||||
_renderFlags.useShadows = false;
|
||||
|
||||
|
@ -94,29 +121,34 @@ SvoViewer::SvoViewer(int& argc, char** argv, QWidget *parent)
|
|||
// We want our corner voxels to be about 1/2 meter high, and our TREE_SCALE is in meters, so...
|
||||
float voxelSize = 0.5f / TREE_SCALE;
|
||||
|
||||
DebugPrint("Reading SVO file\n");
|
||||
qDebug("Reading SVO file\n");
|
||||
|
||||
//H:\highfidelity\hifi-19509\build\interface\resources\voxels1A.svo
|
||||
/**
|
||||
const int MAX_PATH = 1024;
|
||||
char svoFileToRead[MAX_PATH] = "./voxels10.svo"; //"H:\\highfidelity\\hifi-19509\\build\\interface\\resources\\voxels10.svo"
|
||||
if (argc > 1) strcpy(svoFileToRead, argv[1]); // Command line is arg 0 by default.
|
||||
if (argc > 1) {
|
||||
strcpy(svoFileToRead, argv[1]); // Command line is arg 0 by default.
|
||||
qDebug() << svoFileToRead;
|
||||
}
|
||||
**/
|
||||
|
||||
//DebugPrint("Sizeof Octree element is %d\n", sizeof(OctreeElement));
|
||||
//qDebug("Sizeof Octree element is %d\n", sizeof(OctreeElement));
|
||||
|
||||
quint64 readStart = usecTimestampNow();
|
||||
bool readSucceeded = _systemTree.readFromSVOFile(svoFileToRead);
|
||||
DebugPrint("Done reading SVO file : %f seconds : ", (float)(usecTimestampNow() - readStart) / 1000.0f);
|
||||
readSucceeded ? DebugPrint("Succeeded\n") : DebugPrint("Failed\n");
|
||||
bool readSucceeded = _systemTree.readFromSVOFile(qPrintable(svoFileToRead));
|
||||
qDebug("Done reading SVO file : %f seconds : ", (float)(usecTimestampNow() - readStart) / 1000.0f);
|
||||
readSucceeded ? qDebug("Succeeded\n") : qDebug("Failed\n");
|
||||
|
||||
// this should exist... we just loaded it...
|
||||
if (_systemTree.getVoxelAt(voxelSize, 0, voxelSize, voxelSize)) {
|
||||
DebugPrint("corner point voxelSize, 0, voxelSize exists...\n");
|
||||
qDebug("corner point voxelSize, 0, voxelSize exists...\n");
|
||||
} else {
|
||||
DebugPrint("corner point voxelSize, 0, voxelSize does not exists...\n");
|
||||
qDebug("corner point voxelSize, 0, voxelSize does not exists...\n");
|
||||
}
|
||||
|
||||
_nodeCount = _systemTree.getOctreeElementsCount();
|
||||
DebugPrint("Nodes after loading file: %ld nodes\n", _nodeCount);
|
||||
qDebug("Nodes after loading file: %ld nodes\n", _nodeCount);
|
||||
|
||||
// Initialize the display model we're using.
|
||||
switch(_currentShaderModel)
|
||||
|
@ -185,9 +217,9 @@ void SvoViewer::initializeGL()
|
|||
GLenum err = glewInit();
|
||||
if (GLEW_OK != err) {
|
||||
/* Problem: glewInit failed, something is seriously wrong. */
|
||||
DebugPrint("Error: %s\n", glewGetErrorString(err));
|
||||
qDebug("Error: %s\n", glewGetErrorString(err));
|
||||
}
|
||||
DebugPrint("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
|
||||
qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
|
||||
#endif
|
||||
glViewport(0, 0, _width, _height);
|
||||
glGetIntegerv(GL_VIEWPORT, _viewport);
|
||||
|
@ -205,7 +237,7 @@ void SvoViewer::initializeGL()
|
|||
//_idleLoopStdev.reset();
|
||||
_lastTimeFpsUpdated = _lastTimeFpsUpdated = usecTimestampNow();
|
||||
float startupTime = (float)(_lastTimeFpsUpdated - _appStartTickCount) / 1000.0;
|
||||
DebugPrint("Startup time: %4.2f seconds.", startupTime);
|
||||
qDebug("Startup time: %4.2f seconds.", startupTime);
|
||||
//// update before the first render
|
||||
updateProjectionMatrix(_myCamera, true);
|
||||
update(0.0f);
|
||||
|
@ -628,24 +660,10 @@ float SvoViewer::visibleAngleSubtended(AABoundingVolume * volume, Camera * camer
|
|||
return area / (float)_pixelCount;
|
||||
}
|
||||
|
||||
void SvoViewer::DebugPrint(const char* szFormat, ...)
|
||||
{
|
||||
/**
|
||||
char szBuff[TEMP_STRING_BUFFER_MAX];
|
||||
assert(strlen(szFormat) < TEMP_STRING_BUFFER_MAX); // > max_path. Use this only for small messages.
|
||||
va_list arg;
|
||||
va_start(arg, szFormat);
|
||||
vsnprintf(szBuff, sizeof(szBuff), TEMP_STRING_BUFFER_MAX-100, szFormat, arg);
|
||||
va_end(arg);
|
||||
**/
|
||||
|
||||
qDebug(szFormat);
|
||||
}
|
||||
|
||||
GLubyte SvoViewer::PrintGLErrorCode()
|
||||
{
|
||||
GLubyte err = glGetError();
|
||||
if( err != GL_NO_ERROR ) //DebugPrint("GL Error! : %x\n", err);
|
||||
DebugPrint("Error! : %u, %s\n", (unsigned int)err, gluErrorString(err));
|
||||
if( err != GL_NO_ERROR ) //qDebug("GL Error! : %x\n", err);
|
||||
qDebug("Error! : %u, %s\n", (unsigned int)err, gluErrorString(err));
|
||||
return err;
|
||||
}
|
|
@ -162,7 +162,6 @@ public:
|
|||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
|
||||
void PrintToScreen(const int width, const int height, const char* szFormat, ...);
|
||||
static void DebugPrint(const char* szFormat, ...); // utility function.
|
||||
static GLubyte PrintGLErrorCode();
|
||||
|
||||
// Some helper functions.
|
||||
|
|
Loading…
Reference in a new issue