nus-yam/ex-repair huggingface dataset:
Program: 163650
Project: 163650
Buggy source:
protected void restoreGL(){
  blendMode(blendMode);
  if (hints[DISABLE_DEPTH_TEST]) {
    pgl.disable(PGL.DEPTH_TEST);
  }
 else {
    pgl.enable(PGL.DEPTH_TEST);
  }
  pgl.depthFunc(PGL.LEQUAL);
  if (quality < 2) {
    pgl.disable(PGL.MULTISAMPLE);
  }
 else {
    pgl.enable(PGL.MULTISAMPLE);
    pgl.disable(PGL.POINT_SMOOTH);
    pgl.disable(PGL.LINE_SMOOTH);
    pgl.disable(PGL.POLYGON_SMOOTH);
  }
  pgl.viewport(viewport.get(0),viewport.get(1),viewport.get(2),viewport.get(3));
  if (clip) {
    pgl.enable(PGL.SCISSOR_TEST);
    pgl.scissor(clipRect[0],clipRect[1],clipRect[2],clipRect[3]);
  }
 else {
    pgl.disable(PGL.SCISSOR_TEST);
  }
  pgl.frontFace(PGL.CW);
  pgl.disable(PGL.CULL_FACE);
  pgl.activeTexture(PGL.TEXTURE0);
  if (hints[DISABLE_DEPTH_MASK]) {
    pgl.depthMask(false);
  }
 else {
    pgl.depthMask(true);
  }
  currentFramebuffer.bind();
  pgl.drawBuffer(currentFramebuffer.getDefaultDrawBuffer());
}

Fixed version (ground truth):
protected void restoreGL(){
  setBlendMode(blendMode);
  if (hints[DISABLE_DEPTH_TEST]) {
    pgl.disable(PGL.DEPTH_TEST);
  }
 else {
    pgl.enable(PGL.DEPTH_TEST);
  }
  pgl.depthFunc(PGL.LEQUAL);
  if (quality < 2) {
    pgl.disable(PGL.MULTISAMPLE);
  }
 else {
    pgl.enable(PGL.MULTISAMPLE);
    pgl.disable(PGL.POINT_SMOOTH);
    pgl.disable(PGL.LINE_SMOOTH);
    pgl.disable(PGL.POLYGON_SMOOTH);
  }
  pgl.viewport(viewport.get(0),viewport.get(1),viewport.get(2),viewport.get(3));
  if (clip) {
    pgl.enable(PGL.SCISSOR_TEST);
    pgl.scissor(clipRect[0],clipRect[1],clipRect[2],clipRect[3]);
  }
 else {
    pgl.disable(PGL.SCISSOR_TEST);
  }
  pgl.frontFace(PGL.CW);
  pgl.disable(PGL.CULL_FACE);
  pgl.activeTexture(PGL.TEXTURE0);
  if (hints[DISABLE_DEPTH_MASK]) {
    pgl.depthMask(false);
  }
 else {
    pgl.depthMask(true);
  }
  currentFramebuffer.bind();
  pgl.drawBuffer(currentFramebuffer.getDefaultDrawBuffer());
}
Program: 163651
Project: 163651
Buggy source:
protected void drawTexture(int x,int y,int w,int h){
  pgl.drawTexture(texture.glTarget,texture.glName,texture.glWidth,texture.glHeight,x,y,x + w,y + h,x,height - (y + h),x + w,height - y);
}

Fixed version (ground truth):
protected void drawTexture(int x,int y,int w,int h){
  pgl.disable(PGL.BLEND);
  pgl.drawTexture(texture.glTarget,texture.glName,texture.glWidth,texture.glHeight,x,y,x + w,y + h,x,height - (y + h),x + w,height - y);
  pgl.enable(PGL.BLEND);
}
Program: 163653
Project: 163653
Buggy source:
private final float cos(float angle){
  return (float)Math.cos(angle);
}

Fixed version (ground truth):
static private final float cos(float angle){
  return (float)Math.cos(angle);
}
Program: 163654
Project: 163654
Buggy source:
private final float sin(float angle){
  return (float)Math.sin(angle);
}

Fixed version (ground truth):
static private final float sin(float angle){
  return (float)Math.sin(angle);
}
Program: 163655
Project: 163655
Buggy source:
private final float max(float a,float b){
  return (a > b) ? a : b;
}

Fixed version (ground truth):
static private final float max(float a,float b){
  return (a > b) ? a : b;
}
Program: 163656
Project: 163656
Buggy source:
private final float abs(float a){
  return (a < 0) ? -a : a;
}

Fixed version (ground truth):
static private final float abs(float a){
  return (a < 0) ? -a : a;
}
Program: 163658
Project: 163658
Buggy source:
protected void beginDraw(boolean clear0){
  if (!clear0 && glColorFbo[0] != 0) {
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,glColorFbo[0]);
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,glColorTex[backTex],0);
    usingFBOlayer=true;
  }
 else {
    usingFBOlayer=false;
  }
}

Fixed version (ground truth):
protected void beginDraw(boolean clear0){
  if ((!clear0 || FORCE_SCREEN_FBO) && glColorFbo[0] != 0) {
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,glColorFbo[0]);
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,glColorTex[backTex],0);
    if (firstFrame) {
      GLES20.glClearColor(0,0,0,0);
      GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
    }
 else     if (!clear0) {
      drawTexture(GLES20.GL_TEXTURE_2D,glColorTex[frontTex],fboWidth,fboHeight,0,0,pg.width,pg.height,0,0,pg.width,pg.height);
    }
    usingFBOlayer=true;
  }
 else {
    usingFBOlayer=false;
  }
  if (firstFrame) {
    firstFrame=false;
  }
}
Program: 163659
Project: 163659
Buggy source:
protected void endDraw(boolean clear){
  if (usingFBOlayer) {
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,0);
    GLES20.glClearDepthf(1);
    GLES20.glClearColor(0,0,0,0);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    GLES20.glDisable(GLES20.GL_BLEND);
    drawTexture(GLES20.GL_TEXTURE_2D,glColorTex[backTex],fboWidth,fboHeight,0,0,pg.width,pg.height,0,0,pg.width,pg.height);
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,glColorFbo[0]);
    if (!clear) {
      GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,glColorTex[frontTex],0);
      drawTexture(GLES20.GL_TEXTURE_2D,glColorTex[backTex],fboWidth,fboHeight,0,0,pg.width,pg.height,0,0,pg.width,pg.height);
      GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,glColorTex[backTex],0);
    }
    int temp=frontTex;
    frontTex=backTex;
    backTex=temp;
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,0);
  }
}

Fixed version (ground truth):
protected void endDraw(boolean clear){
  if (usingFBOlayer) {
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,0);
    GLES20.glClearDepthf(1);
    GLES20.glClearColor(0,0,0,0);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    GLES20.glDisable(GLES20.GL_BLEND);
    drawTexture(GLES20.GL_TEXTURE_2D,glColorTex[backTex],fboWidth,fboHeight,0,0,pg.width,pg.height,0,0,pg.width,pg.height);
    int temp=frontTex;
    frontTex=backTex;
    backTex=temp;
  }
}
Program: 163661
Project: 163661
Buggy source:
protected void handleKeyEvent(KeyEvent event){
switch (event.getAction()) {
case KeyEvent.PRESSED:
    keyPressed=true;
  keyPressed();
break;
case KeyEvent.RELEASED:
keyPressed=false;
keyReleased();
break;
}
if (event.getAction() == KeyEvent.PRESSED && event.getKeyCode() == android.view.KeyEvent.KEYCODE_BACK) {
exit();
}
}

