I need to be able to create an off-screen buffer using
createGraphics() as part of a library that should be usable in both Processing 2.x and Processing 1.x.
In Processing 2.x, you can use the two-parameter
createGraphics(w,h) which will use the same renderer as that created in the main sketch through the
size() command. However, Processing 1.x requires a three-parameter version
createGraphics(w,h,iRenderer) where iRenderer is an explicit string such as P2D, P3D etc, that indicates the renderer to use.
My question is, what is the best way to use
createGraphics() that works with both Processing 1.x and 2.x? As far as I can see, there is nothing exposed in
PApplet that allows programmatic detection of the renderer type. If there was, I could simply set the
createGraphics renderer type to that of the main sketch. Since this is for a library, I have no control over the renderer that a user of the library may have selected with
size(), so I need to be able to set the appropriate
createGraphics renderer at runtime.
Any thoughts?
1