Java Code Examples for processing.opengl.Texture#available()

The following examples show how to use processing.opengl.Texture#available() . 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: Sobel.java    From PixelFlow with MIT License 6 votes vote down vote up
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, Sobel.TYPE kernel, float[] mad) {
  if(src == dst){
    System.out.println("Sobel error: read-write race");
    return;
  }
  if(kernel == null){
    return; 
  }
  
  kernel.buildShader(context);
 
  Texture tex_src = src.getTexture(); if(!tex_src.available())  return;
  Texture tex_dst = dst.getTexture(); if(!tex_dst.available())  return;
  
  context.begin();
  context.beginDraw(dst);
  apply(kernel.shader, tex_src.glName, dst.width, dst.height, mad);
  context.endDraw();
  context.end("Sobel.apply");
}
 
Example 2
Source File: Median.java    From PixelFlow with MIT License 6 votes vote down vote up
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, Median.TYPE kernel) {
  if(src == dst){
    System.out.println("Median error: read-write race");
    return;
  }
  
  if(kernel == null){
    return;
  }
  kernel.buildShader(context);

  Texture tex_src = src.getTexture(); if(!tex_src.available())  return;
  Texture tex_dst = dst.getTexture(); if(!tex_dst.available())  return;
  
  context.begin();
  context.beginDraw(dst);
  apply(kernel.shader, tex_src.glName, dst.width, dst.height);
  context.endDraw();
  context.end("Median.apply");
}
 
Example 3
Source File: Convolution.java    From PixelFlow with MIT License 6 votes vote down vote up
/**
 * kernel: 0 1 2
 *         3 4 5
 *         6 7 8
 */
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, float[] kernel) {
  if(src == dst){
    System.out.println("Convolution error: read-write race");
    return;
  }
  if(kernel.length < 9) return;
  
  Texture tex_src = src.getTexture(); if(!tex_src.available())  return;
  Texture tex_dst = dst.getTexture(); if(!tex_dst.available())  return;
     
  context.begin();
  context.beginDraw(dst);
  apply(tex_src.glName, dst.width, dst.height, kernel);
  context.endDraw();
  context.end("Convolution.apply");
}
 
Example 4
Source File: FXAA.java    From PixelFlow with MIT License 6 votes vote down vote up
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst) {
  if(src == dst){
    System.out.println("FXAA error: read-write race");
    return;
  }
  
  Texture tex_src = src.getTexture(); if(!tex_src.available())  return;
  Texture tex_dst = dst.getTexture(); if(!tex_dst.available())  return;
  
  // RGBL ... red, green, blue, luminance, for FXAA
  DwFilter.get(context).rgbl.apply(src, src);
     
  context.begin();
  setLinearTextureFiltering(tex_src.glName);
  context.beginDraw(dst);
  apply(tex_src.glName, dst.width, dst.height);
  context.endDraw();
  resetTextureFiltering(tex_src.glName);
  context.end("FXAA.apply");
}
 
Example 5
Source File: DistanceTransform.java    From PixelFlow with MIT License 5 votes vote down vote up
/**
 * texel-data lookup at the nearest neighbor -> voronoi
 * 
 * @param src src color at nn-lookup position
 * @param dst
 */
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst){
  Texture tex_src = src.getTexture();  if(!tex_src .available()) return;
  Texture tex_dst = dst.getTexture();  if(!tex_dst .available()) return;
  
  if(src == dst){
    System.out.println("DistanceTransform.apply error: read-write race");
  }
  int w_dst = dst.width;
  int h_dst = dst.height;
  
  int w_src = src.width;
  int h_src = src.height;
  
  int w_dtnn = tex_dtnn.src.w;
  int h_dtnn = tex_dtnn.src.h;

  context.begin();
  context.beginDraw(dst);
  shader_voronoi.begin();
  shader_voronoi.uniform2f     ("wh_rcp"     , 1f/w_dst, 1f/h_dst);
  shader_voronoi.uniform2f     ("wh_src_rcp" , 1f/w_src, 1f/h_src);
  shader_voronoi.uniform2f     ("wh_dtnn_rcp", 1f/w_dtnn, 1f/h_dtnn);
  shader_voronoi.uniform1f     ("dist_norm"  , param.voronoi_distance_normalization);
  shader_voronoi.uniformTexture("tex_src"    , tex_src.glName);
  shader_voronoi.uniformTexture("tex_dtnn"   , tex_dtnn.src);
  shader_voronoi.drawFullScreenQuad();
  shader_voronoi.end();
  context.endDraw();
  context.end("DistanceTransform.apply");
}
 
Example 6
Source File: Clamp.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, float[] lo, float[] hi) {
  Texture tex_src = src.getTexture(); if(!tex_src.available())  return;
  Texture tex_dst = dst.getTexture(); if(!tex_dst.available())  return;

  context.begin();
  context.beginDraw(dst);
  apply(tex_src.glName, dst.width, dst.height, lo, hi);
  context.endDraw();
  context.end("Clamp.apply");
}
 
Example 7
Source File: Luminance.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL src, DwGLTexture dst) {
  Texture tex_src = src.getTexture();
  if(!tex_src.available()) 
    return;
     
  context.begin();
  context.beginDraw(dst);
  apply(tex_src.glName, dst.w, dst.h);
  context.endDraw();
  context.end("Luminance.apply");
}
 
