Java Code Examples for processing.opengl.PGraphicsOpenGL#beginPGL()

The following examples show how to use processing.opengl.PGraphicsOpenGL#beginPGL() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DwUtils.java    From PixelFlow with MIT License 6 votes vote down vote up
static public void changeTextureFormat(PGraphicsOpenGL pg, int internal_format, int format, int type, int filter, int wrap){
  Texture tex = pg.getTexture();
  if(!tex.available()){
    System.out.println("ERROR DwGLTextureUtils.changeTextureFormat: PGraphicsOpenGL texture not available.");
    return;
  }
  
  PGL pgl = pg.beginPGL();
  pgl.bindTexture  (tex.glTarget, tex.glName);
  pgl.texParameteri(tex.glTarget, GL2ES2.GL_TEXTURE_MIN_FILTER, filter); // GL_NEAREST, GL_LINEAR
  pgl.texParameteri(tex.glTarget, GL2ES2.GL_TEXTURE_MAG_FILTER, filter); 
  pgl.texParameteri(tex.glTarget, GL2ES2.GL_TEXTURE_WRAP_S, wrap);
  pgl.texParameteri(tex.glTarget, GL2ES2.GL_TEXTURE_WRAP_T, wrap);
  pgl.texImage2D   (tex.glTarget, 0, internal_format, tex.glWidth, tex.glHeight, 0, format, type, null);
  pgl.bindTexture  (tex.glTarget, 0);
  pg.endPGL();
  
  pg.beginDraw();
  pg.clear();
  pg.endDraw();
}
 
Example 2
Source File: DwUtils.java    From PixelFlow with MIT License 5 votes vote down vote up
static public void changeTextureWrap(PGraphicsOpenGL pg, int wrap){
  Texture tex = pg.getTexture();
  if(!tex.available()){
    System.out.println("ERROR DwGLTextureUtils.changeTextureWrap: PGraphicsOpenGL texture not available.");
    return;
  }
  PGL pgl = pg.beginPGL();
  pgl.bindTexture  (tex.glTarget, tex.glName); 
  pgl.texParameteri(tex.glTarget, GL2ES2.GL_TEXTURE_WRAP_S, wrap);
  pgl.texParameteri(tex.glTarget, GL2ES2.GL_TEXTURE_WRAP_T, wrap);
  pgl.bindTexture  (tex.glTarget, 0);
  pg.endPGL();
}
 
Example 3
Source File: DwUtils.java    From PixelFlow with MIT License 5 votes vote down vote up
static public void changeTextureFilter(PGraphicsOpenGL pg, int min_filter, int mag_filter){
  Texture tex = pg.getTexture();
  if(!tex.available()){
    System.out.println("ERROR DwGLTextureUtils.changeTextureFilter: PGraphicsOpenGL texture not available.");
    return;
  }
  PGL pgl = pg.beginPGL();
  pgl.bindTexture  (tex.glTarget, tex.glName);
  pgl.texParameteri(tex.glTarget, GL2ES2.GL_TEXTURE_MIN_FILTER, min_filter);
  pgl.texParameteri(tex.glTarget, GL2ES2.GL_TEXTURE_MAG_FILTER, mag_filter);
  pgl.bindTexture  (tex.glTarget, 0);
  pg.endPGL();
}
 
Example 4
Source File: DwUtils.java    From PixelFlow with MIT License 5 votes vote down vote up
/**
 * When chaning multiple parameters, its better to use this source-code directly.
 * 
 * @param pg
 * @param pname
 * @param param
 */
static public void changeTextureParam(PGraphicsOpenGL pg, int pname, int param){
  Texture tex = pg.getTexture();
  if(!tex.available()){
    System.out.println("ERROR DwGLTextureUtils.changeTextureParam: PGraphicsOpenGL texture not available.");
    return;
  }
  PGL pgl = pg.beginPGL();
  pgl.bindTexture  (tex.glTarget, tex.glName);
  pgl.texParameteri(tex.glTarget, pname, param);
  pgl.bindTexture  (tex.glTarget, 0);
  pg.endPGL();
}
 
Example 5
Source File: DwUtils.java    From PixelFlow with MIT License 5 votes vote down vote up
static public void generateMipMaps(PGraphicsOpenGL pg){
    Texture tex = pg.getTexture();
    if(!tex.available()){
      System.out.println("ERROR DwGLTextureUtils.generateMipMaps: PGraphicsOpenGL texture not available.");
      return;
    }

    PGL pgl = pg.beginPGL();
    pgl.bindTexture   (tex.glTarget, tex.glName);
    pgl.texParameteri (tex.glTarget, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_LINEAR);
//    pgl.texParameteri (tex.glTarget, GL2.GL_GENERATE_MIPMAP, GL.GL_TRUE);
    pgl.generateMipmap(tex.glTarget);
    pgl.bindTexture   (tex.glTarget, 0);
    pg.endPGL();
  }