private static void checkLinkError(final int programId) { final GL gl = GLContext.getCurrentGL(); final JoglRenderContext context = (JoglRenderContext) ContextManager.getCurrentContext(); final IntBuffer compiled = context.getDirectNioBuffersSet().getSingleIntBuffer(); compiled.clear(); if (gl.isGL2()) { gl.getGL2().glGetObjectParameterivARB(programId, GL2ES2.GL_LINK_STATUS, compiled); } else { if (gl.isGL2ES2()) { gl.getGL2ES2().glGetProgramiv(programId, GL2ES2.GL_LINK_STATUS, compiled); } } if (compiled.get(0) == GL.GL_FALSE) { if (gl.isGL2()) { gl.getGL2().glGetObjectParameterivARB(programId, GL2ES2.GL_INFO_LOG_LENGTH, compiled); } else { if (gl.isGL2ES2()) { gl.getGL2ES2().glGetProgramiv(programId, GL2ES2.GL_INFO_LOG_LENGTH, compiled); } } final int length = compiled.get(0); String out = null; if (length > 0) { final ByteBuffer infoLogBuf = context.getDirectNioBuffersSet().getInfoLogBuffer(); final ByteBuffer infoLog; if (length <= infoLogBuf.capacity()) { infoLog = infoLogBuf; infoLogBuf.rewind().limit(length); } else { infoLog = BufferUtils.createByteBuffer(length); } if (gl.isGL2()) { gl.getGL2().glGetInfoLogARB(programId, infoLog.limit(), compiled, infoLog); } else { if (gl.isGL2ES2()) { gl.getGL2ES2().glGetProgramInfoLog(programId, infoLog.limit(), compiled, infoLog); } } final byte[] infoBytes = new byte[length]; infoLog.get(infoBytes); out = new String(infoBytes); } logger.severe(out); // throw new Ardor3dException("Error linking GLSL shader: " + out); } }
/** * Check for program errors. If an error is detected, program exits. * * @param compilerState the compiler state for a given shader * @param id shader's id */ private static void checkProgramError( final int compilerState, final int id, final String shaderName) { final GL gl = GLContext.getCurrentGL(); if (compilerState == GL.GL_FALSE) { final JoglRenderContext context = (JoglRenderContext) ContextManager.getCurrentContext(); final IntBuffer iVal = context.getDirectNioBuffersSet().getSingleIntBuffer(); iVal.clear(); if (gl.isGL2()) { gl.getGL2().glGetObjectParameterivARB(id, GL2.GL_OBJECT_INFO_LOG_LENGTH_ARB, iVal); } else { if (gl.isGL2ES2()) { gl.getGL2ES2().glGetProgramiv(id, GL2ES2.GL_INFO_LOG_LENGTH, iVal); } } final int length = iVal.get(0); String out = null; if (length > 0) { final ByteBuffer infoLogBuf = context.getDirectNioBuffersSet().getInfoLogBuffer(); final ByteBuffer infoLog; if (length <= infoLogBuf.capacity()) { infoLog = infoLogBuf; infoLogBuf.rewind().limit(length); } else { infoLog = BufferUtils.createByteBuffer(length); } if (gl.isGL2()) { gl.getGL2().glGetInfoLogARB(id, infoLog.limit(), iVal, infoLog); } else { if (gl.isGL2ES2()) { gl.getGL2ES2().glGetProgramInfoLog(id, infoLog.limit(), iVal, infoLog); } } final byte[] infoBytes = new byte[length]; infoLog.get(infoBytes); out = new String(infoBytes); } logger.severe(out); final String nameString = shaderName.equals("") ? "" : " [ " + shaderName + " ]"; throw new Ardor3dException("Error compiling GLSL shader " + nameString + ": " + out); } }
/** * Check for program errors. If an error is detected, program exits. * * @param compiled the compiler state for a given shader * @param id shader's id */ private static void checkProgramError(final IntBuffer compiled, final int id) { final GL gl = GLU.getCurrentGL(); if (compiled.get(0) == GL.GL_FALSE) { final IntBuffer iVal = BufferUtils.createIntBuffer(1); gl.glGetObjectParameterivARB(id, GL.GL_OBJECT_INFO_LOG_LENGTH_ARB, iVal); final int length = iVal.get(0); String out = null; if (length > 0) { final ByteBuffer infoLog = BufferUtils.createByteBuffer(length); gl.glGetInfoLogARB(id, infoLog.limit(), iVal, infoLog); final byte[] infoBytes = new byte[length]; infoLog.get(infoBytes); out = new String(infoBytes); } logger.severe(out); throw new Ardor3dException("Error compiling GLSL shader: " + out); } }
private static void checkLinkError(final int programId) { final GL gl = GLU.getCurrentGL(); final IntBuffer compiled = BufferUtils.createIntBuffer(1); gl.glGetObjectParameterivARB(programId, GL.GL_LINK_STATUS, compiled); if (compiled.get(0) == GL.GL_FALSE) { gl.glGetObjectParameterivARB(programId, GL.GL_INFO_LOG_LENGTH, compiled); final int length = compiled.get(0); String out = null; if (length > 0) { final ByteBuffer infoLog = BufferUtils.createByteBuffer(length); gl.glGetInfoLogARB(programId, infoLog.limit(), compiled, infoLog); final byte[] infoBytes = new byte[length]; infoLog.get(infoBytes); out = new String(infoBytes); } logger.severe(out); // throw new Ardor3dException("Error linking GLSL shader: " + out); } }