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

Duncan Murdoch murdoch at stats.uwo.ca
Thu Aug 24 18:01:55 CEST 2006


On 8/24/2006 11:19 AM, Gaspard Lequeux wrote:
> Hej,
> 
> 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 at 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
> glRenderMode(GL_FEEDBACK);
> 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...

gl2ps is a separate project, whose source has been included into rgl. 
You can see the gl2ps project page at http://www.geuz.org/gl2ps/.

We're using version 1.2.2, which is a couple of years old.  The current 
stable release of gl2ps is 1.3.1.  It might fix your problem.

I don't know if we modified gl2ps.c or gl2ps.h when they were included, 
but they haven't been modified since.  (Daniel put them in, based on a 
patch from Albrecht Gebhardt, according to the log.)

It would be helpful to know:

1.  Is the rgl source identical to 1.2.2?
2.  Does rgl work if 1.3.1 is dropped in instead?
3.  Does 1.3.1 fix the bug you're seeing?

I'll look into these at some point, but probably not this week.

Duncan Murdoch



More information about the R-help mailing list