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

basic webggl2 support for those that dont need much from webgl2 #623

Open
hrgdavor opened this issue Jul 17, 2021 · 4 comments
Open

basic webggl2 support for those that dont need much from webgl2 #623

hrgdavor opened this issue Jul 17, 2021 · 4 comments

Comments

@hrgdavor
Copy link

hrgdavor commented Jul 17, 2021

openjscad uses regl, and looks to move to webgl2 with fall-back to webgl.

jscad/OpenJSCAD.org#878

currently a kind of workaround is used that supplies context instead of canvas element.
but some small changes will be needded in regl to support this.

@hrgdavor
Copy link
Author

After some exploration, look slike geenral support for WEBGL 2 would be difficult for regl. But what would help is some smaller changes that will enable some users to support webgl2.

For example, just giving opengl2 context to regly, OpenJSCAD works just fine. First issue is that we are unable to add some optimizations by using oes_element_index_uint .

oes_element_index_uint works if we use webgl1 but with webgl context we get to impossible situation

  • if we register extension webgl2 complains
  • if we dont regl complains (does not know it is builtin for webgl2)

@hrgdavor hrgdavor changed the title use webgl2 as default ? basic webggl2 support for those that dont need much from webgl2 Jul 20, 2021
@rreusser
Copy link
Member

Have you seen this issue? #561 I'm not quite sure how to use it, but people have taken a stab at ironing out some of the basic compatibility issues. I don't think regl will ever formally support webgl 2 (unless it's a separate webgl2 fork), but I believe people have had enough luck to at least be able to take advantage of some webgl 2 features.

@hrgdavor
Copy link
Author

@rreusser thanks for the link to the wrapper. Ii it comes to that, I might use it, for now this ugly workaround is enough.

  function createContext (canvas, contextAttributes) {
    function get (type) {
      try {
        return {gl:canvas.getContext(type, contextAttributes), type}
      } catch (e) {
        return null
      }
    }
    return (
      get('webgl2') ||
      get('webgl') ||
      get('experimental-webgl') ||
      get('webgl-experimental')
    )
  }

.......
.......

    const {gl, type} = createContext(canvas)
    const options = {gl}
    if(type === 'webgl'){
        options.extensions = ['oes_element_index_uint']      
    }

@Francis-Tao-jinjin
Copy link

my current workaround is import createREGL from 'regl/dist/regl.unchecked'; + creating webgl2 context by myself, holp this works for you.

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

No branches or pull requests

3 participants