[vtkusers] offscreen rendering vtkGenericopenglRenderWindow
Elhassan Abdou
elhassan.abdou at gmail.com
Tue Dec 12 13:51:41 EST 2017
Hi,
I am trying to do offscreen rendering of a scene. When I captured the
framebuffer and add to Qopenglvtkwidget using image actor the image was
split into two halves as attached in the image attached.
Can you please help me to know how to solve this issue to make the captured
framebuffer looks like the scene shown
VTKWidget1->GetRenderWindow()->AddRenderer(m_rendererLeft);
VTKWidget2->GetRenderWindow()->AddRenderer(m_rendererRight);
VTKWidget1->show();
VTKWidget2->show();
m_SkinMapperLeft->SetInputConnection(m_SkinNormals->GetOutputPort());
m_SkinMapperLeft->ScalarVisibilityOff();
//m_SkinMapperRight->SetInputConnection(m_SkinNormals->GetOutputPort());
//m_SkinMapperRight->ScalarVisibilityOff();
m_SkinActorLeft->SetMapper(m_SkinMapperLeft);
//m_SkinActorRight->SetMapper(m_SkinMapperRight);
m_outlineData->SetInputConnection(m_Volume16Reader->GetOutputPort());
m_mapOutlineLeft->SetInputConnection(m_outlineData->GetOutputPort());
m_outlineActorLeft->SetMapper(m_mapOutlineLeft);
m_outlineActorLeft->GetProperty()->SetColor(0, 0, 0);
m_CameraLeft->SetViewUp(0, 0, -1);
m_CameraLeft->SetPosition(0, 1, 0);
m_CameraLeft->SetFocalPoint(0, 0, 0);
m_CameraLeft->ComputeViewPlaneNormal();
m_CameraLeft->Azimuth(30.0);
m_CameraLeft->Elevation(30.0);
m_rendererLeft->AddActor(m_outlineActorLeft);
m_rendererLeft->AddActor(m_SkinActorLeft);
m_rendererLeft->SetActiveCamera(m_CameraLeft);
m_rendererLeft->ResetCamera();
m_rendererRight->SetActiveCamera(m_CameraLeft);
m_rendererRight->ResetCamera();
m_CameraLeft->Dolly(1.5);
// Set a background color for the renderer and set the size of the
// render window (expressed in pixels).
m_rendererLeft->SetBackground(.2, .3, .4);
m_rendererRight->SetBackground(.2, .3, .4);
//m_rendererRight->SetActiveCamera(m_CameraLeft);
//m_rendererRight->ResetCamera();
//Creates an Empty image
/*m_LeftRenderWindow->SetUseOffScreenBuffers(true);
m_rendererLeft->Render();
int* size = m_LeftRenderWindow->GetSize();
vtkNew<vtkImageData> image;
image->SetDimensions(size[0] - 1, size[1] - 1, 1);
image->AllocateScalars(VTK_UNSIGNED_CHAR, 3);
m_LeftRenderWindow->GetPixelData(0, 0, size[0] - 1, size[1] - 1,0,
vtkArrayDownCast<vtkUnsignedCharArray>(image->GetPointData()->GetScalars()),0);*/
m_LeftRenderWindow->SetUseOffScreenBuffers(false);
m_LeftRenderWindow->Render();
m_LeftRenderWindow->SetUseOffScreenBuffers(true);
m_LeftRenderWindow->Render();
int* size = m_LeftRenderWindow->GetSize();
vtkNew<vtkImageData> image;
image->SetDimensions(size[0] - 1, size[1] - 1, 1);
image->AllocateScalars(VTK_UNSIGNED_CHAR, 3);
m_LeftRenderWindow->GetPixelData(0, 0, size[0] - 1, size[1] - 1, 0,
vtkArrayDownCast<vtkUnsignedCharArray>(image->GetPointData()->GetScalars()),
0);
m_LeftRenderWindow->SetUseOffScreenBuffers(false);
vtkNew<vtkImageActor> imageActor;
imageActor->GetMapper()->SetInputData(image);
m_rendererRight->AddActor(imageActor);
m_rendererRight->Render();
[image: Inline image 1]
Best regards
Elhassan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171212/5a73370f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 290311 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171212/5a73370f/attachment-0001.png>
More information about the vtkusers
mailing list