diff --git a/modules/planetbrowsing/rendering/geometry.cpp b/modules/planetbrowsing/rendering/geometry.cpp index 8e99d0e53b..0b259bf609 100644 --- a/modules/planetbrowsing/rendering/geometry.cpp +++ b/modules/planetbrowsing/rendering/geometry.cpp @@ -8,15 +8,15 @@ namespace openspace { Geometry::Geometry(std::vector elements, - Positions usePositions, Textures useTextures, Normals useNormals) + Positions usePositions, TextureCoordinates useTextures, Normals useNormals) : _vaoID(0) ,_vertexBufferID(0) ,_elementBufferID(0) - ,_usePositions(usePositions == Positions::Yes) - ,_useTextures(useTextures == Textures::Yes) - ,_useNormals(useNormals == Normals::Yes) + ,_useVertexPositions(usePositions == Positions::Yes) + ,_useTextureCoordinates(useTextures == TextureCoordinates::Yes) + ,_useVertexNormals(useNormals == Normals::Yes) { - setElementData(elements); + setElements(elements); } Geometry::~Geometry() { @@ -25,7 +25,8 @@ Geometry::~Geometry() { glDeleteVertexArrays(1, &_vaoID); } -void Geometry::setPositionData(std::vector positions) { +void Geometry::setVertexPositions(std::vector positions) { + _useVertexPositions = true; _vertexData.resize(positions.size()); for (size_t i = 0; i < positions.size(); i++) { @@ -36,7 +37,8 @@ void Geometry::setPositionData(std::vector positions) { } } -void Geometry::setTextureData(std::vector textures) { +void Geometry::setVertexTextureCoordinates(std::vector textures) { + _useTextureCoordinates = true; _vertexData.resize(textures.size()); for (size_t i = 0; i < textures.size(); i++) { @@ -45,7 +47,8 @@ void Geometry::setTextureData(std::vector textures) { } } -void Geometry::setNormalData(std::vector normals) { +void Geometry::setVertexNormals(std::vector normals) { + _useVertexNormals = true; _vertexData.resize(normals.size()); for (size_t i = 0; i < normals.size(); i++) { @@ -55,7 +58,7 @@ void Geometry::setNormalData(std::vector normals) { } } -void Geometry::setElementData(std::vector elements) { +void Geometry::setElements(std::vector elements) { _elementData.resize(elements.size()); for (size_t i = 0; i < elements.size(); i++) { @@ -96,19 +99,19 @@ bool Geometry::initialize() { GL_STATIC_DRAW); // Positions at location 0 - if (_usePositions) { + if (_useVertexPositions) { glEnableVertexAttribArray(0); glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, position))); } // Textures at location 1 - if (_useTextures) { + if (_useTextureCoordinates) { glEnableVertexAttribArray(1); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, texture))); } // Normals at location 2 - if (_useNormals) { + if (_useVertexNormals) { glEnableVertexAttribArray(2); glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast(offsetof(Vertex, normal))); diff --git a/modules/planetbrowsing/rendering/geometry.h b/modules/planetbrowsing/rendering/geometry.h index dd2ba89de1..5baae83010 100644 --- a/modules/planetbrowsing/rendering/geometry.h +++ b/modules/planetbrowsing/rendering/geometry.h @@ -44,21 +44,21 @@ class Geometry { public: enum class Positions { Yes, No }; - enum class Textures { Yes, No }; + enum class TextureCoordinates { Yes, No }; enum class Normals { Yes, No }; Geometry( std::vector elements, // At least elements are required Positions usePositions = Positions::No, - Textures useTextures = Textures::No, + TextureCoordinates useTextures = TextureCoordinates::No, Normals useNormals = Normals::No); ~Geometry(); // Setters - void setPositionData(std::vector positions); - void setTextureData(std::vector textures); - void setNormalData(std::vector normals); - void setElementData(std::vector elements); + void setVertexPositions(std::vector positions); + void setVertexTextureCoordinates(std::vector textures); + void setVertexNormals(std::vector normals); + void setElements(std::vector elements); /** Initialize GPU handles. Before calling this function, the data must be set. @@ -70,9 +70,9 @@ public: protected: // Determines what attribute data is in use - bool _usePositions; - bool _useTextures; - bool _useNormals; + bool _useVertexPositions; + bool _useTextureCoordinates; + bool _useVertexNormals; private: typedef struct { diff --git a/modules/planetbrowsing/rendering/gridgeometry.cpp b/modules/planetbrowsing/rendering/gridgeometry.cpp index 2b29e1ce52..3ed647bce3 100644 --- a/modules/planetbrowsing/rendering/gridgeometry.cpp +++ b/modules/planetbrowsing/rendering/gridgeometry.cpp @@ -8,19 +8,19 @@ namespace { namespace openspace { -GridGeometry::GridGeometry(unsigned int xRes, unsigned int yRes, Positions usePositions, Textures useTextures, Normals useNormals) +GridGeometry::GridGeometry(unsigned int xRes, unsigned int yRes, Positions usePositions, TextureCoordinates useTextures, Normals useNormals) : Geometry(CreateElements(xRes, yRes), usePositions, useTextures, useNormals) { - if(_usePositions){ - setPositionData(CreatePositions(xRes, yRes)); + if(_useVertexPositions){ + setVertexPositions(CreatePositions(xRes, yRes)); } - if (_useTextures) { - setTextureData(CreateTextureCoordinates(xRes, yRes)); + if (_useTextureCoordinates) { + setVertexTextureCoordinates(CreateTextureCoordinates(xRes, yRes)); } - if (_useNormals) { - setNormalData(CreateNormals(xRes, yRes)); + if (_useVertexNormals) { + setVertexNormals(CreateNormals(xRes, yRes)); } } diff --git a/modules/planetbrowsing/rendering/gridgeometry.h b/modules/planetbrowsing/rendering/gridgeometry.h index c2a26bcd9f..f7986ac468 100644 --- a/modules/planetbrowsing/rendering/gridgeometry.h +++ b/modules/planetbrowsing/rendering/gridgeometry.h @@ -43,7 +43,7 @@ class GridGeometry : public Geometry public: GridGeometry(unsigned int xRes, unsigned int yRes, Positions usePositions = Positions::No, - Textures useTextures = Textures::No, + TextureCoordinates useTextures = TextureCoordinates::No, Normals useNormals = Normals::No );