createGraphics()
RenderingDescription
Creates an off-screen rendering surface (PGraphics). Draw into it using beginDraw()/endDraw(), then display with image().
Syntax
PGraphics* createGraphics(int w, int h)
Parameters
| Name | Type | Description |
|---|---|---|
| w | int | width of the graphics buffer |
| h | int | height of the graphics buffer |
Returns
PGraphics*Related
Under the Hood
From Processing.h:
PGraphics* createGraphics(int w, int h);
PGraphics* createGraphics(int w, int h, int renderer);
Under the Hood
From Processing.cpp:
PGraphics* PApplet::createGraphics(int w,int h){return new PGraphics(w,h);}
PGraphics* PApplet::createGraphics(int w,int h,int renderer){
// The renderer argument genuinely matters: a P3D buffer needs
// beginDraw() to set up a real perspective projection with depth
// testing enabled, instead of the flat 2D ortho projection (depth
// range -1..1) used for plain 2D buffers -- without this, any 3D
// content drawn into the buffer (box(), sphere(), translate(...,z))
// gets clipped away entirely by the paper-thin depth range, and
// lighting/depth-testing never activates at all. See PGraphics::
// beginDraw()'s is3D branch for the actual projection setup.
return new PGraphics(w, h, renderer == P3D);
}