Fixed version (ground truth):
protected void handleKeyEvent(KeyEvent event){
switch (event.getAction()) {
case KeyEvent.PRESSED:
    keyPressed=true;
  keyPressed();
break;
case KeyEvent.RELEASED:
keyPressed=false;
keyReleased();
break;
}
handleMethods("String_Node_Str",new Object[]{event});
if (event.getAction() == KeyEvent.PRESSED && event.getKeyCode() == android.view.KeyEvent.KEYCODE_BACK) {
exit();
}
}
Program: 163662
Project: 163662
Buggy source:
static protected void copyGeometry(PShape src,PShape dest){
  copyMatrix(src,dest);
  copyStyles(src,dest);
  copyImage(src,dest);
  if (src.style) {
    for (int i=0; i < src.vertexCount; i++) {
      float[] vert=src.vertices[i];
      dest.normal(vert[PGraphics.NX],vert[PGraphics.NY],vert[PGraphics.NZ]);
      dest.vertex(vert[X],vert[Y],vert[Z],vert[PGraphics.U],vert[PGraphics.V]);
    }
  }
 else {
    for (int i=0; i < src.vertexCount; i++) {
      float[] vert=src.vertices[i];
      if (vert[Z] == 0) {
        dest.vertex(vert[X],vert[Y]);
      }
 else {
        dest.vertex(vert[X],vert[Y],vert[Z]);
      }
    }
  }
  dest.end();
}

Fixed version (ground truth):
static protected void copyGeometry(PShape src,PShape dest){
  copyMatrix(src,dest);
  copyStyles(src,dest);
  copyImage(src,dest);
  if (src.style) {
    for (int i=0; i < src.vertexCount; i++) {
      float[] vert=src.vertices[i];
      dest.fill(vert[PGraphics.R] * 255,vert[PGraphics.G] * 255,vert[PGraphics.B] * 255,vert[PGraphics.A] * 255);
      if (0 < PApplet.dist(vert[PGraphics.NX],vert[PGraphics.NY],vert[PGraphics.NZ],0,0,0)) {
        dest.normal(vert[PGraphics.NX],vert[PGraphics.NY],vert[PGraphics.NZ]);
      }
      dest.vertex(vert[X],vert[Y],vert[Z],vert[PGraphics.U],vert[PGraphics.V]);
    }
  }
 else {
    for (int i=0; i < src.vertexCount; i++) {
      float[] vert=src.vertices[i];
      if (vert[Z] == 0) {
        dest.vertex(vert[X],vert[Y]);
      }
 else {
        dest.vertex(vert[X],vert[Y],vert[Z]);
      }
    }
  }
  dest.end();
}
Program: 163663
Project: 163663
Buggy source:
protected void addChildren(ArrayList<OBJFace> faces,ArrayList<OBJMaterial> materials,ArrayList<PVector> coords,ArrayList<PVector> normals,ArrayList<PVector> texcoords){
  int mtlIdxCur=-1;
  OBJMaterial mtl=null;
  for (int i=0; i < faces.size(); i++) {
    OBJFace face=faces.get(i);
    if (mtlIdxCur != face.matIdx) {
      mtlIdxCur=PApplet.max(0,face.matIdx);
      mtl=materials.get(mtlIdxCur);
    }
    PShape child=new PShapeOBJ(face,mtl,coords,normals,texcoords);
    addChild(child);
  }
}

