processing.opengl.PGraphicsOpenGL Java Examples

The following examples show how to use processing.opengl.PGraphicsOpenGL. 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: Demo_VertexShader_ReloadInlineGlsl.java    From haxademic with MIT License 6 votes vote down vote up
protected void drawApp() {
		// set context
		pg.beginDraw();
		pg.background(0);
		pg.noLights();
		PG.setCenterScreen(pg);
//		PG.basicCameraFromMouse(pg);
		pg.rotateY(FrameLoop.progressRads());
		
		// apply deform shader and draw mesh - CANNOT HAVE PROCESSING LIGHTS TURNED ON!
		shader.set("time", FrameLoop.progressRads());
		shader.set("displaceAmp", 0.4f);
		shader.set("modelviewInv", ((PGraphicsOpenGL) g).modelviewInv);
		pg.shader(shader);

		// apply shader, draw shape
		pg.shape(icosa);
		pg.resetShader();
		pg.endDraw();
		
		// draw pg to screen
		p.image(pg, 0, 0);
	}
 
Example #2
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 #3
Source File: ARDisplay.java    From PapARt with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Start the drawing, to be used in manual mode. This method loads the
 * projection and modelview matrices. It uses the camera member to get the
 * paperScreen location.
 *
 * @param paperScreen
 * @return
 */
@Override
public PGraphicsOpenGL beginDrawOnScreen(PaperScreen paperScreen) {
    PMatrix3D screenPos = paperScreen.getLocation(this.camera);

    this.beginDraw();
    if (this.hasExtrinsics()) {
        screenPos.preApply(getExtrinsics());
    }
    this.graphics.applyMatrix(screenPos);

    // Same origin as in DrawOnPaper
    this.graphics.translate(0, paperScreen.getSize().y);
    this.graphics.scale(1, -1, 1);

    return this.graphics;
}
 
Example #4
Source File: Laplace.java    From PixelFlow with MIT License 6 votes vote down vote up
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 #5
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 #6
Source File: DistanceTransform.java    From PixelFlow with MIT License 6 votes vote down vote up
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 #7
Source File: Rippleskin.java    From haxademic with MIT License 6 votes vote down vote up
protected void drawApp() {
		// set context
		pg.beginDraw();
		pg.background(0);
		pg.noLights();
		PG.setCenterScreen(pg);
//		PG.basicCameraFromMouse(pg);
		pg.rotateY(FrameLoop.progressRads());
		
		// apply deform shader and draw mesh - CANNOT HAVE PROCESSING LIGHTS TURNED ON!
		shader.set("time", FrameLoop.progressRads());
		shader.set("displaceAmp", 0.4f);
		shader.set("modelviewInv", ((PGraphicsOpenGL) g).modelviewInv);

		// apply shader, draw shape
		pg.shader(shader);  
		pg.shape(icosa);
		pg.resetShader();
		pg.endDraw();
		
		// draw pg to screen
		p.image(pg, 0, 0);
	}
 
Example #8
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 #9
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 #10
Source File: DwFlowField.java    From PixelFlow with MIT License 6 votes vote down vote up
public void displayLines(PGraphicsOpenGL dst){
  int   w = dst.width;
  int   h = dst.height;
  int   lines_x   = (int) Math.ceil(w/param.line_spacing);
  int   lines_y   = (int) Math.ceil(h/param.line_spacing);
  int   num_lines = lines_x * lines_y;
  float scale     = param.line_scale;

  context.begin();
  context.beginDraw(dst);
  blendMode();
  shader_display_lines.vert.setDefine("LINE_MODE"   , param.line_mode);
  shader_display_lines.vert.setDefine("LINE_SHADING", param.line_shading);
  shader_display_lines.begin();
  shader_display_lines.uniform4fv    ("col_A"         , 1, param.line_col_A);
  shader_display_lines.uniform4fv    ("col_B"         , 1, param.line_col_B);
  shader_display_lines.uniform2i     ("wh_lines"      ,    lines_x,    lines_y);
  shader_display_lines.uniform2f     ("wh_lines_rcp"  , 1f/lines_x, 1f/lines_y);
  shader_display_lines.uniform1f     ("vel_scale"     , scale);
  shader_display_lines.uniformTexture("tex_velocity"  , tex_vel);
  shader_display_lines.drawFullScreenLines(num_lines, param.line_width, param.line_smooth);
  shader_display_lines.end();
  context.endDraw("FlowField.displayLines");
  context.end();
}
 
