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
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)
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)
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)
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)
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)
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