Solve merge conflict.

This commit is contained in:
Karl Bladin
2016-04-04 12:04:46 -04:00
3 changed files with 19 additions and 9 deletions

View File

@@ -52,6 +52,7 @@ Geometry::~Geometry() {
void Geometry::setVertexPositions(std::vector<glm::vec4> positions) {
_useVertexPositions = true;
_gpuDataNeedUpdate = true;
_vertexData.resize(positions.size());
for (size_t i = 0; i < positions.size(); i++)
{
@@ -65,6 +66,7 @@ void Geometry::setVertexPositions(std::vector<glm::vec4> positions) {
void Geometry::setVertexTextureCoordinates(std::vector<glm::vec2> textures) {
_useTextureCoordinates = true;
_gpuDataNeedUpdate = true;
_vertexData.resize(textures.size());
for (size_t i = 0; i < textures.size(); i++)
{
@@ -76,6 +78,7 @@ void Geometry::setVertexTextureCoordinates(std::vector<glm::vec2> textures) {
void Geometry::setVertexNormals(std::vector<glm::vec3> normals) {
_useVertexNormals = true;
_gpuDataNeedUpdate = true;
_vertexData.resize(normals.size());
for (size_t i = 0; i < normals.size(); i++)
{
@@ -88,13 +91,14 @@ void Geometry::setVertexNormals(std::vector<glm::vec3> normals) {
void Geometry::setElements(std::vector<unsigned int> elements) {
_elementData.resize(elements.size());
_gpuDataNeedUpdate = true;
for (size_t i = 0; i < elements.size(); i++)
{
_elementData[i] = static_cast<GLuint>(elements[i]);
}
}
bool Geometry::initialize() {
bool Geometry::updateDataInGPU() {
// Create VAO
if (_vaoID == 0)
glGenVertexArrays(1, &_vaoID);
@@ -157,7 +161,11 @@ bool Geometry::initialize() {
return true;
}
void Geometry::drawUsingActiveProgram() const {
void Geometry::drawUsingActiveProgram() {
if (_gpuDataNeedUpdate) {
updateDataInGPU();
}
glBindVertexArray(_vaoID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _elementBufferID);
glDrawElements(GL_TRIANGLES, _elementData.size(), GL_UNSIGNED_INT, 0);

View File

@@ -60,11 +60,10 @@ public:
void setVertexNormals(std::vector<glm::vec3> normals);
void setElements(std::vector<unsigned int> elements);
/**
Initialize GPU handles. Before calling this function, the data must be set.
*/
bool initialize();
void drawUsingActiveProgram() const;
void drawUsingActiveProgram();
protected:
// Determines what attribute data is in use
bool _useVertexPositions;
@@ -84,10 +83,15 @@ protected:
std::vector<Vertex> _vertexData;
std::vector<GLuint> _elementData;
private:
bool updateDataInGPU();
// GL handles
GLuint _vaoID;
GLuint _vertexBufferID;
GLuint _elementBufferID;
bool _gpuDataNeedUpdate;
};
} // namespace openspace

View File

@@ -66,8 +66,6 @@ namespace openspace {
// Mainly for debugging purposes @AA
addProperty(_rotation);
_grid.initialize();
}
GlobeMesh::~GlobeMesh() {