dmurdoch / rgl

rgl is a 3D visualization system based on OpenGL. It provides a medium to high level interface for use in R, currently modelled on classic R graphics, with extensions to allow for interaction.
https://dmurdoch.github.io/rgl/
GNU General Public License v2.0
85 stars 21 forks source link

RGL: GLU Library Error : invalid enumerant #266

Closed mwtoews closed 2 years ago

mwtoews commented 2 years ago

Issue

Reporting a warning (or error?) shown running two commands:

library(rgl)
demo(regression)

output:


        demo(regression)
        ---- ~~~~~~~~~~

Type  <Return>   to start : 

> # demo: regression
> # author: Daniel Adler
> 
> rgl.demo.regression <- function(n=100,xa=3,za=8,xb=0.02,zb=0.01,xlim=c(0,100),zlim=c(0,100)) {
...
> rgl.open()

> rgl.demo.regression()
Warning message:
In rgl.spheres(x, esty, z, color = "gray", radius = 1.5, specular = "green",  :
  RGL: GLU Library Error : invalid enumerant

The result displays a new window with the 3D visualization. There does not appear to be any errors, and the visualization appears normal (based on my memory of this demo). The only issue is the message shown in the terminal. Is this of any concern?

System info

dmurdoch commented 2 years ago

I don't see that warning, but I'm not running on Windows. This makes it quite hard to track down: the rgl.spheres function calls a C++ function rgl_spheres, and that function does a lot of work to create the spheres. So I can say "that shouldn't happen", but I can't say how serious it is.

mwtoews commented 2 years ago

Here is a better minimal example:

> library(rgl)
> rgl.spheres(1, texture=system.file("textures/bump_dust.png", package="rgl"))
Warning message:
In rgl.spheres(1, texture = system.file("textures/bump_dust.png",  :
  RGL: GLU Library Error : invalid enumerant
> file.exists(system.file("textures/bump_dust.png", package="rgl"))
[1] TRUE

the rendered sphere does not show any texture, just a plain white sphere: 2022-08-22 12_35_17-RGL device 2  Focus

For what it's worth, I've just installed rgl on a Ubuntu Focal laptop, and I see an identical error/warning and a similar textureless rendered sphere.

There appears to be an issue with the texture argument. Some similar problems: here, here and here. But I'll admit this is way out of my field!

Thanks for taking a look! (And thanks for maintaining this package, I've been using it for 15 years or so!)

dmurdoch commented 2 years ago

I have tracked this down. The reason I wasn't seeing it is that MacOS uses the glGenerateMipmap function from OpenGL 3+, but that function is not available in Windows or Ubuntu, and the workaround code has a bug in it. I should be able to fix it.