Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PYOPENGL_PLATFORM = osmesa not working with DEPTH_ONLY flag #77

Open
ericvg97 opened this issue Oct 8, 2019 · 2 comments
Open

PYOPENGL_PLATFORM = osmesa not working with DEPTH_ONLY flag #77

ericvg97 opened this issue Oct 8, 2019 · 2 comments

Comments

@ericvg97
Copy link

ericvg97 commented Oct 8, 2019

I am running the second example code from the quickstart changing/adding this part of the code:

flags = pyrender.RenderFlags.DEPTH_ONLY | pyrender.RenderFlags.OFFSCREEN
depth = r.render(scene, flags = flags)

And it works fine. However, when I ask it to work with OSMESA at the beginning of the code with:

import os
os.environ['PYOPENGL_PLATFORM'] = 'osmesa'

I get the following error:

Traceback (most recent call last):
  File "prova3.py", line 30, in <module>
    depth = r.render(scene, flags = flags)
  File "/usr/local/lib/python2.7/dist-packages/pyrender/offscreen.py", line 101, in render
    self._renderer.render(scene, flags)
  File "/usr/local/lib/python2.7/dist-packages/pyrender/renderer.py", line 140, in render
    retval = self._forward_pass(scene, flags)
  File "/usr/local/lib/python2.7/dist-packages/pyrender/renderer.py", line 322, in _forward_pass
    self._configure_forward_pass_viewport(flags)
  File "/usr/local/lib/python2.7/dist-packages/pyrender/renderer.py", line 979, in _configure_forward_pass_viewport
    self._configure_main_framebuffer()
  File "/usr/local/lib/python2.7/dist-packages/pyrender/renderer.py", line 1061, in _configure_main_framebuffer
    self.viewport_width, self.viewport_height
  File "/usr/local/lib/python2.7/dist-packages/OpenGL/platform/baseplatform.py", line 409, in __call__
    return self( *args, **named )
  File "/usr/local/lib/python2.7/dist-packages/OpenGL/error.py", line 232, in glCheckError
    baseOperation = baseOperation,
OpenGL.error.GLError: GLError(
	err = 1282,
	description = 'invalid operation',
	baseOperation = glRenderbufferStorageMultisample,
	cArguments = (GL_RENDERBUFFER, 4, GL_RGBA, 400, 400)
)

This would be useful for anyone wanting to work via ssh and without the need to render color (which is particularly our case)

Thank you!

@bolitt
Copy link

bolitt commented Jan 9, 2021

I got the same issue at Line 1091 of renderer.py.

Furthermore, I checked GL_MAX_SAMPLES

glGetIntegerv(GL_MAX_SAMPLES)  # returns 1

However, the spec said it should be at least 4, which is quite weird.

-- Notes --
If I changed Line 1091 and 1096 from samples = 4 to 0. The result will be all empty images.

@bolitt
Copy link

bolitt commented Jan 10, 2021

[Update]
For the error, my fixture is at Line 1091 and 1096:

num_samples = min(glGetIntegerv(GL_MAX_SAMPLES), 4)   # No more than GL_MAX_SAMPLES
glRenderbufferStorageMultisample(GL_RENDERBUFFER, num_samples, GL_RGBA, self.viewport_width, self.viewport_height)
glRenderbufferStorageMultisample(GL_RENDERBUFFER, num_samples, GL_DEPTH_COMPONENT24, self.viewport_width, self.viewport_height)

For the problem of empty images, I also use explicit flags. After digging into the offscreen.py, I find RenderFlags.OFFSCREEN is added automatically, so there is no need to explicitly use RenderFlags.OFFSCREEN in flags.

if self._platform.supports_framebuffers():
    flags |= RenderFlags.OFFSCREEN
    ...
else:
   # If your platform doesn't support framebuffers, it cannot render with `RenderFlags.OFFSCREEN`.
    ...

So argument flags should not contain RenderFlags.OFFSCREEN.

It solves my problem. Hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants