Search code examples
opengl-esglslshaderglsles

OpenGL ES3: no matching overloaded function found for packUnorm2x16


I am trying to pack 2 float values into 1 uint value using packUnorm2x16 method of OpenGL ES3 GLSL. But the compilation of the shader fails with 'packUnorm2x16': no matching overloaded function found error.

This is my fragment shader:

varying highp vec2 vDisplacement;

void main() {
  gl_FragColor = vec4(packUnorm2x16(vDisplacement), vec3(0.0));
}

I am trying to render a result to a GL_R32UI texture.


Solution

  • packUnorm2x16 is supported since OpenGL ES 3.0. You've to add the version qualifier #version 300 es to the first lien of the fragment shader:

    #version 300 es
    
    varying highp vec2 vDisplacement;
    
    void main() {
        gl_FragColor = vec4(packUnorm2x16(vDisplacement), vec3(0.0));
    }