<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>425</bug_id>
          
          <creation_ts>2010-10-29 07:45:27 +0200</creation_ts>
          <short_desc>Can never bind attributes to shader program due to faulty logic</short_desc>
          <delta_ts>2011-04-10 01:33:32 +0200</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Jogl</product>
          <component>opengl</component>
          <version>2</version>
          <rep_platform>All</rep_platform>
          <op_sys>all</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Robert B">robert.c.baruch</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          
          <deadline>2010-11-30</deadline>
          <cf_type>DEFECT</cf_type>
          <cf_scm_refs>2d22d9a880fee84af422505e69c1642c7a505b0f
8297ef88b927e07b41760ab3e9de05bc49fd4695</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>531</commentid>
    <comment_count>0</comment_count>
    <who name="Robert B">robert.c.baruch</who>
    <bug_when>2010-10-29 07:45:27 +0200</bug_when>
    <thetext>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&apos;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&lt;Integer, String&gt; 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(&quot;Failed to compile and link shaders: &quot; + 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&lt;Entry&lt;Integer, String&gt;&gt; attributeSet = attributes.entrySet(); 
        Iterator&lt;Entry&lt;Integer, String&gt;&gt; iterator = attributeSet.iterator(); 
        while (iterator.hasNext()) 
        { 
            Entry&lt;Integer, String&gt; entry = iterator.next(); 
            shaderState.glBindAttribLocation(gl, entry.getKey(), entry.getValue()); 
        } 

        return shaderState; 
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>942</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2011-04-10 01:33:06 +0200</bug_when>
    <thetext>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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>943</commentid>
    <comment_count>2</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2011-04-10 01:33:32 +0200</bug_when>
    <thetext>verified with mentioned test</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>