Hello. I would like to discuss an issue related to a screen capturing program. The following code is capable of screen recording and overlaying the mouse cursor:
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.awt.Rectangle;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Toolkit;
Robot robot;
Point mouse;
Rectangle r;
BufferedImage img1;
PImage img2;
void setup() {
size(1024, 768); // simulator resolution
try { robot = new Robot(); }
catch (Exception e) { println(e.getMessage()); }
r = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
img1 = new BufferedImage(1024, 768, BufferedImage.TYPE_INT_RGB);
stroke(255, 0, 0, 75);
strokeWeight(6);
fill(255, 255, 255, 100);
frameRate(30);
}//setup
void draw() {
background(0);
img1 = robot.createScreenCapture(r);
img2 = new PImage(img1);
image(img2, 0, 0);
mouse = MouseInfo.getPointerInfo().getLocation();
ellipse(mouse.x, mouse.y, 50, 50);
saveFrame("data/screen-######.tif");
}//draw
The program sends about 30 screenshots per second to the data folder. After recording, I use the Movie Maker tool to put all frames together as a video clip.
I have successfully tested the code by MS Flight Simulator X running in full screen mode. I also tried to get screenshots from Laminar Research X-Plane 9. In this case however, the program stored black frames only.
I presume the issue has something to do with the renderer. The MSFS X uses DirectX whilst the X-Plane uses OpenGL.
I would like to ask if it is possible to develop a workaround code in Processing which is capable of capturing screenshots in OpenGL rendering mode. Frankly, I don’t know where I should start from. Every advise is appreciated. Thank you in advance!