Texture widgets render OpenGL example

2,122

SurfaceTexture should be passed to eglCreateWindowSurface, while OpenGL stack is being configured.

I spent a while and built example project and article: https://github.com/mogol/opengl_texture_widget_example https://medium.com/@germansaprykin/opengl-with-texture-widget-f919743d25d9

private void initGL() {
    egl = (EGL10) EGLContext.getEGL();
    eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

    int[] version = new int[2];
    egl.eglInitialize(eglDisplay, version);

    EGLConfig eglConfig = chooseEglConfig();
    eglContext = createContext(egl, eglDisplay, eglConfig);

    eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig, texture, null);

    egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
}
Share:
2,122
German Saprykin
Author by

German Saprykin

Updated on December 04, 2022

Comments

  • German Saprykin
    German Saprykin over 1 year

    My Flutter app needs to display 3d model and allow user to rotate it. I implemented this via native views (ViewController & Activity) and C++ code for rendering, as next step I tried Texture widget to remove native views and use only Flutter. I managed to display OpenGL rendering on iOS via FlutterTexture, but don't understand how to implement on Android. Could you show any examples how to use OpenGL with SurfaceTexture and connect it to Texture widget?

  • PPP
    PPP over 4 years
    I successfully built an example based on yours. It worked, but I'm sturggling in rendering to the texture with glTexImage2D. Could you take a look? stackoverflow.com/questions/58531692/…