Is There a Way to Use the Same Shader on Webgl1 and Desktop?

I’m writing an application that should run both on WebGL1 and on desktop with OpenGL. I’ve got a library that abstracts over the GL API, but now I need to figure out if I can avoid writing the shaders twice, one for web and one for desktop.

I was in great shape working with WebGL2 until I realized that Safari doesn’t support WebGL2 and that makes up a good 16% or so of the global market according to CanIUse.com. :confused:

Unfortunately I want this to work on iPhones so now I need to rewrite my shaders for #version 100 of GLSL. My question is, with GLSL 1.00 shaders work on Desktop using OpenGL 3.3 or is there any tools that can cross-compile my shader to both GLES 3.00 and GLSL 1.00?

OK, I verified that the #version 100 shaders will work on desktop, which is good. I would still prefer not to have to write that version of shader, just because its so limited, but oh well. Hopefully one day Safari will actually support WebGL 2 ( without me having to tell my users to enable the experimental feature ).

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.