GLWpfControl icon indicating copy to clipboard operation
GLWpfControl copied to clipboard

How to Use SwapBuffers in this Control?

Open YamingZ opened this issue 3 years ago • 5 comments

I know there is a SwapBuffers() function in GLControl, is there also SwapBuffers() function in your control? and how should we use it? thanks.

YamingZ avatar Aug 17 '21 04:08 YamingZ

I +1 this question. Even with RenderContinuously set to true in the GLWpfControlSettings, the control still only renders if something causes the layout to change (i.e resizing the Grid column/row containing the control). For my purposes, I would like it to be continuously rendering, and if possible, at a frequency I can define somewhere. Is this possible?

Logix-Dev avatar Sep 08 '21 01:09 Logix-Dev

This might be done by settong an IGraphicsContext in the GLWpfControlSettings.ContextToUse but I'm not sure how to create one

adras avatar Jan 26 '22 11:01 adras

Did anyone find a solution for this by now? I need this SwapBuffer, too.

BanditBloodwyn avatar Mar 31 '22 11:03 BanditBloodwyn

Initially I came here because some tutorials mentioned the SwapBuffer thingy. But in my case it turned out I don't "need" it. I can render fine without swapping buffers. Might not be the fastest way, but it's enough for me right now

In case you're interested, here's my code:

https://github.com/adras/Zero-K-MapEditing/blob/main/MapCreationTool/MapCreationTool/Controls/TerrainControl.xaml https://github.com/adras/Zero-K-MapEditing/blob/main/MapCreationTool/MapCreationTool/Controls/TerrainControl.xaml.cs https://github.com/adras/Zero-K-MapEditing/blob/main/MapCreationTool/MapCreationTool/Terrain/TerrainRenderer.cs

adras avatar Mar 31 '22 11:03 adras

There is no SwapBuffers() function as this control is rendering using a D3D swapchain. I'm not sure if it's possible to trigger a swap in the D3D swapchain directly, but I think wpf manages the compositing and swapchain pretty tightly so it might be pretty difficult.

NogginBops avatar Jul 21 '22 16:07 NogginBops

I asked this question because I was having issues with render synchronization, and I need to take a snapshot after a render call. But soon after I asked the question, I took a snapshot using render to file, so I could ignore the render sync issue with this control, but I had to solve the render sync issue in OpenGL. and finaly I used GL.Finish() API to solve it. Hope can be helpful.

YamingZ avatar Sep 01 '23 07:09 YamingZ