Closed sdreb3421 closed 4 days ago
What version of GLControl are you using?
I'm using 4.0.0-pre.6 with a Windows Forms NET 7 build for Windows. However, I believe I tried this unsuccessfully many years ago with version 3 as well.
Sorry for the very delayed answer, but have you tried looking at the multi-form example project that exists in this repo?
Oh no i haven't. The example shows multiple GL controls on multiple forms I'm assuming? Thanks
Yeah, it does. If you run into any problems feel free to ask any questions here.
I've just recently fixed the build system for this repo so I'll be able to do some work on it, so I expect that I'll update the sample projects soon to use more modern OpenGL. There I can look at maybe making the multi-control sample better (if it isn't fine already).
I've just updated the multi control sample to make use of modern OpenGL and context sharing (#35 ).
This should help in getting multiple GLControl
s to run at the same time.
Wow awesome, this is what I've always dreamed of!
The context sharing part isn't really possible to conveniently achieve without the change I made to GLControl
in #35 so for that you'll have to wait for the next release.
A workaround until then would be to make your own subclass GLControl
and override OnHandleCreated
with the following code
protected override void OnHandleCreated(EventArgs e)
{
if (SharedContext != null)
{
if (SharedContext._nativeWindow == null)
{
throw new InvalidOperationException("The GLControl set as the shared context to this GLControl is not yet initialized. Initialization order when sharing contexts is important.");
}
_glControlSettings.SharedContext = SharedContext.Context;
}
base.OnHandleCreated(e);
}
Okay good to know. I just saw you did a prerelease of the winforms package. Is that what I need? Or the next release of opentk? Thanks
To get the multi control test working you either need to download the source as it is right now, or wait for the next version of GLControl
. GLControl
4.0.0-pre.7
does not have the fix I implemented in #35 so the workaround is needed when using that package version.
I have just released OpenTK.GLControl 4.0.0
which has this fix in it, and is the first stable release of OpenTK.GLControl
(then OpenTK.WinForms
) for OpenTK 4.x!
Closing this, if you have any problems with the released package feel free to repoen this issue!
Great work, thank you!
I've been unable to get multiple GLControls to work in a single WinForms application. My goal is to have multiple tabs/windows that each show the same 3D scene but from different angles. Ideally they would share context/data, but separate contexts would be okay too. Is this possible? Not sure if this is a bug or intended behavior.