def __init__(self):
super().__init__()<EOL>self._closed = False<EOL>gl = QtOpenGL.QGLFormat()<EOL>gl.setVersion(self.gl_version.major, self.gl_version.minor)<EOL>gl.setProfile(QtOpenGL.QGLFormat.CoreProfile)<EOL>gl.setDepthBufferSize(<NUM_LIT>)<EOL>gl.setDoubleBuffer(True)<EOL>gl.setSwapInterval(<NUM_LIT:1> if self.vsync else <NUM_LIT:0>)<EOL>if self.samples > <NUM_LIT:1>:<EOL><INDENT>gl.setSampleBuffers(True)<EOL>gl.setSamples(self.samples)<EOL><DEDENT>self.app = QtWidgets.QApplication([])<EOL>self.widget = QtOpenGL.QGLWidget(gl)<EOL>self.widget.setWindowTitle(self.title)<EOL>if self.fullscreen:<EOL><INDENT>rect = QtWidgets.QDesktopWidget().screenGeometry()<EOL>self.width = rect.width()<EOL>self.height = rect.height()<EOL>self.buffer_width = rect.width() * self.widget.devicePixelRatio()<EOL>self.buffer_height = rect.height() * self.widget.devicePixelRatio()<EOL><DEDENT>if self.resizable:<EOL><INDENT>size_policy = QtWidgets.QSizePolicy(<EOL>QtWidgets.QSizePolicy.Expanding,<EOL>QtWidgets.QSizePolicy.Expanding,<EOL>)<EOL>self.widget.setSizePolicy(size_policy)<EOL>self.widget.resize(self.width, self.height)<EOL><DEDENT>else:<EOL><INDENT>self.widget.setFixedSize(self.width, self.height)<EOL><DEDENT>self.widget.move(QtWidgets.QDesktopWidget().rect().center() - self.widget.rect().center())<EOL>self.widget.resizeGL = self.resize  <EOL>self.widget.show()<EOL>if not self.cursor:<EOL><INDENT>self.widget.setCursor(QtCore.Qt.BlankCursor)<EOL><DEDENT>if self.fullscreen:<EOL><INDENT>self.widget.showFullScreen()<EOL><DEDENT>self.widget.setMouseTracking(True)<EOL>self.widget.keyPressEvent = self.keyPressEvent<EOL>self.widget.keyReleaseEvent = self.keyReleaseEvent<EOL>self.widget.mouseMoveEvent = self.mouseMoveEvent<EOL>self.ctx = moderngl.create_context(require=self.gl_version.code)<EOL>context.WINDOW = self<EOL>self.fbo = self.ctx.screen<EOL>self.buffer_width = self.width * self.widget.devicePixelRatio()<EOL>self.buffer_height = self.height * self.widget.devicePixelRatio()<EOL>self.set_default_viewport()<EOL>
Creates a pyqt application and window overriding the
built in event loop. Sets up keyboard and mouse events
and creates a ``monderngl.Context``.