get opengl Program Status - Java javax.media.opengl

Java examples for javax.media.opengl:GL

Description

get opengl Program Status

Demo Code


import javax.media.opengl.GL2;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.charset.Charset;

public class Main{
    public static String getProgramStatus(GL2 gl, int program, int status) {
        IntBuffer intBuffer = IntBuffer.allocate(1);
        gl.glGetProgramiv(program, status, intBuffer);

        if (intBuffer.get(0) != 1) {
            gl.glGetProgramiv(program, GL2.GL_INFO_LOG_LENGTH, intBuffer);

            int size = intBuffer.get(0);
            if (size > 0) {
                ByteBuffer byteBuffer = ByteBuffer.allocate(size);
                gl.glGetProgramInfoLog(program, size, intBuffer, byteBuffer);
                return new String(byteBuffer.array(),
                        Charset.forName("ASCII"));
            } else {
                return "Unknown";
            }/*from  w w  w.  java2  s . c o  m*/
        }

        return null;
    }
}

Related Tutorials