def init(self, hide_window): # Shift from ARGB to RGBA self.color_palette = [((x << 8) & 0xFFFFFFFF) | 0x000000FF for x in self.color_palette] self.alphamask = 0x000000FF self.color_format = u"RGB" self.buffer_dims = (144, 160) if not glutInit(): raise Exception("OpenGL couldn't initialize!") glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA) glutInitWindowSize(*self._scaledresolution) glutCreateWindow("PyBoy") glutKeyboardFunc(self._key) glutKeyboardUpFunc(self._keyUp) glutSpecialFunc(self._spec) glutSpecialUpFunc(self._specUp) self.events = [] glPixelZoom(self._scale, self._scale) glutReshapeFunc(self._glreshape) glutDisplayFunc(self._gldraw) if hide_window: logger.warning("Hiding the window is not supported in OpenGL")
def resizeGL(self, w, h): glViewport(0, 0, w, h) if self.opengl_resize and self.opengl_data is not None: x_scale = self.width() / float(self.opengl_width) y_scale = self.height() / float(self.opengl_height) if self.opengl_keep_aspect: scale = min(x_scale, y_scale) glPixelZoom(scale, scale) else: glPizelZoom(x_scale, y_scale)
def init(self): # Shift from ARGB to RGBA self.color_palette = [((x << 8) & 0xFFFFFFFF) | 0x000000FF for x in self.color_palette] self.alphamask = 0x000000FF self.color_format = u"RGB" glutInit() glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA) glutInitWindowSize(*self._scaledresolution) glutCreateWindow("PyBoy") glutKeyboardFunc(self._key) glutKeyboardUpFunc(self._keyUp) glutSpecialFunc(self._spec) glutSpecialUpFunc(self._specUp) self.events = [] glPixelZoom(self._scale, self._scale) glutReshapeFunc(self._glreshape) glutDisplayFunc(self._gldraw)
def __init__(self, pyboy, mb, pyboy_argv): super().__init__(pyboy, mb, pyboy_argv) if not self.enabled(): return if not glutInit(): raise Exception("OpenGL couldn't initialize!") glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA) glutInitWindowSize(*self._scaledresolution) glutCreateWindow("PyBoy") glutKeyboardFunc(self._key) glutKeyboardUpFunc(self._keyUp) glutSpecialFunc(self._spec) glutSpecialUpFunc(self._specUp) self.events = [] glPixelZoom(self.scale, self.scale) glutReshapeFunc(self._glreshape) glutDisplayFunc(self._gldraw)
def _glreshape(self, width, height): scale = max(min(height / ROWS, width / COLS), 1) self._scaledresolution = (round(scale * COLS), round(scale * ROWS)) glPixelZoom(scale, scale)