# attempt to render to unbound program

**URL:** https://discourse.vtk.org/t/attempt-to-render-to-unbound-program/2216
**Category:** Support
**Created:** [December 5, 2019, 10:39am UTC](https://discourse.vtk.org/t/attempt-to-render-to-unbound-program/2216 "2019-12-05T10:39:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![aglv](https://discourse.vtk.org/user_avatar/discourse.vtk.org/aglv/32/29_2.png) [@aglv](https://discourse.vtk.org/u/aglv)
#### Post date: [December 5, 2019, 10:39am UTC](https://discourse.vtk.org/t/attempt-to-render-to-unbound-program/2216/1 "2019-12-05T10:39:50Z")

</div>

The software I’m working on uses multiple vtkCocoaGLView instances to display stuff. Since updating to recent VTK versions from VTK 5, the rendering pipeline stops working when switching between windows.

I tracked this down to an unbound vtkShaderProgram, where the corresponding vtkOpenGLShaderCache thinks the shader is bound, but it’s actually not. If using the debugger I -\>Bind() the shader, the views are rendering again, until I switch windows again.

Any suggestions, how to fix this?

---

<div class="post-metadata">

### Author: ![ken-martin](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ken-martin/32/884_2.png) [@ken-martin](https://discourse.vtk.org/u/ken-martin)
#### Post date: [December 6, 2019, 3:36pm UTC](https://discourse.vtk.org/t/attempt-to-render-to-unbound-program/2216/2 "2019-12-06T15:36:45Z")

</div>

Maybe something outside of VTK is binding a different shader which the cache does not know about. In cases like that it can be fixed by calling something like

renderWindow-\>GetShaderCache()-\>ReleaseCurrentShader()

/\*\*

- Release the current shader. Basically go back to
- having no shaders loaded. This is useful for old
- legacy code that relies on no shaders being loaded.  
\*/  
void ReleaseCurrentShader();

at the end of your render (or right before it) either way it should force VTK to rebind the shader

---

<div class="post-metadata">

### Author: ![aglv](https://discourse.vtk.org/user_avatar/discourse.vtk.org/aglv/32/29_2.png) [@aglv](https://discourse.vtk.org/u/aglv)
#### Post date: [December 10, 2019, 10:23am UTC](https://discourse.vtk.org/t/attempt-to-render-to-unbound-program/2216/3 "2019-12-10T10:23:06Z")

</div>

Thanks for the suggestion. It only temporarily resolved my problem, but it came back later on anyway.

I found a fix: the original code used to draw a ‘disabled’ status of the view using macos specific drawing APIs, then passing control over to VTK. That probably messed with the OpenGL stack.

I cleared the custom code and it no longer misbehaves.
