def __init__(self, parent=None): QOpenGLWidget.__init__(self, parent) QOpenGLFunctions.__init__(self) self.core = "--coreprofile" in QCoreApplication.arguments() self.xRot = 0 self.yRot = 0 self.zRot = 0 self.lastPos = 0 self.logo = Logo() self.vao = QOpenGLVertexArrayObject() self.logoVbo = QOpenGLBuffer() self.program = QOpenGLShaderProgram() self.projMatrixLoc = 0 self.mvMatrixLoc = 0 self.normalMatrixLoc = 0 self.lightPosLoc = 0 self.proj = QMatrix4x4() self.camera = QMatrix4x4() self.world = QMatrix4x4() self.transparent = "--transparent" in QCoreApplication.arguments() if self.transparent: fmt = self.format() fmt.setAlphaBufferSize(8) self.setFormat(fmt)
if event.buttons() & Qt.LeftButton: self.setXRotation(self.xRot + 8 * dy) self.setYRotation(self.yRot + 8 * dx) elif event.buttons() & Qt.RightButton: self.setXRotation(self.xRot + 8 * dy) self.setZRotation(self.zRot + 8 * dx) self.lastPos = QPoint(event.pos()) if __name__ == '__main__': app = QApplication(sys.argv) fmt = QSurfaceFormat() fmt.setDepthBufferSize(24) if "--multisample" in QCoreApplication.arguments(): fmt.setSamples(4) if "--coreprofile" in QCoreApplication.arguments(): fmt.setVersion(3, 2) fmt.setProfile(QSurfaceFormat.CoreProfile) QSurfaceFormat.setDefaultFormat(fmt) mainWindow = Window() if "--transparent" in QCoreApplication.arguments(): mainWindow.setAttribute(Qt.WA_TranslucentBackground) mainWindow.setAttribute(Qt.WA_NoSystemBackground, False) mainWindow.resize(mainWindow.sizeHint()) mainWindow.show() res = app.exec_()