On 27 Jun 2010, at 22:19, Duncan Murdoch wrote:
On 27/06/2010 12:58 PM, Matthew Neilson wrote:
Hi there,
I've written a script for reading 3D simulation data into R,
rendering it using RGL, and then saving the resulting plot using
the snapshot3d() function. The results are fantastic! However,
whenever RGL plots anything it automatically brings the viewing
window into focus. Since I'm producing a large number of plots in
a loop, my machine becomes almost unusable for the duration of the
script.
When producing 2D plots in R (i.e. not using RGL), I can easily
call the pdf() function before each plot (and then close it with
the dev.off() function) so that the plot is written directly to a
file, thus bypassing the display. This allows me to set scripts
running in the background, so that I can get on with other
things. ;)
Is there a way of forcing RGL to draw to an "invisible" (virtual,
or buffered?) display that can then be saved using the
snapshot3d() function?
rgl can't do that, but perhaps your OS can, e.g. you set up an X11
server that doesn't display anything on your screen. I don't know
if that's possible or not.
You can avoid bringing the window to the top by setting the top
argument to FALSE when you call snapshot3d, but what I found when
doing this on many systems was that I got a snapshot showing the
overlapping window, not just the contents of the rgl window. What
happens on your system will depend on your graphics driver.
You might also be able to tell rgl (via r3dDefaults) to open the
window mostly off your screen. I don't know if you'll get a useful
snapshot from it.
Thanks for the suggestions!
I tried launching a vnc server on (for example) display :4, and then
using Sys.setenv(DISPLAY=":4") at the beginning of my script.
Unfortunately, vncserver doesn't support GLX, so upon calling open3d()
I'm presented with an error message and the R session terminates.
Setting "top=FALSE" in each RGL-related statement does indeed prevent
the window from being brought to the top, but as you said this results
in unpredictable output -- in my case, the plot only takes up about a
quarter of the plotting window and I'm left with masses of white-space.
Fortunately, your final suggestion suits my needs perfectly! I simply
need to set $windowRect such that the top/right corner of the RGL
device is at the extreme bottom/left corner of my display. This frees
up 99% of my display, and I don't see any flickering/redrawing
(because the only visible portion of the window is the right edge of
its title-bar). Note that at least some of the window must remain on-
screen -- if $windowRect is set such that the entire window is off-
screen, the windowing system becomes messed up.
Thanks again for the help, it's much appreciated!
-Matt
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.