processing / processing/processing4

Copying PGraphics to PImage using .get() or .copy() clears PGraphics object, if the renderer is P2D

Open
#681 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted opengl
Dominant language
Java
Stars
494
Forks
183
Avg merge
4h 39m
Merged PRs (30d)
3

Description

Created by: agrshch

Description

An attempt of copying information from PGraphics to PImage using get() or copy() clears the PGraphics object if P2D renderer is used. It makes impossible many things, for example using PGraphics (or its copy) as a texture for the shader.

Expected Behavior

successful copying, like with default renderer

Current Behavior

both PGraphics and PImage are empty.

Steps to Reproduce

PGraphics img1;

void setup() {
size(300, 300, P2D);

img1 = createGraphics(200, 200, P2D);

img1.beginDraw();
img1.background(120);
img1.endDraw();

PImage img2 = img1.get(); // if comment out this line — grey rectangle appears
}

void draw() {
background(255);
image(img1, 100, 20);
}

Your Environment

  • Processing version: 4.2
  • Operating System and OS version: Mac OS 10.15.7
  • Other information:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided P2D sketch and tracing the PGraphics get() and copy() entry points in the Java core library. Compare the P2D behavior with the default renderer, checking why the source and destination become empty. Done means copying preserves the PGraphics contents and produces a populated PImage under P2D.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.