According to the logic in ShaderProgram and ShaderState, glBindAttribLocation will always fail because it requires that the program be attached to the state but not linked, and attaching the program to the state (attachProgram) requires that the program be linked (because attachProgram calls ShaderProgram.glUseProgram, which requires the program be linked). Perhaps glUseProgram could be modified so that if on is false, it shouldn't check whether the program is linked? Here is a method which illustrates the contradiction: public ShaderState gltLoadShaderPairSrcWithAttributes(GL2 gl, String vertexSrc, String fragmentSrc, HashMap<Integer, String> attributes) { ByteArrayOutputStream verboseOutBuffer = new ByteArrayOutputStream(); PrintStream verboseOut = new PrintStream(verboseOutBuffer, true); // Create ShaderCode objects ShaderCode vertexShaderCode = new ShaderCode(GL2.GL_VERTEX_SHADER, 1, new String[][]{ { vertexSrc } }); ShaderCode fragmentShaderCode = new ShaderCode(GL2.GL_FRAGMENT_SHADER, 1, new String[][]{ { fragmentSrc } }); // Put them in a ShaderProgram ShaderProgram program = new ShaderProgram(); program.add(vertexShaderCode); program.add(fragmentShaderCode); // Create a new ShaderState ShaderState shaderState = new ShaderState(); // Link the programs here? if (!program.link(gl, verboseOut)) throw new GLException("Failed to compile and link shaders: " + verboseOutBuffer.toString()); // Attach the program to the state. Requires that the program be linked. shaderState.attachShaderProgram(gl, program); // Set some attributes. Requires that the program be attached BUT NOT LINKED??? Set<Entry<Integer, String>> attributeSet = attributes.entrySet(); Iterator<Entry<Integer, String>> iterator = attributeSet.iterator(); while (iterator.hasNext()) { Entry<Integer, String> entry = iterator.next(); shaderState.glBindAttribLocation(gl, entry.getKey(), entry.getValue()); } return shaderState; }
Fix http://jogamp.org/git/?p=jogl.git;a=commit;h=2d22d9a880fee84af422505e69c1642c7a505b0f Test http://jogamp.org/git/?p=jogl.git;a=commit;h=8297ef88b927e07b41760ab3e9de05bc49fd4695 http://jogamp.org/git/?p=jogl.git;a=blobdiff;f=src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java;h=9208afc243ce9946c2ce1aee9c24aef0942f86e4;hp=c1f293fff199f49e1be59143f0f9101a15aa1220;hb=8297ef88b927e07b41760ab3e9de05bc49fd4695;hpb=2f2879256fe999c5019bd800f564e9cb2a83a0b6 added ShaderProgram initGL2ES2) method, creating program object before link
verified with mentioned test