[vtkusers] Fullscreen mode problem

Francois Bertel francois.bertel at kitware.com
Mon Jun 1 08:23:52 EDT 2009


Hello,

I have been able to reproduce the issue with a minimal piece of code
on VTK CVS. I added a bug report:

http://www.vtk.org/Bug/view.php?id=9087

On Mon, Jun 1, 2009 at 4:16 AM, Nabil El Ouazzani
<ouanabil at googlemail.com> wrote:
>
> subject:Fullscreen mode problem
> Hi,
>
> I'm having some trouble with the vtkRenderWindow full screen mode under
> X11. When I activate full screen mode, the window renders to full screen
> correctly, however all keyboard/mouse interaction with the window appears
> to cease, ie no further clicks/keypresses are received by the application.
>
> hier is the code:
>    typedef int PipeHandle;
>    XtAppContext app_context;
> void handle_timer(vtkObject* caller, unsigned long, void* clientdata, void*)
> {
>     vtkRenderWindowInteractor* iren=
> static_cast<vtkInteractorStyle*>(caller)->GetInteractor();
>     vtkCamera* cam = reinterpret_cast<vtkCamera*>(clientdata);
>     iren->CreateTimer(VTKI_TIMER_UPDATE);
>     iren->Render();
>     }
>
> void handle_console_event(PipeHandle handle)
> {
>     static char buf[1024];
>     int num_read=0;
>     num_read = read(handle, buf, 1024);
>
>     if(num_read == 5 && (strncmp("exit", buf, 4) == 0 || strncmp("quit",
> buf, 4) == 0))
>     {
>         XtAppSetExitFlag(app_context);
>     }
> }
>
> static void x11_handle_console_event(XtPointer, int* pipe, XtInputId*)
> {
>     handle_console_event(*pipe);
> }
>
> class vtkMyCallback : public vtkCommand
> {
>     public:
>      static vtkMyCallback *New()
>      {
>          return new vtkMyCallback;
>      }
>
>      virtual void Execute(vtkObject *caller1, unsigned long, void*)
>      {
>          vtkXRenderWindowInteractor *interact =
> reinterpret_cast<vtkXRenderWindowInteractor*>(caller1);
>
>          char* key = interact->GetKeySym();
>           if (*key=='g')
>          {
>              this->Actor->GetProperty()->SetColor(0,1,0);
>
>          }
>
>          if (*key=='b')
>          {
>              this->Actor->GetProperty()->SetColor(0,0,1);
>          }
>
>          if (*key=='r')
>          {
>               this->Actor->GetProperty()->SetColor(1,0,0);
>          }
>
>      }
>
>     void SetActor(vtkActor *actor)
>     {
>         this->Actor = actor;
>     }
>
>     protected:
>         vtkActor *Actor;
>         vtkRenderWindow* renWin;
> };
>
> int main()
> {
>     XtToolkitInitialize();
>     app_context = XtCreateApplicationContext();
>     XtAppAddInput(app_context, fileno(stdin),
> (XtPointer)XtInputReadMask,x11_handle_console_event, NULL);
>
> vtkRenderer* ren1 = vtkRenderer::New();
> vtkRenderWindow* renWin = vtkRenderWindow::New();
>    renWin->AddRenderer (ren1);
>
> vtkXRenderWindowInteractor* iren1 = vtkXRenderWindowInteractor::New();
>     iren1->SetRenderWindow(renWin);
>     iren1->Initialize(app_context);
>
> vtkInteractorStyleTrackballCamera *style =
> vtkInteractorStyleTrackballCamera::New();
>     iren1->SetInteractorStyle(style);
>
> vtkCylinderSource *cylinder1 = vtkCylinderSource::New();
>      cylinder1->SetCenter(0,0,0);
>      cylinder1->SetRadius(1);
>      cylinder1->SetHeight(2);
>      cylinder1->SetResolution(100);
>
>
>  vtkPolyDataMapper *cylinderMapper1 = vtkPolyDataMapper::New();
>     cylinderMapper1->SetInputConnection (cylinder1 ->GetOutputPort());
>
> vtkActor *cylinderActor1 = vtkActor::New();
>     cylinderActor1->SetMapper(cylinderMapper1);
>     cylinderActor1->GetProperty()->SetColor(1,0,0);
>     cylinderActor1->SetPosition(1,1,1);
>
>     ren1->AddActor(cylinderActor1);
>     ren1->SetBackground(1, 1, 1 );
>     renWin->FullScreenOn();
>
> vtkCamera *cam1 = vtkCamera::New();
>     ren1->ResetCamera();
>     cam1 = ren1->GetActiveCamera();
>
> vtkCallbackCommand* callback = vtkCallbackCommand::New();
>     callback->SetClientData(cam1);
>     callback->SetCallback(handle_timer);
>     style->AddObserver(vtkCommand::TimerEvent, callback);
>
> vtkMyCallback *cb = vtkMyCallback::New();
>     cb->SetActor(cylinderActor1);
>     style->AddObserver(vtkCommand::KeyReleaseEvent ,cb);
>     iren1->CreateTimer(VTKI_TIMER_FIRST);
>
>     printf("type 'exit' to quit\n");
>
>   while(!XtAppGetExitFlag(app_context))
>   {
>         float x=0,y=0,z=0;
>         for( double i = 0; i<9;i++)
>         {
>             {x=fmod(i,6);
>             y=fmod(i,3);
>             z=fmod(i,9);
>         }
>            cylinderActor1 ->SetPosition(x,y,z);
>          XtAppProcessEvent(app_context, XtIMAll);
>
>         }
>   }
>     return 0;
> }
>
> I am using Debian with VTK5.0, on a system with NVIDIA drivers.
> Can anyone offer any suggestions as to why this is happening?
>
> --
> Cheers,
> ouanabil
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtkusers mailing list