Commit 64af9513 authored by Christopher Tenter's avatar Christopher Tenter

use ACG:GeometryBuffer instead of direct opengl vbo

parent 3bf20e8f
Pipeline #3734 passed with stage
in 60 minutes and 14 seconds
......@@ -766,6 +766,7 @@ updateVBO() {
// Move data to the buffer in gpu memory
vbo_.upload(bufferSize, &vboData[0], GL_STATIC_DRAW);
vbo_.unbind();
}
// Index buffer for selected vertices
......
......@@ -86,7 +86,6 @@ template <class PolyLineCollection>
PolyLineCollectionNodeT<PolyLineCollection>::PolyLineCollectionNodeT(PolyLineCollection& _pl, BaseNode* _parent, std::string _name) :
BaseNode(_parent, _name),
polyline_collection_(_pl),
vbo_(0),
updateVBO_(true),
sphere_(0),
total_vertex_count_(0)
......@@ -149,7 +148,7 @@ draw(GLState& _state, const DrawModes::DrawMode& _drawMode)
ACG::GLState::disable(GL_TEXTURE_2D);
// Bind the vertex array
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, vbo_);
vbo_.bind();
vertexDecl_.activateFixedFunction();
ACG::Vec4f color = _state.ambient_color() + _state.diffuse_color();
......@@ -267,7 +266,7 @@ pick(GLState& _state, PickTarget _target)
if ( polyline_collection_.n_polylines() == 0 )
return;
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, vbo_);
vbo_.bind();
vertexDecl_.activateFixedFunction();;
_state.pick_set_maximum(2);
......@@ -361,10 +360,6 @@ updateVBO() {
// We always output vertex positions
vertexDecl_.addElement(GL_FLOAT, 3, ACG::VERTEX_USAGE_POSITION);
// create vbo if it does not exist
if (!vbo_)
GLState::genBuffersARB(1, &vbo_);
// size in bytes of vbo, create additional vertex for closed loop indexing
unsigned int bufferSize = vertexDecl_.getVertexStride() * offset;
......@@ -386,9 +381,8 @@ updateVBO() {
}
// Move data to the buffer in gpu memory
GLState::bindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_);
GLState::bufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize , vboData_ , GL_STATIC_DRAW_ARB);
GLState::bindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
vbo_.upload(bufferSize, vboData_, GL_STATIC_DRAW);
vbo_.unbind();
// Remove the local storage
delete[] vboData_;
......@@ -439,7 +433,7 @@ getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::S
updateVBO();
// Set to the right vbo
ro.vertexBuffer = vbo_;
ro.vertexBuffer = vbo_.id();
// decl must be static or member, renderer does not make a copy
ro.vertexDecl = &vertexDecl_;
......
......@@ -58,6 +58,8 @@
#include <ACG/GL/VertexDeclaration.hh>
#include <ACG/GL/IRenderer.hh>
#include <ACG/GL/GLPrimitives.hh>
#include <ACG/GL/globjects.hh>
#include <ObjectTypes/PolyLine/PolyLineNodeT.hh>
//== FORWARDDECLARATIONS ======================================================
......@@ -117,7 +119,7 @@ public:
void getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::SceneGraph::DrawModes::DrawMode& _drawMode , const ACG::SceneGraph::Material* _mat);
/// Trigger an update of the vbo
void update() { updateVBO_ = true; };
void update() { updateVBO_ = true; }
void resetVBO() {offsets_.clear();}
private:
......@@ -151,7 +153,7 @@ private:
PolyLineCollection& polyline_collection_;
/// VBO used to render the poly line
unsigned int vbo_;
GeometryBuffer vbo_;
/// Flag to trigger update of vbo
bool updateVBO_;
......@@ -161,6 +163,8 @@ private:
std::vector<std::pair<size_t, size_t> > offsets_;
std::vector< PolyLineNodeT<typename PolyLineCollection::PolyLine> > polylineNodes_;
size_t total_vertex_count_;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment