# How to make a subclass of vtkRenderer?

**URL:** https://discourse.vtk.org/t/how-to-make-a-subclass-of-vtkrenderer/7363
**Category:** Support
**Created:** [December 8, 2021, 4:25am UTC](https://discourse.vtk.org/t/how-to-make-a-subclass-of-vtkrenderer/7363 "2021-12-08T04:25:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![WailmerPail](https://discourse.vtk.org/user_avatar/discourse.vtk.org/wailmerpail/32/3356_2.png) [@WailmerPail](https://discourse.vtk.org/u/WailmerPail)
#### Post date: [December 8, 2021, 4:25am UTC](https://discourse.vtk.org/t/how-to-make-a-subclass-of-vtkrenderer/7363/1 "2021-12-08T04:25:14Z")

</div>

Hi teams,

I want to make a subclass of vtkRenderer, but it does not work.  
Even if I only change the vtkRenderer to “myRnderer”.  
I searched for hours but I can only get the information of "how to make a subclass of vtkActor ", but I got a message here “some macro and function should be override explicitly”.  
Hence, I tried to copy the code of vtkOpenGLRenderer, and know which part should be kept, but I failed to compile it.

So I want to know how can I override vtkRenderer? Which function and macro should be used?

```auto
VTKRENDERINGCORE_EXPORT // I can not compile with that macro sucessfully.
    vtkTypeMacro(VTKMRenderer, vtkRenderer)
    void PrintSelf(ostream& os, vtkIndent indent) override;
   friend class vtkRenderPass;
///
vtkStandardNewMacro(VTKMRenderer)

```

Thank you!

Best regards.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 9, 2021, 9:19pm UTC](https://discourse.vtk.org/t/how-to-make-a-subclass-of-vtkrenderer/7363/2 "2021-12-09T21:19:32Z")

</div>

Hi, Wailmer,

Here’s how I subclass a VTK class (in this case, the `vtkInteractorStyleTrackballCamera` class):

In the `.h`:

```cpp
#include <vtkInteractorStyleTrackballCamera.h>

(...)

class myMouseInteractor : public vtkInteractorStyleTrackballCamera
{
public:

    static myMouseInteractor* New();

    vtkTypeMacro(myMouseInteractor, vtkInteractorStyleTrackballCamera)
   
    (...)

}

```

In the `.cpp`

```cpp
#include <vtkObjectFactory.h>

(...)

// Implementation of the New() function for myMouseInteractor.
vtkStandardNewMacro(myMouseInteractor);

(...)

```

I hope this helps,

Paulo
