3DViewer icon indicating copy to clipboard operation
3DViewer copied to clipboard

Use with other PySide modules

Open jmatthess opened this issue 1 year ago • 0 comments

Hey

I took a stab at trying to integrate your 3d viewer into a pyside6 project. I see that QGLWidget was deprecated in place of QtOpenGLWidgets, when loading a obj file into the scene it seems to hard crash with no error prints. I've narrowed it down to the moderngl vertex_array.py render() function. Although i've switched my code to use pyqt5 instead of pyside6, i'm curious if you'd know why it would crash. Reading the documentation it notes that QOpenGLWidget turns on OpenGL-based compositing for the entire window, where as QGLWidget has a seperate native child window. But can't be sure if that's the reason why and curious if you'd know the differences.

    def render(
        self,
        mode: Optional[int] = None,
        vertices: int = -1,
        *,
        first: int = 0,
        instances: int = -1,
    ) -> None:
        """
        The render primitive (mode) must be the same as the input primitive of the GeometryShader.

        Args:
            mode (int): By default :py:data:`TRIANGLES` will be used.
            vertices (int): The number of vertices to transform.

        Keyword Args:
            first (int): The index of the first vertex to start with.
            instances (int): The number of instances.
        """
        if mode is None:
            mode = self._mode

        if self.scope:
            with self.scope:
                self.mglo.render(mode, vertices, first, instances)
        else:
            self.mglo.render(mode, vertices, first, instances) # <------------------ crashes here

Thanks

jmatthess avatar Nov 02 '23 11:11 jmatthess