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 bufsize * @param length * @param infolog * @see com.jogamp.opengl.GL2ES2#glGetProgramInfoLog(int, int, java.nio.IntBuffer, java.nio.ByteBuffer) */ public void glGetProgramInfoLog(int program, int bufsize, IntBuffer length, ByteBuffer infolog) { try{delegate.glGetProgramInfoLog(program, bufsize, length, infolog);} catch(GLException e){glException(e); throw e;} } /**
/** * @param program * @param bufsize * @param length * @param length_offset * @param infolog * @param infolog_offset * @see com.jogamp.opengl.GL2ES2#glGetProgramInfoLog(int, int, int[], int, byte[], int) */ public void glGetProgramInfoLog(int program, int bufsize, int[] length, int length_offset, byte[] infolog, int infolog_offset) { try{delegate.glGetProgramInfoLog(program, bufsize, length, length_offset, infolog, infolog_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()
/** * 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 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; }