Skip to content

Commit

Permalink
Replace ofVbo by ofVboMesh.
Browse files Browse the repository at this point in the history
  • Loading branch information
prisonerjohn committed Oct 7, 2019
1 parent fc0eaef commit b591929
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion example/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void ofApp::draw()
while (it != this->context.getDevices().end())
{
it->second->getColorTex().bind();
it->second->getPointsVbo().draw(GL_POINTS, 0, it->second->getNumPoints());
it->second->getPointsMesh().draw();
it->second->getColorTex().unbind();

++it;
Expand Down
20 changes: 7 additions & 13 deletions src/ofxRealSense2/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ namespace ofxRealSense2

void Device::disablePoints()
{
this->pointsVbo.clear();
this->pointsMesh.clear();
this->pointsEnabled = false;
}

Expand Down Expand Up @@ -482,16 +482,10 @@ namespace ofxRealSense2
auto vertices = this->points.get_vertices();
auto texCoords = this->points.get_texture_coordinates();
ofLogVerbose(__FUNCTION__) << "Uploading " << this->points.size() << " points";
if (this->pointsVbo.getNumVertices() < this->points.size())
{
this->pointsVbo.setVertexData((const float *)vertices, 3, this->points.size(), GL_STREAM_DRAW);
this->pointsVbo.setTexCoordData((const float *)texCoords, this->points.size(), GL_STREAM_DRAW);
}
else
{
this->pointsVbo.updateVertexData((const float *)vertices, this->points.size());
this->pointsVbo.updateTexCoordData((const float *)texCoords, this->points.size());
}
this->pointsMesh.setUsage(GL_STREAM_DRAW);
this->pointsMesh.setMode(OF_PRIMITIVE_POINTS);
this->pointsMesh.getVertices().assign(reinterpret_cast<const ofDefaultVertexType*>(vertices), reinterpret_cast<const ofDefaultVertexType*>(vertices + this->points.size()));
this->pointsMesh.getTexCoords().assign(reinterpret_cast<const ofDefaultTexCoordType*>(texCoords), reinterpret_cast<const ofDefaultTexCoordType*>(texCoords + this->points.size()));
}
}
}
Expand Down Expand Up @@ -537,9 +531,9 @@ namespace ofxRealSense2
return this->colorTex;
}

const ofVbo& Device::getPointsVbo() const
const ofVboMesh& Device::getPointsMesh() const
{
return this->pointsVbo;
return this->pointsMesh;
}

const size_t Device::getNumPoints() const
Expand Down
6 changes: 3 additions & 3 deletions src/ofxRealSense2/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "ofPixels.h"
#include "ofTexture.h"
#include "ofThread.h"
#include "ofVbo.h"
#include "ofVboMesh.h"

namespace ofxRealSense2
{
Expand Down Expand Up @@ -56,7 +56,7 @@ namespace ofxRealSense2
const ofTexture& getInfraredTex() const;
const ofTexture& getColorTex() const;

const ofVbo& getPointsVbo() const;
const ofVboMesh& getPointsMesh() const;
const size_t getNumPoints() const;

float getDistance(int x, int y) const;
Expand Down Expand Up @@ -135,7 +135,7 @@ namespace ofxRealSense2
rs2::pointcloud pointCloud;
rs2::points points;
bool pointsEnabled;
ofVbo pointsVbo;
ofVboMesh pointsMesh;

rs2::decimation_filter decimationFilter;
rs2::disparity_transform disparityTransform;
Expand Down

0 comments on commit b591929

Please sign in to comment.