[vtkusers] Cannot get Vtk output in an existing OpenGL rendering context within MFC.
resmi s
resmioct1989 at gmail.com
Mon Mar 18 05:38:56 EDT 2013
I was creating an application which uses vtkGPUVolumeRayCasting. I want to
display the output in an existing OpenGL rendering context which is within
MFC. The output is displayed in the MFC window, but mouse interactions are
not possible. And the vtk render window is also displayed. I had tried
vtkMFCWindow, but i couldnt build it in MTd mode. The code is as shown
below:
vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renWin =
vtkSmartPointer<vtkRenderWindow>::New();
CRect rect;
GetClientRect(hWnd, &rect);
//renWin->SetSize(50, 50);
//renWin->Render();
//renWin->AddRenderer(ren);
//vtkSmartPointer<vtkRenderWindowInteractor> iren =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
//iren->SetRenderWindow(renWin);
vtkWin32OpenGLRenderWindow *rw =
vtkWin32OpenGLRenderWindow::New()/*SafeDownCast(renWin)*/;
rw->SetSize(500, 500);
rw->Render();
rw->AddRenderer(ren);
vtkSmartPointer<vtkWin32RenderWindowInteractor> iren =
vtkSmartPointer<vtkWin32RenderWindowInteractor>::New();
iren->SetRenderWindow(rw);
rw->SetWindowId(hWnd);
rw->SetParentId(hWnd);
rw->SetDeviceContext(hDC);
rw->SetContextId(hRC);
//----raycastmapper
vtkSmartPointer<vtkGPUVolumeRayCastMapper> volumeMapper =
vtkSmartPointer<vtkGPUVolumeRayCastMapper>::New();
volumeMapper->SetInputConnection(scale->GetOutputPort());
volumeMapper->SetBlendModeToComposite();
volumeMapper->AutoAdjustSampleDistancesOn();
volumeMapper->SetImageSampleDistance(0.5);
volumeMapper->SetMaximumImageSampleDistance(0.5);
/////set volume color
///set volume scalar opacity
///set volume gradient opacity
////set volume property
vtkSmartPointer<vtkVolume> volume = vtkSmartPointer<vtkVolume>::New();
volume->SetMapper(volumeMapper);
volume->SetProperty(volumeProperty);
ren->AddViewProp(volume);
vtkCamera *camera = ren->GetActiveCamera();
double *c = volume->GetCenter();
camera->SetFocalPoint(c[0], c[1], c[2]);
camera->SetPosition(c[0] + 400, c[1], c[2]);
camera->SetViewUp(0, 0, -1);
vtkSmartPointer<vtkInteractorStyleTrackballActor> style =
vtkSmartPointer<vtkInteractorStyleTrackballActor>::New();
iren->SetInteractorStyle(style);
iren->Initialize();
iren->Start();
Can anyone pls help in solving this.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130318/0875ac3f/attachment.htm>
More information about the vtkusers
mailing list