Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close rgl X11 windows?

I want to create a 3D animation with rgl package. My code is like this:

for (frame in 1:100) {
    open3d()
    ... # run some commands here for plotting, like points3d() or spheres3d()
     # Now, save the frame to a png file
    rgl.snapshot(paste0("Frame",sprintf("%04d",frame),".png"))     
}

It works fine and creates an snapshot in PNG file for each frame. But after that, there would be 100 open X11 windows. The other problem is that I guess with opening many windows the running time would be too high.

I tried using rgl.close() and clear3d(), none of them worked fine (they made the output png files to be black).

Is there anyway?

like image 887
Ali Avatar asked Nov 16 '25 16:11

Ali


2 Answers

I realized this is an old question, but this is the simple solution I came up with to close all rgl windows.

while (rgl.cur() > 0) { rgl.close() }
like image 107
DrPo Avatar answered Nov 18 '25 07:11

DrPo


# rgl.close() ... works fine and is self explanatory

3D visualization device system

Description
3D real-time rendering system.
Usage
# Low level rgl.* interface
rgl.open(useNULL = rgl.useNULL())     # open new device
rgl.close()    # close current device
like image 43
LBV Avatar answered Nov 18 '25 06:11

LBV



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!