Team Ai
Apppublic

OpenMotionLab/MotionGPT

sourceHugging Facemitupdated 1y agoView on Hugging Face
118likes
base.py77 linesDownload Raw Back to platforms
1import abc2 3import six4 5 6@six.add_metaclass(abc.ABCMeta)7class Platform(object):8    """Base class for all OpenGL platforms.9 10    Parameters11    ----------12    viewport_width : int13        The width of the main viewport, in pixels.14    viewport_height : int15        The height of the main viewport, in pixels16    """17 18    def __init__(self, viewport_width, viewport_height):19        self.viewport_width = viewport_width20        self.viewport_height = viewport_height21 22    @property23    def viewport_width(self):24        """int : The width of the main viewport, in pixels.25        """26        return self._viewport_width27 28    @viewport_width.setter29    def viewport_width(self, value):30        self._viewport_width = value31 32    @property33    def viewport_height(self):34        """int : The height of the main viewport, in pixels.35        """36        return self._viewport_height37 38    @viewport_height.setter39    def viewport_height(self, value):40        self._viewport_height = value41 42    @abc.abstractmethod43    def init_context(self):44        """Create an OpenGL context.45        """46        pass47 48    @abc.abstractmethod49    def make_current(self):50        """Make the OpenGL context current.51        """52        pass53 54    @abc.abstractmethod55    def make_uncurrent(self):56        """Make the OpenGL context uncurrent.57        """58        pass59 60    @abc.abstractmethod61    def delete_context(self):62        """Delete the OpenGL context.63        """64        pass65 66    @abc.abstractmethod67    def supports_framebuffers(self):68        """Returns True if the method supports framebuffer rendering.69        """70        pass71 72    def __del__(self):73        try:74            self.delete_context()75        except Exception:76            pass77