diff --git a/example/src/ofApp.cpp b/example/src/ofApp.cpp index 1cda586..be20fbd 100644 --- a/example/src/ofApp.cpp +++ b/example/src/ofApp.cpp @@ -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; diff --git a/src/ofxRealSense2/Device.cpp b/src/ofxRealSense2/Device.cpp index 9246be4..0c9a166 100644 --- a/src/ofxRealSense2/Device.cpp +++ b/src/ofxRealSense2/Device.cpp @@ -333,7 +333,7 @@ namespace ofxRealSense2 void Device::disablePoints() { - this->pointsVbo.clear(); + this->pointsMesh.clear(); this->pointsEnabled = false; } @@ -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(vertices), reinterpret_cast(vertices + this->points.size())); + this->pointsMesh.getTexCoords().assign(reinterpret_cast(texCoords), reinterpret_cast(texCoords + this->points.size())); } } } @@ -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 diff --git a/src/ofxRealSense2/Device.h b/src/ofxRealSense2/Device.h index a587023..0bbbe25 100644 --- a/src/ofxRealSense2/Device.h +++ b/src/ofxRealSense2/Device.h @@ -6,7 +6,7 @@ #include "ofPixels.h" #include "ofTexture.h" #include "ofThread.h" -#include "ofVbo.h" +#include "ofVboMesh.h" namespace ofxRealSense2 { @@ -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; @@ -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;