createGraphics on Windows10, mode Java
First problem:
using FX2D renderer results in a NullPointerException
at “beginDraw”
Second problem:
not compiling, Type mismatch, “cannot convert from processing.core.PGraphics to PGraphics”
(Pure Woodoo. If I copy the code into a new file, problem is gone, but reproduceable with the first file.
The files are bytewise identical.)
what am I doing wrong?
// first example:
final String renderer = FX2D; //FX2D; //P2D; //JAVA2D;
PGraphics pg;
void setup() {
size(200, 200, renderer);
pg = createGraphics(100, 100, renderer);
}
void draw() {
pg.beginDraw(); // --> NullPointerException
pg.background(102);
pg.stroke(255);
pg.line(pg.width*0.5, pg.height*0.5, mouseX, mouseY);
pg.endDraw();
image(pg, 50, 50);
}
// second example:
final String renderer = P2D; //FX2D; //P2D; //JAVA2D;
// Defaults:
int fps = 30; // Framerate
int displayInitialWidth = 800;
int displayInitialHeight = 600;
// Globals
PGraphics overlay;
/// Screen and rendering settings
void settings()
{
size(displayInitialWidth, displayInitialHeight, renderer);
pixelDensity(displayDensity());
smooth(4);
}
/// Initialization
void setup()
{
frameRate(fps);
surface.setResizable(true);
overlay = createGraphics(width, height, renderer);
overlay.smooth(4);
}
// Loop
void draw()
{
overlay.beginDraw();
overlay.background(0xFFFFFFFF);
overlay.line(0, 0, mouseX, mouseY);
overlay.endDraw();
image(overlay, 0, 0);
}