Example #11
Source File: BaseDisplay.java    From PapARt with GNU Lesser General Public License v3.0 6 votes vote down vote up
public PGraphicsOpenGL beginDrawOnScreen(PaperScreen paperScreen) {
    PMatrix3D screenPos;

    if (this.hasCamera()) {
        screenPos = paperScreen.getLocation(this.getCamera());
    } else {
        // Get the markerboard viewed by the camera
        screenPos = paperScreen.getExtrinsics();
    }
    this.beginDraw();
    this.graphics.applyMatrix(screenPos);

    // Same origin as in DrawOnPaper
    this.graphics.translate(0, paperScreen.getSize().y);
    this.graphics.scale(1, -1, 1);
    return this.graphics;
}
 
Example #12
Source File: Skylight_BasicGUI.java    From PixelFlow with MIT License 6 votes vote down vote up
public void displayScene(PGraphicsOpenGL canvas){
  if(canvas == skylight.renderer.pg_render){
    canvas.background(BACKGROUND);
    displaySamples(canvas);
  }
  
  if(canvas == geombuffer.pg_geom){
    canvas.pgl.clearDepth(1.0f);
    canvas.pgl.clearColor(1, 1, 1, clip_z_far);
    canvas.pgl.clear(PGL.COLOR_BUFFER_BIT | PGL.DEPTH_BUFFER_BIT);
  }
  
  canvas.pushMatrix();
  canvas.applyMatrix(mat_scene_view);
  canvas.shape(shp_group);
  canvas.popMatrix();
}
 
Example #13
Source File: SummedAreaTable.java    From PixelFlow with MIT License 6 votes vote down vote up
/**
 * 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 #14
Source File: DwLiquidFX.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL pg_src, PGraphicsOpenGL pg_dst){
    int w = pg_src.width;
    int h = pg_src.height;
//    tex_particles.resize(context, GL2.GL_RGBA8, w, h, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, GL2.GL_LINEAR, 4, 1);
    tex_particles.resize(context, GL2.GL_RGBA16F, w, h, GL2.GL_RGBA, GL2.GL_FLOAT, GL2.GL_LINEAR, 4, 2);
//    for(int i = 0; i < 50; i++){
    filter.copy.apply(pg_src, tex_particles);
    apply(tex_particles);
//    }
    filter.copy.apply(tex_particles, pg_dst);

  }
 
Example #15
Source File: CamImageGray.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #16
Source File: BoxBlur.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL src, PGraphicsOpenGL dst, PGraphicsOpenGL tmp, int radius) {
    if(src == tmp || dst == tmp){
      System.out.println("BoxBlur 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;
    
//    tmp.beginDraw();
    context.begin();
    context.beginDraw(tmp);
    pass(tex_src.glName, tmp.width, tmp.height, radius, HORZ);
    context.endDraw();
    context.end("BoxBlur.apply - HORZ");
//    tmp.endDraw();

//    dst.beginDraw();
    context.begin();
    context.beginDraw(dst);
    pass(tex_tmp.glName, dst.width, dst.height, radius, VERT);
    context.endDraw();
    context.end("BoxBlur.apply - VERT");
//    dst.endDraw(); 
  }
 
Example #17
Source File: DwFlowFieldParticles.java    From PixelFlow with MIT License 5 votes vote down vote up
public void displayParticles(PGraphicsOpenGL canvas){
  if(param.size_display <= 0) return;
  context.begin();
  context.beginDraw(canvas);
  displayParticles(canvas.width, canvas.height);
  context.endDraw();
  context.end("DwFlowFieldParticles.displayParticles PGraphicsOpenGL");
}
 
Example #18
Source File: Bloom.java    From PixelFlow with MIT License 5 votes vote down vote up
/**
 * 
 * "src_luminance" serves as the source texture for the bloom pass.
 * e.g this texture can be the result of a brightness-prepass on dst_composition.
 *  
 * "dst_bloom" is the merged result of several iterations of gaussian-blurs.
 * 
 * "dst_composition" is the final result of additive blending with "dst_bloom".
 * 
 * 
 * @param src_luminance
 * @param dst_bloom
 * @param dst_composition
 */
