[vtkusers] Render using Multipass (vtkRenderstate / vtkRenderPass) framework, in an existing OpenGL context

Bryn Lloyd lloyd at itis.ethz.ch
Tue May 31 10:45:21 EDT 2011


Hi

 

I have been trying to write some code, which allows me to use some of the
rendering methods in VTK within an existing context, with direct calls to
OpenGL done before the VTK render call.

 

It seems the nice Multipass framework by François Bertel
(http://cmake.org/Wiki/VTK/MultiPass_Rendering) could be used for this
purpose. I tried following code (see below). However, if run an example
which plots two triangles – one directly using OpenGL – one using a
vtkPolyData+Mapper+Actor, then the final color of the triangles is always
set by the color property of the vtkActor, even if I set a different color
in the direct OpenGL code.

 

Does anybody have an idea what I am doing wrong here?

Is there a nice example somewhere, which uses the Multipass framework mixed
with a different rendering library/OpenGL code?

 

Thanks!

Bryn

 

 

void Setup()

{

       // Setup renderer and render window

       m_Renderer = vtkRenderer::New();

 

       m_RenderWindow = vtkWin32OpenGLRenderWindow::New();

       m_RenderWindow->SetWindowId(WindowId);

       m_RenderWindow->SetParentId(ParentId);

       m_RenderWindow->SetContextId((HGLRC)ContextId);

       m_RenderWindow->SetDeviceContext((HDC)DeviceContext);

       m_RenderWindow->AddRenderer(m_Renderer);

 

       vtkOpaquePass  * opaquePass = vtkOpaquePass::New();

       vtkLightsPass * lights = vtkLightsPass::New();

 

       vtkRenderPassCollection * opasses = vtkRenderPassCollection::New();

       passes->AddItem(lights);

       passes->AddItem(opaquePass);

 

       vtkSequencePass * seq = vtkSequencePass::New();

       seq->SetPasses(passes);

 

       m_Renderer->SetPass(seq);

}

 

 

The callback function is:

 

void Callback()

{

       glPushMatrix();

       glBegin( GL_TRIANGLES );

       glColor3f( 1.0f, 1.0f, 1.0f ); glVertex3f( 0.2f, 1.0f, 0.0f );

       glColor3f( 1.0f, 1.0f, 1.0f ); glVertex3f( 1.07f, -0.5f, 0.0f );

       glColor3f( 1.0f, 1.0f, 1.0f ); glVertex3f( -0.67f, -0.5f, 0.0f );

       glEnd();

 

       glPopMatrix();

       glPushMatrix();

       m_Renderer->Render();

       glPopMatrix();

}

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110531/1ce79537/attachment.htm>


More information about the vtkusers mailing list