Work on Qt version of example.
This commit is contained in:
parent
ee5e33612c
commit
00f19e05a4
@ -16,8 +16,14 @@ OpenGLWidget::OpenGLWidget(QWidget *parent)
|
|||||||
|
|
||||||
void OpenGLWidget::setVolume(PolyVox::Volume<PolyVox::uint8>* volData)
|
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;
|
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.
|
//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.
|
//This three-level for loop iterates over each region.
|
||||||
for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ)
|
for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ)
|
||||||
@ -48,16 +54,13 @@ void OpenGLWidget::setVolume(PolyVox::Volume<PolyVox::uint8>* volData)
|
|||||||
|
|
||||||
|
|
||||||
Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ);
|
Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ);
|
||||||
if(g_bUseOpenGLVertexBufferObjects)
|
if(m_bUseOpenGLVertexBufferObjects)
|
||||||
{
|
{
|
||||||
//g_openGLSurfacePatches[uRegionX][uRegionY][uRegionZ] = BuildOpenGLSurfacePatch(*ispCurrent);
|
|
||||||
OpenGLSurfacePatch openGLSurfacePatch = BuildOpenGLSurfacePatch(*ispCurrent);
|
OpenGLSurfacePatch openGLSurfacePatch = BuildOpenGLSurfacePatch(*ispCurrent);
|
||||||
m_mapOpenGLSurfacePatches.insert(make_pair(v3dRegPos, openGLSurfacePatch));
|
m_mapOpenGLSurfacePatches.insert(make_pair(v3dRegPos, openGLSurfacePatch));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//g_indexedSurfacePatches[uRegionX][uRegionY][uRegionZ] = ispCurrent;
|
|
||||||
//m_volIndexedSurfacePatches->setVoxelAt(uRegionX,uRegionY,uRegionZ,ispCurrent);
|
|
||||||
m_mapIndexedSurfacePatches.insert(make_pair(v3dRegPos, ispCurrent));
|
m_mapIndexedSurfacePatches.insert(make_pair(v3dRegPos, ispCurrent));
|
||||||
}
|
}
|
||||||
//delete ispCurrent;
|
//delete ispCurrent;
|
||||||
@ -65,11 +68,12 @@ void OpenGLWidget::setVolume(PolyVox::Volume<PolyVox::uint8>* volData)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGLWidget::initializeGL()
|
void OpenGLWidget::initializeGL()
|
||||||
{
|
{
|
||||||
g_bUseOpenGLVertexBufferObjects = true;
|
m_bUseOpenGLVertexBufferObjects = true;
|
||||||
if(g_bUseOpenGLVertexBufferObjects)
|
if(m_bUseOpenGLVertexBufferObjects)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
//If we are on Windows we will need GLEW to access recent OpenGL functionality
|
//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)
|
for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX)
|
||||||
{
|
{
|
||||||
Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ);
|
Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ);
|
||||||
if(g_bUseOpenGLVertexBufferObjects)
|
if(m_bUseOpenGLVertexBufferObjects)
|
||||||
{
|
{
|
||||||
renderRegionVertexBufferObject(m_mapOpenGLSurfacePatches[v3dRegPos]);
|
renderRegionVertexBufferObject(m_mapOpenGLSurfacePatches[v3dRegPos]);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ class OpenGLWidget : public QGLWidget
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool g_bUseOpenGLVertexBufferObjects;
|
bool m_bUseOpenGLVertexBufferObjects;
|
||||||
|
|
||||||
//Creates a volume 128x128x128
|
//Creates a volume 128x128x128
|
||||||
PolyVox::Volume<PolyVox::uint8>* m_volData;
|
PolyVox::Volume<PolyVox::uint8>* m_volData;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user