public void apply(PGraphicsOpenGL src_luminance, PGraphicsOpenGL dst_bloom, PGraphicsOpenGL dst_composition){

  // 1) create blur levels
  gaussianpyramid.apply(src_luminance, param.blur_radius);
  
  // 2) compute blur-texture weights
  tex_weights = computeWeights(tex_weights);

  // 3a) merge + blend: dst_bloom is not null, therefore the extra pass
  if(dst_bloom != null){
    //merge.apply(dst_bloom, gaussianpyramid.tex_blur, tex_weights);
    mergeBlurLayers(dst_bloom);
    if(dst_composition != null){
      context.pushRenderSettings(additive_blend);
      DwFilter.get(context).copy.apply(dst_bloom, dst_composition);
      context.popRenderSettings();
    }
    return;
  }
  
  // 3b) merge + blend:  dst_bloom is null, so we merge + blend into dst_composition
  context.pushRenderSettings(additive_blend);
  //merge.apply(dst_composition, gaussianpyramid.tex_blur, tex_weights);
  mergeBlurLayers(dst_composition);
  context.popRenderSettings();
}
 
Example #19
Source File: DrawUtils.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
static public void drawImage(PGraphicsOpenGL g, PImage img, int x, int y, int w, int h) {
//        g.pushMatrix();
//        g.translate(x, y);
//        g.scale(-1, 1, 1);
//        g.rotate(PApplet.PI);
//        g.image(img, 0, 0, w, h);
//        g.popMatrix();

//        g.beginShape(QUADS);
//        g.texture(img);
//        g.vertex(x, y, 0, h);
//        g.vertex(x, y + h, 0, 0);
//        g.vertex(x + w, y + h, w, 0);
//        g.vertex(x + w, y, w, h);
//        g.endShape();

        g.pushMatrix();
        g.translate(x, y);
        g.beginShape(QUADS);
        g.textureMode(NORMAL);
        g.texture(img);
        g.vertex(0, 0, 0, 1);
        g.vertex(0, h, 0, 0);
        g.vertex(w, h, 1, 0);
        g.vertex(w, 0, 1, 1);
        g.endShape();
        
        g.popMatrix();

    }
 
Example #20
Source File: DwFlowFieldParticles.java    From PixelFlow with MIT License 5 votes vote down vote up
public void displayTrail(PGraphicsOpenGL canvas){
  if(param.display_line_width <= 0) return;
  context.begin();
  context.beginDraw(canvas);
  displayTrail(canvas.width, canvas.height);
  context.endDraw();
  context.end("DwFlowFieldParticles.displayTrail PGraphicsOpenGL");
}
 
Example #21
Source File: Demo_Polygon.java    From haxademic with MIT License 5 votes vote down vote up
protected void drawApp() {
		background(0);
		
//		camera test
//		p.translate(0, 0, -1500 * Mouse.xNorm);
//		p.rotateX(Mouse.yNorm * 3f);
		displaceTexture.offsetX(p.frameCount/100f);
		displaceTexture.update();
		// draw & generate shapes
		pg.beginDraw();
		// apply deform shader and draw mesh - CANNOT HAVE PROCESSING LIGHTS TURNED ON!
		polygonShader.shader().set("time", p.frameCount);
		polygonShader.shader().set("displacementMap", displaceTexture.texture());
		polygonShader.shader().set("displaceAmp", baseShapeSize);
		polygonShader.shader().set("modelviewInv", ((PGraphicsOpenGL) g).modelviewInv);
		polygonShader.update();
		// apply polygons shader
		pg.shader(polygonShader.shader());  

		BrightnessStepFilter.instance(p).setBrightnessStep(-1f/255f);
		BrightnessStepFilter.instance(p).applyTo(pg);
		if(clearsBg) pg.background(255);
		if(p.frameCount % RESET_FRAME_INTERVAL == 0) newSeedPolygon();
		movePolygons();
		drawPolygons();
		createNeighbors();
		closeNeighbors();
		removePolygons();
		pg.resetShader();

		pg.endDraw();
		// postProcess();
	
		// draw main buffer to screen
		ImageUtil.cropFillCopyImage(pg, p.g, false);
		
		// draw debug log
		log.printToScreen(p.g, 20, 20);
		DebugView.setValue("Polygons", polygons.size());
	}
 