Example 8
Source File: Clamp.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL src, DwGLTexture dst, float[] lo, float[] hi) {
  Texture tex_src = src.getTexture();
  if(!tex_src.available()) 
    return;
     
  context.begin();
  context.beginDraw(dst);
  apply(tex_src.glName, dst.w, dst.h, lo, hi);
  context.endDraw();
  context.end("Clamp.apply");
}
 
Example 9
Source File: RGBL.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst) {
  Texture tex_src = src.getTexture(); if(!tex_src.available())  return;
  Texture tex_dst = dst.getTexture(); if(!tex_dst.available())  return;

  context.begin();
  context.beginDraw(dst);
  apply(tex_src.glName, dst.width, dst.height);
  context.endDraw();
  context.end("RGBL.apply");
}
 
Example 10
Source File: MinMaxGlobal.java    From PixelFlow with MIT License 5 votes vote down vote up
/**
 * 
 * remap pixels [min, max] to [0, 1]
 * 
 */
public void map(PGraphicsOpenGL pg_src, PGraphicsOpenGL pg_dst, boolean per_channel){
  Texture tex_src = pg_src.getTexture(); if(!tex_src.available()) return;
  context.begin();
  context.beginDraw(pg_dst);
  map(pg_dst.width, pg_dst.height, tex_src.glName, per_channel);
  context.endDraw();
  context.end("MinMaxGlobal.map");
}
 
Example 11
Source File: Threshold.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL src, DwGLTexture dst) {
  Texture tex_src = src.getTexture();
  if(!tex_src.available()) 
    return;
     
  context.begin();
  context.beginDraw(dst);
  apply(tex_src.glName, dst.w, dst.h);
  context.endDraw();
  context.end("Threshold.apply");
}
 
Example 12
Source File: Multiply.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, PGraphicsOpenGL mul) {
  Texture tex_src = src.getTexture(); if(!tex_src.available())  return;
  Texture tex_dst = dst.getTexture(); if(!tex_dst.available())  return;
  Texture tex_mul = mul.getTexture(); if(!tex_mul.available())  return; 
  
  context.begin();
  context.beginDraw(dst);
  apply(tex_src.glName, dst.width, dst.height, tex_mul.glName);
  context.endDraw();
  context.end("Multiply.apply");
}
 
Example 13
Source File: Merge.java    From PixelFlow with MIT License 5 votes vote down vote up
public TexMad set(PGraphicsOpenGL pg, float mul, float add){
  Texture tex = pg.getTexture(); if(!tex.available()) return this;
  this.tex = tex.glName;
  this.mul = mul;
  this.add = add;
  return this;
}
 
Example 14
Source File: GaussianBlur.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, PGraphicsOpenGL tmp, int radius, float sigma) {
    if(src == tmp || dst == tmp){
      System.out.println("GaussianBlur error: read-write race");
      return;
    }
    if(radius <= 0){
      return; 
    }
    
    Texture tex_src = src.getTexture(); if(!tex_src.available()) return;
    Texture tex_dst = dst.getTexture(); if(!tex_dst.available()) return;
    Texture tex_tmp = tmp.getTexture(); if(!tex_tmp.available()) return;
    
    context.begin();
    
    context.beginDraw(tmp);
    pass(tex_src.glName, tmp.width, tmp.height, radius, sigma, HORZ);
    context.endDraw("GaussianBlur.apply - HORZ");

//    Texture tex_tmp = tmp.getTexture();
    
    context.beginDraw(dst);
    pass(tex_tmp.glName, dst.width, dst.height, radius, sigma, VERT);
    context.endDraw("GaussianBlur.apply - VERT");
    
    context.end();
  }
 
Example 15
Source File: Gamma.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, float gamma) {
  Texture tex_src = src.getTexture(); if(!tex_src.available()) return;
  Texture tex_dst = dst.getTexture(); if(!tex_dst.available()) return;
  
  context.begin();
  context.beginDraw(dst);
  apply(tex_src.glName,dst.width, dst.height, gamma);
  context.endDraw();
  context.end("GammaCorrection.apply");
}
 
Example 16
Source File: Mad.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, float[] mad) {
  Texture tex_src = src.getTexture(); if(!tex_src.available())  return;
  Texture tex_dst = dst.getTexture(); if(!tex_dst.available())  return;
     
  context.begin();
  context.beginDraw(dst);
  apply(tex_src.glName, dst.width, dst.height, mad);
  context.endDraw();
  context.end("Mad.apply");
}
 
Example 17
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 18
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();
  }
 
Example 19
Source File: DwShadertoy.java    From PixelFlow with MIT License 5 votes vote down vote up
/**
 * uniform sampler2D iChannel0..3; // image/buffer/sound, Sampler for input textures i
 * @param channel
 * @param tex
 */
public void set_iChannel(int channel, PGraphicsOpenGL pg){
  Texture tex2D = pg.getTexture(); 
  if(tex2D.available()){
    set_iChannel(channel, tex2D.glName, tex2D.glWidth, tex2D.glHeight, 1, "sampler2D");
  }
}
 
Example 20
Source File: Multiply.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, float[] multiplier) {
  Texture tex_src = src.getTexture(); if(!tex_src.available())  return;
  Texture tex_dst = dst.getTexture(); if(!tex_dst.available())  return;

  context.begin();
  context.beginDraw(dst);
  apply(tex_src.glName, dst.width, dst.height, multiplier);
  context.endDraw();
  context.end("Multiply.apply");
}