pyrender icon indicating copy to clipboard operation
pyrender copied to clipboard

"TypeError: 'NoneType' object is not callable" when calling Renderer.render_text()

Open sven1904 opened this issue 9 months ago • 3 comments

OS: Ubuntu 24.04 pyrender: 0.1.45 pyglet: 2.0.15 PyOpenGL: 3.1.0 trimesh: 4.3.2

When I try to turn rotation on by pressing 'a', I get the following error log:

Traceback (most recent call last):
  File "/home/sti/.local/lib/python3.12/site-packages/OpenGL/latebind.py", line 41, in __call__
    return self._finalCall( *args, **named )
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sti/.local/lib/python3.12/site-packages/pyrender/viewer.py", line 349, in __init__
    self._init_and_start_app()
  File "/home/sti/.local/lib/python3.12/site-packages/pyrender/viewer.py", line 1030, in _init_and_start_app
    pyglet.app.run()
  File "/home/sti/.local/lib/python3.12/site-packages/pyglet/app/__init__.py", line 76, in run
    event_loop.run(interval)
  File "/home/sti/.local/lib/python3.12/site-packages/pyglet/app/base.py", line 163, in run
    timeout = self.idle()
              ^^^^^^^^^^^
  File "/home/sti/.local/lib/python3.12/site-packages/pyglet/app/base.py", line 224, in idle
    self.clock.call_scheduled_functions(dt)
  File "/home/sti/.local/lib/python3.12/site-packages/pyglet/clock.py", line 217, in call_scheduled_functions
    item.func(now - item.last_ts, *item.args, **item.kwargs)
  File "/home/sti/.local/lib/python3.12/site-packages/pyglet/app/base.py", line 118, in _redraw_windows
    window.dispatch_event('on_draw')
  File "/home/sti/.local/lib/python3.12/site-packages/pyglet/window/__init__.py", line 672, in dispatch_event
    super().dispatch_event(*args)
  File "/home/sti/.local/lib/python3.12/site-packages/pyglet/event.py", line 387, in dispatch_event
    if getattr(self, event_type)(*args):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sti/.local/lib/python3.12/site-packages/pyrender/viewer.py", line 571, in on_draw
    self._renderer.render_text(
  File "/home/sti/.local/lib/python3.12/site-packages/pyrender/renderer.py", line 203, in render_text
    font._add_to_context()
  File "/home/sti/.local/lib/python3.12/site-packages/pyrender/font.py", line 148, in _add_to_context
    ch.texture._add_to_context()
  File "/home/sti/.local/lib/python3.12/site-packages/pyrender/texture.py", line 184, in _add_to_context
    self._texid = glGenTextures(1)
                  ^^^^^^^^^^^^^^^^
  File "/home/sti/.local/lib/python3.12/site-packages/OpenGL/latebind.py", line 61, in __call__
    return self.wrapperFunction( self.baseFunction, *args, **named )
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sti/.local/lib/python3.12/site-packages/OpenGL/GL/exceptional.py", line 178, in glGenTextures
    baseFunction( count, textures)
  File "/home/sti/.local/lib/python3.12/site-packages/OpenGL/latebind.py", line 45, in __call__
    return self._finalCall( *args, **named )
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sti/.local/lib/python3.12/site-packages/OpenGL/wrapper.py", line 657, in wrapperCall
    result = wrappedOperation( *cArguments )
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sti/.local/lib/python3.12/site-packages/OpenGL/platform/baseplatform.py", line 402, in __call__
    return self( *args, **named )
           ^^^^^^^^^^^^^^^^^^^^^^
ctypes.ArgumentError: ("argument 2: TypeError: No array-type handler for type _ctypes.type (value: <cparam 'P' (0x717fab06aea0)>) registered", (1, <cparam 'P' (0x717fab06aea0)>))

That has nothing to do with the actual rotation, but calling render_text(...) on the renderer object causes this problem. Since I use this function in my application to display various crucial information, I need some functional text rendering. Although this problem seems to be related to the PyOpenGL library when loading texture for fonts, do you know if there's any workaround to show text until this bug is fixed in the library?

sven1904 avatar May 21 '24 13:05 sven1904