Search code examples
openglglslwebglwebgl2

Can this WebGL 2.0 code be compiled using desktop (non-ES) OpenGL?


I came across the following bit of GLSL code. I've tried compiling it in my OpenGL desktop application, but the compiler says "Unsupported construction":

float[] 
    camx = float[] ( .2351, 1.2351, 1.2351, 1., .2, .41, .545,.545, .5,.084,.145,  3.04,.12, .44,.44,.416, -1.404, .21,.2351, .2351),
    camy = float[] (-.094,  .35,     .28,  .38,  .04, .11, -.44,-.44,.35,.0614,.418, 1.,-.96, .67,.8,.0, -1., -.06,-.094),
    camz = float[] ( .608,  .608,    .35,   .3608, -.03, .48,.032,.032, .47,0.201,.05,.28,.3, 1.445,1.,1.4, 2.019, .508,.608),

    lookx = float[] (-.73, -.627, -1., -.3, -1., -.72, -.82,-.82,-.67,-.5,-.07,-.67,-.27, -.35,-.35,-.775, .08, -.727),
    looky = float[] (-.364, -.2,   -.2,  -.2,  0., -.39, -.5, -.5,-.56,-.37,-.96,-.74,-.94, -.35,-.35,-.1, .83,-.364),
    lookz = float[] (-.582, -.582, -.5, -.35, -.0, -.58, -.2776,-.2776,-.48,-.79,-.25,.06,-.18, -.87,-.87,.23, .55, -.582),

    minsx = float[] (-.3252,-.3252,-.3252,-.3252,-.3252,-.3252,-.3252,-1.1, -1.05,-1.05,-1.21,-1.22,-1.04,-0.737,-.62,-10., -.653,  -.653, -.3252),
    minsy = float[] (-.7862,-.7862,-.7862,-.7862,-.7862,-.7862,-.7862,-.787, -1.05,-1.05,-.954,-1.17,-.79,-0.73,-.71,-.75, -2.,   -2., -.7862),
    minsz = float[] (-.0948,-.0948,-.0948,-.0948,-.0948,-.0948,-.0948,-.095,-0.0001,-0.0001,-.0001,-.032,-.126,-1.23,-.85,-.787, -.822, -1.073, -.0948),
    minsw = float[] ( .69, .69, .69, .69, .69, .678, .678,  .678,.7,.73,1.684,1.49,.833, .627,.77,.826,  1.8976, 1.8899, .69),

    maxsx = float[] ( .35,.3457,.3457,.3457,.3457, .3457,.3457,.3457, 1.05,1.05,.39,.85,.3457,.73,.72,5., .888,  .735, .35),
    maxsy = float[] (1.,1.0218,1.0218,1.0218,1.0218,1.0218,1.0218,1.0218,1.05,1.05,.65,.65,1.0218,0.73,.74,1.67, .1665, 1.),
    maxsz = float[] (1.22,1.2215,1.2215,1.2215,1.2215,1.2215,1.2215,1.2215, 1.27,1.4,1.27,1.27,1.2215,.73,.74,.775, 1.2676, 1.22),
    maxsw = float[] ( .84, .84, .84, .84, .84, .9834,.9834,.9834,.95,.93,2.74,1.23,.9834, .8335,.14,1.172, .7798, .84);

What do I need to make it run - what OpenGL version, what GLSL version? Is it at all possible? Tried with #version 130 as well as #version 450.

What is this array declaration syntax even called? Because I don't know that, I can't Google it.


Solution

  • I don't know if

    float[] var = float[](1.0, 2.0, 3.0);
    

    is legal on WebGL, but this:

    float var[] = float[](1.0, 2.0, 3.0);
    

    is legal in WebGL, OpenGL ES and desktop OpenGL shaders language.