List of usage examples for org.lwjgl.opengl ARBShaderObjects glGetInfoLogARB
public static void glGetInfoLogARB(@NativeType("GLhandleARB") int obj, @Nullable @NativeType("GLsizei *") int[] length, @NativeType("GLcharARB *") ByteBuffer infoLog)
From source file:com.ardor3d.scene.state.lwjgl.LwjglShaderObjectsStateUtil.java
License:Open Source License
private static void checkLinkError(final int programId) { final IntBuffer compiled = BufferUtils.createIntBuffer(1); ARBShaderObjects.glGetObjectParameterARB(programId, GL20.GL_LINK_STATUS, compiled); if (compiled.get(0) == GL11.GL_FALSE) { ARBShaderObjects.glGetObjectParameterARB(programId, GL20.GL_INFO_LOG_LENGTH, compiled); final int length = compiled.get(0); String out = null;/*from w w w . j a v a 2 s. co m*/ if (length > 0) { final ByteBuffer infoLog = BufferUtils.createByteBuffer(length); ARBShaderObjects.glGetInfoLogARB(programId, 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); } }
From source file:com.ardor3d.scene.state.lwjgl.LwjglShaderObjectsStateUtil.java
License:Open Source License
/** * Check for program errors. If an error is detected, program exits. * // w ww.ja va 2 s. c om * @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 String shaderName) { if (compiled.get(0) == GL11.GL_FALSE) { final IntBuffer iVal = BufferUtils.createIntBuffer(1); ARBShaderObjects.glGetObjectParameterARB(id, ARBShaderObjects.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); ARBShaderObjects.glGetInfoLogARB(id, 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); } }
From source file:com.threerings.jme.util.ShaderCache.java
License:Open Source License
/** * Loads the specified shaders (prepending the supplied preprocessor definitions) * and returns a GLSL shader state. One of the supplied names may be <code>null</code> * in order to use the fixed-function pipeline for that part. The method returns * <code>null</code> if the shaders fail to compile (JME will log an error). * * @param defs a number of preprocessor definitions to be #defined in both shaders * (e.g., "ENABLE_FOG", "NUM_LIGHTS 2"). *///from ww w . j av a 2s . c o m protected GLSLShaderObjectsState loadShaders(String vert, String frag, String[] defs) { GLSLShaderObjectsState sstate = DisplaySystem.getDisplaySystem().getRenderer() .createGLSLShaderObjectsState(); sstate.load((vert == null) ? null : getSource(vert, defs), (frag == null) ? null : getSource(frag, defs)); // check its link status IntBuffer ibuf = BufferUtils.createIntBuffer(1); ARBShaderObjects.glGetObjectParameterARB(sstate.getProgramID(), ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB, ibuf); if (ibuf.get(0) == 0) { return null; // failed to link } // check the info log ARBShaderObjects.glGetObjectParameterARB(sstate.getProgramID(), ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB, ibuf); if (ibuf.get(0) == 0) { return sstate; // no error } ByteBuffer bbuf = BufferUtils.createByteBuffer(ibuf.get(0)); ARBShaderObjects.glGetInfoLogARB(sstate.getProgramID(), ibuf, bbuf); String log = Charset.forName("US-ASCII").decode(bbuf).toString(); // if it runs in software mode, that counts as a failure return (log.indexOf("software") == -1) ? sstate : null; }
From source file:org.smurn.jply.lwjgldemo.LWJGLDemo.java
License:Apache License
/** * Helper to get the log messages from the shader compiler. */// ww w . j a v a 2 s.c om private static boolean printLogInfo(int obj) { IntBuffer iVal = BufferUtils.createIntBuffer(1); ARBShaderObjects.glGetObjectParameterARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB, iVal); int length = iVal.get(); if (length > 1) { // We have some info we need to output. ByteBuffer infoLog = BufferUtils.createByteBuffer(length); iVal.flip(); ARBShaderObjects.glGetInfoLogARB(obj, iVal, infoLog); byte[] infoBytes = new byte[length]; infoLog.get(infoBytes); String out = new String(infoBytes); System.out.println("Info log:\n" + out); } else { return true; } return false; }
From source file:zildo.fwk.gfx.PixelShaders.java
License:Open Source License
private void printLogInfo(int obj) { IntBuffer iVal = BufferUtils.createIntBuffer(1); ARBShaderObjects.glGetObjectParameterARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB, iVal); int length = iVal.get(); if (length > 0) { // We have some info we need to output. ByteBuffer infoLog = BufferUtils.createByteBuffer(length); iVal.flip();//from w w w . j a va 2s .com ARBShaderObjects.glGetInfoLogARB(obj, iVal, infoLog); byte[] infoBytes = new byte[length]; infoLog.get(infoBytes); String out = new String(infoBytes); System.out.println("Info log:\n" + out); } Util.checkGLError(); }
From source file:zildo.platform.opengl.LwjglPixelShaders.java
License:Open Source License
private void printLogInfo(int obj) { IntBuffer iVal = ZUtils.createIntBuffer(1); ARBShaderObjects.glGetObjectParameterARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB, iVal); int length = iVal.get(); if (length > 0) { // We have some info we need to output. ByteBuffer infoLog = ZUtils.createByteBuffer(length); iVal.flip();//from ww w. j a v a 2s . c o m ARBShaderObjects.glGetInfoLogARB(obj, iVal, infoLog); byte[] infoBytes = new byte[length]; infoLog.get(infoBytes); String out = new String(infoBytes); System.out.println("Info log:\n" + out); } Util.checkGLError(); }