processing / processing/processing4

Add a PGraphics/framebuffer stack ala `createFrameBuffer()`

Open
#726 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Created by: scudly

I would like to have a PGraphics / framebuffer stack that works analogously to the matrix stack such that all the default drawing functions apply to the framebuffer currently at the top of the stack without having to reference it explicitly.

All too often, I write code that draws some complex object to the screen and then later end up wanting to draw it to a PGraphics instead so that I can, for instance, generate the image at a much higher resolution. This requires re-writing the code to pass in a PGraphics parameter (or using a global variable) and changing all of the drawing functions to use that PGraphics instead, such as line() to pg.line(). It's messy, error-prone (I always seem to miss changing a width to pg.width), and clutters up the code with all the pg. prefixes.

A far simpler mechanism would use a framebuffer stack with a pushFB( PGraphics pg ) / popFB() pair such that all drawing commands (and width and height constants) apply only to the framebuffer at the top of the stack. pushFB( pg ) would call endDraw() on the current top of stack, push pg on the stack, and then pg.beginDraw(). popFB() would endDraw() the top FB, pop it from the stack, and beginDraw() the new top. The stack is initialized with the default framebuffer and popping it either does nothing or throws an error.

All drawing functions would then be modified (entirely internally and invisible to the users, without any changes to the current API) to apply to the top-of-stack framebufffer. Anyone not using the FB stack wouldn't even know it's there, exactly analogous with the matrix stack.

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 locating the existing matrix stack and the PGraphics drawing lifecycle, especially beginDraw() and endDraw(). Trace how default drawing functions and width/height currently select the default framebuffer. Done means a pushFB()/popFB() stack applies those operations to the top framebuffer while preserving existing behavior when unused.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.