Moment of truth.
Here is the last revision, I hope!
I’m sad to say this, but this only supports the P2D
and P3D
renderers!
Pretty sure most people will be using GPU
-based rendering anyway, amIrite?
Also, there is bad luck involved…
In short, this could change with newer versions of Processing, …and:
The code, yay!:
import com.jogamp.newt.opengl.GLWindow;
// [https://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/newt/opengl/GLWindow.html];
GLWindow window;
void setup() {
size(640, 480, P3D);
registerMethod("post", this); // Never forget the "this dot", and also this!!11!
sphereDetail(8);
surface.setResizable(true);
surface.setTitle("haha press f11");
window = (GLWindow) surface.getNative();
}
void draw() {
background(0);
stroke(255);
strokeWeight(8);
line(
map(window.getX(), 0, displayWidth, 0, width*1.75), 0,
map(window.getX(), 0, displayWidth, 0, width*1.75),
map(window.getY(), 0, displayHeight, 0, height*2.5)
);
if (mousePressed) stroke(255f, 0, 0);
strokeWeight(1f);
noFill();
lights();
translate(mouseX, mouseY);
rotateX(millis()*.001f);
rotateZ(millis()*.001f);
sphere(50f);
}
boolean fs;
void keyPressed() {
if (keyCode == 107) {
fs = !fs;
surface.setSize(displayWidth, displayHeight);
if (!fs) surface.setSize(640, 480);
}
}
void post() {
if (fs)
if (!window.isUndecorated()) {
window.setVisible(false);
try {
window.setUndecorated(true);
}
catch(Exception e) {
}
window.setVisible(true);
while (!window.isUndecorated());
} else surface.setLocation(0, 0);
else if (window.isUndecorated())
try {
window.setVisible(false);
window.setUndecorated(false);
window.setVisible(true);
}
catch(Exception e) {
}
}