processing.opengl.Texture Java Examples
The following examples show how to use
processing.opengl.Texture.
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: DwFluid2D.java From PixelFlow with MIT License | 6 votes |
public void addObstacles(PGraphics2D pg){ Texture tex = pg.getTexture(); if(!tex.available()) return; // int[] pg_tex_handle = new int[1]; context.begin(); // context.getGLTextureHandle(pg, pg_tex_handle); context.beginDraw(tex_obstacleC.dst); DwGLSLProgram shader = shader_addObstacleTexture; shader.begin(); shader.uniform2f ("wh" , fluid_w, fluid_h); shader.uniformTexture("tex_src", tex.glName); shader.drawFullScreenQuad(); shader.end(); context.endDraw(); context.end("Fluid.addObstacles"); tex_obstacleC.swap(); }
Example #2
Source File: DwFluid2D.java From PixelFlow with MIT License | 6 votes |
public void addDensity(PGraphics2D pg, float intensity_scale, int blend_mode, float mix){ Texture tex = pg.getTexture(); if(!tex.available()) return; // int[] pg_tex_handle = new int[1]; context.begin(); // context.getGLTextureHandle(pg, pg_tex_handle); context.beginDraw(tex_density.dst); DwGLSLProgram shader = shader_addDensityTexture; shader.begin(); shader.uniform2f ("wh" , fluid_w, fluid_h); shader.uniform1f ("intensity_scale", intensity_scale); shader.uniform1i ("blend_mode" , blend_mode); shader.uniform1f ("mix_value" , mix); shader.uniformTexture("tex_density_old", tex_density.src); shader.uniformTexture("tex_density_src", tex.glName); shader.drawFullScreenQuad(); shader.end(); context.endDraw(); context.end("Fluid.addDensity"); tex_density.swap(); }
Example #3
Source File: SummedAreaTable.java From PixelFlow with MIT License | 6 votes |
/** * applies a box-blur using the SAT-Textures (needs to be created in previous step) * * @param dst * @param radius */ public void apply(PGraphicsOpenGL dst, int radius){ Texture tex_dst = dst.getTexture(); if(!tex_dst.available()) return; int w_sat = sat_src.w; int h_sat = sat_src.h; int w_dst = tex_dst.glWidth; int h_dst = tex_dst.glHeight; DwGLSLProgram shader = shader_blur; context.begin(); context.beginDraw(dst); shader.begin(); shader.uniform2f ("wh_dst" , w_dst, h_dst); shader.uniform2f ("wh_sat" , w_sat, h_sat); shader.uniformTexture("tex_sat", sat_src); shader.uniform1i ("radius", radius); shader.drawFullScreenQuad(); shader.end(); context.endDraw(); context.end("SummedAreaTable.apply"); }
Example #4
Source File: DoG.java From PixelFlow with MIT License | 6 votes |
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, PGraphicsOpenGL tmp) { Texture tex_src = src.getTexture(); if(!tex_src.available()) return; Texture tex_dst = dst.getTexture(); if(!tex_dst .available()) return; Texture tex_tmp = dst.getTexture(); if(!tex_tmp .available()) return; if(src == dst) System.out.println("WARNING: DoG.apply src == dst"); if(src == tmp) System.out.println("WARNING: DoG.apply src == tmp"); if(dst == tmp) System.out.println("WARNING: DoG.apply dst == tmp"); DwFilter filter = DwFilter.get(context); filter.gaussblur.apply(src, dst, tmp, param.kernel_A); filter.gaussblur.apply(src, src, tmp, param.kernel_B); TexMad tm0 = new TexMad(src, +param.mult, param.shift * 0.5f); TexMad tm1 = new TexMad(dst, -param.mult, param.shift * 0.5f); filter.merge.apply(dst, tm0, tm1); }
Example #5
Source File: Sobel.java From PixelFlow with MIT License | 6 votes |
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 #6
Source File: Laplace.java From PixelFlow with MIT License | 6 votes |
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, Laplace.TYPE kernel, float[] mad) { if(src == dst){ System.out.println("Laplace 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("LaplaceFilter.apply"); }
Example #7
Source File: Convolution.java From PixelFlow with MIT License | 6 votes |
/** * 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 #8
Source File: DistanceTransform.java From PixelFlow with MIT License | 6 votes |
public void computeDistanceThreshold(PGraphicsOpenGL dst, float distance_threshold, float[] colA, float[] colB){ Texture tex_dst = dst.getTexture(); if(!tex_dst .available()) return; int w = dst.width; int h = dst.height; context.begin(); context.beginDraw(dst); shader_threshold.begin(); shader_threshold.uniform2f ("wh_rcp" , 1f/w, 1f/h); shader_threshold.uniform4fv ("colA" , 1, colA); shader_threshold.uniform4fv ("colB" , 1, colB); shader_threshold.uniform1f ("threshold", distance_threshold); shader_threshold.uniformTexture("tex_dtnn" , tex_dtnn.src); shader_threshold.drawFullScreenQuad(); shader_threshold.end(); context.endDraw(); context.end("DistanceTransform.computeDistanceThreshold"); }
Example #9
Source File: CamImageColor.java From PapARt with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void update(IplImage iplImage) { Texture tex = ((PGraphicsOpenGL) parent.g).getTexture(this); ByteBuffer imageBuffer = iplImage.getByteBuffer(); if (this.incomingFormat == Camera.PixelFormat.BGR) { ImageUtils.byteBufferBRGtoARGB(imageBuffer, argbBuffer); } if (this.incomingFormat == Camera.PixelFormat.RGB) { ImageUtils.byteBufferRGBtoARGB(imageBuffer, argbBuffer); } if (this.incomingFormat == Camera.PixelFormat.ARGB) { argbBuffer = iplImage.getByteBuffer(); } tex.copyBufferFromSource(null, argbBuffer, width, height); argbBuffer.rewind(); }
Example #10
Source File: Median.java From PixelFlow with MIT License | 6 votes |
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 #11
Source File: FXAA.java From PixelFlow with MIT License | 6 votes |
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 #12
Source File: DwUtils.java From PixelFlow with MIT License | 6 votes |
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 #13
Source File: ImageSequencePlayer.java From haxademic with MIT License | 5 votes |
public void dispose() { // https://forum.processing.org/two/discussion/6898/how-to-correctly-release-pimage-memory // https://github.com/jeffThompson/ProcessingTeachingSketches/blob/master/Utilities/AvoidPImageMemoryLeaks/AvoidPImageMemoryLeaks.pde for (int i = 0; i < imageSequence.size(); i++) { Object cache = P.p.g.getCache(imageSequence.get(i)); if (cache instanceof Texture) { ((Texture) cache).disposeSourceBuffer(); } P.p.g.removeCache(imageSequence.get(i)); } imageSequence.clear(); }
Example #14
Source File: DwUtils.java From PixelFlow with MIT License | 5 votes |
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 #15
Source File: ShaderTextureWarp.java From haxademic with MIT License | 5 votes |
protected void firstFrame() { ((PGraphics)g).textureWrap(Texture.REPEAT); // _warpShader = p.loadShader(FileUtil.getFile("haxademic/shaders/texturewarp/round-tunnel.glsl")); _warpShader = p.loadShader(FileUtil.getPath("haxademic/shaders/texturewarp/square-tunnel.glsl")); _warpShader.set("time", p.frameCount/100f); PImage img = p.loadImage(FileUtil.getPath("images/ello-grid-crap-512.png")); _warpShader.set("textureInput", img); }
Example #16
Source File: ImageUtils.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
public static void updateTexture(opencv_core.IplImage img, Texture tex) { System.out.println("Update Texture broken ? May Require CustomTexture..."); // if (img.nChannels() == 3) { // tex.putBuffer(GL.GL_BGR, GL.GL_UNSIGNED_BYTE, img.getIntBuffer()); // } // if (img.nChannels() == 4) { // tex.putBuffer(GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, img.getIntBuffer()); // } }
Example #17
Source File: CamImageGray.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void update(opencv_core.IplImage iplImage) { Texture tex = ((PGraphicsOpenGL) parent.g).getTexture(this); ByteBuffer imageBuffer = iplImage.getByteBuffer(); if (incomingFormat == PixelFormat.GRAY) { ImageUtils.byteBufferGRAYtoARGB(imageBuffer, argbBuffer); } if (incomingFormat == PixelFormat.GRAY_32) { ImageUtils.byteBufferGRAY32toARGB(imageBuffer, argbBuffer); } if (incomingFormat == PixelFormat.FLOAT_DEPTH_KINECT2) { ImageUtils.byteBufferDepthK2toARGB(imageBuffer, argbBuffer); } if (incomingFormat == PixelFormat.DEPTH_KINECT_MM) { ImageUtils.byteBufferDepthK1MMtoARGB(imageBuffer, argbBuffer); } if (incomingFormat == PixelFormat.REALSENSE_Z16) { ImageUtils.byteBufferZ16toARGB(imageBuffer, argbBuffer); } if (incomingFormat == PixelFormat.OPENNI_2_DEPTH) { ImageUtils.byteBufferShorttoARGB(imageBuffer, argbBuffer); } // Utils.byteBufferBRGtoARGB(bgrBuffer, argbBuffer); tex.copyBufferFromSource(null, argbBuffer, width, height); imageBuffer.rewind(); }
Example #18
Source File: CamImageGray.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected final void camInit(PApplet parent) { this.parent = parent; Texture tex = ((PGraphicsOpenGL) parent.g).getTexture(this); if (tex == null) { throw new RuntimeException("CamImage: Impossible to get the Processing Texture. " + "Check the size arguments, or input image."); } tex.setBufferSource(this); // Second time with bufferSource. tex = ((PGraphicsOpenGL) parent.g).getTexture(this); argbBuffer = ByteBuffer.allocateDirect(this.pixels.length * 4); }
Example #19
Source File: DwUtils.java From PixelFlow with MIT License | 5 votes |
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 #20
Source File: Multiply.java From PixelFlow with MIT License | 5 votes |
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 #21
Source File: DepthOfField.java From PixelFlow with MIT License | 5 votes |
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, DwScreenSpaceGeometryBuffer geom) { Texture tex_src = src .getTexture(); if(!tex_src .available()) return; Texture tex_geom = geom.pg_geom.getTexture(); if(!tex_geom.available()) return; if(src == dst){ System.out.println("DepthOfField.apply error: read-write race"); } int w = dst.width; int h = dst.height; // dst.loadTexture(); context.begin(); context.beginDraw(dst); shader.begin(); shader.uniform2f ("wh" , w, h); shader.uniform2f ("clip_nf" , param.clip_z_near, param.clip_z_far); shader.uniform2f ("focus_pos" , param.focus_pos[0], param.focus_pos[1]); shader.uniform1f ("mult_blur" , param.mult_blur); shader.uniformTexture("tex_src" , tex_src.glName); shader.uniformTexture("tex_geom" , tex_geom.glName); shader.drawFullScreenQuad(); shader.end(); context.endDraw(); context.end("DepthOfField.apply"); }
Example #22
Source File: ImageUtil.java From haxademic with MIT License | 5 votes |
public static void removeImageFromGraphicsCache(PImage img, PGraphics pg) { // https://forum.processing.org/two/discussion/6898/how-to-correctly-release-pimage-memory // https://github.com/jeffThompson/ProcessingTeachingSketches/blob/master/Utilities/AvoidPImageMemoryLeaks/AvoidPImageMemoryLeaks.pde // https://forum.processing.org/one/topic/pimage-memory-leak-example.html // for (int i = 0; i < imageSequence.size(); i++) { Object cache = pg.getCache(img); pg.removeCache(img); if (cache instanceof Texture) { ((Texture) cache).disposeSourceBuffer(); } // } // imageSequence.clear(); }
Example #23
Source File: CamImageColor.java From PapARt with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected final void camInit(PApplet parent) { this.parent = parent; Texture tex = ((PGraphicsOpenGL) parent.g).getTexture(this); if (tex == null) { throw new RuntimeException("CamImage: Impossible to get the Processing Texture. " + "Check the size arguments, or input image."); } tex.setBufferSource(this); // Second time with bufferSource. tex = ((PGraphicsOpenGL) parent.g).getTexture(this); if (this.incomingFormat != Camera.PixelFormat.ARGB) { argbBuffer = ByteBuffer.allocateDirect(this.pixels.length * 4); } }
Example #24
Source File: Multiply.java From PixelFlow with MIT License | 5 votes |
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"); }
Example #25
Source File: BilateralFilter.java From PixelFlow with MIT License | 5 votes |
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, int radius, float sigma_color, float sigma_space) { if(src == dst){ System.out.println("BilateralFilter 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; context.begin(); context.beginDraw(dst); apply(tex_src.glName, dst.width, dst.height, radius, sigma_color, sigma_space); context.endDraw(); context.end("BilateralFilter.apply"); }
Example #26
Source File: Clamp.java From PixelFlow with MIT License | 5 votes |
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 #27
Source File: Clamp.java From PixelFlow with MIT License | 5 votes |
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 #28
Source File: Threshold.java From PixelFlow with MIT License | 5 votes |
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 #29
Source File: Threshold.java From PixelFlow with MIT License | 5 votes |
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("Threshold.apply"); }
Example #30
Source File: ImageSequenceMovieClip.java From haxademic with MIT License | 5 votes |
public void dispose(PGraphics pg) { // https://forum.processing.org/two/discussion/6898/how-to-correctly-release-pimage-memory // https://github.com/jeffThompson/ProcessingTeachingSketches/blob/master/Utilities/AvoidPImageMemoryLeaks/AvoidPImageMemoryLeaks.pde // https://forum.processing.org/one/topic/pimage-memory-leak-example.html for (int i = 0; i < imageSequence.size(); i++) { Object cache = pg.getCache(imageSequence.get(i)); pg.removeCache(imageSequence.get(i)); if (cache instanceof Texture) { ((Texture) cache).disposeSourceBuffer(); } } imageSequence.clear(); }