MCPcopy Create free account
hub / github.com/Kitware/VTK / Download

Method Download

Rendering/OpenGL2/vtkTextureObject.cxx:1461–1506  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1459
1460//------------------------------------------------------------------------------
1461vtkPixelBufferObject* vtkTextureObject::Download(unsigned int target, unsigned int level)
1462{
1463 assert(this->Context);
1464 assert(this->Handle);
1465
1466 vtkPixelBufferObject* pbo = vtkPixelBufferObject::New();
1467 pbo->SetContext(this->Context);
1468
1469 int vtktype = ::vtkGetVTKType(this->Type);
1470 if (vtktype == 0)
1471 {
1472 vtkErrorMacro("Failed to determine type.");
1473 return nullptr;
1474 }
1475
1476 unsigned int size = this->Width * this->Height * this->Depth;
1477
1478 // doesn't matter which Upload*D method we use since we are not really
1479 // uploading any data, simply allocating GPU space.
1480 if (!pbo->Upload1D(vtktype, nullptr, size, this->Components, 0))
1481 {
1482 vtkErrorMacro("Could not allocate memory for PBO.");
1483 pbo->Delete();
1484 return nullptr;
1485 }
1486
1487 pbo->Bind(vtkPixelBufferObject::PACKED_BUFFER);
1488 this->Bind();
1489
1490#ifndef GL_ES_VERSION_3_0
1491 glGetTexImage(target, level, this->Format, this->Type, BUFFER_OFFSET(0));
1492#else
1493 (void)level;
1494 (void)target;
1495 // you can do something with glReadPixels and binding a texture as a FBO
1496 // I believe for ES 2.0
1497#endif
1498
1499 vtkOpenGLCheckErrorMacro("failed at glGetTexImage");
1500 this->Deactivate();
1501 pbo->UnBind();
1502
1503 pbo->SetComponents(this->Components);
1504
1505 return pbo;
1506}
1507
1508//------------------------------------------------------------------------------
1509vtkPixelBufferObject* vtkTextureObject::Download()

Callers 14

RenderDelegateMethod · 0.45
RenderMethod · 0.45
RenderMethod · 0.45
RenderMethod · 0.45
TestComputeShaderFunction · 0.45
StreamingFindMinMaxMethod · 0.45
vtkTextureIO.cxxFile · 0.45
GatherVectorsMethod · 0.45
ApplyLICMethod · 0.45
RequestDataMethod · 0.45
StreamingFindMinMaxFunction · 0.45

Calls 9

BindMethod · 0.95
DeactivateMethod · 0.95
vtkGetVTKTypeFunction · 0.85
SetComponentsMethod · 0.80
DeleteMethod · 0.65
assertFunction · 0.50
NewFunction · 0.50
SetContextMethod · 0.45
UnBindMethod · 0.45

Tested by 1

TestComputeShaderFunction · 0.36