コード例 #1
0
ファイル: application.py プロジェクト: Madness75/arcade
    def __init__(self,
                 width: Number = 800,
                 height: Number = 600,
                 title: str = 'Arcade Window',
                 fullscreen: bool = False,
                 resizable: bool = False,
                 update_rate=1 / 60,
                 antialiasing: bool = True):
        """
        Construct a new window

        :param float width: Window width
        :param float height: Window height
        :param str title: Title (appears in title bar)
        :param bool fullscreen: Should this be full screen?
        :param bool resizable: Can the user resize the window?
        :param float update_rate: How frequently to update the window.
        :param bool antialiasing: Should OpenGL's anti-aliasing be enabled?
        """
        if antialiasing:
            config = pyglet.gl.Config(major_version=3,
                                      minor_version=3,
                                      double_buffer=True,
                                      sample_buffers=1,
                                      samples=4)
        else:
            config = pyglet.gl.Config(major_version=3,
                                      minor_version=3,
                                      double_buffer=True)

        try:
            super().__init__(width=width,
                             height=height,
                             caption=title,
                             resizable=resizable,
                             config=config)
        except pyglet.window.NoSuchConfigException:
            raise NoOpenGLException(
                "Unable to create an OpenGL 3.3+ context. "
                "Check to make sure your system supports OpenGL 3.3 or higher."
            )

        if antialiasing:
            try:
                gl.glEnable(gl.GL_MULTISAMPLE_ARB)
            except pyglet.gl.GLException:
                print("Warning: Anti-aliasing not supported on this computer.")

        if update_rate:
            from pyglet import compat_platform
            if compat_platform == 'darwin' or compat_platform == 'linux':
                # Set vsync to false, or we'll be limited to a 1/30 sec update rate possibly
                self.context.set_vsync(False)
            self.set_update_rate(update_rate)

        super().set_fullscreen(fullscreen)
        self.invalid = False
        set_window(self)
        set_viewport(0, self.width, 0, self.height)
        self.current_view = None
コード例 #2
0
    def __init__(self,
                 width: float = 800,
                 height: float = 600,
                 title: str = 'Arcade Window',
                 fullscreen: bool = False,
                 resizable: bool = False,
                 update_rate=1 / 60):
        config = pyglet.gl.Config(major_version=3,
                                  minor_version=3,
                                  double_buffer=True)

        super().__init__(width=width,
                         height=height,
                         caption=title,
                         resizable=resizable,
                         config=config)

        if update_rate:
            from pyglet import compat_platform
            if compat_platform == 'darwin':
                # Set vsync to false, or we'll be limited to a 1/30 sec update rate possibly
                self.context.set_vsync(False)

            self.set_update_rate(1 / 60)

        super().set_fullscreen(fullscreen)
        self.invalid = False
        set_window(self)
        set_viewport(0, self.width, 0, self.height)
コード例 #3
0
ファイル: application.py プロジェクト: Yao2001/arcade
    def set_viewport(self, left: Number, right: Number, bottom: Number, top: Number):
        """
        Set the viewport. (What coordinates we can see.
        Used to scale and/or scroll the screen.)

        :param Number left:
        :param Number right:
        :param Number bottom:
        :param Number top:
        """
        set_viewport(left, right, bottom, top)
