使用处理opengl创建视频
Create a video using processing opengl
我正在创建一个 REST API
以根据用户输入和提供的动画类型动态生成视频。所以,我为此使用处理 2.2.1。
我想使用 OPENGL
生成 3D 动画。但是 OPENGL
需要 Window 对象。由于我在后台使用处理来生成帧,我如何使用 OPENGL
处理来生成没有交互方式的动画帧而不显示 window.
我的示例代码
import com.hamoid.VideoExport;
import processing.core.*;
public class CircleSketch extends PApplet {
private VideoExport videoExport;
public void setup() {
size(400, 400,OPENGL);
videoExport = new VideoExport(this, "F:/work/tmp.mp4");
background(0);
}
public void draw() {
background(0);
fill(200);
rotateX(radians(50));
rectMode(CENTER);
rect(width/2,height/2, 100, 100);
videoExport.saveFrame();
}
}
DisplayFrame
Class
public class DisplayFrame extends javax.swing.JFrame {
public DisplayFrame(){
this.setSize(600, 600); //The window Dimensions
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
javax.swing.JPanel panel = new javax.swing.JPanel();
panel.setBounds(20, 20, 600, 600);
processing.core.PApplet sketch = new CircleSketch();
panel.add(sketch);
this.add(panel);
this.setVisible(false);
sketch.init(); //this is the function used to start the execution of the sketch
}
public static void main(String[] args) {
new DisplayFrame().setVisible(false);
}
}
有什么建议吗???
how can I use processing with OPENGL to generate animated frames without interactive means without displaying the window.
简而言之:鉴于当前的 OpenGL 驱动程序模型你不能(只要你想使用 GPU 进行渲染)。 期间,就是这样。
如果您可以忍受软件渲染(慢),那么 OSMesa。同样在可预见的未来,驱动程序模型应该会发生变化,从而允许在无头环境中使用 OpenGL。在那之前,您需要一个 window 某种图形环境,它实际上主动提供显示输出(因此启动 X11 服务器并在后台运行它是不够的)。
我正在创建一个 REST API
以根据用户输入和提供的动画类型动态生成视频。所以,我为此使用处理 2.2.1。
我想使用 OPENGL
生成 3D 动画。但是 OPENGL
需要 Window 对象。由于我在后台使用处理来生成帧,我如何使用 OPENGL
处理来生成没有交互方式的动画帧而不显示 window.
我的示例代码
import com.hamoid.VideoExport;
import processing.core.*;
public class CircleSketch extends PApplet {
private VideoExport videoExport;
public void setup() {
size(400, 400,OPENGL);
videoExport = new VideoExport(this, "F:/work/tmp.mp4");
background(0);
}
public void draw() {
background(0);
fill(200);
rotateX(radians(50));
rectMode(CENTER);
rect(width/2,height/2, 100, 100);
videoExport.saveFrame();
}
}
DisplayFrame
Class
public class DisplayFrame extends javax.swing.JFrame {
public DisplayFrame(){
this.setSize(600, 600); //The window Dimensions
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
javax.swing.JPanel panel = new javax.swing.JPanel();
panel.setBounds(20, 20, 600, 600);
processing.core.PApplet sketch = new CircleSketch();
panel.add(sketch);
this.add(panel);
this.setVisible(false);
sketch.init(); //this is the function used to start the execution of the sketch
}
public static void main(String[] args) {
new DisplayFrame().setVisible(false);
}
}
有什么建议吗???
how can I use processing with OPENGL to generate animated frames without interactive means without displaying the window.
简而言之:鉴于当前的 OpenGL 驱动程序模型你不能(只要你想使用 GPU 进行渲染)。 期间,就是这样。
如果您可以忍受软件渲染(慢),那么 OSMesa。同样在可预见的未来,驱动程序模型应该会发生变化,从而允许在无头环境中使用 OpenGL。在那之前,您需要一个 window 某种图形环境,它实际上主动提供显示输出(因此启动 X11 服务器并在后台运行它是不够的)。