def setUseOpenGL(self, useOpenGL): if not QT_NO_OPENGL: if (useOpenGL and QGLFormat.hasOpenGL()): if (not self.viewport()): format = QGLFormat.defaultFormat() format.setDepth(False) # No need for a depth buffer format.setSampleBuffers(True) # Enable anti-aliasing self.setViewport(QGLWidget(format)) else: if self.viewport(): self.setViewport(None) v = self.viewport() if (self.mMode == MapViewMode.StaticContents): v.setAttribute(Qt.WA_StaticContents) v.setMouseTracking(True) else: pass
if e.key() == Qt.Key_Up: # print('Up') GLWidget.Rect2colY += rect2Speed elif e.key() == Qt.Key_Down: # print('Down') GLWidget.Rect2colY -= rect2Speed # if not control and isPrintable(e.key()): # print(e.text()) if __name__ == '__main__': app = QApplication(sys.argv) f = QGLFormat.defaultFormat() f.setSampleBuffers(True) QGLFormat.setDefaultFormat(f) if not QGLFormat.hasOpenGL(): QMessageBox.information(None, "OpenGL samplebuffers", "This system does not support OpenGL.") sys.exit(0) widget = GLWidget(None) if not widget.format().sampleBuffers(): QMessageBox.information( None, "OpenGL samplebuffers", "This system does not have sample buffer support.") sys.exit(0)
def quad(self, primitive, x1, y1, x2, y2, x3, y3, x4, y4): GL.glBegin(primitive) GL.glVertex2d(x1, y1) GL.glVertex2d(x2, y2) GL.glVertex2d(x3, y3) GL.glVertex2d(x4, y4) GL.glEnd() if __name__ == '__main__': app = QApplication(sys.argv) f = QGLFormat.defaultFormat() f.setSampleBuffers(True) QGLFormat.setDefaultFormat(f) if not QGLFormat.hasOpenGL(): QMessageBox.information(None, "OpenGL samplebuffers", "This system does not support OpenGL.") sys.exit(0) widget = GLWidget(None) if not widget.format().sampleBuffers(): QMessageBox.information(None, "OpenGL samplebuffers", "This system does not have sample buffer support.") sys.exit(0)