Program: 57891
Project: 57891
Buggy source:
/** 
 * Render the second stage of the hierarchy (Texture)
 * @param gl
 */
private void renderLevel2(GL2 gl){
  float fHeight;
  fHeight=viewFrustum.getHeight();
  float fWidthLevel2=renderStyle.getWidthLevel2() * fScalingLevel2;
  int iFirstTexture=0;
  int iLastTexture=0;
  int iFirstElementFirstTexture=iFirstSampleLevel1;
  int iLastElementLastTexture=iLastSampleLevel1;
  int iNrTexturesInUse=0;
  gl.glPushAttrib(GL2.GL_CURRENT_BIT | GL2.GL_LINE_BIT);
  gl.glPushName(pickingManager.getPickingID(uniqueID,PickingType.HIER_HEAT_MAP_FIELD_SELECTION,1));
  gl.glTexParameteri(GL2.GL_TEXTURE_2D,GL2.GL_TEXTURE_WRAP_S,GL2.GL_CLAMP);
  gl.glTexParameteri(GL2.GL_TEXTURE_2D,GL2.GL_TEXTURE_WRAP_T,GL2.GL_CLAMP);
  gl.glTexParameteri(GL2.GL_TEXTURE_2D,GL2.GL_TEXTURE_MAG_FILTER,GL2.GL_NEAREST);
  gl.glTexParameteri(GL2.GL_TEXTURE_2D,GL2.GL_TEXTURE_MIN_FILTER,GL2.GL_NEAREST);
  if (bSkipLevel1) {
    Texture TexTemp1=textures.get(0);
    TexTemp1.enable();
    TexTemp1.bind();
    TextureCoords texCoords1=TexTemp1.getImageTexCoords();
    gl.glBegin(GL2.GL_QUADS);
    gl.glTexCoord2d(texCoords1.left(),texCoords1.top());
    gl.glVertex3f(0,0,0);
    gl.glTexCoord2d(texCoords1.left(),texCoords1.bottom());
    gl.glVertex3f(0,fHeight,0);
    gl.glTexCoord2d(texCoords1.right(),texCoords1.bottom());
    gl.glVertex3f(fWidthLevel2,fHeight,0);
    gl.glTexCoord2d(texCoords1.right(),texCoords1.top());
    gl.glVertex3f(fWidthLevel2,0,0);
    gl.glEnd();
    TexTemp1.disable();
  }
 else {
    while (numberSamples.get(iFirstTexture) < iFirstElementFirstTexture) {
      iFirstElementFirstTexture-=numberSamples.get(iFirstTexture);
      if (iFirstTexture < numberSamples.size() - 1)       iFirstTexture++;
    }
    while (iLastElementLastTexture > numberSamples.get(iLastTexture)) {
      iLastElementLastTexture-=numberSamples.get(iLastTexture);
      iLastTexture++;
      if (iLastTexture == numberSamples.size() - 1) {
        if (iLastElementLastTexture > iSamplesPerTexture)         iLastElementLastTexture=iSamplesPerTexture;
        break;
      }
    }
    iNrTexturesInUse=iLastTexture - iFirstTexture + 1;
    if (iNrTexturesInUse == 1) {
      float fScalingFirstElement=(float)iFirstElementFirstTexture / numberSamples.get(iFirstTexture);
      float fScalingLastElement=(float)(iLastElementLastTexture + 1) / numberSamples.get(iFirstTexture);
      Texture TexTemp1=textures.get(iFirstTexture);
      TexTemp1.enable();
      TexTemp1.bind();
      TextureCoords texCoords1=TexTemp1.getImageTexCoords();
      gl.glBegin(GL2.GL_QUADS);
      gl.glTexCoord2d(texCoords1.left(),texCoords1.top() * fScalingLastElement);
      gl.glVertex3f(0,0,0);
      gl.glTexCoord2d(texCoords1.left(),texCoords1.bottom() + fScalingFirstElement);
      gl.glVertex3f(0,fHeight,0);
      gl.glTexCoord2d(texCoords1.right(),texCoords1.bottom() + fScalingFirstElement);
      gl.glVertex3f(fWidthLevel2,fHeight,0);
      gl.glTexCoord2d(texCoords1.right(),texCoords1.top() * fScalingLastElement);
      gl.glVertex3f(fWidthLevel2,0,0);
      gl.glEnd();
      TexTemp1.disable();
    }
 else     if (iNrTexturesInUse == 2) {
      float fScalingLastTexture=(float)(iLastElementLastTexture + 1) / iSamplesLevel2;
      float fRatioFirstTexture=(float)(numberSamples.get(iFirstTexture) - iFirstElementFirstTexture) / numberSamples.get(iFirstTexture);
      float fRatioLastTexture=(float)(iLastElementLastTexture + 1) / numberSamples.get(iLastTexture);
      Texture TexTemp1=textures.get(iFirstTexture);
      TexTemp1.enable();
      TexTemp1.bind();
      TextureCoords texCoords1=TexTemp1.getImageTexCoords();
      gl.glBegin(GL2.GL_QUADS);
      gl.glTexCoord2d(texCoords1.left(),texCoords1.top());
      gl.glVertex3f(0,fHeight * fScalingLastTexture,0);
      gl.glTexCoord2d(texCoords1.left(),texCoords1.bottom() + (1 - fRatioFirstTexture));
      gl.glVertex3f(0,fHeight,0);
      gl.glTexCoord2d(texCoords1.right(),texCoords1.bottom() + (1 - fRatioFirstTexture));
      gl.glVertex3f(fWidthLevel2,fHeight,0);
      gl.glTexCoord2d(texCoords1.right(),texCoords1.top());
      gl.glVertex3f(fWidthLevel2,fHeight * fScalingLastTexture,0);
      gl.glEnd();
      TexTemp1.disable();
      Texture TexTemp2=textures.get(iLastTexture);
      TexTemp2.enable();
      TexTemp2.bind();
      TextureCoords texCoords2=TexTemp2.getImageTexCoords();
      gl.glBegin(GL2.GL_QUADS);
      gl.glTexCoord2d(texCoords2.left(),texCoords2.top() * fRatioLastTexture);
      gl.glVertex3f(0,0,0);
      gl.glTexCoord2d(texCoords2.left(),texCoords2.bottom());
      gl.glVertex3f(0,fHeight * fScalingLastTexture,0);
      gl.glTexCoord2d(texCoords2.right(),texCoords2.bottom());
      gl.glVertex3f(fWidthLevel2,fHeight * fScalingLastTexture,0);
      gl.glTexCoord2d(texCoords2.right(),texCoords2.top() * fRatioLastTexture);
      gl.glVertex3f(fWidthLevel2,0,0);
      gl.glEnd();
      TexTemp2.disable();
    }
 else     if (iNrTexturesInUse == 3) {
      float fScalingFirstTexture=(float)(iSamplesPerTexture - iFirstElementFirstTexture) / iSamplesLevel2;
      float fScalingLastTexture=(float)(iLastElementLastTexture + 1) / iSamplesLevel2;
      float fRatioFirstTexture=(float)(numberSamples.get(iLastTexture) - iFirstElementFirstTexture) / numberSamples.get(iFirstTexture);
      float fRatioLastTexture=(float)(iLastElementLastTexture + 1) / numberSamples.get(iLastTexture);
      Texture TexTemp1=textures.get(iFirstTexture);
      TexTemp1.enable();
      TexTemp1.bind();
      TextureCoords texCoords1=TexTemp1.getImageTexCoords();
      gl.glBegin(GL2.GL_QUADS);
      gl.glTexCoord2d(texCoords1.left(),texCoords1.top());
      gl.glVertex3f(0,fHeight * (1 - fScalingFirstTexture),0);
      gl.glTexCoord2d(texCoords1.left(),texCoords1.bottom() + (1 - fRatioFirstTexture));
      gl.glVertex3f(0,fHeight,0);
      gl.glTexCoord2d(texCoords1.right(),texCoords1.bottom() + (1 - fRatioFirstTexture));
      gl.glVertex3f(fWidthLevel2,fHeight,0);
      gl.glTexCoord2d(texCoords1.right(),texCoords1.top());
      gl.glVertex3f(fWidthLevel2,fHeight * (1 - fScalingFirstTexture),0);
      gl.glEnd();
      TexTemp1.disable();
      Texture TexTemp2=textures.get(iFirstTexture + 1);
      TexTemp2.enable();
      TexTemp2.bind();
      TextureCoords texCoords2=TexTemp2.getImageTexCoords();
      gl.glBegin(GL2.GL_QUADS);
      gl.glTexCoord2d(texCoords2.left(),texCoords2.top());
      gl.glVertex3f(0,fHeight * fScalingLastTexture,0);
      gl.glTexCoord2d(texCoords2.left(),texCoords2.bottom());
      gl.glVertex3f(0,fHeight * (1 - fScalingFirstTexture),0);
      gl.glTexCoord2d(texCoords2.right(),texCoords2.bottom());
      gl.glVertex3f(fWidthLevel2,fHeight * (1 - fScalingFirstTexture),0);
      gl.glTexCoord2d(texCoords2.right(),texCoords2.top());
      gl.glVertex3f(fWidthLevel2,fHeight * fScalingLastTexture,0);
      gl.glEnd();
      TexTemp2.disable();
      Texture TexTemp3=textures.get(iLastTexture);
      TexTemp3.enable();
      TexTemp3.bind();
      TextureCoords texCoords3=TexTemp3.getImageTexCoords();
      gl.glBegin(GL2.GL_QUADS);
      gl.glTexCoord2d(texCoords3.left(),texCoords3.top() * fRatioLastTexture);
      gl.glVertex3f(0,0,0);
      gl.glTexCoord2d(texCoords3.left(),texCoords3.bottom());
      gl.glVertex3f(0,fHeight * fScalingLastTexture,0);
      gl.glTexCoord2d(texCoords3.right(),texCoords3.bottom());
      gl.glVertex3f(fWidthLevel2,fHeight * fScalingLastTexture,0);
      gl.glTexCoord2d(texCoords3.right(),texCoords3.top() * fRatioLastTexture);
      gl.glVertex3f(fWidthLevel2,0,0);
      gl.glEnd();
      TexTemp3.disable();
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
  }
  gl.glPopName();
  gl.glPopAttrib();
}

Fixed version (ground truth):
/** 
 * Render the second stage of the hierarchy (Texture)
 * @param gl
 */
private void renderLevel2(GL2 gl){
  float fHeight;
  fHeight=viewFrustum.getHeight();
  float fWidthLevel2=renderStyle.getWidthLevel2() * fScalingLevel2;
  int iFirstTexture=0;
  int iLastTexture=0;
  int iFirstElementFirstTexture=iFirstSampleLevel1;
  int iLastElementLastTexture=iLastSampleLevel1;
  int iNrTexturesInUse=0;
  gl.glPushAttrib(GL2.GL_CURRENT_BIT | GL2.GL_LINE_BIT);
  gl.glPushName(pickingManager.getPickingID(uniqueID,PickingType.HIER_HEAT_MAP_FIELD_SELECTION,1));
  gl.glTexEnvi(GL2.GL_TEXTURE_ENV,GL2.GL_TEXTURE_ENV_MODE,GL2.GL_DECAL);
  gl.glTexParameteri(GL2.GL_TEXTURE_2D,GL2.GL_TEXTURE_WRAP_S,GL2.GL_CLAMP);
  gl.glTexParameteri(GL2.GL_TEXTURE_2D,GL2.GL_TEXTURE_WRAP_T,GL2.GL_CLAMP);
  gl.glTexParameteri(GL2.GL_TEXTURE_2D,GL2.GL_TEXTURE_MAG_FILTER,GL2.GL_NEAREST);
  gl.glTexParameteri(GL2.GL_TEXTURE_2D,GL2.GL_TEXTURE_MIN_FILTER,GL2.GL_NEAREST);
  if (bSkipLevel1) {
    Texture TexTemp1=textures.get(0);
    TexTemp1.enable();
    TexTemp1.bind();
    TextureCoords texCoords1=TexTemp1.getImageTexCoords();
    gl.glBegin(GL2.GL_QUADS);
    gl.glTexCoord2d(texCoords1.left(),texCoords1.top());
    gl.glVertex3f(0,0,0);
    gl.glTexCoord2d(texCoords1.left(),texCoords1.bottom());
    gl.glVertex3f(0,fHeight,0);
    gl.glTexCoord2d(texCoords1.right(),texCoords1.bottom());
    gl.glVertex3f(fWidthLevel2,fHeight,0);
    gl.glTexCoord2d(texCoords1.right(),texCoords1.top());
    gl.glVertex3f(fWidthLevel2,0,0);
    gl.glEnd();
    TexTemp1.disable();
  }
 else {
    while (numberSamples.get(iFirstTexture) < iFirstElementFirstTexture) {
      iFirstElementFirstTexture-=numberSamples.get(iFirstTexture);
      if (iFirstTexture < numberSamples.size() - 1)       iFirstTexture++;
    }
    while (iLastElementLastTexture > numberSamples.get(iLastTexture)) {
      iLastElementLastTexture-=numberSamples.get(iLastTexture);
      iLastTexture++;
      if (iLastTexture == numberSamples.size() - 1) {
        if (iLastElementLastTexture > iSamplesPerTexture)         iLastElementLastTexture=iSamplesPerTexture;
        break;
      }
    }
    iNrTexturesInUse=iLastTexture - iFirstTexture + 1;
    if (iNrTexturesInUse == 1) {
      float fScalingFirstElement=(float)iFirstElementFirstTexture / numberSamples.get(iFirstTexture);
      float fScalingLastElement=(float)(iLastElementLastTexture + 1) / numberSamples.get(iFirstTexture);
      Texture TexTemp1=textures.get(iFirstTexture);
      TexTemp1.enable();
      TexTemp1.bind();
      TextureCoords texCoords1=TexTemp1.getImageTexCoords();
      gl.glBegin(GL2.GL_QUADS);
      gl.glTexCoord2d(texCoords1.left(),texCoords1.top() * fScalingLastElement);
      gl.glVertex3f(0,0,0);
      gl.glTexCoord2d(texCoords1.left(),texCoords1.bottom() + fScalingFirstElement);
      gl.glVertex3f(0,fHeight,0);
      gl.glTexCoord2d(texCoords1.right(),texCoords1.bottom() + fScalingFirstElement);
      gl.glVertex3f(fWidthLevel2,fHeight,0);
      gl.glTexCoord2d(texCoords1.right(),texCoords1.top() * fScalingLastElement);
      gl.glVertex3f(fWidthLevel2,0,0);
      gl.glEnd();
      TexTemp1.disable();
    }
 else     if (iNrTexturesInUse == 2) {
      float fScalingLastTexture=(float)(iLastElementLastTexture + 1) / iSamplesLevel2;
      float fRatioFirstTexture=(float)(numberSamples.get(iFirstTexture) - iFirstElementFirstTexture) / numberSamples.get(iFirstTexture);
      float fRatioLastTexture=(float)(iLastElementLastTexture + 1) / numberSamples.get(iLastTexture);
      Texture TexTemp1=textures.get(iFirstTexture);
      TexTemp1.enable();
      TexTemp1.bind();
      TextureCoords texCoords1=TexTemp1.getImageTexCoords();
      gl.glBegin(GL2.GL_QUADS);
      gl.glTexCoord2d(texCoords1.left(),texCoords1.top());
      gl.glVertex3f(0,fHeight * fScalingLastTexture,0);
      gl.glTexCoord2d(texCoords1.left(),texCoords1.bottom() + (1 - fRatioFirstTexture));
      gl.glVertex3f(0,fHeight,0);
      gl.glTexCoord2d(texCoords1.right(),texCoords1.bottom() + (1 - fRatioFirstTexture));
      gl.glVertex3f(fWidthLevel2,fHeight,0);
      gl.glTexCoord2d(texCoords1.right(),texCoords1.top());
      gl.glVertex3f(fWidthLevel2,fHeight * fScalingLastTexture,0);
      gl.glEnd();
      TexTemp1.disable();
      Texture TexTemp2=textures.get(iLastTexture);
      TexTemp2.enable();
      TexTemp2.bind();
      TextureCoords texCoords2=TexTemp2.getImageTexCoords();
      gl.glBegin(GL2.GL_QUADS);
      gl.glTexCoord2d(texCoords2.left(),texCoords2.top() * fRatioLastTexture);
      gl.glVertex3f(0,0,0);
      gl.glTexCoord2d(texCoords2.left(),texCoords2.bottom());
      gl.glVertex3f(0,fHeight * fScalingLastTexture,0);
      gl.glTexCoord2d(texCoords2.right(),texCoords2.bottom());
      gl.glVertex3f(fWidthLevel2,fHeight * fScalingLastTexture,0);
      gl.glTexCoord2d(texCoords2.right(),texCoords2.top() * fRatioLastTexture);
      gl.glVertex3f(fWidthLevel2,0,0);
      gl.glEnd();
      TexTemp2.disable();
    }
 else     if (iNrTexturesInUse == 3) {
      float fScalingFirstTexture=(float)(iSamplesPerTexture - iFirstElementFirstTexture) / iSamplesLevel2;
      float fScalingLastTexture=(float)(iLastElementLastTexture + 1) / iSamplesLevel2;
      float fRatioFirstTexture=(float)(numberSamples.get(iLastTexture) - iFirstElementFirstTexture) / numberSamples.get(iFirstTexture);
      float fRatioLastTexture=(float)(iLastElementLastTexture + 1) / numberSamples.get(iLastTexture);
      Texture TexTemp1=textures.get(iFirstTexture);
      TexTemp1.enable();
      TexTemp1.bind();
      TextureCoords texCoords1=TexTemp1.getImageTexCoords();
      gl.glBegin(GL2.GL_QUADS);
      gl.glTexCoord2d(texCoords1.left(),texCoords1.top());
      gl.glVertex3f(0,fHeight * (1 - fScalingFirstTexture),0);
      gl.glTexCoord2d(texCoords1.left(),texCoords1.bottom() + (1 - fRatioFirstTexture));
      gl.glVertex3f(0,fHeight,0);
      gl.glTexCoord2d(texCoords1.right(),texCoords1.bottom() + (1 - fRatioFirstTexture));
      gl.glVertex3f(fWidthLevel2,fHeight,0);
      gl.glTexCoord2d(texCoords1.right(),texCoords1.top());
      gl.glVertex3f(fWidthLevel2,fHeight * (1 - fScalingFirstTexture),0);
      gl.glEnd();
      TexTemp1.disable();
      Texture TexTemp2=textures.get(iFirstTexture + 1);
      TexTemp2.enable();
      TexTemp2.bind();
      TextureCoords texCoords2=TexTemp2.getImageTexCoords();
      gl.glBegin(GL2.GL_QUADS);
      gl.glTexCoord2d(texCoords2.left(),texCoords2.top());
      gl.glVertex3f(0,fHeight * fScalingLastTexture,0);
      gl.glTexCoord2d(texCoords2.left(),texCoords2.bottom());
      gl.glVertex3f(0,fHeight * (1 - fScalingFirstTexture),0);
      gl.glTexCoord2d(texCoords2.right(),texCoords2.bottom());
      gl.glVertex3f(fWidthLevel2,fHeight * (1 - fScalingFirstTexture),0);
      gl.glTexCoord2d(texCoords2.right(),texCoords2.top());
      gl.glVertex3f(fWidthLevel2,fHeight * fScalingLastTexture,0);
      gl.glEnd();
      TexTemp2.disable();
      Texture TexTemp3=textures.get(iLastTexture);
      TexTemp3.enable();
      TexTemp3.bind();
      TextureCoords texCoords3=TexTemp3.getImageTexCoords();
      gl.glBegin(GL2.GL_QUADS);
      gl.glTexCoord2d(texCoords3.left(),texCoords3.top() * fRatioLastTexture);
      gl.glVertex3f(0,0,0);
      gl.glTexCoord2d(texCoords3.left(),texCoords3.bottom());
      gl.glVertex3f(0,fHeight * fScalingLastTexture,0);
      gl.glTexCoord2d(texCoords3.right(),texCoords3.bottom());
      gl.glVertex3f(fWidthLevel2,fHeight * fScalingLastTexture,0);
      gl.glTexCoord2d(texCoords3.right(),texCoords3.top() * fRatioLastTexture);
      gl.glVertex3f(fWidthLevel2,0,0);
      gl.glEnd();
      TexTemp3.disable();
    }
 else {
      throw new IllegalStateException("String_Node_Str");
    }
  }
  gl.glPopName();
  gl.glPopAttrib();
}