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

Method ReadPixels

Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx:1304–1476  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1302
1303//------------------------------------------------------------------------------
1304int vtkOpenGLRenderWindow::ReadPixels(
1305 const vtkRecti& rect, int front, int glformat, int gltype, void* data, int right)
1306{
1307 // set the current window
1308 this->MakeCurrent();
1309
1310 if (rect.GetWidth() < 0 || rect.GetHeight() < 0)
1311 {
1312 // invalid box
1313 return VTK_ERROR;
1314 }
1315
1316 // Must clear previous errors first.
1317#ifdef VTK_REPORT_OPENGL_ERRORS
1318 while (glGetError() != GL_NO_ERROR)
1319 {
1320 }
1321#endif
1322
1323 this->GetState()->vtkglDisable(GL_SCISSOR_TEST);
1324
1325 // Calling pack alignment ensures that we can grab the any size window
1326 this->GetState()->vtkglPixelStorei(GL_PACK_ALIGNMENT, 1);
1327
1328 this->GetState()->PushReadFramebufferBinding();
1329
1330 if (front)
1331 {
1332 this->DisplayFramebuffer->Bind(GL_READ_FRAMEBUFFER);
1333 this->DisplayFramebuffer->ActivateReadBuffer(right ? 1 : 0);
1334 }
1335 else
1336 {
1337 this->RenderFramebuffer->Bind(GL_READ_FRAMEBUFFER);
1338 this->RenderFramebuffer->ActivateReadBuffer(0);
1339
1340 // Let's determine if we're reading from an FBO.
1341 bool resolveMSAA = this->GetBufferNeedsResolving();
1342
1343 if (resolveMSAA)
1344 {
1345 this->GetState()->PushDrawFramebufferBinding();
1346 int* fbsize = this->RenderFramebuffer->GetLastSize();
1347 this->ResolveFramebuffer->Resize(fbsize[0], fbsize[1]);
1348 this->ResolveFramebuffer->Bind(GL_DRAW_FRAMEBUFFER);
1349
1350 // Now blit to resolve the MSAA and get an anti-aliased rendering in
1351 // resolvedFBO.
1352 this->GetState()->vtkglBlitFramebuffer(rect.GetLeft(), rect.GetBottom(), rect.GetRight(),
1353 rect.GetTop(), rect.GetLeft(), rect.GetBottom(), rect.GetRight(), rect.GetTop(),
1354 GL_COLOR_BUFFER_BIT, GL_NEAREST);
1355 this->GetState()->PopDrawFramebufferBinding();
1356
1357 // Now make the resolvedFBO the read buffer and read from it.
1358 this->ResolveFramebuffer->Bind(GL_READ_FRAMEBUFFER);
1359 this->ResolveFramebuffer->ActivateReadBuffer(0);
1360 }
1361 }

Callers 3

GetPixelDataMethod · 0.95
GetRGBAPixelDataMethod · 0.95
GetRGBACharPixelDataMethod · 0.95

Calls 15

vtkglDisableMethod · 0.80
vtkglPixelStoreiMethod · 0.80
ActivateReadBufferMethod · 0.80
vtkglBlitFramebufferMethod · 0.80
MakeCurrentMethod · 0.45
GetWidthMethod · 0.45
GetHeightMethod · 0.45

Tested by

no test coverage detected