What can i await as status after linking shaders?

classic Classic list List threaded Threaded
4 messages Options
adi
Reply | Threaded
Open this post in threaded view
|

What can i await as status after linking shaders?

adi
Hi

What can in await in the buffer after linking my shaders?

int linked[] = new int[1];
gl.glLinkProgram(shaderProgram);
gl.glGetProgramiv(shaderProgram, GL4.GL_LINK_STATUS, linked,0);

 
is linked[0]==0  OK
or an error?
The documentation says nothing.
Reply | Threaded
Open this post in threaded view
|

Re: What can i await as status

Sven Gothel
Administrator
On 02/04/2013 05:13 PM, adi [via jogamp] wrote:

> Hi
>
> What can in await in the buffer after linking my shaders?
>
> *int linked[] = new int[1];
> gl.glLinkProgram(shaderProgram);
> gl.glGetProgramiv(shaderProgram, GL4.GL_LINK_STATUS, linked,0);*
>  
> is linked[0]==0  OK
> or an error?
> The documentation says nothing.
https://www.opengl.org/sdk/docs/man4/xhtml/glGetProgram.xml

.. it says a lot :)

Pls be aware that we do not copy the OpenGL spec in JOGL,
hence you may want to read the HTML references or the
OpenGL spec itself, i.e.
  http://www.opengl.org/registry/doc/glspec42.core.20120119.withchanges.pdf

We use this shader state to validate program link validity as well:

http://jogamp.org/git/?p=jogl.git;a=blob;f=src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java;h=eceeea6db965d283f71766d531d27687d486411f;hb=HEAD#l104

~Sven



signature.asc (911 bytes) Download Attachment
adi
Reply | Threaded
Open this post in threaded view
|

Re: What can i await as status

adi
Thanks for your hints
Reply | Threaded
Open this post in threaded view
|

Re: What can i await as status

Danny02
I check for shader errors like this:
int programObject=...;
gl.glValidateProgram(programObject);
        int[] error = new int[]{-1};
        gl.glGetProgramiv(programObject, GL2GL3.GL_LINK_STATUS, error, 0);
        if (error[0] != GL.GL_TRUE) {
            int[] len = new int[1];
            gl.glGetProgramiv(programObject, GL2ES2.GL_INFO_LOG_LENGTH, len, 0);
            if (len[0] == 0) {
                return null;
            }
            byte[] errormessage = new byte[len[0]];
            gl.glGetProgramInfoLog(programObject, len[0], len, 0, errormessage, 0);
            return new String(errormessage, 0, len[0]);
        }

and for the single shaderobjects(fragment, vertex ...)
it is qutie similiar:

int[] error = new int[]{-1};
        gl.glGetShaderiv(shader, GL2ES2.GL_COMPILE_STATUS, error, 0);

        if (error[0] != GL.GL_TRUE) {
            int[] len = new int[1];
            gl.glGetShaderiv(shader, GL2ES2.GL_INFO_LOG_LENGTH, len, 0);
            if (len[0] == 0) {
                return null;
            }
            byte[] errormessage = new byte[len[0]];
            gl.glGetShaderInfoLog(shader, len[0], len, 0, errormessage, 0);

            return new String(errormessage, 0, len[0] + 1);
}