nus-yam/ex-repair huggingface dataset:
Program: 70751
Project: 70751
Buggy source:
@Override public void end(){
  flush();
  mode=0;
  maxverts=0;
  gl=null;
  drawing=false;
}

Fixed version (ground truth):
@Override public void end(){
  flush();
  if (mode == GL.GL_LINE_LOOP && loopBuff != null) {
    vbuff.put(loopBuff);
    vbuff.flip();
    draw(gl,GL.GL_LINE_STRIP,vbuff,nverts + 1);
  }
  vbuff.clear();
  nverts=0;
  mode=0;
  maxverts=0;
  gl=null;
  drawing=false;
  loopBuff=null;
}
Program: 70752
Project: 70752
Buggy source:
@Override public void begin(GL gl,int glMode,int maxVertices){
  this.gl=(GL2GL3)gl;
  this.mode=glMode;
  this.maxverts=maxVertices;
  drawing=true;
  vertexStride=0;
  if (normalsEnabled) {
    normalOffset=vertexStride;
    vertexStride+=NORMAL_BYTES;
  }
 else {
    normalOffset=-1;
  }
  if (colorsEnabled) {
    colorOffset=vertexStride;
    vertexStride+=COLOR_BYTES;
  }
 else {
    colorOffset=-1;
  }
  if (texcoordsEnabled) {
    texcoordOffset=vertexStride;
    vertexStride+=TEXCOORD_BYTES;
  }
 else {
    texcoordOffset=-1;
  }
  positionOffset=vertexStride;
  vertexStride+=POSITION_BYTES;
  ensureBufferCapacity(maxVertices * vertexStride);
  bind(gl,vbuff,normalOffset,colorOffset,texcoordOffset,positionOffset,vertexStride);
}

Fixed version (ground truth):
@Override public void begin(GL gl,int glMode,int maxVertices){
  this.gl=(GL2GL3)gl;
  this.mode=glMode;
  if (maxVertices < 12) {
    maxVertices=12;
  }
switch (glMode) {
case GL.GL_POINTS:
case GL.GL_LINE_STRIP:
case GL.GL_LINE_LOOP:
case GL.GL_TRIANGLE_STRIP:
case GL.GL_TRIANGLE_FAN:
    break;
case GL.GL_LINES:
  if ((maxVertices % 2) == 1) {
    ++maxVertices;
  }
break;
case GL.GL_TRIANGLES:
{
int off=(3 - maxVertices % 3) % 3;
maxVertices+=off;
break;
}
}
this.maxverts=maxVertices;
drawing=true;
vertexStride=0;
if (normalsEnabled) {
normalOffset=vertexStride;
vertexStride+=NORMAL_BYTES;
}
 else {
normalOffset=-1;
}
if (colorsEnabled) {
colorOffset=vertexStride;
vertexStride+=COLOR_BYTES;
}
 else {
colorOffset=-1;
}
if (texcoordsEnabled) {
texcoordOffset=vertexStride;
vertexStride+=TEXCOORD_BYTES;
}
 else {
texcoordOffset=-1;
}
positionOffset=vertexStride;
vertexStride+=POSITION_BYTES;
ensureBufferCapacity(maxVertices * vertexStride);
loopBuff=null;
bind(gl,vbuff,normalOffset,colorOffset,texcoordOffset,positionOffset,vertexStride);
}
Program: 70753
Project: 70753
Buggy source:
public void setSurfaceRendering(SurfaceRender mode){
  if (mySurfaceRendering != mode) {
    if (myStressPlotRanging == Ranging.Auto) {
      myStressPlotRange.set(0,0);
    }
    SurfaceRender oldMode=mySurfaceRendering;
    if (myFem != null) {
switch (mode) {
case Strain:
        myFem.setComputeNodalStrain(true);
      myFem.updateStressAndStiffness();
    break;
case Stress:
  myFem.setComputeNodalStress(true);
myFem.updateStressAndStiffness();
break;
default :
{
myFem.setComputeNodalStrain(false);
myFem.setComputeNodalStress(false);
break;
}
}
}
MeshBase mesh=getMesh();
if (mesh != null) {
boolean oldStressOrStrain=isStressOrStrainRendering(oldMode);
boolean newStressOrStrain=isStressOrStrainRendering(mode);
if (newStressOrStrain != oldStressOrStrain) {
if (newStressOrStrain) {
saveMeshColoring(mesh);
mesh.setVertexColoringEnabled();
mySurfaceRendering=mode;
updateVertexColors();
}
 else {
mySurfaceRendering=mode;
restoreMeshColoring(mesh);
}
}
}
mySurfaceRendering=mode;
}
mySurfaceRenderingMode=PropertyUtils.propagateValue(this,"String_Node_Str",mode,mySurfaceRenderingMode);
}

Fixed version (ground truth):
public void setSurfaceRendering(SurfaceRender mode){
  if (mySurfaceRendering != mode) {
    if (myStressPlotRanging == Ranging.Auto) {
      myStressPlotRange.set(0,0);
    }
    SurfaceRender oldMode=mySurfaceRendering;
    if (myFem != null) {
switch (mode) {
case Strain:
        myFem.setComputeNodalStrain(true);
      myFem.updateStressAndStiffness();
    break;
case Stress:
  myFem.setComputeNodalStress(true);
myFem.updateStressAndStiffness();
break;
default :
{
myFem.setComputeNodalStrain(false);
myFem.setComputeNodalStress(false);
break;
}
}
}
MeshBase mesh=getMesh();
if (mesh != null) {
boolean oldStressOrStrain=isStressOrStrainRendering(oldMode);
boolean newStressOrStrain=isStressOrStrainRendering(mode);
if (newStressOrStrain != oldStressOrStrain) {
if (newStressOrStrain) {
saveShading();
saveMeshColoring(mesh);
mesh.setVertexColoringEnabled();
mesh.setVertexColorMixing(ColorMixing.REPLACE);
myRenderProps.setShading(Shading.NONE);
mySurfaceRendering=mode;
updateVertexColors();
}
 else {
mySurfaceRendering=mode;
restoreMeshColoring(mesh);
restoreShading();
}
}
}
mySurfaceRendering=mode;
}
mySurfaceRenderingMode=PropertyUtils.propagateValue(this,"String_Node_Str",mode,mySurfaceRenderingMode);
}
Program: 70754
Project: 70754
Buggy source:
protected void restoreMeshColoring(MeshBase mesh){
  if (mySavedColors == null) {
    mesh.clearColors();
  }
 else {
    mesh.setColors(mySavedColors,mySavedColorIndices);
    if (mySavedVertexColoring) {
      mesh.setVertexColoringEnabled();
    }
 else     if (mySavedFeatureColoring) {
      mesh.setFeatureColoringEnabled();
    }
  }
}

