尝试使用 jogl 加载和初始化着色器

Trying to load and initialize a shader using jogl

正在尝试初始化 JOGL 中的一些着色器。

知道为什么错误是空的吗?我检查了它的大小,它看起来大于 0,因为没有打印 "Unknown"

vertexShaderProgram = gl.glCreateShader(GL2.GL_VERTEX_SHADER);
fragmentShaderProgram = gl.glCreateShader(GL2.GL_FRAGMENT_SHADER);
gl.glShaderSource(vertexShaderProgram, 1, vsrc, null, 0);
gl.glCompileShader(vertexShaderProgram);
gl.glShaderSource(fragmentShaderProgram, 1, fsrc, null, 0);
gl.glCompileShader(fragmentShaderProgram);
shaderprogram = gl.glCreateProgram();

gl.glAttachShader(shaderprogram, vertexShaderProgram);
gl.glAttachShader(shaderprogram, fragmentShaderProgram);
gl.glLinkProgram(shaderprogram);
gl.glValidateProgram(shaderprogram);
IntBuffer intBuffer = IntBuffer.allocate(1);
gl.glGetProgramiv(shaderprogram, GL2.GL_LINK_STATUS, intBuffer);

System.out.println("got link status");

if (intBuffer.get(0) != 1) {
    gl.glGetProgramiv(shaderprogram, GL2.GL_INFO_LOG_LENGTH, intBuffer);
    int size = intBuffer.get(0);
    System.err.println("Program link error: ");
    if (size > 0) {
        ByteBuffer byteBuffer = ByteBuffer.allocate(size);
        gl.glGetProgramInfoLog(shaderprogram, size, intBuffer, byteBuffer);
        for (byte b: byteBuffer.array()) {
            System.err.print((char) b);
        }
    } else {
        System.out.println("Unknown");
    }
    System.exit(1);
}

我在控制台上收到错误,但不包含任何数据..

got link status
Program link error: 

这是我的片段着色器..

< FILE :: fragmentShader.txt >
uniform sampler2D fish_y_offset;
uniform float alphavalue;
void main()
{
    gl_FragColor = texture2D(fish_y_offset, gl_TexCoord[0].st);
    gl_FragColor.a=alphavalue;

}

这是我的顶点着色器..

< FILE :: vertextShader.txt >
uniform float waveTime;
uniform float waveWidth;
uniform float waveHeight;
void main(void)
{
    vec4 v = vec4(gl_Vertex);
    v.y = 11 + sin(waveWidth * v.x + waveTime) * cos(waveWidth * v.z + waveTime) * waveHeight;
    gl_Position = gl_ModelViewProjectionMatrix * v;
    gl_TexCoord[0] = gl_MultiTexCoord0;
}

每次着色器编译后检查着色器日志。

https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGetShaderInfoLog.xml