Example #22
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 #23
Source File: PointCloud.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void initPointCloud() {
        PGL pgl = ((PGraphicsOpenGL) parentApplet.g).pgl;

        // TODO: lookt at the shaders... 
        myShader = parentApplet.loadShader(PointCloud.class.getResource("points.frag").toString(),
                PointCloud.class.getResource("points.vert").toString());

        myShader.bind();
        shaderProgram = myShader.glProgram;
        vertLoc = pgl.getAttribLocation(shaderProgram, "vertex");
        colorsLoc = pgl.getAttribLocation(shaderProgram, "color");
        transformLoc = pgl.getUniformLocation(shaderProgram, "transform");

        myShader.unbind();

//         System.out.println("Shader program " + shaderProgram + " vertex loc " + vertLoc + " transform loc " + transformLoc + " colors " + colorsLoc);
        // Allocate the buffer in central memory (native),  then java, then OpenGL 
        // Native memory         
        int byteSize = nbPoints * 4 * 4; // 4 : SizeOf Float   -> ? SIZEOF_FLOAT
        verticesNative = ByteBuffer.allocateDirect(byteSize).order(ByteOrder.nativeOrder()).
                asFloatBuffer();
        colorsNative = ByteBuffer.allocateDirect(byteSize).order(ByteOrder.nativeOrder()).asIntBuffer();

        // Java memory 
        verticesJava = new float[nbPoints * 4];
        colorsJava = new int[nbPoints];

//        System.out.println("Buffer vertex object: " + glVertBuff);
        // unbind the buffer.
        pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
        
        // Generate a buffer color data and color. 
        IntBuffer intBuffer = IntBuffer.allocate(2);
        pgl.genBuffers(2, intBuffer);
        vertexBuffer = intBuffer.get(0);
        colorBuffer = intBuffer.get(1);
        
    }
 
Example #24
Source File: PaperScreen.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Disable the drawing and clear the offscreen.
 */
public void noDraw() {
    setDrawing(false);
    PGraphicsOpenGL pg = getGraphics();
    pg.beginDraw();
    pg.clear();
    pg.endDraw();
}
 
Example #25
Source File: CamImageColor.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #26
Source File: Demo_VertexShader_PShaderHotSwap.java    From haxademic with MIT License 5 votes vote down vote up
protected void drawApp() {
		// set context
		pg.beginDraw();
		pg.background(0);
		pg.noLights();
		PG.setCenterScreen(pg);
		PG.basicCameraFromMouse(pg);
//		pg.rotateY(AnimationLoop.progressRads());
		
		// apply deform shader and draw mesh - CANNOT HAVE PROCESSING LIGHTS TURNED ON!
		shaderHotSwap.shader().set("time", FrameLoop.progressRads());
		shaderHotSwap.shader().set("displaceAmp", 0.4f);
		shaderHotSwap.shader().set("modelviewInv", ((PGraphicsOpenGL) g).modelviewInv);

		// apply shader, draw shape
		pg.shader(shaderHotSwap.shader());  
		pg.shape(icosa);
		pg.resetShader();
		pg.endDraw();
		
		// draw pg to screen
		p.image(pg, 0, 0);
		
		// recompile if needed & show shader compile error messages
		shaderHotSwap.update();
		shaderHotSwap.showShaderStatus(p.g);
	}
 
Example #27
Source File: PG.java    From haxademic with MIT License 5 votes vote down vote up
public static PGraphics newPG2DFast(int w, int h) {
		PGraphics newPG = P.p.createGraphics(w, h, PRenderers.P2D);
//		newPG.noSmooth();
	    ((PGraphicsOpenGL)newPG).textureSampling(2);
		newPG.beginDraw();
		newPG.background(0, 0);
		newPG.noStroke();
//		newPG.hint(PConstants.DISABLE_DEPTH_SORT);
//		newPG.hint(PConstants.DISABLE_DEPTH_TEST);
//		newPG.hint(PConstants.DISABLE_DEPTH_MASK);
		newPG.endDraw();
		PG.setTextureRepeat(newPG, false);
		return newPG;
	}
 
Example #28
Source File: Merge.java    From PixelFlow with MIT License 5 votes vote down vote up
public void apply(PGraphicsOpenGL dst, TexMad ... tex){
  if(tex == null) return;
  Texture tex_dst = dst.getTexture(); if(!tex_dst.available())  return;
  context.begin();
  context.beginDraw(dst);
  apply(tex_dst.glWidth, tex_dst.glHeight, tex);
  context.endDraw();
  context.end("Merge.apply");
}
 
Example #29
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 #30
Source File: LuminanceThreshold.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("LuminanceThreshold.apply");
}