Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

l3m
Copy link
Contributor

@l3m l3m commented Apr 21, 2015

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:

          int major = 3;
          int minor = 0;
          var flags = GraphicsContextFlags.AngleDirect3D11 | GraphicsContextFlags.Embedded;

          // create platform window
          var win = OpenTK.Platform.Utilities.CreateWindowsWindowInfo(_control.Handle);
          // create angle window
          _window_info = OpenTK.Platform.Utilities.CreateAngleWindowInfo(win);
          // create GraphicsContext as usual
          _context = new GraphicsContext(mode, _window_info, major, minor, flags);

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.

@l3m
Copy link
Contributor Author

l3m commented May 13, 2015

Any chance this will get merged? Are there any other changes you would want me to do to get it merge-ready?

@Frassle
Copy link
Contributor

Frassle commented May 13, 2015

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.

Jonas Boesch added 4 commits January 6, 2016 14:20
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.
@l3m
Copy link
Contributor Author

l3m commented Jan 6, 2016

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...

@cpages
Copy link

cpages commented Nov 25, 2016

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?

@l3m
Copy link
Contributor Author

l3m commented Nov 25, 2016

@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.

@varon
Copy link
Member

varon commented Nov 25, 2016

@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.

@wcdeich4
Copy link
Contributor

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......?

@varon
Copy link
Member

varon commented Nov 26, 2016

Yes, but it's all been moved. Scroll down to where we merge and look at the 'conflicting files'.

@wcdeich4
Copy link
Contributor

@varon - so then, they could access glControl, but they'd have to change the part of their code that calls it?

@wcdeich4
Copy link
Contributor

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.

@l3m
Copy link
Contributor Author

l3m commented Nov 26, 2016

@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.

@wcdeich4
Copy link
Contributor

@l3m - I just looked at it. Is that native/un-managed C++ ?

@mzanin
Copy link

mzanin commented Nov 28, 2016

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.

@l3m l3m closed this Nov 28, 2016
@l3m
Copy link
Contributor Author

l3m commented Nov 28, 2016

Closing this as @mzanin will open a new PRQ with the rebased version.

@JimSEOW
Copy link

JimSEOW commented Sep 23, 2017

@l3m
I am looking for suggestions on how to replace OpenTK.GLControl based on System.Windows.Forms.UserControl to e.g. UWP: Windows.UI.Xaml.Controls.UserControl

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants