I'm having a problem with rgl.snapshot.  If I run the following code *once* and *once only*, all is well.

data(trees) 
attach(trees)
plot3d(Height, Girth, Volume, type='s')
rgl.snapshot("/home/user/pic.png", fmt="png", top=TRUE )

And the pic.png looks right.  But if I try to rerun rgl.snapshot anytime again in this session, the file pic.png still outputs but is nothing but colored lines, like in a TV test pattern.

I also tried the built-in example:

    shade3d(oh3d(), color="red")
     rgl.bringtotop()
     rgl.viewpoint(0,20)
     setwd(path)
     for (i in 1:45) {
       rgl.viewpoint(i,20)
       filename <- paste("pic",formatC(i,digits=1,flag="0"),".png",sep="")
       rgl.snapshot(filename)
     }

and all the png files are colored lines.

I seem to have no trouble installing rgl (my configure output is below), and I have seen the previous messages about finding paths to the X11 etc. lirbaries.  My libpng is up to date.  I have tried this on two different Ubuntu hardy machines and get the same thing.

Anybody else out there get this?

Thanks.

Configure output

 sudo R CMD INSTALL --configure-args='--x-includes=/usr/include/X11 --x-libraries=/usr/lib' rgl_0.79.tar.gz 
* Installing to library '/usr/local/lib/R/site-library'
* Installing *source* package 'rgl' ...
checking for gcc... gcc -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for gcc... (cached) gcc -std=gnu99
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc -std=gnu99 accepts -g... (cached) yes
checking for gcc -std=gnu99 option to accept ANSI C... (cached) none needed
checking for libpng-config... yes
configure: using libpng-config
configure: using libpng dynamic linkage
checking for X... libraries /usr/lib, headers /usr/include/X11
checking GL/gl.h usability... yes
checking GL/gl.h presence... yes
checking for GL/gl.h... yes
checking GL/glu.h usability... yes
checking GL/glu.h presence... yes
checking for GL/glu.h... yes
checking for glEnd in -lGL... yes
checking for gluProject in -lGLU... yes
checking for freetype-config... yes
configure: using Freetype and FTGL
configure: creating ./config.status
config.status: creating src/Makevars
	[[alternative HTML version deleted]]

