Shader Android错误:“无效的版本着色器”

时间:2019-10-30 20:13:30

标签: java android opengl-es

我遵循https://stackoverflow.com/a/31095254/6655884并执行了以下操作(在版本指令中添加了\ n换行符)

public class OrwellShaders {
    public class Vertex {
        public static final String vertex  = 
            "#version 330 es\n " +
            "layout (location = 0) in vec3 aPos;\n " +
            "layout (location = 1) in vec2 aTexCoord;\n " +
            "\n " +
            "out vec2 TexCoord;\n " +
            "\n " +
            "void main()\n " +
            "{\n " +
            "    gl_Position = vec4(aPos, 1.0);\n " +
            "    TexCoord = vec2(aTexCoord.x, aTexCoord.y);\n " +
            "};\n";
    }

但是我仍然得到Adreno error Invalid #version shader

我的手机装有Android 8,因此应该有支持。我没有使用GLSurfaceView,所以没有setEGLContextClientVersion(3)我只是在使用

egl = (EGL10) EGLContext.getEGL();
        eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
        if (eglDisplay == EGL10.EGL_NO_DISPLAY) {
        //...

1 个答案:

答案 0 :(得分:1)

删除“ #version 330 es \ n”。我遇到了类似的错误,删除此错误使GLSL可以编译