# How to use original OpenGL in VTK program?

**URL:** https://discourse.vtk.org/t/how-to-use-original-opengl-in-vtk-program/4636
**Category:** Support
**Created:** [November 12, 2020, 3:40am UTC](https://discourse.vtk.org/t/how-to-use-original-opengl-in-vtk-program/4636 "2020-11-12T03:40:37Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![xyh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/xyh/32/2598_2.png) [@xyh](https://discourse.vtk.org/u/xyh)
#### Post date: [November 12, 2020, 3:40am UTC](https://discourse.vtk.org/t/how-to-use-original-opengl-in-vtk-program/4636/1 "2020-11-12T03:40:37Z")

</div>

I am new to vtk, can you tell me how to use vtk and opengl in the one window (such as QVTKOpenGLWindow)?  
For examle, there is a cube painted by vtk, how to add a triangle by opengl in same window?  
Thanks.

---

<div class="post-metadata">

### Author: ![xyh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/xyh/32/2598_2.png) [@xyh](https://discourse.vtk.org/u/xyh)
#### Post date: [November 13, 2020, 6:44am UTC](https://discourse.vtk.org/t/how-to-use-original-opengl-in-vtk-program/4636/2 "2020-11-13T06:44:49Z")

</div>

Some things have been rendered in the QOpenGLWindow through opengl, how to add more through vtk to render, vtkExternalOpenGLRenderWindow?

---

<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: [November 16, 2020, 1:45pm UTC](https://discourse.vtk.org/t/how-to-use-original-opengl-in-vtk-program/4636/3 "2020-11-16T13:45:00Z")

</div>

Hello, friend,

Please, take a look at this: [https://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/RenderPassExistingContext](https://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/RenderPassExistingContext) But its approach is the opposite: you create a standalone OpenGL window and then pass its OpenGL context to VTK to use for rendering.

regards,

Paulo

---

<div class="post-metadata">

### Author: ![user\_42](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/u/e19b73/32.png) [@user\_42](https://discourse.vtk.org/u/user_42)
#### Post date: [December 2, 2021, 10:54am UTC](https://discourse.vtk.org/t/how-to-use-original-opengl-in-vtk-program/4636/4 "2021-12-02T10:54:31Z")

</div>

Hi, the link redirects to the examples page instead of the specific example you mentioned, could please share it again or post the code of the example here?

---

<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 2, 2021, 7:47pm UTC](https://discourse.vtk.org/t/how-to-use-original-opengl-in-vtk-program/4636/5 "2021-12-02T19:47:20Z")

</div>

Unfortunately they took down the page without providing a replacement. At least I could not readily locate the example. Maybe it was renamed. Sorry.

---

<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 2, 2021, 7:51pm UTC](https://discourse.vtk.org/t/how-to-use-original-opengl-in-vtk-program/4636/7 "2021-12-02T19:51:27Z")

</div>

I found it on Wayback Machine web archiving service: [VTK/Examples/Cxx/Visualization/RenderPassExistingContext - KitwarePublic](https://web.archive.org/web/20200502044901/https://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/RenderPassExistingContext)

I recommend saving the HTML of the page or having it re-uploaded to the new VTK examples site. Wayback Machine has been around for many years, but who knows how long it will remain available.

---

<div class="post-metadata">

### Author: ![user\_42](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/u/e19b73/32.png) [@user\_42](https://discourse.vtk.org/u/user_42)
#### Post date: [December 7, 2021, 4:00pm UTC](https://discourse.vtk.org/t/how-to-use-original-opengl-in-vtk-program/4636/8 "2021-12-07T16:00:41Z")

</div>

That’s great, thank you very much! So if I understand correctly, in this example I render my volume in VTK and pass it to an OpenGL context for visualisation?

---

<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 7, 2021, 8:42pm UTC](https://discourse.vtk.org/t/how-to-use-original-opengl-in-vtk-program/4636/9 "2021-12-07T20:42:56Z")

</div>

You’re welcome. It’s more like: you create a standalone OpenGL window and then pass its OpenGL context to VTK to use for rendering.
