-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow using OpenGL ES3 with Angle and extract a Direct3D shared handle #253
Conversation
Any chance this will get merged? Are there any other changes you would want me to do to get it merge-ready? |
Just haven't had a chance to look through it properly. Still feel the offscreen stuff needs to be exposed in a less angle specific way. This really needs others to give some input to work out how best to handle this. |
The shared context parameter can be either the EglContext directly, or the facade, and we cast to see what it is.
+ GraphicsContextFlags now has Angle and Offscreen flags. + Egl now has PLATFORM_ANGLE related const ints. + Added eglGetPlatformDisplayEXT p/invoke definition + Added eglQuerySurfacePointerANGLE p/invoke definition + EglWindowInfo.CreatePbufferSurface was commented out. Enabled and fixed it. + GraphicsContextFlags.Offscreen will make the context create a PbufferSurface instead of a WindowSurface in EglContext + SurfaceType enum to select surface type for SelectGraphicsMode
Both WindowInfo and PlatformFactory wrap the actual platform-specific WindowInfo and PlatformFactory. For offscreen rendering, AngleWindowInfo can be used with a DummyWindowInfo. The API to add additional surfaces was added to IAngleWindowInfo, since all those calls need the Display parameter that is only available on EglWindowInfo (which is not exposed to users).
This fix will keep existing behavior (forced sharing) in the default case, but adds a new constructor that allows explicitly specifying the shared context. A user can now explicitly specify null for the shared context to get a new non-shared context.
Updated and rebased my prq on the latest develop. I would be really happy if I could get some pointers on what to do to get this accepted. We're using custom-built NuGet packages for a way too long now based on my branch, and while it runs well, I would prefer to be able to return to OpenTK baseline at some point... |
Would it be possible to revive/review this pr? I'm also interested in the copy-less approach that this patch provides for wpf apps. @l3m do you think this is still a valid approach or you have a better solution? |
@cpages Well, I no longer work on this project, but it's in use since shortly after the original prq and it works well. ANGLE is a special case and therefore I feel it warrants treating it a bit differently, but I would be happy if someone could fix whatever issues people have with it that blocks it from being accepted. Unfortunately, I won't have time for this, as I'm no longer at the company (moved on to greener pastures :)). Maybe @mzanin could take that over? Everyone would profit if this functionality made it into OpenTK mainline. |
@cpages It should be pretty simple to migrate this PR over to the new source organization, not much has changed in the actual code files if you want to give it a bash. As a disclaimer, I'd need a maintainer who's familiar with GLControl to give a thumbs up before we can merge, too. |
Um - please forgive a dumb question as I have been busy @ work - but I just looked at code on https://github.com/opentk/opentk and the OpenTK.GLControl is still there......? |
Yes, but it's all been moved. Scroll down to where we merge and look at the 'conflicting files'. |
@varon - so then, they could access glControl, but they'd have to change the part of their code that calls it? |
BTW, @Frassle had a point about doing things in a more angle-non-specific way. Usually you specify what angle you want when you setup the camera. |
@wcdeich4 ANGLE (Almost Native Graphics Layer Engine) is a google OpenGL ES toolkit, see https://github.com/google/angle. It efficiently maps OpenGL ES calls to other GLs (DirectX9/11, OpenGL), which means you can use GLES rendering on windows machines without recent graphics drivers or with drivers where Open GL support is lacking or broken. |
@l3m - I just looked at it. Is that native/un-managed C++ ? |
I rebased this on the develop branch just now without any major difficulty and it still appears to work as intended. The MakeCurrent call was removed from the EglContext constructor so I just needed to change the usage to call that explicitly. I can do a new pull request once this one is closed. |
Closing this as @mzanin will open a new PRQ with the rebased version. |
@l3m There is solution to use (OpenGL ES) Angle for UWP XAML (e.g. Windows.UI.Xaml.Controls.UserControl) I am seeking suggestions on how to bring (OpenGL) e.g. OpenTKCore to UWP XAML (e.g. Windows.UI.Xaml.Controls.UserControl) We already have .NET Core Systems.Drawing. We just need to replace the Form.UserControl to UWP's UserControl I hope there is already users here thinking along this line. |
This is an updated version of #234
As discussed in the previous prq and in chat with @Frassle, this version avoids using a specific offscreen rendering instance for Angle. Instead, the angle window info and the angle factory use an internal platform-window or platform-factory.
As shown in my wpf-gles demo here, a user can instantiate an angle window and the OpenTK graphics context as follows:
Additional surfaces for offscreen rendering can be created and destroyed on IAngleWindowInfo, and the underlying surface pointer can be queried there as well. As the EGLDisplay is not otherwise exposed to the user, this seems to right place to do it.