# Why is my CUBE not displayed in vtkRenderWindow ?

**URL:** <https://discourse.vtk.org/t/why-is-my-cube-not-displayed-in-vtkrenderwindow/11809>\
**Category:** Development\
**Tags:** code\
**Created:** [June 25, 2023, 6:10am UTC](https://discourse.vtk.org/t/why-is-my-cube-not-displayed-in-vtkrenderwindow/11809 "2023-06-25T06:10:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhuofalin](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhuofalin/32/7146_2.png) [@zhuofalin](https://discourse.vtk.org/u/zhuofalin)\
**Post date:** [June 25, 2023, 6:10am UTC](https://discourse.vtk.org/t/why-is-my-cube-not-displayed-in-vtkrenderwindow/11809/1 "2023-06-25T06:10:39Z")

</div>

- **When I ran the example code today, I found that the code ran successfully, but the window showing the result was not displayed. What is the reason?**

- Environment: windows10, IDE: VS2022, and use cmake to program .sln files

- Here is the code, [sourceCode](https://gitlab.kitware.com/vtk/vtk/-/blob/v9.2.0/Examples/DataManipulation/Cxx/Cube.cxx)

```auto
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkCellArray.h>
#include <vtkFloatArray.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPointData.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>

#include <array>

int main()
{
    vtkNew<vtkNamedColors> colors;

    std::array<std::array<double, 3>, 8> pts = { { { { 0, 0, 0 } }, { { 1, 0, 0 } }, { { 1, 1, 0 } },
      { { 0, 1, 0 } }, { { 0, 0, 1 } }, { { 1, 0, 1 } }, { { 1, 1, 1 } }, { { 0, 1, 1 } } } };
    // The ordering of the corner points on each face.
    std::array<std::array<vtkIdType, 4>, 6> ordering = { { { { 0, 1, 2, 3 } }, { { 4, 5, 6, 7 } },
      { { 0, 1, 5, 4 } }, { { 1, 2, 6, 5 } }, { { 2, 3, 7, 6 } }, { { 3, 0, 4, 7 } } } };

    // We'll create the building blocks of polydata including data attributes.
    vtkNew<vtkPolyData> cube;
    vtkNew<vtkPoints> points;
    vtkNew<vtkCellArray> polys;
    vtkNew<vtkFloatArray> scalars;

    // Load the point, cell, and data attributes.
    for (auto i = 0ul; i < pts.size(); ++i)
    {
        points->InsertPoint(i, pts[i].data());
        scalars->InsertTuple1(i, i);
    }
    for (auto&& i : ordering)
    {
        polys->InsertNextCell(vtkIdType(i.size()), i.data());
    }

    // We now assign the pieces to the vtkPolyData.
    cube->SetPoints(points);
    cube->SetPolys(polys);
    cube->GetPointData()->SetScalars(scalars);

    // Now we'll look at it.
    vtkNew<vtkPolyDataMapper> cubeMapper;
    cubeMapper->SetInputData(cube);
    cubeMapper->SetScalarRange(cube->GetScalarRange());
    vtkNew<vtkActor> cubeActor;
    cubeActor->SetMapper(cubeMapper);

    // The usual rendering stuff.
    vtkNew<vtkCamera> camera;
    camera->SetPosition(1, 1, 1);
    camera->SetFocalPoint(0, 0, 0);

    vtkNew<vtkRenderer> renderer;
    vtkNew<vtkRenderWindow> renWin;
    renWin->AddRenderer(renderer);

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

    renderer->AddActor(cubeActor);
    renderer->SetActiveCamera(camera);
    renderer->ResetCamera();
    renderer->SetBackground(colors->GetColor3d("Cornsilk").GetData());

    renWin->SetSize(600, 600);

    // interact with data
    renWin->Render();
    iren->Start();

    return EXIT_SUCCESS;
}

```

- This is what I get when I run it locally  

- Could you help me, thanks all. Looking forward to your reply.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [June 28, 2023, 7:00pm UTC](https://discourse.vtk.org/t/why-is-my-cube-not-displayed-in-vtkrenderwindow/11809/2 "2023-06-28T19:00:34Z")

</div>

When nothing is displayed after `Start()`, it often means that some of these needed VTK libraries is not linked by cmake:

```plaintext
  InteractionStyle
  RenderingFreeType
  RenderingOpenGL2

```

Can you post your CMakeLists.txt?
