This works fine. When OnPaint is called, the control, which covers the whole window, is cleared to red.
Now, WPF controls when OnPaint is called, not me. When I'll be rendering video, I need to be able to draw to the screen when I decide to. So I've put the above code in an infinite loop and made it execute on a BackgroundWorker thread. Now, the problem is that wglMakeCurrent fails in this situation with"error 170: the requested resource is in use". Consequently, the call to glClear() (and any further rendering) does nothing.
I don't understand exactly which resource is in use and why, and I'd like to know what's wrong with my approach.
Thanks!
P.S. here is the initialization code in case this could be useful. It is hooked to the "Load" event of the control. And yes this is essentially copy-pasted from a tutorial on the net.
Awesome! PowerToys just keeps rapidly getting better and better. 👏🏽 Looking forward to the day Peek matches the speed and compatibility of the QuickLook app on the Microsoft Store, and PowerRename matches the versatility of File Renamer Turbo.
maybe he is a Gypsie. There’s a guy I watch on YouTube (indigotraveller) and he just did a little series on the Romani Gypsies and gold is one of the most valued assets and like the super rich ones have everything made with gold just because.
Question
Andre S. Veteran
I'm trying to make a video player in WPF, using libavcodec for decoding and OpenGL for rendering.
I host my own C++/CLI control derived from Windows.Forms.UserControl inside a WindowsFormsHost. I use its Handle to initialize an OpenGL context.
Here is the code for my override of OnPaint:
This works fine. When OnPaint is called, the control, which covers the whole window, is cleared to red.
Now, WPF controls when OnPaint is called, not me. When I'll be rendering video, I need to be able to draw to the screen when I decide to. So I've put the above code in an infinite loop and made it execute on a BackgroundWorker thread. Now, the problem is that wglMakeCurrent fails in this situation with"error 170: the requested resource is in use". Consequently, the call to glClear() (and any further rendering) does nothing.
I don't understand exactly which resource is in use and why, and I'd like to know what's wrong with my approach.
Thanks!
P.S. here is the initialization code in case this could be useful. It is hooked to the "Load" event of the control. And yes this is essentially copy-pasted from a tutorial on the net.
Link to comment
https://www.neowin.net/forum/topic/989712-wpf-rendering-with-opengl-in-another-thread/Share on other sites
1 answer to this question
Recommended Posts