コード例 #4
0
    def __init__(self,
                 width: float = 800,
                 height: float = 600,
                 title: str = 'Arcade Window',
                 fullscreen: bool = False,
                 resizable: bool = False,
                 update_rate=1 / 60,
                 antialiasing=True):
        """
        Construct a new window

        :param float width: Window width
        :param float height: Window height
        :param str title: Title (appears in title bar)
        :param bool fullscreen: Should this be full screen?
        :param bool resizable: Can the user resize the window?
        :param float update_rate: How refuent to update the window.
        """
        if antialiasing:
            config = pyglet.gl.Config(major_version=3,
                                      minor_version=3,
                                      double_buffer=True,
                                      sample_buffers=1,
                                      samples=4)
        else:
            config = pyglet.gl.Config(major_version=3,
                                      minor_version=3,
                                      double_buffer=True)

        super().__init__(width=width,
                         height=height,
                         caption=title,
                         resizable=resizable,
                         config=config)

        if antialiasing:
            try:
                gl.glEnable(gl.GL_MULTISAMPLE_ARB)
            except pyglet.gl.GLException:
                print("Warning: Anti-aliasing not supported on this computer.")

        if update_rate:
            from pyglet import compat_platform
            if compat_platform == 'darwin' or compat_platform == 'linux':
                # Set vsync to false, or we'll be limited to a 1/30 sec update rate possibly
                self.context.set_vsync(False)

            self.set_update_rate(1 / 60)

        super().set_fullscreen(fullscreen)
        self.invalid = False
        set_window(self)
        set_viewport(0, self.width, 0, self.height)
コード例 #5
0
    def __init__(self, width: float = 800, height: float = 600,
                 title: str = 'Arcade Window', fullscreen: bool = False,
                 resizable: bool = False, update_rate=1/60):
        config = pyglet.gl.Config(major_version=3, minor_version=3, double_buffer=True)

        super().__init__(width=width, height=height, caption=title,
                         resizable=resizable, config=config)

        if update_rate:
            self.set_update_rate(update_rate)
        super().set_fullscreen(fullscreen)
        self.invalid = False
        set_window(self)
        set_viewport(0, self.width, 0, self.height)
コード例 #6
0
    def set_viewport(self, left: Number, right: Number, bottom: Number,
                     top: Number):
        """
        Set the viewport. (What coordinates we can see.
        Used to scale and/or scroll the screen.)

        Args:
            left:
            right:
            bottom:
            top:

        Returns:

        """
        set_viewport(left, right, bottom, top)
コード例 #7
0
    def __init__(self,
                 width: int = 800,
                 height: int = 600,
                 title: str = 'Arcade Window',
                 fullscreen: bool = False,
                 resizable: bool = False,
                 update_rate: Optional[float] = 1 / 60,
                 antialiasing: bool = True):
        """
        Construct a new window

        :param int width: Window width
        :param int height: Window height
        :param str title: Title (appears in title bar)
        :param bool fullscreen: Should this be full screen?
        :param bool resizable: Can the user resize the window?
        :param float update_rate: How frequently to update the window.
        :param bool antialiasing: Should OpenGL's anti-aliasing be enabled?
        """
        if antialiasing:
            config = pyglet.gl.Config(major_version=3,
                                      minor_version=3,
                                      double_buffer=True,
                                      sample_buffers=1,
                                      samples=4)
        else:
            config = pyglet.gl.Config(major_version=3,
                                      minor_version=3,
                                      double_buffer=True)

        try:
            super().__init__(width=width,
                             height=height,
                             caption=title,
                             resizable=resizable,
                             config=config,
                             vsync=False)
        except pyglet.window.NoSuchConfigException:
            raise NoOpenGLException(
                "Unable to create an OpenGL 3.3+ context. "
                "Check to make sure your system supports OpenGL 3.3 or higher."
            )

        if antialiasing:
            try:
                gl.glEnable(gl.GL_MULTISAMPLE_ARB)
            except pyglet.gl.GLException:
                print("Warning: Anti-aliasing not supported on this computer.")

        # Required for transparency
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)

        if update_rate:
            from pyglet import compat_platform
            if compat_platform == 'darwin' or compat_platform == 'linux':
                # Set vsync to false, or we'll be limited to a 1/30 sec update rate possibly
                self.context.set_vsync(False)
            self.set_update_rate(update_rate)

        super().set_fullscreen(fullscreen)
        self.invalid = False
        set_window(self)
        set_viewport(0, self.width, 0, self.height)
        self.current_view: Optional[View] = None
        self.button_list: List[gui.TextButton] = []
        self.dialogue_box_list: List[gui.DialogueBox] = []
        self.text_list: List[gui.Text] = []
        self.textbox_list: List[gui.TextBox] = []
        self.textbox_time = 0.0
        self.key: Optional[int] = None