Fixed version (ground truth):
protected void restoreMeshColoring(MeshBase mesh){
  if (mySavedColors == null) {
    mesh.clearColors();
  }
 else {
    mesh.setColors(mySavedColors,mySavedColorIndices);
    if (mySavedVertexColoring) {
      mesh.setVertexColoringEnabled();
    }
 else     if (mySavedFeatureColoring) {
      mesh.setFeatureColoringEnabled();
    }
  }
  mesh.setVertexColorMixing(mySavedColorMixing);
}
Program: 70755
Project: 70755
Buggy source:
@Override public FemMeshBase copy(int flags,Map<ModelComponent,ModelComponent> copyMap){
  FemMeshBase fmb=(FemMeshBase)super.copy(flags,copyMap);
  if (mySurfaceRenderingMode == PropertyMode.Explicit) {
    fmb.setSurfaceRendering(mySurfaceRendering);
  }
  if (myStressPlotRangingMode == PropertyMode.Explicit) {
    fmb.setStressPlotRanging(myStressPlotRanging);
  }
  if (myStressPlotRangeMode == PropertyMode.Explicit) {
    fmb.setStressPlotRange(myStressPlotRange);
  }
  if (myColorMapMode == PropertyMode.Explicit) {
    fmb.setColorMap(myColorMap);
  }
  FemModel3d newFem=(FemModel3d)copyMap.get(myFem);
  if (newFem != null) {
    fmb.myFem=newFem;
  }
 else {
    fmb.myFem=myFem;
  }
  return fmb;
}

Fixed version (ground truth):
@Override public FemMeshBase copy(int flags,Map<ModelComponent,ModelComponent> copyMap){
  FemMeshBase fmb=(FemMeshBase)super.copy(flags,copyMap);
  if (mySurfaceRenderingMode == PropertyMode.Explicit) {
    fmb.setSurfaceRendering(mySurfaceRendering);
  }
  if (myStressPlotRangingMode == PropertyMode.Explicit) {
    fmb.setStressPlotRanging(myStressPlotRanging);
  }
  if (myStressPlotRangeMode == PropertyMode.Explicit) {
    fmb.setStressPlotRange(myStressPlotRange);
  }
  if (myColorMapMode == PropertyMode.Explicit) {
    fmb.setColorMap(myColorMap);
  }
  FemModel3d newFem=(FemModel3d)copyMap.get(myFem);
  if (newFem != null) {
    fmb.myFem=newFem;
  }
 else {
    fmb.myFem=myFem;
  }
  if (mySavedColors != null) {
    fmb.mySavedColors=new ArrayList<float[]>(mySavedColors.size());
    for (    float[] c : mySavedColors) {
      fmb.mySavedColors.add(Arrays.copyOf(c,c.length));
    }
  }
 else {
    fmb.mySavedColors=null;
  }
  if (mySavedColorIndices != null) {
    fmb.mySavedColorIndices=Arrays.copyOf(mySavedColorIndices,mySavedColorIndices.length);
  }
 else {
    fmb.mySavedColorIndices=null;
  }
  fmb.mySavedVertexColoring=mySavedVertexColoring;
  fmb.mySavedFeatureColoring=mySavedFeatureColoring;
  fmb.mySavedColorMixing=mySavedColorMixing;
  fmb.mySavedShading=mySavedShading;
  fmb.mySavedShadingMode=mySavedShadingMode;
  return fmb;
}
Program: 70756
Project: 70756
Buggy source:
@Override public void render(Renderer renderer,RenderProps props,int flags){
  if (isSelected() || (myFem != null && myFem.isSelected())) {
    flags|=Renderer.HIGHLIGHT;
  }
  PropertyMode oldShadingMode=null;
  Shading oldShading=null;
  if (isStressOrStrainRendering(mySurfaceRendering)) {
    renderer.setVertexColorMixing(ColorMixing.REPLACE);
    oldShadingMode=props.getShadingMode();
    oldShading=props.getShading();
    props.setShading(Shading.NONE);
  }
 else   if (mySurfaceRendering == SurfaceRender.None) {
    return;
  }
  if (renderer.isSelecting()) {
    renderer.beginSelectionQuery(0);
  }
  super.render(renderer,props,flags);
  if (renderer.isSelecting()) {
    renderer.endSelectionQuery();
  }
  if (oldShading != null) {
    props.setShading(oldShading);
    props.setShadingMode(oldShadingMode);
  }
}

Fixed version (ground truth):
@Override public void render(Renderer renderer,RenderProps props,int flags){
  if (isSelected() || (myFem != null && myFem.isSelected())) {
    flags|=Renderer.HIGHLIGHT;
  }
  if (mySurfaceRendering == SurfaceRender.None) {
    return;
  }
  if (renderer.isSelecting()) {
    renderer.beginSelectionQuery(0);
  }
  super.render(renderer,props,flags);
  if (renderer.isSelecting()) {
    renderer.endSelectionQuery();
  }
}
Program: 70757
Project: 70757
Buggy source:
protected void saveMeshColoring(MeshBase mesh){
  mySavedColors=mesh.getColors();
  mySavedColorIndices=mesh.getColorIndices();
  mySavedVertexColoring=mesh.getVertexColoringEnabled();
  mySavedFeatureColoring=mesh.getFeatureColoringEnabled();
}

