private static String getProgramInfoLog(final GL3 gl, final int programObj) { final int[] infoLogLength = new int[1]; gl.glGetProgramiv(programObj, gl.GL_INFO_LOG_LENGTH, infoLogLength, 0); if (infoLogLength[0] == 0) { return "valid"; } final int[] charsWritten = new int[1]; final byte[] infoLogBytes = new byte[infoLogLength[0]]; gl.glGetProgramInfoLog(programObj, infoLogLength[0], charsWritten, 0, infoLogBytes, 0); return new String(infoLogBytes, 0, charsWritten[0]); } }
/** * @param program * @param pname * @param params * @see com.jogamp.opengl.GL2ES2#glGetProgramiv(int, int, java.nio.IntBuffer) */ public void glGetProgramiv(int program, int pname, IntBuffer params) { try{delegate.glGetProgramiv(program, pname, params);} catch(GLException e){glException(e); throw e;} } /**
public int getProgramParameter(final int pParameterName) { final int lParameter[] = new int[1]; mGL.getGL3().glGetProgramiv(mProgramId, pParameterName, lParameter, 0); return lParameter[0]; }
/** * @param program * @param pname * @param params * @param params_offset * @see com.jogamp.opengl.GL2ES2#glGetProgramiv(int, int, int[], int) */ public void glGetProgramiv(int program, int pname, int[] params, int params_offset) { try{delegate.glGetProgramiv(program, pname, params, params_offset);} catch(GLException e){glException(e); throw e;} } /**
public String getInfoLog() { IntBuffer statBuf = IntBuffer.allocate(1); statBuf.clear(); gl.glGetProgramiv(programID, GL4.GL_INFO_LOG_LENGTH, statBuf); ByteBuffer log = ByteBuffer.allocate(statBuf.get(0)); gl.glGetProgramInfoLog(programID, statBuf.get(0), null, log); return Charset.forName("US-ASCII").decode(log).toString(); }//end getInfoLog()
public boolean validate() { IntBuffer statBuf = IntBuffer.allocate(1); gl.glValidateProgram(programID); gl.glGetProgramiv(programID, GL4.GL_VALIDATE_STATUS, statBuf); return statBuf.get(0) == GL3.GL_TRUE; }//end validate()
/** * For debugging: Print program log info * * @param id program ID */ private void printProgramLogInfo(int id) { IntBuffer infoLogLength = ByteBuffer .allocateDirect(4) .order(ByteOrder.nativeOrder()) .asIntBuffer(); gl.glGetProgramiv(id, GL_INFO_LOG_LENGTH, infoLogLength); if (infoLogLength.get(0) > 0) { infoLogLength.put(0, infoLogLength.get(0) - 1); } ByteBuffer infoLog = ByteBuffer .allocateDirect(infoLogLength.get(0)) .order(ByteOrder.nativeOrder()); gl.glGetProgramInfoLog(id, infoLogLength.get(0), null, infoLog); String infoLogString = Charset.forName("US-ASCII").decode(infoLog).toString(); if (infoLogString.trim().length() > 0) { logger.warning("program log:\n"+infoLogString); } }
@Override public void glGetProgramiv(int program, int pname, IntBuffer params) { GLContext.getCurrentGL().getGL3().glGetProgramiv(program, pname, params); }
/** * Links this program. */ public void link() { if(programHandle == 0) { throw new RuntimeException("Program not created!"); } gl.glLinkProgram(this.programHandle); String linkageInfo = getProgramInfoLog(gl, this.programHandle); //throw exception if linking failed int[] linkageStatus = new int[1]; gl.glGetProgramiv(this.programHandle, gl.GL_LINK_STATUS, linkageStatus, 0); if (linkageStatus[0] == gl.GL_FALSE) { throw new RuntimeException(linkageInfo); } gl.glValidateProgram(this.programHandle); String validationInfo = getProgramInfoLog(gl, this.programHandle); //throw exception if validation failed int[] validationStatus = new int[1]; gl.glGetProgramiv(this.programHandle, gl.GL_LINK_STATUS, validationStatus, 0); if (validationStatus[0] == gl.GL_FALSE) { throw new RuntimeException(validationInfo); } }
@Override public String glGetProgramInfoLog(int program) { int[] logLength = new int[1]; GLContext.getCurrentGL().getGL3().glGetProgramiv(program, GL2.GL_INFO_LOG_LENGTH, logLength, 0); byte[] log = new byte[logLength[0]]; GLContext.getCurrentGL().getGL3().glGetProgramInfoLog(program, logLength[0], null, 0, log, 0); return new String(log); }
public String getProgramInfoLog() { final int status[] = new int[1]; mGL.getGL3().glGetProgramiv(mProgramId, GL3.GL_LINK_STATUS, status, 0); final int lLogLength = getProgramParameter(GL2ES2.GL_INFO_LOG_LENGTH); if (status[0] == GL3.GL_TRUE) return ""; final int[] lLength = new int[1]; final byte[] lBytes = new byte[lLogLength + 1]; mGL.getGL3().glGetProgramInfoLog(mProgramId, lLogLength, lLength, 0, lBytes, 0); final String logMessage = toString() + "\n" + new String(lBytes); return logMessage; }
private static int createProgram( final GL3 g, final int vs, final int fs, final IntBuffer status) { final int id = g.glCreateProgram(); if (id == 0) { throw new GLException("glCreateProgram failed"); } g.glAttachShader(id, vs); g.glAttachShader(id, fs); g.glLinkProgram(id); g.glGetProgramiv(id, GL2ES2.GL_LINK_STATUS, status); if (status.get(0) == GL.GL_FALSE) { final ByteBuffer buffer = Buffers.newDirectByteBuffer(8192); final IntBuffer buffer_length = Buffers.newDirectIntBuffer(1); g.glGetProgramInfoLog(id, 8192, buffer_length, buffer); final byte[] raw = new byte[buffer.remaining()]; buffer.get(raw); final String tt = new String(raw); throw new GLException("compile: program: " + tt); } return id; }
gl.glGetProgramiv(glProgram, GL_VALIDATE_STATUS, validateStatus, 0); if (validateStatus[0] != GL_TRUE)