MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / bindPoints_

Method bindPoints_

source/MRViewer/MRRenderPointsObject.cpp:263–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261
262
263void RenderPointsObject::bindPoints_( GLStaticHolder::ShaderType shaderType )
264{
265 MR_TIMER;
266 auto shader = GLStaticHolder::getShaderId( shaderType );
267 GL_EXEC( glBindVertexArray( pointsArrayObjId_ ) );
268 GL_EXEC( glUseProgram( shader ) );
269 if ( objPoints_->hasVisualRepresentation() )
270 {
271 auto pointCloud = objPoints_->pointCloud();
272
273 const auto positions = loadVertPosBuffer_();
274 bindVertexAttribArray( shader, "position", vertPosBuffer_, positions, 3, positions.dirty(), positions.glSize() != 0 );
275
276 const auto normals = loadVertNormalsBuffer_();
277 bindVertexAttribArray( shader, "normal", vertNormalsBuffer_, normals, 3, normals.dirty(), normals.glSize() != 0 );
278 hasNormalsBackup_ = !pointCloud->normals.empty();
279 }
280 else
281 {
282 bindVertexAttribArray( shader, "position", vertPosBuffer_, std::vector<Vector3f>{}, 3, false, vertPosBuffer_.size() != 0 );
283 bindVertexAttribArray( shader, "normal", vertNormalsBuffer_, std::vector<Vector3f>{}, 3, false, vertNormalsBuffer_.size() != 0 );
284 }
285
286 const auto colors = loadVertColorsBuffer_();
287 bindVertexAttribArray( shader, "K", vertColorsBuffer_, colors, 4, colors.dirty(), colors.glSize() != 0 );
288
289 auto validIndices = loadValidIndicesBuffer_();
290 validIndicesBuffer_.loadDataOpt( GL_ELEMENT_ARRAY_BUFFER, validIndices.dirty(), validIndices );
291
292 // Selection
293 GL_EXEC( glActiveTexture( GL_TEXTURE0 ) );
294 auto vertSelectionTexture = loadVertSelectionTextureBuffer_();
295 vertSelectionTex_.loadDataOpt( vertSelectionTexture.dirty(),
296 {
297 .resolution = GlTexture2::ToResolution( vertSelectionTextureSize_ ),
298 .internalFormat = GL_R32UI,
299 .format = GL_RED_INTEGER,
300 .type = GL_UNSIGNED_INT
301 },
302 vertSelectionTexture );
303 GL_EXEC( glUniform1i( glGetUniformLocation( shader, "selection" ), 0 ) );
304
305 dirty_ &= ~DIRTY_MESH;
306}
307
308void RenderPointsObject::bindPointsPicker_()
309{

Callers

nothing calls this directly

Calls 7

dirtyMethod · 0.80
glSizeMethod · 0.80
bindVertexAttribArrayFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
loadDataOptMethod · 0.45

Tested by

no test coverage detected