Compile fixes for GCC/Linux
This commit is contained in:
parent
321d3eb7d4
commit
1d8fc25cb7
@ -192,7 +192,7 @@ int main(int argc, char *argv[])
|
|||||||
for (int32_t x = 0; x < volData.getWidth(); x += extractedRegionSize)
|
for (int32_t x = 0; x < volData.getWidth(); x += extractedRegionSize)
|
||||||
{
|
{
|
||||||
// Specify the region to extract based on a starting position and the desired region sze.
|
// Specify the region to extract based on a starting position and the desired region sze.
|
||||||
Region regToExtract(x, y, z, x + extractedRegionSize, y + extractedRegionSize, z + extractedRegionSize);
|
PolyVox::Region regToExtract(x, y, z, x + extractedRegionSize, y + extractedRegionSize, z + extractedRegionSize);
|
||||||
|
|
||||||
// If you uncomment this line you will be able to see that the volume is rendered as multiple seperate meshes.
|
// If you uncomment this line you will be able to see that the volume is rendered as multiple seperate meshes.
|
||||||
//regToExtract.shrink(1);
|
//regToExtract.shrink(1);
|
||||||
|
@ -12,7 +12,7 @@ using namespace std;
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
OpenGLWidget::OpenGLWidget(QWidget *parent)
|
OpenGLWidget::OpenGLWidget(QWidget *parent)
|
||||||
:QGLWidget(parent)
|
:QGLWidget(parent)
|
||||||
,m_viewableRegion(Region(0, 0, 0, 255, 255, 255))
|
,m_viewableRegion(PolyVox::Region(0, 0, 0, 255, 255, 255))
|
||||||
,m_xRotation(0)
|
,m_xRotation(0)
|
||||||
,m_yRotation(0)
|
,m_yRotation(0)
|
||||||
{
|
{
|
||||||
@ -23,7 +23,7 @@ void OpenGLWidget::setShader(QSharedPointer<QGLShaderProgram> shader)
|
|||||||
mShader = shader;
|
mShader = shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLWidget::setViewableRegion(Region viewableRegion)
|
void OpenGLWidget::setViewableRegion(PolyVox::Region viewableRegion)
|
||||||
{
|
{
|
||||||
m_viewableRegion = viewableRegion;
|
m_viewableRegion = viewableRegion;
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public:
|
|||||||
// The GL_ARRAY_BUFFER will contain the list of vertex positions
|
// The GL_ARRAY_BUFFER will contain the list of vertex positions
|
||||||
glGenBuffers(1, &(meshData.vertexBuffer));
|
glGenBuffers(1, &(meshData.vertexBuffer));
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, meshData.vertexBuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, meshData.vertexBuffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, vecVertices.size() * sizeof(MeshType::VertexType), vecVertices.data(), GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, vecVertices.size() * sizeof(typename MeshType::VertexType), vecVertices.data(), GL_STATIC_DRAW);
|
||||||
|
|
||||||
// and GL_ELEMENT_ARRAY_BUFFER will contain the indices
|
// and GL_ELEMENT_ARRAY_BUFFER will contain the indices
|
||||||
glGenBuffers(1, &(meshData.indexBuffer));
|
glGenBuffers(1, &(meshData.indexBuffer));
|
||||||
@ -80,20 +80,20 @@ public:
|
|||||||
|
|
||||||
// Every surface extractor outputs valid positions for the vertices, so tell OpenGL how these are laid out
|
// Every surface extractor outputs valid positions for the vertices, so tell OpenGL how these are laid out
|
||||||
glEnableVertexAttribArray(0); // Attrib '0' is the vertex positions
|
glEnableVertexAttribArray(0); // Attrib '0' is the vertex positions
|
||||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(MeshType::VertexType), (GLvoid*)(offsetof(MeshType::VertexType, position))); //take the first 3 floats from every sizeof(decltype(vecVertices)::value_type)
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(typename MeshType::VertexType), (GLvoid*)(offsetof(typename MeshType::VertexType, position))); //take the first 3 floats from every sizeof(decltype(vecVertices)::value_type)
|
||||||
|
|
||||||
// Some surface extractors also generate normals, so tell OpenGL how these are laid out. If a surface extractor
|
// Some surface extractors also generate normals, so tell OpenGL how these are laid out. If a surface extractor
|
||||||
// does not generate normals then nonsense values are written into the buffer here and sghould be ignored by the
|
// does not generate normals then nonsense values are written into the buffer here and sghould be ignored by the
|
||||||
// shader. This is mostly just to simplify this example code - in a real application you will know whether your
|
// shader. This is mostly just to simplify this example code - in a real application you will know whether your
|
||||||
// chosen surface extractor generates normals and can skip uploading them if not.
|
// chosen surface extractor generates normals and can skip uploading them if not.
|
||||||
glEnableVertexAttribArray(1); // Attrib '1' is the vertex normals.
|
glEnableVertexAttribArray(1); // Attrib '1' is the vertex normals.
|
||||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(MeshType::VertexType), (GLvoid*)(offsetof(MeshType::VertexType, normal)));
|
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(typename MeshType::VertexType), (GLvoid*)(offsetof(typename MeshType::VertexType, normal)));
|
||||||
|
|
||||||
// Finally a surface extractor will probably output additional data. This is highly application dependant. For this example code
|
// Finally a surface extractor will probably output additional data. This is highly application dependant. For this example code
|
||||||
// we're just uploading it as a set of bytes which we can read individually, but real code will want to do something specialised here.
|
// we're just uploading it as a set of bytes which we can read individually, but real code will want to do something specialised here.
|
||||||
glEnableVertexAttribArray(2); //We're talking about shader attribute '2'
|
glEnableVertexAttribArray(2); //We're talking about shader attribute '2'
|
||||||
GLint size = (std::min)(sizeof(MeshType::VertexType::VoxelType), size_t(4)); // Can't upload more that 4 components (vec4 is GLSL's biggest type)
|
GLint size = (std::min)(sizeof(typename MeshType::VertexType::VoxelType), size_t(4)); // Can't upload more that 4 components (vec4 is GLSL's biggest type)
|
||||||
glVertexAttribIPointer(2, size, GL_UNSIGNED_BYTE, sizeof(MeshType::VertexType), (GLvoid*)(offsetof(MeshType::VertexType, material)));
|
glVertexAttribIPointer(2, size, GL_UNSIGNED_BYTE, sizeof(typename MeshType::VertexType), (GLvoid*)(offsetof(typename MeshType::VertexType, material)));
|
||||||
|
|
||||||
// We're done uploading and can now unbind.
|
// We're done uploading and can now unbind.
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user