From 1d8fc25cb752d1a250c50dc794ffe9eff03ed932 Mon Sep 17 00:00:00 2001 From: David Williams Date: Mon, 26 May 2014 23:14:29 +0200 Subject: [PATCH] Compile fixes for GCC/Linux --- examples/OpenGL/main.cpp | 2 +- examples/common/OpenGLWidget.cpp | 4 ++-- examples/common/OpenGLWidget.h | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/OpenGL/main.cpp b/examples/OpenGL/main.cpp index 27b0ac6b..c339fa0b 100644 --- a/examples/OpenGL/main.cpp +++ b/examples/OpenGL/main.cpp @@ -192,7 +192,7 @@ int main(int argc, char *argv[]) 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. - 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. //regToExtract.shrink(1); diff --git a/examples/common/OpenGLWidget.cpp b/examples/common/OpenGLWidget.cpp index ddc314eb..bc2d3e40 100644 --- a/examples/common/OpenGLWidget.cpp +++ b/examples/common/OpenGLWidget.cpp @@ -12,7 +12,7 @@ using namespace std; //////////////////////////////////////////////////////////////////////////////// OpenGLWidget::OpenGLWidget(QWidget *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_yRotation(0) { @@ -23,7 +23,7 @@ void OpenGLWidget::setShader(QSharedPointer shader) mShader = shader; } -void OpenGLWidget::setViewableRegion(Region viewableRegion) +void OpenGLWidget::setViewableRegion(PolyVox::Region viewableRegion) { m_viewableRegion = viewableRegion; diff --git a/examples/common/OpenGLWidget.h b/examples/common/OpenGLWidget.h index d87b4161..eaff700a 100644 --- a/examples/common/OpenGLWidget.h +++ b/examples/common/OpenGLWidget.h @@ -71,7 +71,7 @@ public: // The GL_ARRAY_BUFFER will contain the list of vertex positions glGenBuffers(1, &(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 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 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 // 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 // chosen surface extractor generates normals and can skip uploading them if not. 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 // 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' - GLint size = (std::min)(sizeof(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))); + 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(typename MeshType::VertexType), (GLvoid*)(offsetof(typename MeshType::VertexType, material))); // We're done uploading and can now unbind. glBindVertexArray(0);