Re: [R] rgl: exporting to pdf or png does not work

From: Gaspard Lequeux <>
Date: Fri 25 Aug 2006 - 01:19:10 EST


On Wed, 23 Aug 2006, Duncan Murdoch wrote:

> On 8/23/2006 5:15 PM, Gaspard Lequeux wrote:
>> When exporting a image from rgl, the following error is encountered:
>>> rgl.postscript('testing.pdf', fmt="pdf")
>> RGL: ERROR: can't bind glx context to window
>> RGL: ERROR: can't bind glx context to window
>> Warning messages:
>> 1: X11 protocol error: GLXBadContextState
>> 2: X11 protocol error: GLXBadContextState
>> The pdf file is created and is readable, but all the labels are gone.
>> Taking a snapshot (to png) gives 'failed' and no file is created.
>> Version of rgl used: 0.67-2 (2006-07-11)
>> Version of R used: R 2.3.1; i486-pc-linux-gnu; 2006-07-13 01:31:16;
>> Running Debian GNU/Linux testing (Etch).
> That looks like an X11 error to me, not something that I'm very likely
> to be able to fix. If you can debug the error, it would be helpful.

Actually after upgrading everything (debian testing (etch)) and restarting X, I didn't get that error anymore. It was worse: R crashed:

> library(rgl);triangles3d(c(1,,2,3),c(1,2,4),c(1,3,5));rgl.postscript('testing.pdf','pdf')
X Error of failed request: GLXBadContextState

   Major opcode of failed request: 142 (GLX)    Minor opcode of failed request: 5 (X_GLXMakeCurrent)    Serial number of failed request: 85
   Current serial number in output stream: 85 glequeux@toidi:~/seqanal$

I downloaded the source package (debian testing (etch), rgl-0.67-2).

In rgl-0.67-2/src/ I changed the following files:

rglview.cpp, around line 587. Commenting the function call gl2psBeginPage removed the crash (but also no pdf output...)

I enabled this function again and went to gl2ps.c, to the function gl2psBeginPage. At the end of that function, around line 4426, commenting out the line
removes the R crash, but of course still no pdf output (well, only the background).

GL_FEEDBACK is defined in /usr/include/GL/gl.h as:

/* Render Mode */

#define GL_FEEDBACK				0x1C01
#define GL_RENDER				0x1C00
#define GL_SELECT				0x1C02

Trying glRenderMode(GL_RENDER) removed the crash, but still only the background in the pdf.

If someone has some suggestions about what to do next...

/Gaspard mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri Aug 25 01:25:06 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 25 Aug 2006 - 04:26:14 EST.

Mailing list information is available at Please read the posting guide before posting to the list.