# Rendering Text in VR mode

**URL:** <https://discourse.slicer.org/t/rendering-text-in-vr-mode/16343>\
**Category:** Support\
**Tags:** virtual-reality\
**Created:** [March 3, 2021, 8:21pm UTC](https://discourse.slicer.org/t/rendering-text-in-vr-mode/16343 "2021-03-03T20:21:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raj\_Kumar\_Ranabhat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/raj_kumar_ranabhat/32/9857_2.png) [@Raj\_Kumar\_Ranabhat](https://discourse.slicer.org/u/Raj_Kumar_Ranabhat)\
**Post date:** [March 3, 2021, 8:21pm UTC](https://discourse.slicer.org/t/rendering-text-in-vr-mode/16343/1 "2021-03-03T20:21:55Z")

</div>

Is it possible to render a scripted text or message in Virtual Reality Environment in addition with Rendered label map Model ?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 4, 2021, 1:44am UTC](https://discourse.slicer.org/t/rendering-text-in-vr-mode/16343/2 "2021-03-04T01:44:26Z")

</div>

Markups would be the most convenient way of displaying labels, but they use 2D text actors, which I think are rendered with ghosting. However, there are many 3D text actors that you can add to the scene, for example:

```python
viewIndex = 0
label = vtk.vtkFlagpoleLabel()
label.SetInput("My label")
renderWindow = slicer.app.layoutManager().threeDWidget(viewIndex).threeDView().renderWindow()
renderer = renderWindow.GetRenderers().GetFirstRenderer()
renderer.AddActor(label)
renderer.Render()

```

You need to replace `viewIndex` with the index of the virtual reality view.

---

<div class="post-metadata">

**Author:** ![Raj\_Kumar\_Ranabhat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/raj_kumar_ranabhat/32/9857_2.png) [@Raj\_Kumar\_Ranabhat](https://discourse.slicer.org/u/Raj_Kumar_Ranabhat)\
**Post date:** [March 5, 2021, 6:30pm UTC](https://discourse.slicer.org/t/rendering-text-in-vr-mode/16343/3 "2021-03-05T18:30:32Z")

</div>

thank you Andras, I am getting this error while trying to use vtk.FlagpoleLabel(). Do I need to import any other library beside vtk to work it out ?

vtk.vtkFlagpoleLabel()

Traceback (most recent call last):

File “”, line 1, in

AttributeError: module ‘vtkmodules.all’ has no attribute ‘vtkFlagpoleLabel’

Using slicer 4.11.0

Thank you !!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 5, 2021, 6:33pm UTC](https://discourse.slicer.org/t/rendering-text-in-vr-mode/16343/4 "2021-03-05T18:33:16Z")

</div>

vtkFlagpoleLabel has been added to VTK recently, so it is only available in Slicer Preview Releases (VTK9), but there are other similar 3D text actors in VTK8 that you can use in Slicer-4.11.
