[vtk-developers] possible bug in vtk 7.1 - OpenGL2

Roberto Gori r.gori at cineca.it
Fri Aug 12 13:37:03 EDT 2016


Hi,

thx for your answer 

you are right but the result is the same.

it works using a vtkActor instead of a vtkFollower.

From: Ken Martin 
Sent: Friday, August 12, 2016 7:02 PM
To: Roberto Gori 
Cc: VTK Developers 
Subject: Re: [vtk-developers] possible bug in vtk 7.1 - OpenGL2

What happens if you remove the TextureMapToPlane? PlaneSource generates texture coordinate by default. So connect that directly to the mapper and what happens?

On Fri, Aug 12, 2016 at 12:21 PM, Roberto Gori <r.gori at cineca.it> wrote:

  Hi,

  sorry for cross-posting but no one is answering to my question on the vtkusers list.

  As you can see running this code the plane is visualized without texture.

  I think the problem is in rendering a texture on a vtkFollower. 
  Can someone open a bug on Mantis? 


  #include <vtkImageData.h>
  #include <vtkJPEGReader.h>
  #include <vtkPolyDataMapper.h>
  #include <vtkPolyData.h>
  #include <vtkSmartPointer.h>
  #include <vtkTextureMapToPlane.h>
  #include <vtkPlaneSource.h>
  #include <vtkTexture.h>
  #include <vtkRenderer.h>
  #include <vtkRenderWindow.h>
  #include <vtkRenderWindowInteractor.h>
  #include <vtkFollower.h>
  #include <vtkVersion.h>

  int main ( int argc, char *argv[] )
  {
  // Parse command line arguments
  if ( argc != 2 )
  {
  std::cerr << "Usage: " << argv[0] << " Filename" << std::endl;
  return EXIT_FAILURE;
  }

  std::cout << "VTK version:" << vtkVersion::GetVTKVersion() << std::endl;

  std::string inputFilename = argv[1];

  // Read the image which will be the texture
  vtkSmartPointer<vtkJPEGReader> jPEGReader =
  vtkSmartPointer<vtkJPEGReader>::New();
  jPEGReader->SetFileName ( inputFilename.c_str() );

  // Create a plane
  vtkSmartPointer<vtkPlaneSource> plane =
  vtkSmartPointer<vtkPlaneSource>::New();
  plane->SetCenter(0.0, 0.0, 0.0);
  plane->SetNormal(0.0, 0.0, 1.0);

  // Apply the texture
  vtkSmartPointer<vtkTexture> texture =
  vtkSmartPointer<vtkTexture>::New();
  texture->SetInputConnection(jPEGReader->GetOutputPort());

  vtkSmartPointer<vtkTextureMapToPlane> texturePlane =
  vtkSmartPointer<vtkTextureMapToPlane>::New();
  texturePlane->SetInputConnection(plane->GetOutputPort());

  vtkSmartPointer<vtkPolyDataMapper> planeMapper =
  vtkSmartPointer<vtkPolyDataMapper>::New();
  planeMapper->SetInputConnection(texturePlane->GetOutputPort());

  vtkSmartPointer<vtkFollower> texturedPlane =
  vtkSmartPointer<vtkFollower>::New();
  texturedPlane->SetMapper(planeMapper);
  texturedPlane->SetTexture(texture);


  // Visualize the textured plane
  vtkSmartPointer<vtkRenderer> renderer =
  vtkSmartPointer<vtkRenderer>::New();
  renderer->AddActor(texturedPlane);

  renderer->SetBackground(.1, .2, .3); // Background color dark blue
  renderer->ResetCamera();

  texturedPlane->SetCamera(renderer->GetActiveCamera());


  vtkSmartPointer<vtkRenderWindow> renderWindow =
  vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->AddRenderer(renderer);

  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
  vtkSmartPointer<vtkRenderWindowInteractor>::New();
  renderWindowInteractor->SetRenderWindow(renderWindow);

  renderWindow->Render();

  renderWindowInteractor->Start();

  return EXIT_SUCCESS;
  }




  _______________________________________________
  Powered by www.kitware.com

  Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

  Search the list archives at: http://markmail.org/search/?q=vtk-developers

  Follow this link to subscribe/unsubscribe:
  http://public.kitware.com/mailman/listinfo/vtk-developers







-- 

Ken Martin PhD 
Chairman & CFO
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971 

This communication, including all attachments, contains confidential and legally privileged information, and it is intended only for the use of the addressee.  Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken in reliance on it is prohibited and may be unlawful. If you received this communication in error please notify us immediately and destroy the original message.  Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20160812/b8e2c419/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wlEmoticon-smile[1].png
Type: image/png
Size: 1046 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20160812/b8e2c419/attachment-0001.png>


More information about the vtk-developers mailing list