# Problems with vtkRenderWindowInteractor on macOS using Cocoa

**URL:** https://discourse.vtk.org/t/problems-with-vtkrenderwindowinteractor-on-macos-using-cocoa/805
**Category:** Support
**Created:** [April 20, 2019, 4:42pm UTC](https://discourse.vtk.org/t/problems-with-vtkrenderwindowinteractor-on-macos-using-cocoa/805 "2019-04-20T16:42:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![NoeMurr](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/n/ed8c4c/32.png) [@NoeMurr](https://discourse.vtk.org/u/NoeMurr)
#### Post date: [April 20, 2019, 4:42pm UTC](https://discourse.vtk.org/t/problems-with-vtkrenderwindowinteractor-on-macos-using-cocoa/805/1 "2019-04-20T16:42:51Z")

</div>

Hi all,

I’m learning VTK reading the book VTKTextBook.  
I’ve tried to execute the Cone example at link:  
[https://lorensen.github.io/VTKExamples/site/Cxx/GeometricObjects/Cone/](https://lorensen.github.io/VTKExamples/site/Cxx/GeometricObjects/Cone/)

When I run it I’ve got a strange behavior that is difficult to explain  
with words, but you can see it in the gif at the following link:

The code that I have used is a little different from the code of the  
example but both of them give the same problem.

you can see the code of my .cpp file:

```auto
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkConeSource.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>

int main(int, char* []) {
	vtkNew<vtkNamedColors> colors;
	
	vtkNew<vtkConeSource> cone;
	cone->SetHeight(3.0);
	cone->SetRadius(1.0);
	cone->SetResolution(10);
	
	vtkNew<vtkPolyDataMapper> coneMapper;
	coneMapper->SetInputConnection(cone->GetOutputPort());
	
	vtkNew<vtkActor> coneActor;
	coneActor->SetMapper(coneMapper);
	
	vtkNew<vtkRenderer> ren1;
	ren1->AddActor(coneActor);
	ren1->SetBackground(
	colors->GetColor3d("MidnightBlue").GetData());

	vtkNew<vtkRenderWindow> renWin;
	renWin->AddRenderer(ren1);
	renWin->SetSize(300, 300);

	vtkNew<vtkRenderWindowInteractor> interactor;
	interactor->SetRenderWindow(renWin);

	interactor->Start();
	for (auto i = 0; i < 360; ++i) {
		// render the image
		renWin->Render();
		// rotate the active camera by one degree
		ren1->GetActiveCamera()->Azimuth(1);
	}
	return EXIT_SUCCESS;
}

```

and my CMakeLists.txt:

```auto
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)

project(Cone)

set(VTK_USE_CARBON ON)

find_package(VTK COMPONENTS 
  vtkCommonCore
  vtkCommonDataModel
  vtkFiltersSources
  vtkInteractionStyle
  vtkRenderingCore
  vtkRenderingFreeType
  vtkRenderingOpenGL2 QUIET)
if (NOT VTK_FOUND)
  message("Skipping Cone: ${VTK_NOT_FOUND_MESSAGE}")
  return ()
endif()
message (STATUS "VTK_VERSION: ${VTK_VERSION}")
if (VTK_VERSION VERSION_LESS "8.90.0")
  # old system
  include(${VTK_USE_FILE})
  add_executable(Cone Cone.cpp)
  target_link_libraries(Cone PRIVATE ${VTK_LIBRARIES})
else ()
  # include all components
  add_executable(Cone Cone.cxx )
  target_link_libraries(Cone PRIVATE ${VTK_LIBRARIES})
  # vtk_module_autoinit is needed
  vtk_module_autoinit(
    TARGETS Cone
    MODULES ${VTK_LIBRARIES}
  )
endif ()

```

I have already asked the same question on the mailing list vtk-users, but I didn’t received an answer.  
Where is the problem?

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [April 22, 2019, 12:24am UTC](https://discourse.vtk.org/t/problems-with-vtkrenderwindowinteractor-on-macos-using-cocoa/805/2 "2019-04-22T00:24:52Z")

</div>

The code does exactly what it supposed to do. First rotate the cone using the interactor (`interactor->Start()`). Clicking `X` quits the interactor, so the short animation that you added (with the `for` loop) can run. When that’s done, the application exits.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)
#### Post date: [April 22, 2019, 2:21am UTC](https://discourse.vtk.org/t/problems-with-vtkrenderwindowinteractor-on-macos-using-cocoa/805/3 "2019-04-22T02:21:29Z")

</div>

It sounds like the joystick interaction mode is confusing to you (and I understand why). You can enter ‘trackball’ mode, which you might find more intuitive, by typing the ‘t’ key when the VTK window is in focus.
