Refactoring example code.
This commit is contained in:
parent
3f849e19a4
commit
565aa21799
@ -72,7 +72,6 @@ public:
|
||||
BasicExample(QWidget *parent)
|
||||
:OpenGLWidget(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -72,7 +72,6 @@ public:
|
||||
DecodeOnGPUExample(QWidget *parent)
|
||||
:OpenGLWidget(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -47,7 +47,16 @@ using namespace std;
|
||||
|
||||
const int32_t g_uVolumeSideLength = 128;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
class OpenGLExample : public OpenGLWidget
|
||||
{
|
||||
public:
|
||||
OpenGLExample(QWidget *parent)
|
||||
:OpenGLWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void initialize() override
|
||||
{
|
||||
FilePager<MaterialDensityPair88>* pager = new FilePager<MaterialDensityPair88>(".");
|
||||
PagedVolume<MaterialDensityPair88> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(g_uVolumeSideLength - 1, g_uVolumeSideLength - 1, g_uVolumeSideLength - 1)), pager);
|
||||
@ -78,13 +87,6 @@ int main(int argc, char *argv[])
|
||||
createCubeInVolume(volData, Vector3DInt32(midPos - 10, 1, midPos - 10), Vector3DInt32(midPos + 10, maxPos - 1, midPos + 10), MaterialDensityPair44::getMaxDensity());
|
||||
createCubeInVolume(volData, Vector3DInt32(midPos - 10, midPos - 10, 1), Vector3DInt32(midPos + 10, midPos + 10, maxPos - 1), MaterialDensityPair44::getMaxDensity());
|
||||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
OpenGLWidget openGLWidget(0);
|
||||
|
||||
|
||||
openGLWidget.show();
|
||||
|
||||
QSharedPointer<QGLShaderProgram> shader(new QGLShaderProgram);
|
||||
|
||||
if (!shader->addShaderFromSourceFile(QGLShader::Vertex, ":/openglexample.vert"))
|
||||
@ -99,7 +101,7 @@ int main(int argc, char *argv[])
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
openGLWidget.setShader(shader);
|
||||
setShader(shader);
|
||||
|
||||
QTime time;
|
||||
time.start();
|
||||
@ -129,7 +131,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Pass the surface to the OpenGL window. Note that we are also passing an offset in this multi-mesh example. This is because
|
||||
// the surface extractors return a mesh with 'local space' positions to reduce storage requirements and precision problems.
|
||||
openGLWidget.addMesh(decodedMesh, decodedMesh.getOffset());
|
||||
addMesh(decodedMesh, decodedMesh.getOffset());
|
||||
|
||||
meshCounter++;
|
||||
}
|
||||
@ -138,9 +140,17 @@ int main(int argc, char *argv[])
|
||||
|
||||
cout << "Rendering volume as " << meshCounter << " seperate meshes" << endl;
|
||||
|
||||
setViewableRegion(volData.getEnclosingRegion());
|
||||
}
|
||||
};
|
||||
|
||||
openGLWidget.setViewableRegion(volData.getEnclosingRegion());
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//Create and show the Qt OpenGL window
|
||||
QApplication app(argc, argv);
|
||||
OpenGLExample openGLWidget(0);
|
||||
openGLWidget.show();
|
||||
|
||||
//Run the message pump.
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -139,13 +139,17 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
class PagingExample : public OpenGLWidget
|
||||
{
|
||||
//Create and show the Qt OpenGL window
|
||||
QApplication app(argc, argv);
|
||||
OpenGLWidget openGLWidget(0);
|
||||
openGLWidget.show();
|
||||
public:
|
||||
PagingExample(QWidget *parent)
|
||||
:OpenGLWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void initialize() override
|
||||
{
|
||||
PerlinNoisePager* pager = new PerlinNoisePager();
|
||||
PagedVolume<MaterialDensityPair44> volData(PolyVox::Region::MaxRegion(), pager, 64);
|
||||
volData.setMemoryUsageLimit(8 * 1024 * 1024); // 8Mb
|
||||
@ -177,9 +181,18 @@ int main(int argc, char *argv[])
|
||||
auto decodedMesh = decodeMesh(mesh);
|
||||
|
||||
//Pass the surface to the OpenGL window
|
||||
openGLWidget.addMesh(decodedMesh);
|
||||
addMesh(decodedMesh);
|
||||
|
||||
openGLWidget.setViewableRegion(reg2);
|
||||
setViewableRegion(reg2);
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//Create and show the Qt OpenGL window
|
||||
QApplication app(argc, argv);
|
||||
PagingExample openGLWidget(0);
|
||||
openGLWidget.show();
|
||||
|
||||
//Run the message pump.
|
||||
return app.exec();
|
||||
|
@ -68,13 +68,17 @@ void createSphereInVolume(PagedVolume<uint8_t>& volData, float fRadius)
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
class SmoothLODExample : public OpenGLWidget
|
||||
{
|
||||
//Create and show the Qt OpenGL window
|
||||
QApplication app(argc, argv);
|
||||
OpenGLWidget openGLWidget(0);
|
||||
openGLWidget.show();
|
||||
public:
|
||||
SmoothLODExample(QWidget *parent)
|
||||
:OpenGLWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void initialize() override
|
||||
{
|
||||
//Create an empty volume and then place a sphere in it
|
||||
PagedVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0, 0, 0), Vector3DInt32(63, 63, 63)));
|
||||
createSphereInVolume(volData, 28);
|
||||
@ -100,10 +104,19 @@ int main(int argc, char *argv[])
|
||||
auto decodedMeshHighLOD = decodeMesh(meshHighLOD);
|
||||
|
||||
//Pass the surface to the OpenGL window
|
||||
openGLWidget.addMesh(decodedMeshHighLOD, Vector3DInt32(30, 0, 0));
|
||||
openGLWidget.addMesh(decodedMeshLowLOD, Vector3DInt32(0, 0, 0), 63.0f / 31.0f);
|
||||
addMesh(decodedMeshHighLOD, Vector3DInt32(30, 0, 0));
|
||||
addMesh(decodedMeshLowLOD, Vector3DInt32(0, 0, 0), 63.0f / 31.0f);
|
||||
|
||||
openGLWidget.setViewableRegion(volData.getEnclosingRegion());
|
||||
setViewableRegion(volData.getEnclosingRegion());
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//Create and show the Qt OpenGL window
|
||||
QApplication app(argc, argv);
|
||||
SmoothLODExample openGLWidget(0);
|
||||
openGLWidget.show();
|
||||
|
||||
//Run the message pump.
|
||||
return app.exec();
|
||||
|
Loading…
x
Reference in New Issue
Block a user