Fixed version (ground truth):
protected void saveMeshColoring(MeshBase mesh){
  mySavedColors=mesh.getColors();
  mySavedColorIndices=mesh.getColorIndices();
  mySavedVertexColoring=mesh.getVertexColoringEnabled();
  mySavedFeatureColoring=mesh.getFeatureColoringEnabled();
  mySavedColorMixing=mesh.getVertexColorMixing();
}
Program: 70761
Project: 70761
Buggy source:
private int renderList(Renderer renderer,SortedRenderableList list,int qid,int flags){
  boolean selecting=renderer.isSelecting();
  for (int i=0; i < list.size(); i++) {
    try {
      IsRenderable r=list.get(i);
      if (selecting && r instanceof IsSelectable) {
        IsSelectable s=(IsSelectable)r;
        try {
          int numq=s.numSelectionQueriesNeeded();
          if (renderer.isSelectable(s)) {
            if (numq >= 0) {
              renderer.beginSubSelection(s,qid);
            }
 else {
              renderer.beginSelectionQuery(qid);
            }
            r.render(renderer,flags);
            if (numq >= 0) {
              renderer.endSubSelection();
            }
 else {
              renderer.endSelectionQuery();
            }
          }
          qid+=(numq >= 0 ? numq : 1);
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
 else       if (selecting) {
      }
 else {
        r.render(renderer,flags);
      }
      renderer.restoreDefaultState(true);
    }
 catch (    Exception e) {
      renderer.restoreDefaultState(false);
      e.printStackTrace();
    }
  }
  return qid;
}

Fixed version (ground truth):
private int renderList(Renderer renderer,SortedRenderableList list,int qid,int flags){
  boolean selecting=renderer.isSelecting();
  for (int i=0; i < list.size(); i++) {
    try {
      IsRenderable r=list.get(i);
      if (selecting && r instanceof IsSelectable) {
        IsSelectable s=(IsSelectable)r;
        try {
          int numq=s.numSelectionQueriesNeeded();
          if (renderer.isSelectable(s)) {
            if (numq >= 0) {
              renderer.beginSubSelection(s,qid);
            }
 else {
              renderer.beginSelectionQuery(qid);
            }
            r.render(renderer,flags);
            if (numq >= 0) {
              renderer.endSubSelection();
            }
 else {
              renderer.endSelectionQuery();
            }
          }
          qid+=(numq >= 0 ? numq : 1);
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
 else       if (selecting) {
      }
 else {
        r.render(renderer,flags);
      }
      renderer.restoreDefaultState(true);
    }
 catch (    Exception e) {
      renderer.restoreDefaultState(false);
      throw e;
    }
  }
  return qid;
}
Program: 70762
Project: 70762
Buggy source:
/** 
 * Creates an AffineTransform2d and initializes its components to the specified values.
 * @param A value for the A matrix
 * @param p value for the p vector
 */
public AffineTransform2d(Vector2d p,Matrix2d A){
  this.A=new Matrix2d(A);
  this.p=new Vector2d(p);
  M=A;
  b=p;
}

Fixed version (ground truth):
/** 
 * Creates an AffineTransform2d and initializes it to the provided
 * @param A value for the A matrix
 * @param p value for the p vector
 */
public AffineTransform2d(AffineTransform2dBase T){
  this.A=new Matrix2d(T.getMatrix());
  this.p=new Vector2d(T.getOffset());
  M=this.A;
  b=this.p;
}
Program: 70763
Project: 70763
Buggy source:
public Object clone(){
  try {
    return super.clone();
  }
 catch (  CloneNotSupportedException e) {
    throw new InternalErrorException("String_Node_Str" + getClass());
  }
}

Fixed version (ground truth):
public abstract Matrix2dBase clone();
Program: 70764
Project: 70764
Buggy source:
protected void addTextureCoords(RenderObject r,MeshBase mesh){
  if (mesh.hasTextureCoords()) {
    ArrayList<Vector3d> coords=mesh.getTextureCoords();
    for (int i=0; i < coords.size(); i++) {
      Vector3d coord=coords.get(i);
      r.addTextureCoord((float)coord.x,(float)(1 - coord.y));
    }
  }
}

Fixed version (ground truth):
protected void addTextureCoords(RenderObject r,MeshBase mesh){
  if (mesh.hasTextureCoords()) {
    ArrayList<Vector3d> coords=mesh.getTextureCoords();
    for (int i=0; i < coords.size(); i++) {
      Vector3d coord=coords.get(i);
      r.addTextureCoord((float)coord.x,(float)coord.y);
    }
  }
}
Program: 70765
Project: 70765
Buggy source:
protected void drawDragBox(GL2 gl){
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glPushMatrix();
  gl.glLoadIdentity();
  gl.glMatrixMode(GL2.GL_MODELVIEW);
  gl.glPushMatrix();
  gl.glLoadIdentity();
  boolean savedLighting=isLightingOn();
  gl.glDisable(GL2.GL_LIGHTING);
  gl.glColor3f(0.5f,0.5f,0.5f);
  double x0=2 * myDragBox.x / (double)width - 1;
  double x1=x0 + 2 * myDragBox.width / (double)width;
  double y0=1 - 2 * myDragBox.y / (double)height;
  double y1=y0 - 2 * myDragBox.height / (double)height;
  gl.glBegin(GL2.GL_LINE_LOOP);
  gl.glVertex3d(x0,y0,0);
  gl.glVertex3d(x1,y0,0);
  gl.glVertex3d(x1,y1,0);
  gl.glVertex3d(x0,y1,0);
  gl.glEnd();
  if (savedLighting) {
    gl.glEnable(GL2.GL_LIGHTING);
  }
  gl.glPopMatrix();
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glPopMatrix();
  gl.glMatrixMode(GL2.GL_MODELVIEW);
}

Fixed version (ground truth):
protected void drawDragBox(GL2 gl){
  setColor(0.5f,0.5f,0.5f,1.0f);
  begin2DRendering(-1,1,-1,1);
  double x0=2 * myDragBox.x / (double)width - 1;
  double x1=x0 + 2 * myDragBox.width / (double)width;
  double y0=1 - 2 * myDragBox.y / (double)height;
  double y1=y0 - 2 * myDragBox.height / (double)height;
  maybeUpdateState(gl);
  gl.glBegin(GL2.GL_LINE_LOOP);
  gl.glVertex3d(x0,y0,0);
  gl.glVertex3d(x1,y0,0);
  gl.glVertex3d(x1,y1,0);
  gl.glVertex3d(x0,y1,0);
  gl.glEnd();
  end2DRendering();
}
Program: 70766
Project: 70766
Buggy source:
public boolean popViewMatrix(){
  if (viewMatrixStack.size() == 0) {
    return false;
  }
  viewMatrix=viewMatrixStack.pop();
  myViewState=viewStateStack.pop();
  if (Math.abs(viewMatrix.getOffset().norm()) < 1e-5) {
    System.err.println("String_Node_Str");
    Thread.dumpStack();
  }
  invalidateViewMatrix();
  return true;
}

Fixed version (ground truth):
public boolean popViewMatrix(){
  if (viewMatrixStack.size() == 0) {
    return false;
  }
  viewMatrix=viewMatrixStack.pop();
  myViewState=viewStateStack.pop();
  if (Math.abs(viewMatrix.getOffset().norm()) < 1e-5) {
  }
  invalidateViewMatrix();
  return true;
}
Program: 70767
Project: 70767
Buggy source:
public void setViewMatrix(RigidTransform3d v){
synchronized (viewMatrix) {
    viewMatrix.set(v);
  }
  if (Math.abs(viewMatrix.getOffset().norm()) < 1e-5) {
    System.err.println("String_Node_Str");
    Thread.dumpStack();
  }
  invalidateViewMatrix();
}

Fixed version (ground truth):
public void setViewMatrix(RigidTransform3d v){
synchronized (viewMatrix) {
    viewMatrix.set(v);
  }
  if (Math.abs(viewMatrix.getOffset().norm()) < 1e-5) {
  }
  invalidateViewMatrix();
}
Program: 70768
Project: 70768
Buggy source:
/** 
 * {@inheritDoc}
 */
public void setModelMatrix2d(double left,double right,double bottom,double top){
  AffineTransform3d XMW=new AffineTransform3d();
  double w=right - left;
  double h=top - bottom;
  XMW.A.m00=2 / w;
  XMW.A.m11=2 / h;
  XMW.p.set(-(left + right) / w,-(top - bottom) / h,0);
  setModelMatrix(XMW);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public void setModelMatrix2d(double left,double right,double bottom,double top){
  AffineTransform3d XMW=new AffineTransform3d();
  double w=right - left;
  double h=top - bottom;
  XMW.A.m00=2 / w;
  XMW.A.m11=2 / h;
  XMW.p.set(-(left + right) / w,-(top + bottom) / h,0);
  setModelMatrix(XMW);
}
Program: 70769
Project: 70769
Buggy source:
/** 
 * Sets the eyeToWorld transform for this viewer, using the canonical parameters used by the GL <code>lookat</code> method.
 * @param eye position of the eye, in world coordinates
 * @param center point that the eye is looking at, in world coordinates
 * @param up up direction, in world coordinates
 */
public void setEyeToWorld(Point3d eye,Point3d center,Vector3d up){
  Vector3d zaxis=new Vector3d();
  Vector3d yaxis=new Vector3d();
  Vector3d xaxis=new Vector3d();
  zaxis.sub(eye,center);
  double n=zaxis.norm();
  if (n > 1e-12) {
    zaxis.scale(1.0 / n);
  }
 else {
    RotationMatrix3d R=new RotationMatrix3d();
    R.rotateZDirection(up);
    R.getColumn(0,zaxis);
    R.getColumn(1,xaxis);
    R.getColumn(2,yaxis);
  }
  xaxis.cross(up,zaxis);
  n=xaxis.norm();
  if (n > 1e-6) {
    xaxis.scale(1.0 / n);
    yaxis.cross(zaxis,xaxis);
    yaxis.normalize();
  }
 else {
    RotationMatrix3d R=new RotationMatrix3d();
    R.rotateZDirection(zaxis);
    R.getColumn(1,yaxis);
    R.getColumn(0,xaxis);
  }
synchronized (viewMatrix) {
    viewMatrix.set(new double[]{xaxis.x,xaxis.y,xaxis.z,-xaxis.dot(eye),yaxis.x,yaxis.y,yaxis.z,-yaxis.dot(eye),zaxis.x,zaxis.y,zaxis.z,-zaxis.dot(eye)});
  }
  if (Math.abs(viewMatrix.getOffset().norm()) < 1e-5) {
    System.err.println("String_Node_Str");
    Thread.dumpStack();
  }
  invalidateViewMatrix();
}

Fixed version (ground truth):
/** 
 * Sets the eyeToWorld transform for this viewer, using the canonical parameters used by the GL <code>lookat</code> method.
 * @param eye position of the eye, in world coordinates
 * @param center point that the eye is looking at, in world coordinates
 * @param up up direction, in world coordinates
 */
public void setEyeToWorld(Point3d eye,Point3d center,Vector3d up){
  Vector3d zaxis=new Vector3d();
  Vector3d yaxis=new Vector3d();
  Vector3d xaxis=new Vector3d();
  zaxis.sub(eye,center);
  double n=zaxis.norm();
  if (n > 1e-12) {
    zaxis.scale(1.0 / n);
  }
 else {
    RotationMatrix3d R=new RotationMatrix3d();
    R.rotateZDirection(up);
    R.getColumn(0,zaxis);
    R.getColumn(1,xaxis);
    R.getColumn(2,yaxis);
  }
  xaxis.cross(up,zaxis);
  n=xaxis.norm();
  if (n > 1e-6) {
    xaxis.scale(1.0 / n);
    yaxis.cross(zaxis,xaxis);
    yaxis.normalize();
  }
 else {
    RotationMatrix3d R=new RotationMatrix3d();
    R.rotateZDirection(zaxis);
    R.getColumn(1,yaxis);
    R.getColumn(0,xaxis);
  }
synchronized (viewMatrix) {
    viewMatrix.set(new double[]{xaxis.x,xaxis.y,xaxis.z,-xaxis.dot(eye),yaxis.x,yaxis.y,yaxis.z,-yaxis.dot(eye),zaxis.x,zaxis.y,zaxis.z,-zaxis.dot(eye)});
  }
  if (Math.abs(viewMatrix.getOffset().norm()) < 1e-5) {
  }
  invalidateViewMatrix();
}
Program: 70772
Project: 70772
Buggy source:
public Object clone(){
  try {
    return super.clone();
  }
 catch (  CloneNotSupportedException e) {
    throw new InternalErrorException("String_Node_Str");
  }
}

Fixed version (ground truth):
public Matrix3dBase clone(){
  try {
    return (Matrix3dBase)super.clone();
  }
 catch (  CloneNotSupportedException e) {
    throw new InternalErrorException("String_Node_Str");
  }
}
Program: 70773
Project: 70773
Buggy source:
private void disableTransparency(GL2 gl){
  if (!alphaFaceCulling) {
    gl.glEnable(GL2.GL_CULL_FACE);
    gl.glDepthMask(true);
  }
  gl.glDisable(GL2.GL_BLEND);
}

Fixed version (ground truth):
private void disableTransparency(GL2 gl){
  if (!alphaFaceCulling) {
    setFaceStyle(FaceStyle.FRONT);
    gl.glDepthMask(true);
  }
  gl.glDisable(GL2.GL_BLEND);
}
Program: 70775
Project: 70775
Buggy source:
private void enableTransparency(GL2 gl){
  gl.glEnable(GL2.GL_BLEND);
  if (!alphaFaceCulling) {
    gl.glDepthMask(false);
    gl.glDisable(GL2.GL_CULL_FACE);
  }
  gl.glBlendFunc(sBlending.value(),dBlending.value());
}

Fixed version (ground truth):
private void enableTransparency(GL2 gl){
  gl.glEnable(GL2.GL_BLEND);
  if (!alphaFaceCulling) {
    gl.glDepthMask(false);
    setFaceStyle(FaceStyle.FRONT_AND_BACK);
  }
  gl.glBlendFunc(sBlending.value(),dBlending.value());
}
Program: 70776
Project: 70776
Buggy source:
public void display(GLAutoDrawable drawable,int flags){
  if (!myInternalRenderListValid) {
    buildInternalRenderList();
  }
  maybeUpdateState(gl);
  gl.glPushMatrix();
  if (selectTrigger) {
    mySelector.setupSelection(drawable);
    selectEnabled=true;
    selectTrigger=false;
  }
  drawable.setAutoSwapBufferMode(selectEnabled ? false : true);
  doDisplay(drawable,flags);
  if (selectEnabled) {
    selectEnabled=false;
    mySelector.processSelection(drawable);
  }
 else {
    fireRerenderListeners();
  }
  gl.glPopMatrix();
  if (frameCapture != null) {
synchronized (frameCapture) {
      if (grab) {
        offscreenCapture(flags);
        grab=false;
      }
      if (grabWaitComplete) {
        frameCapture.waitForCompletion();
        grabWaitComplete=false;
      }
      if (grabClose) {
        frameCapture.waitForCompletion();
        frameCapture.dispose(gl);
        frameCapture=null;
      }
    }
  }
}

Fixed version (ground truth):
public void display(GLAutoDrawable drawable,int flags){
  this.drawable=drawable;
  this.gl=drawable.getGL().getGL2();
  if (!myInternalRenderListValid) {
    buildInternalRenderList();
  }
  maybeUpdateState(gl);
  gl.glPushMatrix();
  if (selectTrigger) {
    mySelector.setupSelection(drawable);
    selectEnabled=true;
    selectTrigger=false;
  }
  drawable.setAutoSwapBufferMode(selectEnabled ? false : true);
  doDisplay(drawable,flags);
  if (selectEnabled) {
    selectEnabled=false;
    mySelector.processSelection(drawable);
  }
 else {
    fireRerenderListeners();
  }
  gl.glPopMatrix();
  if (frameCapture != null) {
synchronized (frameCapture) {
      if (grab) {
        offscreenCapture(flags);
        grab=false;
      }
      if (grabWaitComplete) {
        frameCapture.waitForCompletion();
        grabWaitComplete=false;
      }
      if (grabClose) {
        frameCapture.waitForCompletion();
        frameCapture.dispose(gl);
        frameCapture=null;
      }
    }
  }
  this.drawable=null;
  this.gl=null;
}
Program: 70777
Project: 70777
Buggy source:
/** 
 * Draw triangular faces, using the current Shading, lighting and material, and computing a single "face" normal from the coordinates (so the current "shading" really matters only if it is Shading.NONE).
 */
public void drawTriangle(float[] pnt0,float[] pnt1,float[] pnt2){
  GL2 gl=getGL2();
  maybeUpdateState(gl);
  float[] normal=new float[3];
  computeNormal(pnt0,pnt1,pnt2,normal);
  gl.glBegin(GL2.GL_TRIANGLES);
  gl.glNormal3fv(normal,0);
  gl.glVertex3fv(pnt0,0);
  gl.glVertex3fv(pnt1,0);
  gl.glVertex3fv(pnt2,0);
  gl.glEnd();
}

Fixed version (ground truth):
/** 
 * Draw triangular faces, using the current Shading, lighting and material, and computing a single "face" normal from the coordinates (so the current "shading" really matters only if it is Shading.NONE).
 */
public void drawTriangle(float[] pnt0,float[] pnt1,float[] pnt2){
  GLSupport.checkAndPrintGLError(gl);
  GL2 gl=getGL2();
  maybeUpdateState(gl);
  float[] normal=new float[3];
  computeNormal(pnt0,pnt1,pnt2,normal);
  gl.glBegin(GL2.GL_TRIANGLES);
  gl.glNormal3fv(normal,0);
  gl.glVertex3fv(pnt0,0);
  gl.glVertex3fv(pnt1,0);
  gl.glVertex3fv(pnt2,0);
  gl.glEnd();
}
Program: 70778
Project: 70778
Buggy source:
@Override public void begin2DRendering(double left,double right,double bottom,double top){
  int attribBits=(GL2.GL_ENABLE_BIT | GL2.GL_TEXTURE_BIT | GL2.GL_COLOR_BUFFER_BIT| GL2.GL_DEPTH_BUFFER_BIT| GL2.GL_TRANSFORM_BIT);
  gl.glPushAttrib(attribBits);
  setLightingOn(false);
  gl.glDisable(GL2.GL_DEPTH_TEST);
  gl.glDisable(GL2.GL_CULL_FACE);
  gl.glMatrixMode(GL2.GL_TEXTURE);
  gl.glPushMatrix();
  gl.glLoadIdentity();
  pushModelMatrix();
  pushViewMatrix();
  super.pushProjectionMatrix();
  setModelMatrix(RigidTransform3d.IDENTITY);
  setViewMatrix(RigidTransform3d.IDENTITY);
  setOrthogonal2d(left,right,bottom,top);
  rendering2d=true;
}

Fixed version (ground truth):
@Override public void begin2DRendering(double left,double right,double bottom,double top){
  int attribBits=(GL2.GL_ENABLE_BIT | GL2.GL_TEXTURE_BIT | GL2.GL_COLOR_BUFFER_BIT| GL2.GL_DEPTH_BUFFER_BIT| GL2.GL_TRANSFORM_BIT);
  gl.glPushAttrib(attribBits);
  setLightingOn(false);
  gl.glDisable(GL2.GL_DEPTH_TEST);
  setFaceStyle(FaceStyle.FRONT_AND_BACK);
  gl.glMatrixMode(GL2.GL_TEXTURE);
  gl.glPushMatrix();
  gl.glLoadIdentity();
  pushModelMatrix();
  pushViewMatrix();
  super.pushProjectionMatrix();
  setModelMatrix(RigidTransform3d.IDENTITY);
  setViewMatrix(RigidTransform3d.IDENTITY);
  setOrthogonal2d(left,right,bottom,top);
  rendering2d=true;
}
Program: 70779
Project: 70779
Buggy source:
/** 
 * First orphans the original buffer, potentially causing a re-allocation, then returns a mapped buffer ready for writing.
 */
public ByteBuffer mapNewBuffer(GL3 gl){
  gl.glBindBuffer(target,boId);
  gl.glBufferData(target,size,null,usage);
  return gl.glMapBuffer(target,GL.GL_WRITE_ONLY);
}

Fixed version (ground truth):
/** 
 * First orphans the original buffer, potentially causing a re-allocation, then returns a mapped buffer ready for writing.
 */
public ByteBuffer mapNewBuffer(GL3 gl){
  bind(gl);
  gl.glBufferData(target,size,null,usage);
  return gl.glMapBuffer(target,GL.GL_WRITE_ONLY);
}
Program: 70780
Project: 70780
Buggy source:
public void update(GL3 gl,ByteBuffer buff,int start,int size){
  gl.glBindBuffer(target,boId);
  if (start == 0 && size >= this.size) {
    gl.glBufferData(target,size,null,usage);
  }
  gl.glBufferSubData(target,start * GLSupport.BYTE_SIZE,size * GLSupport.BYTE_SIZE,buff);
}

Fixed version (ground truth):
public void update(GL3 gl,ByteBuffer buff,int start,int size){
  bind(gl);
  if (start == 0 && size >= this.size) {
    gl.glBufferData(target,size,null,usage);
  }
  gl.glBufferSubData(target,start * GLSupport.BYTE_SIZE,size * GLSupport.BYTE_SIZE,buff);
}
Program: 70781
Project: 70781
Buggy source:
public void fill(GL3 gl,ByteBuffer buff,int size,int usage){
  setInfo(size * GLSupport.BYTE_SIZE,usage);
  gl.glBindBuffer(target,boId);
  gl.glBufferData(target,size * GLSupport.BYTE_SIZE,buff,usage);
}

Fixed version (ground truth):
public void fill(GL3 gl,ByteBuffer buff,int size,int usage){
  setInfo(size * GLSupport.BYTE_SIZE,usage);
  bind(gl);
  gl.glBufferData(target,size * GLSupport.BYTE_SIZE,buff,usage);
}
Program: 70782
Project: 70782
Buggy source:
/** 
 * Retrieve a mapped buffer to the underlying VBO data
 * @param gl
 * @param access either GL3.GL_WRITE_ONLY, GL3.GL_READ_ONLY, or GL3.GL_READ_WRITE;
 * @return the mapped buffer
 */
public ByteBuffer mapBuffer(GL3 gl,int access){
  gl.glBindBuffer(target,boId);
  return gl.glMapBuffer(target,access);
}

Fixed version (ground truth):
/** 
 * Retrieve a mapped buffer to the underlying VBO data
 * @param gl
 * @param access either GL3.GL_WRITE_ONLY, GL3.GL_READ_ONLY, or GL3.GL_READ_WRITE;
 * @return the mapped buffer
 */
public ByteBuffer mapBuffer(GL3 gl,int access){
  bind(gl);
  return gl.glMapBuffer(target,access);
}
Program: 70783
Project: 70783
Buggy source:
public void bind(GL3 gl){
  if (target == 0) {
    System.err.println("String_Node_Str");
  }
  gl.glBindBuffer(target,boId);
}

Fixed version (ground truth):
public void bind(GL3 gl){
  System.out.println("String_Node_Str" + boId + "String_Node_Str"+ target+ "String_Node_Str");
  gl.glBindBuffer(target,boId);
}
Program: 70784
Project: 70784
Buggy source:
public void allocate(GL3 gl,int size,int usage){
  setInfo(size,usage);
  gl.glBindBuffer(target,boId);
  gl.glBufferData(target,size,null,usage);
}

Fixed version (ground truth):
public void allocate(GL3 gl,int size,int usage){
  setInfo(size,usage);
  bind(gl);
  gl.glBufferData(target,size,null,usage);
}
Program: 70785
Project: 70785
Buggy source:
/** 
 * Maps only a portion of the underlying buffer
 */
public ByteBuffer mapBufferRange(GL3 gl,int offset,int length,int access){
  gl.glBindBuffer(target,boId);
  return gl.glMapBufferRange(target,offset,length,access);
}

Fixed version (ground truth):
/** 
 * Maps only a portion of the underlying buffer
 */
public ByteBuffer mapBufferRange(GL3 gl,int offset,int length,int access){
  bind(gl);
  return gl.glMapBufferRange(target,offset,length,access);
}
Program: 70786
Project: 70786
Buggy source:
private void drawPoints(Renderer renderer,int gidx,RenderProps props,boolean selected){
  Shading savedShading=renderer.setPointShading(props);
  renderer.setPointColoring(props,selected);
switch (props.getPointStyle()) {
case POINT:
{
      int size=props.getPointSize();
      if (size > 0) {
        renderer.drawPoints(myRob,gidx,PointStyle.POINT,size);
      }
      break;
    }
case SPHERE:
{
    double rad=props.getPointRadius();
    if (rad > 0) {
      renderer.drawPoints(myRob,gidx,PointStyle.SPHERE,rad);
    }
    break;
  }
}
renderer.setShading(savedShading);
}

Fixed version (ground truth):
private void drawPoints(Renderer renderer,int gidx,RenderProps props,boolean selected){
  Shading savedShading=renderer.setPointShading(props);
  renderer.setPointColoring(props,selected);
  PointStyle style=props.getPointStyle();
switch (style) {
case POINT:
{
      int size=props.getPointSize();
      if (size > 0) {
        renderer.drawPoints(myRob,gidx,PointStyle.POINT,size);
      }
      break;
    }
case CUBE:
case SPHERE:
{
    double rad=props.getPointRadius();
    if (rad > 0) {
      renderer.drawPoints(myRob,gidx,style,rad);
    }
    break;
  }
}
renderer.setShading(savedShading);
}
Program: 70787
Project: 70787
Buggy source:
public void render(Renderer renderer,int flags){
  RenderProps props=myRenderProps;
  if (renderer.isSelecting()) {
    PointStyle style=props.getPointStyle();
    if (style == PointStyle.POINT) {
      int size=props.getPointSize();
      if (size > 0) {
        renderer.setPointSize(size);
      }
 else {
        return;
      }
    }
    for (int i=0; i < size(); i++) {
      Point pnt=get(i);
      if (pnt.getRenderProps() == null && renderer.isSelectable(pnt)) {
        float[] v0=pnt.myRenderCoords;
        renderer.beginSelectionQuery(i);
switch (style) {
case POINT:
{
            renderer.drawPoint(v0);
            break;
          }
case SPHERE:
{
          renderer.drawSphere(v0,props.getPointRadius());
          break;
        }
    }
    renderer.endSelectionQuery();
  }
}
if (style == PointStyle.POINT) {
  renderer.setPointSize(1);
}
}
 else if (myRob != null) {
int numReg=myRob.numPoints(REG_GRP);
int numSel=myRob.numPoints(SEL_GRP);
if (numSel > 0) {
  drawPoints(renderer,SEL_GRP,props,true);
}
if (numReg > 0) {
  drawPoints(renderer,REG_GRP,props,false);
}
}
}

Fixed version (ground truth):
public void render(Renderer renderer,int flags){
  RenderProps props=myRenderProps;
  if (renderer.isSelecting()) {
    PointStyle style=props.getPointStyle();
    if (style == PointStyle.POINT) {
      int size=props.getPointSize();
      if (size > 0) {
        renderer.setPointSize(size);
      }
 else {
        return;
      }
    }
    for (int i=0; i < size(); i++) {
      Point pnt=get(i);
      if (pnt.getRenderProps() == null && renderer.isSelectable(pnt)) {
        float[] v0=pnt.myRenderCoords;
        renderer.beginSelectionQuery(i);
switch (style) {
case POINT:
{
            renderer.drawPoint(v0);
            break;
          }
case CUBE:
{
          renderer.drawCube(v0,2 * props.getPointRadius());
        }
case SPHERE:
{
        renderer.drawSphere(v0,props.getPointRadius());
        break;
      }
  }
  renderer.endSelectionQuery();
}
}
if (style == PointStyle.POINT) {
renderer.setPointSize(1);
}
}
 else if (myRob != null) {
int numReg=myRob.numPoints(REG_GRP);
int numSel=myRob.numPoints(SEL_GRP);
if (numSel > 0) {
drawPoints(renderer,SEL_GRP,props,true);
}
if (numReg > 0) {
drawPoints(renderer,REG_GRP,props,false);
}
}
}
Program: 70792
Project: 70792
Buggy source:
public void render(Renderer renderer,PointMesh mesh,RenderProps props,boolean selected){
  if (mesh.numVertices() == 0) {
    return;
  }
  renderer.pushModelMatrix();
  if (mesh.isRenderBuffered()) {
    renderer.mulModelMatrix(mesh.getXMeshToWorldRender());
  }
 else {
    renderer.mulModelMatrix(mesh.XMeshToWorld);
  }
  float savedLineWidth=renderer.getLineWidth();
  Shading savedShadeModel=renderer.getShading();
  PointStyle pointStyle=props.getPointStyle();
  if (pointStyle == PointStyle.POINT && !mesh.hasNormals()) {
    renderer.setShading(Shading.NONE);
  }
 else {
    renderer.setShading(props.getShading());
  }
  ColorInterpolation savedColorInterp=null;
  if (usingHSV(mesh)) {
    savedColorInterp=renderer.setColorInterpolation(ColorInterpolation.HSV);
  }
  renderer.setPointColoring(props,selected);
switch (pointStyle) {
case POINT:
{
      int size=props.getPointSize();
      if (size > 0) {
        renderer.drawPoints(myRob,PointStyle.POINT,size);
      }
      break;
    }
case SPHERE:
{
    double rad=props.getPointRadius();
    if (rad > 0) {
      renderer.drawPoints(myRob,PointStyle.SPHERE,rad);
    }
    break;
  }
}
if (savedColorInterp != null) {
renderer.setColorInterpolation(savedColorInterp);
}
if (mesh.getNormalRenderLen() > 0) {
renderer.setLineWidth(props.getLineWidth());
renderer.setLineColoring(props,selected);
renderer.drawLines(myRob);
}
renderer.setLineWidth(savedLineWidth);
renderer.setShading(savedShadeModel);
renderer.popModelMatrix();
}

Fixed version (ground truth):
public void render(Renderer renderer,PointMesh mesh,RenderProps props,boolean selected){
  if (mesh.numVertices() == 0) {
    return;
  }
  renderer.pushModelMatrix();
  if (mesh.isRenderBuffered()) {
    renderer.mulModelMatrix(mesh.getXMeshToWorldRender());
  }
 else {
    renderer.mulModelMatrix(mesh.XMeshToWorld);
  }
  float savedLineWidth=renderer.getLineWidth();
  Shading savedShadeModel=renderer.getShading();
  PointStyle pointStyle=props.getPointStyle();
  if (pointStyle == PointStyle.POINT && !mesh.hasNormals()) {
    renderer.setShading(Shading.NONE);
  }
 else {
    renderer.setShading(props.getShading());
  }
  ColorInterpolation savedColorInterp=null;
  if (usingHSV(mesh)) {
    savedColorInterp=renderer.setColorInterpolation(ColorInterpolation.HSV);
  }
  renderer.setPointColoring(props,selected);
switch (pointStyle) {
case POINT:
{
      int size=props.getPointSize();
      if (size > 0) {
        renderer.drawPoints(myRob,PointStyle.POINT,size);
      }
      break;
    }
case CUBE:
case SPHERE:
{
    double rad=props.getPointRadius();
    if (rad > 0) {
      renderer.drawPoints(myRob,pointStyle,rad);
    }
    break;
  }
}
if (savedColorInterp != null) {
renderer.setColorInterpolation(savedColorInterp);
}
if (mesh.getNormalRenderLen() > 0) {
renderer.setLineWidth(props.getLineWidth());
renderer.setLineColoring(props,selected);
renderer.drawLines(myRob);
}
renderer.setLineWidth(savedLineWidth);
renderer.setShading(savedShadeModel);
renderer.popModelMatrix();
}
Program: 70800
Project: 70800
Buggy source:
@Override public GL2DisplayList acquire(){
  System.out.println("String_Node_Str" + listId + "String_Node_Str"+ this+ "String_Node_Str");
  return (GL2DisplayList)super.acquire();
}

Fixed version (ground truth):
@Override public GL2DisplayList acquire(){
  return (GL2DisplayList)super.acquire();
}
Program: 70801
Project: 70801
Buggy source:
@Override public void dispose(){
  if (displayList != null) {
    System.out.println("String_Node_Str" + this + "String_Node_Str");
    displayList.release();
    displayList=null;
  }
}

Fixed version (ground truth):
@Override public void dispose(GL2 gl){
  if (displayList != null) {
    displayList.releaseDispose(gl);
    displayList=null;
  }
}
Program: 70802
Project: 70802
Buggy source:
public GL2Object(GL2DisplayList displayList){
  this.displayList=displayList.acquire();
  System.out.println("String_Node_Str" + this + "String_Node_Str");
}

Fixed version (ground truth):
public GL2Object(GL2DisplayList displayList){
  this.displayList=displayList.acquire();
}
Program: 70803
Project: 70803
Buggy source:
public PrimitiveKey(PrimitiveType type,int resolution,boolean capped){
  this.type=type;
  this.resolution=resolution;
switch (type) {
case CONE:
case CYLINDER:
    this.capped=capped;
  break;
case SPHERE:
case SPINDLE:
this.capped=false;
break;
}
}

Fixed version (ground truth):
public PrimitiveKey(PrimitiveType type,int resolution,boolean capped){
  this.type=type;
switch (type) {
case CONE:
case CYLINDER:
    this.resolution=resolution;
  this.capped=capped;
break;
case SPHERE:
case SPINDLE:
this.resolution=resolution;
this.capped=false;
break;
case CUBE:
this.capped=false;
this.resolution=0;
break;
}
}
Program: 70804
Project: 70804
Buggy source:
@Deprecated public int getNormalSetIdx(){
  return normalSetIdx;
}

Fixed version (ground truth):
@Deprecated public int getNormalSetIdx(){
  return 0;
}
Program: 70805
Project: 70805
Buggy source:
@Deprecated public int getPositionSetIdx(){
  return positionSetIdx;
}

Fixed version (ground truth):
@Deprecated public int getPositionSetIdx(){
  return 0;
}
Program: 70806
Project: 70806
Buggy source:
@Deprecated public int getTextureCoordSetIdx(){
  return textureSetIdx;
}

Fixed version (ground truth):
@Deprecated public int getTextureCoordSetIdx(){
  return 0;
}
Program: 70807
Project: 70807
Buggy source:
@Deprecated public int numNormalSets(){
  return numNormalSets;
}

Fixed version (ground truth):
@Deprecated public int numNormalSets(){
  if (hasNormals()) {
    return 1;
  }
  return 0;
}
Program: 70808
Project: 70808
Buggy source:
@Deprecated public int numTextureCoordSets(){
  return numTextureSets;
}

Fixed version (ground truth):
@Deprecated public int numTextureCoordSets(){
  if (hasTextureCoords()) {
    return 1;
  }
  return 0;
}
Program: 70809
Project: 70809
Buggy source:
@Deprecated public int numPositionSets(){
  return numPositionSets;
}

Fixed version (ground truth):
@Deprecated public int numPositionSets(){
  if (hasPositions()) {
    return 1;
  }
  return 0;
}
Program: 70810
Project: 70810
Buggy source:
@Deprecated public int getColorSetIdx(){
  return colorSetIdx;
}

Fixed version (ground truth):
@Deprecated public int getColorSetIdx(){
  return 0;
}
Program: 70811
Project: 70811
Buggy source:
/** 
 * Retrieves the normal at the supplied index.  If the returned normal is modified, then   {@link #notifyNormalsModified()} mustbe called.
 * @param nidx normal index
 * @return normal {x,y,z}
 */
public float[] getNormal(int nidx){
  if (nidx < 0) {
    return null;
  }
  return normals.get(nidx);
}

Fixed version (ground truth):
@Deprecated public float[] getNormal(int gidx,int idx){
  return getNormal(idx);
}
Program: 70812
Project: 70812
Buggy source:
@Deprecated public int numColorSets(){
  return numColorSets;
}

Fixed version (ground truth):
@Deprecated public int numColorSets(){
  if (hasColors()) {
    return 1;
  }
  return 0;
}
Program: 70813
Project: 70813
Buggy source:
/** 
 * Retrieves the texture coordinate at the supplied index.  If the returned texture coordinate is modified, then   {@link #notifyTextureCoordsModified()} must be manually called.
 * @param tidx position index
 * @return texture coordinate {x,y}
 */
public float[] getTextureCoord(int tidx){
  if (tidx < 0) {
    return null;
  }
  return texcoords.get(tidx);
}

Fixed version (ground truth):
@Deprecated public float[] getTextureCoord(int gidx,int idx){
  return getTextureCoord(idx);
}
Program: 70815
Project: 70815
Buggy source:
/** 
 * Retrieves the color at the supplied index.  If the returned color is modified, then   {@link #notifyColorsModified()} must be manually called.
 * @param cidx color index
 * @return color {red, green, blue, alpha}
 */
public byte[] getColor(int cidx){
  if (cidx < 0) {
    return null;
  }
  return colors.get(cidx);
}

Fixed version (ground truth):
@Deprecated public byte[] getColor(int gidx,int idx){
  return getColor(idx);
}
Program: 70816
Project: 70816
Buggy source:
/** 
 * Retrieves the position at the supplied index.  If the returned position is modified, then   {@link #notifyPositionsModified()} must be manually called.
 * @param pidx position index
 * @return position {x,y,z}
 */
public float[] getPosition(int pidx){
  if (pidx < 0) {
    return null;
  }
  return positions.get(pidx);
}

Fixed version (ground truth):
@Deprecated public float[] getPosition(int gidx,int idx){
  return getPosition(idx);
}
Program: 70818
Project: 70818
Buggy source:
private void drawPoints(Renderer renderer,RenderProps props,boolean selected){
  Shading savedShading=renderer.setPointShading(props);
  renderer.setPointColoring(props,selected);
switch (props.getPointStyle()) {
case POINT:
{
      int size=props.getPointSize();
      if (size > 0) {
        renderer.drawPoints(myRob,PointStyle.POINT,size);
      }
      break;
    }
case SPHERE:
{
    double rad=props.getPointRadius();
    if (rad > 0) {
      renderer.drawPoints(myRob,PointStyle.SPHERE,rad);
    }
    break;
  }
}
renderer.setShading(savedShading);
}

Fixed version (ground truth):
private void drawPoints(Renderer renderer,int gidx,RenderProps props,boolean selected){
  Shading savedShading=renderer.setPointShading(props);
  renderer.setPointColoring(props,selected);
switch (props.getPointStyle()) {
case POINT:
{
      int size=props.getPointSize();
      if (size > 0) {
        renderer.drawPoints(myRob,gidx,PointStyle.POINT,size);
      }
      break;
    }
case SPHERE:
{
    double rad=props.getPointRadius();
    if (rad > 0) {
      renderer.drawPoints(myRob,gidx,PointStyle.SPHERE,rad);
    }
    break;
  }
}
renderer.setShading(savedShading);
}
Program: 70819
Project: 70819
Buggy source:
public void render(Renderer renderer,int flags){
  RenderProps props=myRenderProps;
  if (renderer.isSelecting()) {
    PointStyle style=props.getPointStyle();
    if (style == PointStyle.POINT) {
      int size=props.getPointSize();
      if (size > 0) {
        renderer.setPointSize(size);
      }
 else {
        return;
      }
    }
    for (int i=0; i < size(); i++) {
      Point pnt=get(i);
      if (pnt.getRenderProps() == null && renderer.isSelectable(pnt)) {
        float[] v0=pnt.myRenderCoords;
        renderer.beginSelectionQuery(i);
switch (style) {
case POINT:
{
            renderer.drawPoint(v0);
            break;
          }
case SPHERE:
{
          renderer.drawSphere(v0,props.getPointRadius());
          break;
        }
    }
    renderer.endSelectionQuery();
  }
}
if (style == PointStyle.POINT) {
  renderer.setPointSize(1);
}
}
 else if (myRob != null) {
int numReg=myRob.numPoints(REG_GRP);
int numSel=myRob.numPoints(SEL_GRP);
if (numReg > 0) {
  myRob.pointGroup(REG_GRP);
  drawPoints(renderer,props,false);
}
if (numSel > 0) {
  myRob.pointGroup(SEL_GRP);
  drawPoints(renderer,props,true);
}
}
}

Fixed version (ground truth):
public void render(Renderer renderer,int flags){
  RenderProps props=myRenderProps;
  if (renderer.isSelecting()) {
    PointStyle style=props.getPointStyle();
    if (style == PointStyle.POINT) {
      int size=props.getPointSize();
      if (size > 0) {
        renderer.setPointSize(size);
      }
 else {
        return;
      }
    }
    for (int i=0; i < size(); i++) {
      Point pnt=get(i);
      if (pnt.getRenderProps() == null && renderer.isSelectable(pnt)) {
        float[] v0=pnt.myRenderCoords;
        renderer.beginSelectionQuery(i);
switch (style) {
case POINT:
{
            renderer.drawPoint(v0);
            break;
          }
case SPHERE:
{
          renderer.drawSphere(v0,props.getPointRadius());
          break;
        }
    }
    renderer.endSelectionQuery();
  }
}
if (style == PointStyle.POINT) {
  renderer.setPointSize(1);
}
}
 else if (myRob != null) {
int numReg=myRob.numPoints(REG_GRP);
int numSel=myRob.numPoints(SEL_GRP);
if (numReg > 0) {
  drawPoints(renderer,REG_GRP,props,false);
}
if (numSel > 0) {
  drawPoints(renderer,SEL_GRP,props,true);
}
}
}
Program: 70820
Project: 70820
Buggy source:
public void maybeUpdateMaterials(GL2 gl){
  if (myCurrentMaterialModified && !isSelecting()) {
    if (mySelectedColorActive) {
      mySelectedColor[3]=myCurrentMaterial.getAlpha();
      gl.glColor4fv(mySelectedColor,0);
      myCurrentMaterial.apply(gl);
      gl.glMaterialfv(GL2.GL_FRONT_AND_BACK,GL2.GL_AMBIENT_AND_DIFFUSE,mySelectedColor,0);
    }
 else {
      gl.glColor4fv(myCurrentMaterial.getDiffuse(),0);
      myCurrentMaterial.apply(gl);
      if (myBackColor != null) {
        gl.glMaterialfv(GL2.GL_BACK,GL2.GL_AMBIENT_AND_DIFFUSE,myBackColor,0);
      }
    }
    myCurrentMaterialModified=false;
  }
}

Fixed version (ground truth):
public void maybeUpdateMaterials(GL2 gl){
  if (myCurrentMaterialModified) {
    if (isSelecting()) {
      gl.glColor4fv(mySelectingColor,0);
      myCurrentMaterial.apply(gl);
      gl.glMaterialfv(GL2.GL_FRONT_AND_BACK,GL2.GL_AMBIENT_AND_DIFFUSE,mySelectingColor,0);
    }
 else {
      if (mySelectedColorActive) {
        mySelectedColor[3]=myCurrentMaterial.getAlpha();
        gl.glColor4fv(mySelectedColor,0);
        myCurrentMaterial.apply(gl);
        gl.glMaterialfv(GL2.GL_FRONT_AND_BACK,GL2.GL_AMBIENT_AND_DIFFUSE,mySelectedColor,0);
      }
 else {
        gl.glColor4fv(myCurrentMaterial.getDiffuse(),0);
        myCurrentMaterial.apply(gl);
        if (myBackColor != null) {
          gl.glMaterialfv(GL2.GL_BACK,GL2.GL_AMBIENT_AND_DIFFUSE,myBackColor,0);
        }
      }
    }
    myCurrentMaterialModified=false;
  }
}
Program: 70821
Project: 70821
Buggy source:
public void bindInstancedVertices(GL3 gl,int gidx){
  int vstart=2 * pointGroupOffsets[gidx];
  int loc=pposAttr.getLocation();
  if (positionInfo != null) {
    GL3AttributeStorage storage=positionPutter.storage();
    vbos[positionInfo.vboIndex].bind(gl);
    gl.glEnableVertexAttribArray(loc);
    gl.glVertexAttribPointer(loc,storage.size(),storage.getGLType(),storage.isNormalized(),positionInfo.stride,positionInfo.offset + vstart * positionInfo.stride);
    gl.glVertexAttribDivisor(loc,1);
  }
  loc=pclrAttr.getLocation();
  if (colorInfo != null) {
    GL3AttributeStorage storage=colorPutter.storage();
    vbos[colorInfo.vboIndex].bind(gl);
    gl.glEnableVertexAttribArray(loc);
    gl.glVertexAttribPointer(loc,storage.size(),storage.getGLType(),storage.isNormalized(),colorInfo.stride,colorInfo.offset + vstart * colorInfo.stride);
    gl.glVertexAttribDivisor(loc,1);
  }
}

Fixed version (ground truth):
public void bindInstancedVertices(GL3 gl,int gidx){
  int vstart=pointGroupOffsets[gidx];
  int loc=pposAttr.getLocation();
  if (positionInfo != null) {
    GL3AttributeStorage storage=positionPutter.storage();
    vbos[positionInfo.vboIndex].bind(gl);
    gl.glEnableVertexAttribArray(loc);
    gl.glVertexAttribPointer(loc,storage.size(),storage.getGLType(),storage.isNormalized(),positionInfo.stride,positionInfo.offset + vstart * positionInfo.stride);
    gl.glVertexAttribDivisor(loc,1);
  }
  loc=pclrAttr.getLocation();
  if (colorInfo != null) {
    GL3AttributeStorage storage=colorPutter.storage();
    vbos[colorInfo.vboIndex].bind(gl);
    gl.glEnableVertexAttribArray(loc);
    gl.glVertexAttribPointer(loc,storage.size(),storage.getGLType(),storage.isNormalized(),colorInfo.stride,colorInfo.offset + vstart * colorInfo.stride);
    gl.glVertexAttribDivisor(loc,1);
  }
}