Fixed version (ground truth):
protected void addChildren(ArrayList<OBJFace> faces,ArrayList<OBJMaterial> materials,ArrayList<PVector> coords,ArrayList<PVector> normals,ArrayList<PVector> texcoords){
  int mtlIdxCur=-1;
  OBJMaterial mtl=null;
  for (int i=0; i < faces.size(); i++) {
    OBJFace face=faces.get(i);
    if (mtlIdxCur != face.matIdx || face.matIdx == -1) {
      mtlIdxCur=PApplet.max(0,face.matIdx);
      mtl=materials.get(mtlIdxCur);
    }
    PShape child=new PShapeOBJ(face,mtl,coords,normals,texcoords);
    addChild(child);
  }
}
Program: 163666
Project: 163666
Buggy source:
static protected PShape loadShapeImpl(PGraphics pg,String filename,String extension){
  PShapeOBJ obj=null;
  if (extension.equals("String_Node_Str")) {
    obj=new PShapeOBJ(pg.parent,filename);
  }
 else   if (extension.equals("String_Node_Str")) {
    try {
      InputStream input=new GZIPInputStream(pg.parent.createInput(filename));
      obj=new PShapeOBJ(pg.parent,PApplet.createReader(input));
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  if (obj != null) {
    boolean prevStroke=pg.stroke;
    int prevTextureMode=pg.textureMode;
    pg.stroke=false;
    pg.textureMode=NORMAL;
    PShapeOpenGL p3d=PShapeOpenGL.createShape3D(pg.parent,obj);
    pg.stroke=prevStroke;
    pg.textureMode=prevTextureMode;
    return p3d;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
static protected PShape loadShapeImpl(PGraphics pg,String filename,String extension){
  PShapeOBJ obj=null;
  if (extension.equals("String_Node_Str")) {
    obj=new PShapeOBJ(pg.parent,filename);
  }
 else   if (extension.equals("String_Node_Str")) {
    try {
      InputStream input=new GZIPInputStream(pg.parent.createInput(filename));
      obj=new PShapeOBJ(pg.parent,PApplet.createReader(input));
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  if (obj != null) {
    int prevTextureMode=pg.textureMode;
    pg.textureMode=NORMAL;
    PShapeOpenGL p3d=PShapeOpenGL.createShape3D(pg.parent,obj);
    pg.textureMode=prevTextureMode;
    return p3d;
  }
 else {
    return null;
  }
}
Program: 163667
Project: 163667
Buggy source:
protected int getTypeFromVertexShader(String filename){
  String[] source=parent.loadStrings(filename);
  Pattern pointPattern=Pattern.compile("String_Node_Str");
  Pattern linePattern=Pattern.compile("String_Node_Str");
  Pattern lightPattern1=Pattern.compile("String_Node_Str");
  Pattern lightPattern2=Pattern.compile("String_Node_Str");
  Pattern texPattern=Pattern.compile("String_Node_Str");
  int type=PShader.COLOR;
  for (int i=0; i < source.length; i++) {
    boolean foundPoint=pointPattern.matcher(source[i]).find();
    boolean foundLine=linePattern.matcher(source[i]).find();
    boolean foundLight=lightPattern1.matcher(source[i]).find() || lightPattern2.matcher(source[i]).find();
    boolean foundTex=texPattern.matcher(source[i]).find();
    if (foundPoint) {
      type=PShader.POINT;
    }
 else     if (foundLine) {
      type=PShader.LINE;
    }
 else     if (foundLight && foundTex) {
      type=PShader.TEXLIGHT;
    }
 else     if (foundLight) {
      type=PShader.LIGHT;
    }
 else     if (foundTex) {
      type=PShader.TEXTURE;
    }
    if (type != PShader.COLOR)     break;
  }
  return type;
}

Fixed version (ground truth):
protected int getTypeFromVertexShader(String filename){
  String[] source=parent.loadStrings(filename);
  Pattern pointPattern=Pattern.compile("String_Node_Str");
  Pattern linePattern=Pattern.compile("String_Node_Str");
  Pattern lightPattern1=Pattern.compile("String_Node_Str");
  Pattern lightPattern2=Pattern.compile("String_Node_Str");
  Pattern texPattern=Pattern.compile("String_Node_Str");
  boolean foundPoint=false;
  boolean foundLine=false;
  boolean foundLight=false;
  boolean foundTex=false;
  for (int i=0; i < source.length; i++) {
    foundPoint|=pointPattern.matcher(source[i]).find();
    foundLine|=linePattern.matcher(source[i]).find();
    foundLight|=lightPattern1.matcher(source[i]).find();
    foundLight|=lightPattern2.matcher(source[i]).find();
    foundTex|=texPattern.matcher(source[i]).find();
  }
  int type=PShader.COLOR;
  if (foundPoint) {
    type=PShader.POINT;
  }
 else   if (foundLine) {
    type=PShader.LINE;
  }
 else   if (foundLight && foundTex) {
    type=PShader.TEXLIGHT;
  }
 else   if (foundLight) {
    type=PShader.LIGHT;
  }
 else   if (foundTex) {
    type=PShader.TEXTURE;
  }
  return type;
}
Program: 163668
Project: 163668
Buggy source:
public final float hue(int what){
  if (what != cacheHsbKey) {
    Color.RGBToHSV((what >> 16) & 0xff,(what >> 8) & 0xff,what & 0xff,cacheHsbValue);
    cacheHsbKey=what;
  }
  return cacheHsbValue[0] * colorModeX;
}

Fixed version (ground truth):
public final float hue(int what){
  if (what != cacheHsbKey) {
    Color.RGBToHSV((what >> 16) & 0xff,(what >> 8) & 0xff,what & 0xff,cacheHsbValue);
    cacheHsbKey=what;
  }
  return (cacheHsbValue[0] / 360f) * colorModeX;
}
Program: 163669
Project: 163669
Buggy source:
protected boolean bufferUpdate(int[] pixels){
  BufferData data=null;
  try {
    data=bufferCache.remove(0);
  }
 catch (  NoSuchElementException ex) {
    PGraphics.showWarning("String_Node_Str");
  }
  if (data != null) {
    if ((data.w != width) || (data.h != height)) {
      init(data.w,data.h);
    }
    bind();
    setNative(data.rgbBuf,0,0,width,height);
    unbind();
    data.rgbBuf.get(pixels);
    convertToARGB(pixels);
    data.dispose();
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
protected boolean bufferUpdate(int[] pixels){
  BufferData data=null;
  try {
    data=bufferCache.remove(0);
  }
 catch (  NoSuchElementException ex) {
    PGraphics.showWarning("String_Node_Str");
  }
  if (data != null) {
    if ((data.w != width) || (data.h != height)) {
      init(data.w,data.h);
    }
    setNative(data.rgbBuf,0,0,width,height);
    data.rgbBuf.get(pixels);
    convertToARGB(pixels);
    data.dispose();
    return true;
  }
 else {
    return false;
  }
}
Program: 163670
Project: 163670
Buggy source:
public void setFrameRate(float framerate){
  pgl.setFramerate(framerate);
}

Fixed version (ground truth):
public void setFrameRate(float frameRate){
  pgl.setFrameRate(frameRate);
}
Program: 163671
Project: 163671
Buggy source:
public Object initCache(PImage img){
  Texture tex=(Texture)img.getCache(pgPrimary);
  if (tex == null || tex.contextIsOutdated()) {
    tex=addTexture(img);
    img.loadPixels();
    tex.set(img.pixels);
  }
  return tex;
}

Fixed version (ground truth):
public Object initCache(PImage img){
  Texture tex=(Texture)img.getCache(pgPrimary);
  if (tex == null || tex.contextIsOutdated()) {
    tex=addTexture(img);
    if (tex != null) {
      img.loadPixels();
      tex.set(img.pixels);
    }
  }
  return tex;
}
Program: 163672
Project: 163672
Buggy source:
void addArc(float a,float b,float c,float d,float start,float stop,boolean fill,boolean stroke,int ellipseMode){
  float x=a;
  float y=b;
  float w=c;
  float h=d;
  if (ellipseMode == CORNERS) {
    w=c - a;
    h=d - b;
  }
 else   if (ellipseMode == RADIUS) {
    x=a - c;
    y=b - d;
    w=c * 2;
    h=d * 2;
  }
 else   if (ellipseMode == CENTER) {
    x=a - c / 2f;
    y=b - d / 2f;
  }
  if (Float.isInfinite(start) || Float.isInfinite(stop))   return;
  if (stop < start)   return;
  while (start < 0) {
    start+=TWO_PI;
    stop+=TWO_PI;
  }
  if (stop - start > TWO_PI) {
    start=0;
    stop=TWO_PI;
  }
  float hr=w / 2f;
  float vr=h / 2f;
  float centerX=x + hr;
  float centerY=y + vr;
  int startLUT=(int)(0.5f + (start / TWO_PI) * SINCOS_LENGTH);
  int stopLUT=(int)(0.5f + (stop / TWO_PI) * SINCOS_LENGTH);
  if (fill) {
    vertex(centerX,centerY,VERTEX);
  }
  int increment=1;
  int pidx, idx;
  pidx=idx=0;
  for (int i=startLUT; i < stopLUT; i+=increment) {
    int ii=i % SINCOS_LENGTH;
    if (ii < 0)     ii+=SINCOS_LENGTH;
    idx=addVertex(centerX + cosLUT[ii] * hr,centerY + sinLUT[ii] * vr,VERTEX);
    if (0 < i) {
      if (stroke)       addEdge(pidx,idx,i == 1,false);
    }
    pidx=idx;
  }
  idx=addVertex(centerX + cosLUT[stopLUT % SINCOS_LENGTH] * hr,centerY + sinLUT[stopLUT % SINCOS_LENGTH] * vr,VERTEX);
  if (stroke)   addEdge(pidx,idx,false,true);
}

Fixed version (ground truth):
void addArc(float a,float b,float c,float d,float start,float stop,boolean fill,boolean stroke,int ellipseMode){
  float x=a;
  float y=b;
  float w=c;
  float h=d;
  if (ellipseMode == CORNERS) {
    w=c - a;
    h=d - b;
  }
 else   if (ellipseMode == RADIUS) {
    x=a - c;
    y=b - d;
    w=c * 2;
    h=d * 2;
  }
 else   if (ellipseMode == CENTER) {
    x=a - c / 2f;
    y=b - d / 2f;
  }
  if (Float.isInfinite(start) || Float.isInfinite(stop))   return;
  if (stop < start)   return;
  while (start < 0) {
    start+=TWO_PI;
    stop+=TWO_PI;
  }
  if (stop - start > TWO_PI) {
    start=0;
    stop=TWO_PI;
  }
  float hr=w / 2f;
  float vr=h / 2f;
  float centerX=x + hr;
  float centerY=y + vr;
  int startLUT=(int)(0.5f + (start / TWO_PI) * SINCOS_LENGTH);
  int stopLUT=(int)(0.5f + (stop / TWO_PI) * SINCOS_LENGTH);
  if (fill) {
    vertex(centerX,centerY,VERTEX);
  }
  int increment=1;
  int pidx, idx;
  pidx=idx=0;
  for (int i=startLUT; i < stopLUT; i+=increment) {
    int ii=i % SINCOS_LENGTH;
    if (ii < 0)     ii+=SINCOS_LENGTH;
    idx=addVertex(centerX + cosLUT[ii] * hr,centerY + sinLUT[ii] * vr,VERTEX);
    if (startLUT < i) {
      if (stroke)       addEdge(pidx,idx,i == startLUT + 1,false);
    }
    pidx=idx;
  }
  idx=addVertex(centerX + cosLUT[stopLUT % SINCOS_LENGTH] * hr,centerY + sinLUT[stopLUT % SINCOS_LENGTH] * vr,VERTEX);
}
Program: 163673
Project: 163673
Buggy source:
public void hint(int which){
  boolean oldValue=hints[which];
  super.hint(which);
  boolean newValue=hints[which];
  if (oldValue == newValue) {
    return;
  }
  if (which == DISABLE_DEPTH_TEST) {
    flush();
    pgl.disableDepthTest();
    pgl.setClearColor(0,0,0,0);
    pgl.clearDepthBuffer();
  }
 else   if (which == ENABLE_DEPTH_TEST) {
    flush();
    pgl.enableDepthTest();
  }
 else   if (which == DISABLE_DEPTH_MASK) {
    flush();
    pgl.disableDepthMask();
  }
 else   if (which == ENABLE_DEPTH_MASK) {
    flush();
    pgl.enableDepthMask();
  }
 else   if (which == DISABLE_ACCURATE_2D) {
    flush();
    setFlushMode(FLUSH_WHEN_FULL);
  }
 else   if (which == ENABLE_ACCURATE_2D) {
    flush();
    setFlushMode(FLUSH_CONTINUOUSLY);
  }
 else   if (which == DISABLE_TEXTURE_CACHE) {
    flush();
  }
 else   if (which == DISABLE_PERSPECTIVE_CORRECTED_LINES) {
    if (0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount) {
      flush();
    }
  }
 else   if (which == ENABLE_PERSPECTIVE_CORRECTED_LINES) {
    if (0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount) {
      flush();
    }
  }
}

Fixed version (ground truth):
public void hint(int which){
  boolean oldValue=which > 0 ? hints[which] : hints[-which];
  super.hint(which);
  boolean newValue=which > 0 ? hints[which] : hints[-which];
  if (oldValue == newValue) {
    return;
  }
  if (which == DISABLE_DEPTH_TEST) {
    flush();
    pgl.disableDepthTest();
    pgl.setClearColor(0,0,0,0);
    pgl.clearDepthBuffer();
  }
 else   if (which == ENABLE_DEPTH_TEST) {
    flush();
    pgl.enableDepthTest();
  }
 else   if (which == DISABLE_DEPTH_MASK) {
    flush();
    pgl.disableDepthMask();
  }
 else   if (which == ENABLE_DEPTH_MASK) {
    flush();
    pgl.enableDepthMask();
  }
 else   if (which == DISABLE_ACCURATE_2D) {
    flush();
    setFlushMode(FLUSH_WHEN_FULL);
  }
 else   if (which == ENABLE_ACCURATE_2D) {
    flush();
    setFlushMode(FLUSH_CONTINUOUSLY);
  }
 else   if (which == DISABLE_TEXTURE_CACHE) {
    flush();
  }
 else   if (which == DISABLE_PERSPECTIVE_CORRECTED_LINES) {
    if (0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount) {
      flush();
    }
  }
 else   if (which == ENABLE_PERSPECTIVE_CORRECTED_LINES) {
    if (0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount) {
      flush();
    }
  }
}
Program: 163674
Project: 163674
Buggy source:
public void directionalLight(float r,float g,float b,float nx,float ny,float nz){
  if (!lights) {
    enableLighting();
  }
  if (lightCount == MAX_LIGHTS) {
    throw new RuntimeException("String_Node_Str" + MAX_LIGHTS + "String_Node_Str");
  }
  colorCalc(r,g,b);
  lightDiffuse[lightCount][0]=calcR;
  lightDiffuse[lightCount][1]=calcG;
  lightDiffuse[lightCount][2]=calcB;
  lightDiffuse[lightCount][3]=1.0f;
  lightType[lightCount]=DIRECTIONAL;
  lightFalloffConstant[lightCount]=currentLightFalloffConstant;
  lightFalloffLinear[lightCount]=currentLightFalloffLinear;
  lightFalloffQuadratic[lightCount]=currentLightFalloffQuadratic;
  lightSpecular[lightCount][0]=currentLightSpecular[0];
  lightSpecular[lightCount][1]=currentLightSpecular[1];
  lightSpecular[lightCount][2]=currentLightSpecular[2];
  lightSpecular[lightCount][3]=currentLightSpecular[3];
  float invn=1.0f / PApplet.dist(0,0,0,nx,ny,nz);
  lightNormal[lightCount][0]=invn * nx;
  lightNormal[lightCount][1]=invn * ny;
  lightNormal[lightCount][2]=invn * nz;
  lightNormal[lightCount][3]=0.0f;
  lightEnable(lightCount);
  lightNoAmbient(lightCount);
  lightDirection(lightCount);
  lightDiffuse(lightCount);
  lightSpecular(lightCount);
  lightFalloff(lightCount);
  lightNoSpot(lightCount);
  lightCount++;
}

Fixed version (ground truth):
public void directionalLight(float r,float g,float b,float nx,float ny,float nz){
  if (!lights) {
    enableLighting();
  }
  if (lightCount == MAX_LIGHTS) {
    throw new RuntimeException("String_Node_Str" + MAX_LIGHTS + "String_Node_Str");
  }
  colorCalc(r,g,b);
  lightDiffuse[lightCount][0]=calcR;
  lightDiffuse[lightCount][1]=calcG;
  lightDiffuse[lightCount][2]=calcB;
  lightDiffuse[lightCount][3]=1.0f;
  lightType[lightCount]=DIRECTIONAL;
  lightFalloffConstant[lightCount]=currentLightFalloffConstant;
  lightFalloffLinear[lightCount]=currentLightFalloffLinear;
  lightFalloffQuadratic[lightCount]=currentLightFalloffQuadratic;
  lightSpecular[lightCount][0]=currentLightSpecular[0];
  lightSpecular[lightCount][1]=currentLightSpecular[1];
  lightSpecular[lightCount][2]=currentLightSpecular[2];
  lightSpecular[lightCount][3]=currentLightSpecular[3];
  lightNormal[lightCount][0]=-nx;
  lightNormal[lightCount][1]=-ny;
  lightNormal[lightCount][2]=-nz;
  lightNormal[lightCount][3]=0.0f;
  lightEnable(lightCount);
  lightNoAmbient(lightCount);
  lightDirection(lightCount);
  lightDiffuse(lightCount);
  lightSpecular(lightCount);
  lightFalloff(lightCount);
  lightNoSpot(lightCount);
  lightCount++;
}
Program: 163676
Project: 163676
Buggy source:
/** 
 * Same as glFrustum(), except that it wipes out (rather than multiplies against) the current perspective matrix. <P> Implementation based on the explanation in the OpenGL blue book.
 */
public void frustum(float left,float right,float bottom,float top,float znear,float zfar){
  float temp, temp2, temp3, temp4;
  temp=2.0f * znear;
  temp2=right - left;
  temp3=top - bottom;
  temp4=zfar - znear;
  glprojection[0]=temp / temp2;
  glprojection[1]=0.0f;
  glprojection[2]=0.0f;
  glprojection[3]=0.0f;
  glprojection[4]=0.0f;
  glprojection[5]=temp / temp3;
  glprojection[6]=0.0f;
  glprojection[7]=0.0f;
  glprojection[8]=(right + left) / temp2;
  glprojection[9]=(top + bottom) / temp3;
  glprojection[10]=(-zfar - znear) / temp4;
  glprojection[11]=-1.0f;
  glprojection[12]=0.0f;
  glprojection[13]=0.0f;
  glprojection[14]=(-temp * zfar) / temp4;
  glprojection[15]=0.0f;
  gl.glMatrixMode(GL10.GL_PROJECTION);
  gl.glLoadMatrixf(glprojection,0);
  copyGLArrayToPMatrix(glprojection,projection);
  projectionUpdated=true;
  PApplet.arrayCopy(glprojection,pprojection);
  gl.glMatrixMode(GL10.GL_MODELVIEW);
}

Fixed version (ground truth):
/** 
 * Same as glFrustum(), except that it wipes out (rather than multiplies against) the current perspective matrix. <P> Implementation based on the explanation in the OpenGL blue book.
 */
public void frustum(float left,float right,float bottom,float top,float znear,float zfar){
  float temp, temp2, temp3, temp4;
  temp=2.0f * znear;
  temp2=right - left;
  temp3=top - bottom;
  temp4=zfar - znear;
  glprojection[0]=temp / temp2;
  glprojection[1]=0.0f;
  glprojection[2]=0.0f;
  glprojection[3]=0.0f;
  glprojection[4]=0.0f;
  glprojection[5]=-temp / temp3;
  glprojection[6]=0.0f;
  glprojection[7]=0.0f;
  glprojection[8]=(right + left) / temp2;
  glprojection[9]=(top + bottom) / temp3;
  glprojection[10]=(-zfar - znear) / temp4;
  glprojection[11]=-1.0f;
  glprojection[12]=0.0f;
  glprojection[13]=0.0f;
  glprojection[14]=(-temp * zfar) / temp4;
  glprojection[15]=0.0f;
  gl.glMatrixMode(GL10.GL_PROJECTION);
  gl.glLoadMatrixf(glprojection,0);
  copyGLArrayToPMatrix(glprojection,projection);
  projectionUpdated=true;
  PApplet.arrayCopy(glprojection,pprojection);
  gl.glMatrixMode(GL10.GL_MODELVIEW);
}
Program: 163678
Project: 163678
Buggy source:
public void beginShape(int kind){
  shape=kind;
  if (hints[ENABLE_DEPTH_SORT]) {
    shapeFirst=vertexCount;
    shapeLast=0;
  }
 else {
    vertexCount=0;
    pathCount=0;
    faceCount=0;
    pointCount=0;
    lineCount=0;
    triangleCount=0;
  }
  shapeTextures=0;
  noTexture();
}

Fixed version (ground truth):
public void beginShape(int kind){
  shape=kind;
  if (hints[ENABLE_DEPTH_SORT]) {
    shapeFirst=vertexCount;
    shapeLast=0;
  }
 else {
    vertexCount=0;
    curveVertexCount=0;
    pathCount=0;
    faceCount=0;
    pointCount=0;
    lineCount=0;
    triangleCount=0;
  }
  shapeTextures=0;
  noTexture();
}
Program: 163679
Project: 163679
Buggy source:
public void endDraw(){
  if (primarySurface) {
    Canvas screen=null;
    try {
      screen=parent.getSurfaceHolder().lockCanvas(null);
      if (screen != null) {
        screen.drawBitmap(bitmap,new Matrix(),null);
      }
    }
  finally {
      if (screen != null) {
        parent.getSurfaceHolder().unlockCanvasAndPost(screen);
      }
    }
  }
  if (!primarySurface) {
    loadPixels();
  }
  modified=true;
}

Fixed version (ground truth):
public void endDraw(){
  if (primarySurface) {
    Canvas screen=null;
    try {
      screen=parent.getSurfaceHolder().lockCanvas(null);
      if (screen != null) {
        screen.drawBitmap(bitmap,new Matrix(),null);
      }
    }
  finally {
      if (screen != null) {
        parent.getSurfaceHolder().unlockCanvasAndPost(screen);
      }
    }
  }
 else {
    loadPixels();
  }
  setModified();
  super.updatePixels();
}
Program: 163680
Project: 163680
Buggy source:
public void rect(float a,float b,float c,float d,float tl,float tr,float br,float bl){
  float hradius, vradius;
switch (rectMode) {
case CORNERS:
    break;
case CORNER:
  c+=a;
d+=b;
break;
case RADIUS:
hradius=c;
vradius=d;
c=a + hradius;
d=b + vradius;
a-=hradius;
b-=vradius;
break;
case CENTER:
hradius=c / 2.0f;
vradius=d / 2.0f;
c=a + hradius;
d=b + vradius;
a-=hradius;
b-=vradius;
}
if (a > c) {
float temp=a;
a=c;
c=temp;
}
if (b > d) {
float temp=b;
b=d;
d=temp;
}
rectImpl(a,b,c,d,tl,tr,br,bl);
}

Fixed version (ground truth):
public void rect(float a,float b,float c,float d,float tl,float tr,float br,float bl){
  float hradius, vradius;
switch (rectMode) {
case CORNERS:
    break;
case CORNER:
  c+=a;
d+=b;
break;
case RADIUS:
hradius=c;
vradius=d;
c=a + hradius;
d=b + vradius;
a-=hradius;
b-=vradius;
break;
case CENTER:
hradius=c / 2.0f;
vradius=d / 2.0f;
c=a + hradius;
d=b + vradius;
a-=hradius;
b-=vradius;
}
if (a > c) {
float temp=a;
a=c;
c=temp;
}
if (b > d) {
float temp=b;
b=d;
d=temp;
}
float maxRounding=PApplet.min((c - a) / 2,(d - b) / 2);
if (tl > maxRounding) tl=maxRounding;
if (tr > maxRounding) tr=maxRounding;
if (br > maxRounding) br=maxRounding;
if (bl > maxRounding) bl=maxRounding;
rectImpl(a,b,c,d,tl,tr,br,bl);
}
Program: 163681
Project: 163681
Buggy source:
protected PImage getImpl(int x,int y,int w,int h){
  PImage newbie=parent.createImage(w,h,ARGB);
  PTexture newbieTex=addTexture(newbie);
  IntBuffer newbieBuffer=IntBuffer.allocate(w * h);
  gl.glReadPixels(x,height - y,w,-h,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,newbieBuffer);
  copyToTexture(newbieTex,newbieBuffer,0,0,w,h);
  newbie.loadPixels();
  newbieTex.get(newbie.pixels);
  return newbie;
}

Fixed version (ground truth):
protected PImage getImpl(int x,int y,int w,int h){
  PImage newbie=parent.createImage(w,h,ARGB);
  PTexture newbieTex=addTexture(newbie);
  IntBuffer newbieBuffer=IntBuffer.allocate(w * h);
  boolean nonCurrent=!primarySurface && offscreenFramebuffer != currentFramebuffer;
  if (nonCurrent) {
    pushFramebuffer();
    setFramebuffer(offscreenFramebuffer);
  }
  gl.glReadPixels(x,height - y - h,w,h,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,newbieBuffer);
  if (nonCurrent) {
    popFramebuffer();
  }
  copyToTexture(newbieTex,newbieBuffer,0,0,w,h);
  newbie.loadPixels();
  newbieTex.flippedY=true;
  newbieTex.get(newbie.pixels);
  return newbie;
}
Program: 163682
Project: 163682
Buggy source:
protected void loadTextureImpl(int sampling){
  if (width == 0 || height == 0)   return;
  if (texture == null) {
    PTexture.Parameters params=PTexture.newParameters(ARGB,sampling);
    texture=new PTexture(parent,width,height,params);
    texture.setFlippedY(true);
    this.setCache(a3d,texture);
    this.setParams(a3d,params);
    texCrop=new int[4];
    texCrop[0]=0;
    texCrop[1]=0;
    texCrop[2]=width;
    texCrop[3]=height;
  }
}

Fixed version (ground truth):
protected void loadTextureImpl(int sampling){
  if (width == 0 || height == 0)   return;
  if (texture == null) {
    PTexture.Parameters params=PTexture.newParameters(ARGB,sampling);
    texture=new PTexture(parent,width,height,params);
    texture.setFlippedY(true);
    this.setCache(a3d,texture);
    this.setParams(a3d,params);
    texCrop=new int[4];
    texCrop[0]=0;
    texCrop[1]=height;
    texCrop[2]=width;
    texCrop[3]=-height;
  }
}
Program: 163683
Project: 163683
Buggy source:
/** 
 * Remove the shape with index idx.
 */
public void removeChild(int idx){
  if (idx < childCount) {
    PShape child=children[idx];
    for (int i=idx; i < childCount - 1; i++) {
      children[i]=children[i + 1];
    }
    childCount--;
    if (child.getName() != null && nameTable != null) {
      nameTable.remove(child.getName());
    }
  }
}

Fixed version (ground truth):
/** 
 * Remove the child shape with index idx.
 */
public void removeChild(int idx){
  if (idx < childCount) {
    PShape child=children[idx];
    for (int i=idx; i < childCount - 1; i++) {
      children[i]=children[i + 1];
    }
    childCount--;
    if (child.getName() != null && nameTable != null) {
      nameTable.remove(child.getName());
    }
  }
}
Program: 163685
Project: 163685
Buggy source:
/** 
 * Add a shape to the name lookup table.
 */
protected void addName(String nom,PShape shape){
  if (parent != null) {
    parent.addName(nom,shape);
  }
 else {
    if (nameTable == null) {
      nameTable=new HashMap<String,PShape>();
    }
    nameTable.put(nom,shape);
  }
}

Fixed version (ground truth):
/** 
 * Add a shape to the name lookup table.
 */
public void addName(String nom,PShape shape){
  if (parent != null) {
    parent.addName(nom,shape);
  }
 else {
    if (nameTable == null) {
      nameTable=new HashMap<String,PShape>();
    }
    nameTable.put(nom,shape);
  }
}
Program: 163686
Project: 163686
Buggy source:
/** 
 * Add a shape to the name lookup table.
 */
protected void addName(String nom,PShape shape){
  if (nameTable == null) {
    nameTable=new HashMap<String,PShape>();
  }
  nameTable.put(nom,shape);
}

Fixed version (ground truth):
/** 
 * Add a shape to the name lookup table.
 */
public void addName(String nom,PShape shape){
  if (nameTable == null) {
    nameTable=new HashMap<String,PShape>();
  }
  nameTable.put(nom,shape);
}
Program: 163687
Project: 163687
Buggy source:
public PShape groupChildren(PShape[] gchildren,String gname){
  if (family != GROUP)   return null;
  PShape3D group=new PShape3D();
  group.family=PShape.GROUP;
  group.name=gname;
  group.papplet=papplet;
  group.a3d=a3d;
  group.gl=gl;
  group.root=root;
  PShape child, p;
  int idx;
  child=gchildren[0];
  p=child.parent;
  if (p != null) {
    idx=p.getChildIdx(child);
    if (idx < 0)     idx=0;
  }
 else {
    p=this;
    idx=0;
  }
  p.addChild(group,idx);
  for (int i=0; i < gchildren.length; i++) {
    child=gchildren[i];
    p=child.parent;
    if (p != null) {
      idx=p.getChildIdx(child);
      if (-1 < idx) {
        p.removeChild(idx);
      }
    }
  }
  group.firstVertex=root.vertexCount;
  group.lastVertex=0;
  for (int i=0; i < gchildren.length; i++) {
    group.firstVertex=PApplet.min(group.firstVertex,((PShape3D)gchildren[i]).firstVertex);
    group.lastVertex=PApplet.max(group.lastVertex,((PShape3D)gchildren[i]).lastVertex);
  }
  for (int i=0; i < gchildren.length; i++) {
    group.addChildImpl(gchildren[i],false);
  }
  return group;
}

Fixed version (ground truth):
public PShape groupChildren(PShape[] gchildren,String gname){
  if (family != GROUP)   return null;
  PShape3D group=new PShape3D();
  group.family=PShape.GROUP;
  group.name=gname;
  group.papplet=papplet;
  group.a3d=a3d;
  group.gl=gl;
  group.root=root;
  PShape child, p;
  int idx;
  child=gchildren[0];
  p=child.parent;
  if (p != null) {
    idx=p.getChildIndex(child);
    if (idx < 0)     idx=0;
  }
 else {
    p=this;
    idx=0;
  }
  p.addChild(group,idx);
  for (int i=0; i < gchildren.length; i++) {
    child=gchildren[i];
    p=child.parent;
    if (p != null) {
      idx=p.getChildIndex(child);
      if (-1 < idx) {
        p.removeChild(idx);
      }
    }
  }
  group.firstVertex=root.vertexCount;
  group.lastVertex=0;
  for (int i=0; i < gchildren.length; i++) {
    group.firstVertex=PApplet.min(group.firstVertex,((PShape3D)gchildren[i]).firstVertex);
    group.lastVertex=PApplet.max(group.lastVertex,((PShape3D)gchildren[i]).lastVertex);
  }
  for (int i=0; i < gchildren.length; i++) {
    group.addChildImpl(gchildren[i],false);
  }
  return group;
}
Program: 163688
Project: 163688
Buggy source:
/** 
 * This utility method creates a texture for the provided image, and adds it to the metadata cache of the image.
 * @param img the image to have a texture metadata associated to it
 */
protected PTexture addTexture(PImage img){
  PTexture.Parameters params=(PTexture.Parameters)img.getParams(a3d);
  if (params == null) {
    params=PTexture.newParameters();
    img.setParams(a3d,params);
  }
  PTexture tex=new PTexture(img.parent,img.width,img.height,params);
  img.loadPixels();
  tex.set(img.pixels);
  img.setCache(a3d,tex);
  return tex;
}

Fixed version (ground truth):
/** 
 * This utility method creates a texture for the provided image, and adds it to the metadata cache of the image.
 * @param img the image to have a texture metadata associated to it
 */
protected PTexture addTexture(PImage img){
  PTexture.Parameters params=(PTexture.Parameters)img.getParams(a3d);
  if (params == null) {
    params=PTexture.newParameters();
    img.setParams(a3d,params);
  }
  PTexture tex=new PTexture(img.parent,img.width,img.height,params);
  if (img.pixels == null) {
    img.loadPixels();
  }
  tex.set(img.pixels);
  img.setCache(a3d,tex);
  return tex;
}
Program: 163690
Project: 163690
Buggy source:
/** 
 * First try to create a default font, but if that's not possible, throw   an exception that halts the program because textFont() has not been used  prior to the specified method.
 */
protected void defaultFontOrDeath(String method,float size){
  if (parent != null) {
    textFont=parent.createDefaultFont(size);
  }
 else {
    throw new RuntimeException("String_Node_Str" + method + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * First try to create a default font, but if that's not possible, throw an exception that halts the program because textFont() has not been used prior to the specified method.
 */
protected void defaultFontOrDeath(String method,float size){
  if (parent != null) {
    textFont=parent.createDefaultFont(size);
  }
 else {
    throw new RuntimeException("String_Node_Str" + method + "String_Node_Str");
  }
}
Program: 163691
Project: 163691
Buggy source:
static final public String hex(int what,int digits){
  String stuff=Integer.toHexString(what).toUpperCase();
  int length=stuff.length();
  if (length > digits) {
    return stuff.substring(length - digits);
  }
 else   if (length < digits) {
    return "String_Node_Str".substring(8 - (digits - length)) + stuff;
  }
  return stuff;
}

Fixed version (ground truth):
/** 
 * Format an integer as a hex string using the specified number of digits.
 * @param what the value to format
 * @param digits the number of digits (maximum 8)
 * @return a String object with the formatted values
 */
static final public String hex(int what,int digits){
  String stuff=Integer.toHexString(what).toUpperCase();
  if (digits > 8) {
    digits=8;
  }
  int length=stuff.length();
  if (length > digits) {
    return stuff.substring(length - digits);
  }
 else   if (length < digits) {
    return "String_Node_Str".substring(8 - (digits - length)) + stuff;
  }
  return stuff;
}
Program: 163692
Project: 163692
Buggy source:
/** 
 * Returns a String that contains the binary value of an int. The digits parameter determines how many digits will be used.
 */
static final public String binary(int what,int digits){
  String stuff=Integer.toBinaryString(what);
  int length=stuff.length();
  if (length > digits) {
    return stuff.substring(length - digits);
  }
 else   if (length < digits) {
    int offset=32 - (digits - length);
    return "String_Node_Str".substring(offset) + stuff;
  }
  return stuff;
}

Fixed version (ground truth):
/** 
 * Returns a String that contains the binary value of an int. The digits parameter determines how many digits will be used.
 */
static final public String binary(int what,int digits){
  String stuff=Integer.toBinaryString(what);
  if (digits > 32) {
    digits=32;
  }
  int length=stuff.length();
  if (length > digits) {
    return stuff.substring(length - digits);
  }
 else   if (length < digits) {
    int offset=32 - (digits - length);
    return "String_Node_Str".substring(offset) + stuff;
  }
  return stuff;
}
Program: 163695
Project: 163695
Buggy source:
protected void copyToTexture(IntBuffer buffer,int glid,int gltarget){
  gl.glEnable(gltarget);
  gl.glBindTexture(gltarget,glid);
  gl.glTexSubImage2D(gltarget,0,0,0,width,height,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,buffer);
  gl.glDisable(gltarget);
}

Fixed version (ground truth):
protected void copyToTexture(IntBuffer buffer,int glid,int gltarget){
  gl.glEnable(gltarget);
  gl.glBindTexture(gltarget,glid);
  gl.glTexSubImage2D(gltarget,0,0,0,width,height,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,buffer);
  gl.glBindTexture(gltarget,0);
  gl.glDisable(gltarget);
}
Program: 163696
Project: 163696
Buggy source:
protected void clearMultitextureBlend(int num){
  for (int i=0; i < num; i++) {
    gl11.glActiveTexture(GL11.GL_TEXTURE0 + i);
    gl11.glTexEnvi(GL11.GL_TEXTURE_ENV,GL11.GL_TEXTURE_ENV_MODE,GL11.GL_MODULATE);
  }
}

Fixed version (ground truth):
protected void clearMultitextureBlend(int num){
  for (int i=0; i < num; i++) {
    gl11.glActiveTexture(GL11.GL_TEXTURE0 + i);
    gl11.glTexEnvi(GL11.GL_TEXTURE_ENV,GL11.GL_TEXTURE_ENV_MODE,GL11.GL_MODULATE);
  }
  if (blend) {
    blend(blendMode);
  }
 else {
    noBlend();
  }
}
Program: 163698
Project: 163698
Buggy source:
protected void drawTexture(PTexture tex,int[] crop,int x,int y,int w,int h){
  gl.glEnable(tex.getGLTarget());
  gl.glBindTexture(tex.getGLTarget(),tex.getGLID());
  gl.glDepthMask(false);
  gl.glDisable(GL10.GL_BLEND);
  gl.glTexEnvf(GL10.GL_TEXTURE_ENV,GL10.GL_TEXTURE_ENV_MODE,GL10.GL_REPLACE);
  gl11.glTexParameteriv(GL10.GL_TEXTURE_2D,GL11Ext.GL_TEXTURE_CROP_RECT_OES,crop,0);
  gl11x.glDrawTexiOES(x,y,0,w,h);
  gl.glTexEnvf(GL10.GL_TEXTURE_ENV,GL10.GL_TEXTURE_ENV_MODE,GL10.GL_MODULATE);
  gl.glDisable(tex.getGLTarget());
  if (hints[DISABLE_DEPTH_MASK]) {
    gl.glDepthMask(false);
  }
 else {
    gl.glDepthMask(true);
  }
  if (blend) {
    blend(blendMode);
  }
 else {
    noBlend();
  }
}

Fixed version (ground truth):
protected void drawTexture(PTexture tex,int[] crop,int x,int y,int w,int h){
  gl.glEnable(tex.getGLTarget());
  gl.glBindTexture(tex.getGLTarget(),tex.getGLID());
  gl.glDepthMask(false);
  gl.glDisable(GL10.GL_BLEND);
  gl.glTexEnvf(GL10.GL_TEXTURE_ENV,GL10.GL_TEXTURE_ENV_MODE,GL10.GL_REPLACE);
  gl11.glTexParameteriv(GL10.GL_TEXTURE_2D,GL11Ext.GL_TEXTURE_CROP_RECT_OES,crop,0);
  gl11x.glDrawTexiOES(x,y,0,w,h);
  gl.glTexEnvf(GL10.GL_TEXTURE_ENV,GL10.GL_TEXTURE_ENV_MODE,GL10.GL_MODULATE);
  gl.glBindTexture(tex.getGLTarget(),0);
  gl.glDisable(tex.getGLTarget());
  if (hints[DISABLE_DEPTH_MASK]) {
    gl.glDepthMask(false);
  }
 else {
    gl.glDepthMask(true);
  }
  if (blend) {
    blend(blendMode);
  }
 else {
    noBlend();
  }
}
Program: 163699
Project: 163699
Buggy source:
protected void copyToTexture(PTexture tex,IntBuffer buffer,int x,int y,int w,int h){
  gl.glEnable(tex.getGLTarget());
  gl.glBindTexture(tex.getGLTarget(),tex.getGLID());
  gl.glTexSubImage2D(tex.getGLTarget(),0,x,y,w,h,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,buffer);
  gl.glDisable(tex.getGLTarget());
}

Fixed version (ground truth):
protected void copyToTexture(PTexture tex,IntBuffer buffer,int x,int y,int w,int h){
  gl.glEnable(tex.getGLTarget());
  gl.glBindTexture(tex.getGLTarget(),tex.getGLID());
  gl.glTexSubImage2D(tex.getGLTarget(),0,x,y,w,h,GL10.GL_RGBA,GL10.GL_UNSIGNED_BYTE,buffer);
  gl.glBindTexture(tex.getGLTarget(),0);
  gl.glDisable(tex.getGLTarget());
}
Program: 163701
Project: 163701
Buggy source:
protected void addNewFace(boolean firstFace,PImage[] images){
  if (faceCount == faceOffset.length) {
    faceOffset=PApplet.expand(faceOffset);
    faceLength=PApplet.expand(faceLength);
    PImage tempi[][]=new PImage[faceCount << 1][MAX_TEXTURES];
    PApplet.arrayCopy(faceTextures,0,tempi,0,faceCount);
    faceTextures=tempi;
  }
  faceOffset[faceCount]=firstFace ? 0 : triangleCount;
  faceLength[faceCount]=1;
  PImage p[]=faceTextures[faceCount];
  if (1 < numMultitextures) {
    PApplet.arrayCopy(images,0,p,0,numMultitextures);
  }
  if (0 < numMultitextures) {
    p[0]=images[0];
  }
 else {
    p[0]=null;
  }
  faceCount++;
}

Fixed version (ground truth):
protected void addNewFace(boolean firstFace,PImage[] images){
  if (faceCount == faceOffset.length) {
    faceOffset=PApplet.expand(faceOffset);
    faceLength=PApplet.expand(faceLength);
    PImage tempi[][]=new PImage[faceCount << 1][MAX_TEXTURES];
    PApplet.arrayCopy(faceTextures,0,tempi,0,faceCount);
    faceTextures=tempi;
  }
  faceOffset[faceCount]=firstFace ? 0 : triangleCount;
  faceLength[faceCount]=1;
  PImage p[]=faceTextures[faceCount];
  if (1 < numMultitextures) {
    PApplet.arrayCopy(images,0,p,0,numMultitextures);
  }
  if (0 < numMultitextures) {
    p[0]=images[0];
  }
 else {
    p[0]=null;
  }
  java.util.Arrays.fill(p,numMultitextures,maxTextureUnits,null);
  faceCount++;
}
Program: 163704
Project: 163704
Buggy source:
protected void loadTexcoords(int unit,int first,int last){
  if (last < first || first < 0 || vertexCount <= last) {
    PGraphics.showWarning("String_Node_Str");
    updateElement=-1;
    return;
  }
  if (updateElement != -1) {
    PGraphics.showWarning("String_Node_Str");
    return;
  }
  if (PGraphicsAndroid3D.maxTextureUnits <= unit) {
    PGraphics.showWarning("String_Node_Str");
    return;
  }
  updateElement=TEXCOORDS;
  firstUpdateIdx=first;
  lastUpdateIdx=last;
  if (numTexBuffers <= unit) {
    addTexBuffers(unit - numTexBuffers + 1);
  }
  gl.glBindBuffer(GL11.GL_ARRAY_BUFFER,glTexCoordBufferID[unit]);
  int offset=first * 2;
  int size=(last - first + 1) * 2;
  texCoordBuffer.limit(texCoordBuffer.capacity());
  texCoordBuffer.rewind();
  texCoordBuffer.get(texcoords,offset,size);
  updateTexunit=unit;
}

Fixed version (ground truth):
protected void loadTexcoords(int unit,int first,int last){
  if (last < first || first < 0 || vertexCount <= last) {
    PGraphics.showWarning("String_Node_Str");
    updateElement=-1;
    return;
  }
  if (updateElement != -1) {
    PGraphics.showWarning("String_Node_Str");
    return;
  }
  if (PGraphicsAndroid3D.maxTextureUnits <= unit) {
    PGraphics.showWarning("String_Node_Str");
    return;
  }
  updateElement=TEXCOORDS;
  firstUpdateIdx=first;
  lastUpdateIdx=last;
  if (numTexBuffers <= unit) {
    addTexBuffers(unit - numTexBuffers + 1);
  }
  gl.glBindBuffer(GL11.GL_ARRAY_BUFFER,glTexCoordBufferID[unit]);
  int offset=first * 2;
  int size=(last - first + 1) * 2;
  texCoordBuffer.limit(texCoordBuffer.capacity());
  texCoordBuffer.rewind();
  texCoordBuffer.get(texcoords,offset,size);
  normalizeTexcoords(unit);
  updateTexunit=unit;
}
Program: 163705
Project: 163705
Buggy source:
public void updateTexcoords(){
  if (updateElement == TEXCOORDS) {
    int offset=firstUpdateIdx * 2;
    int size=(lastUpdateIdx - firstUpdateIdx + 1) * 2;
    texCoordBuffer.position(0);
    texCoordBuffer.put(texcoords,offset,size);
    texCoordBuffer.flip();
    gl.glBufferSubData(GL11.GL_ARRAY_BUFFER,offset * PGraphicsAndroid3D.SIZEOF_FLOAT,size * PGraphicsAndroid3D.SIZEOF_FLOAT,texCoordBuffer);
    gl.glBindBuffer(GL11.GL_ARRAY_BUFFER,0);
    texCoordSet[updateTexunit]=true;
    updateElement=-1;
  }
 else {
    PGraphics.showWarning("String_Node_Str");
  }
}

Fixed version (ground truth):
public void updateTexcoords(){
  if (updateElement == TEXCOORDS) {
    int offset=firstUpdateIdx * 2;
    int size=(lastUpdateIdx - firstUpdateIdx + 1) * 2;
    unnormalizeTexcoords(updateTexunit);
    texCoordBuffer.position(0);
    texCoordBuffer.put(texcoords,offset,size);
    texCoordBuffer.flip();
    gl.glBufferSubData(GL11.GL_ARRAY_BUFFER,offset * PGraphicsAndroid3D.SIZEOF_FLOAT,size * PGraphicsAndroid3D.SIZEOF_FLOAT,texCoordBuffer);
    gl.glBindBuffer(GL11.GL_ARRAY_BUFFER,0);
    texCoordSet[updateTexunit]=true;
    updateElement=-1;
  }
 else {
    PGraphics.showWarning("String_Node_Str");
  }
}