Work on Qt version of example.

This commit is contained in:
David Williams 2009-03-28 09:36:09 +00:00
parent ee5e33612c
commit 00f19e05a4
2 changed files with 46 additions and 42 deletions

View File

@ -16,8 +16,14 @@ OpenGLWidget::OpenGLWidget(QWidget *parent)
void OpenGLWidget::setVolume(PolyVox::Volume<PolyVox::uint8>* volData)
{
//First we free anything from the previous volume (if there was one).
m_mapOpenGLSurfacePatches.clear();
m_mapIndexedSurfacePatches.clear();
m_volData = volData;
//If we have any volume data then generate the new surface patches.
if(m_volData != 0)
{
//Our volume is broken down into cuboid regions, and we create one mesh for each region.
//This three-level for loop iterates over each region.
for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ)
@ -48,28 +54,26 @@ void OpenGLWidget::setVolume(PolyVox::Volume<PolyVox::uint8>* volData)
Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ);
if(g_bUseOpenGLVertexBufferObjects)
if(m_bUseOpenGLVertexBufferObjects)
{
//g_openGLSurfacePatches[uRegionX][uRegionY][uRegionZ] = BuildOpenGLSurfacePatch(*ispCurrent);
OpenGLSurfacePatch openGLSurfacePatch = BuildOpenGLSurfacePatch(*ispCurrent);
m_mapOpenGLSurfacePatches.insert(make_pair(v3dRegPos, openGLSurfacePatch));
}
else
{
//g_indexedSurfacePatches[uRegionX][uRegionY][uRegionZ] = ispCurrent;
//m_volIndexedSurfacePatches->setVoxelAt(uRegionX,uRegionY,uRegionZ,ispCurrent);
m_mapIndexedSurfacePatches.insert(make_pair(v3dRegPos, ispCurrent));
}
//delete ispCurrent;
}
}
}
}
}
void OpenGLWidget::initializeGL()
{
g_bUseOpenGLVertexBufferObjects = true;
if(g_bUseOpenGLVertexBufferObjects)
m_bUseOpenGLVertexBufferObjects = true;
if(m_bUseOpenGLVertexBufferObjects)
{
#ifdef WIN32
//If we are on Windows we will need GLEW to access recent OpenGL functionality
@ -134,7 +138,7 @@ void OpenGLWidget::paintGL()
for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX)
{
Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ);
if(g_bUseOpenGLVertexBufferObjects)
if(m_bUseOpenGLVertexBufferObjects)
{
renderRegionVertexBufferObject(m_mapOpenGLSurfacePatches[v3dRegPos]);
}

View File

@ -37,7 +37,7 @@ class OpenGLWidget : public QGLWidget
private:
bool g_bUseOpenGLVertexBufferObjects;
bool m_bUseOpenGLVertexBufferObjects;
//Creates a volume 128x128x128
PolyVox::Volume<PolyVox::uint8>* m_volData;