-
-
Notifications
You must be signed in to change notification settings - Fork 477
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
Use glutin
to render to Surface
/NativeWindow
without winit
/ndk_glue
#1324
Comments
@lattice0 Wow, I didn't expect you to have an issue open on this for well over 1.5 years :) Is it resolved now that you've submitted a |
@MarijnS95 I didn't solve it yet. I'm implementing I also have a Kotlin Android POC of my SurfaceTexture backend: https://github.com/lattice0/glium_surface_texture_poc/blob/master/app/src/main/rust/surface_texture_glium/src/lib.rs I don't know to which functions should I map glium's I presumed SurfaceTexture's
If someone could help me with this I'd be very glad, I'm already deep into lots of small PRs to add functionality to support thtis |
Going through the trail of your In short you probably don't want all this complication with |
glutin
to render to Surface
/NativeWindow
without winit
/ndk_glue
I forgot to say. The reason I'm doing this is to render with glium in Flutter, and the only way to render in Flutter is to a SurfaceTexture, because its API gives me one 😩
…-------- Mensagem Original --------
Ativo 27 de mai. de 2022 06:38, Marijn Suijten escreveu:
Going through the trail of your SurfaceTexture PR this sparked a nice discussion that ended in [maplibre/maplibre-rs#53 (comment)](maplibre/maplibre-rs#53 (comment)) and finally a PR with that working: [maplibre/maplibre-rs#99](maplibre/maplibre-rs#99).
In short you probably don't want all this complication with SurfaceTexture and the "update" functions. You should be able to get hold of a Surface - which is really just a NativeWindow - and pass that into glutin. You can't yet, but that's what I'm working on while adding supporting the Suspended/Resumed events, in order to also support generic Surfaces without winit (though it may be complicated on the API front).
—
Reply to this email directly, [view it on GitHub](#1324 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ABSTHAJ2DJFGNQPIPHILXP3VMCJX7ANCNFSM4R5N77YA).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@MarijnS95 here's an example: https://stackoverflow.com/questions/58531692/how-to-render-opengl-in-flutter-for-android Flutter gives you a |
@lattice0 Right, I'm curious about that example directly passing the |
@MarijnS95 yes, when I tried to glue If you want to see my very crazy try: https://github.com/lattice0/glium_surface_texture_poc/blob/1e8f669f9dee7d6ef8dd6589fac31754f9c0aea9/app/src/main/rust/surface_texture_glium/src/lib.rs this is where I try to create the EGL display before glium calls some stuff. Also it has my submodules with my modifications to glium and android-ndk-rs for which I'm maintaining until/if the PRs get accepted. However I don't feel like this is correct at all |
@lattice0 I could point out many errors in your codebase, starting with:
I will later test if/how this works with your I've cooked up an example for you, together with a small WIP change in https://github.com/MarijnS95/AndroidNativeSurface Enjoy! 🥳 |
@MarijnS95 thank you very much for your attention and example, very helpful. On my example I modified many times the signatures so I completely forgot to fix. Anyways, the reason I need Anyways, I have a Context:
however you seem to use pure opengl calls, while I wanted to use Glium, so I still need a custom Backend for SurfaceTexture if I'm correct? Or maybe not, because I have a window now, from which I can get a display. So, it looks like I can get glium to work, and I can create a Window for each Surface created from a SurfaceTexture. The word Window bothers me, it seems to say that it won't work with many SurfaceTexture (I plan to use 20 of them). |
@lattice0 Fair enough, but you have enough API available to turn a It seems that you don't even need to bind a GL context to the
If Glium supports |
I didn't even know https://github.com/MarijnS95/AndroidNativeSurface/compare/glium |
Could the latest glutin api help with that? You can create a EglSurface from the native window now just fine. |
@kchibisov That's exactly why I was waiting for the refactor, the design you proposed earlier makes sense but I'll have a more proper/in-depth look later. In #1417 at least it seems that you need the raw window handle "quite early on" even though EGL doesn't need it, making things inconvenient. |
The example isn't quite optimal here, right, since only WGL needs it that early, you may adjust it to account for that. The default api that builds display with EGL doesn't require it at all, and it only required by |
Yeah, so I'd want to make that an |
I updated the aforementioned project (https://github.com/MarijnS95/AndroidNativeSurface) to use the The example should probably be improved to use some animation (spinning/transforming the triangle) to repeatedly re-render instead of only once on surface (re?)creation, also to demonstrate how/where to store the context and other |
I want to render OpenGL inside Flutter. I've already made it work in Java and I know it's possible in C++.
Flutter has this external texture concept where it creates a
SurfaceTexture surfaceTexture
that I can render into. Given thesurfaceTexture
, this is how I render things in Java:after that, it's all a matter of calling opengl functions like
glTexImage
to send textures,glDraw
to draw, etc.Can I use this lib or even glium to simply create an
eglSurface
from asurfaceTexture
and then draw things on it?I don't think
glium
orglutin
have the power to do anything with asurfaceTexture
. But maybe I can create the eglSurface (from a surfaceTexture) in java calling from Rust, then it returns and then I can issue opengl calls using glutin? Something like this:flutter engine calls java code
java code creates the surfaceTexture from flutter call and gives it an id
java starts rust code
rust code starts glutin or glium and fills vertex buffers, etc
rust code calls java with the id and thus java code can create the egl surface and make it current
java code call returns, now glium can issue opengl calls like
glTexImage
andglDraw
, since theeglSurface
is current, things will be drawn to itThe text was updated successfully, but these errors were encountered: