def __init__(self, ddsFile, debugContext=False, parent=None, f=Qt.WindowFlags()): super(DDSWidget, self).__init__(parent, f) self.ddsFile = ddsFile self.clean = True self.logger = None self.program = None self.transparecyProgram = None self.texture = None self.vbo = None self.vao = None self.backgroundColour = None if debugContext: format = QSurfaceFormat() format.setOption(QSurfaceFormat.DebugContext) self.setFormat(format) self.logger = QOpenGLDebugLogger(self)
def create_format(): fmt = QSurfaceFormat() fmt.setProfile(QSurfaceFormat.CoreProfile) fmt.setVersion(3, 3) #vmware max opengl version is 3.3 fmt.setAlphaBufferSize(8) fmt.setStencilBufferSize(8) fmt.setDepthBufferSize(24) fmt.setOption(QSurfaceFormat.DebugContext) return fmt
def __init__(self, args, glWidget=QOpenGLWidget, requestedGLVersion=(2, 1)): super(_TestApplication, self).__init__(args) glType = QOpenGLContext.openGLModuleType() format = QSurfaceFormat() format.setDepthBufferSize(24) if glType == QOpenGLContext.LibGL: info("OPENGL MODULE TYPE", "LibGL") format.setVersion(requestedGLVersion[0], requestedGLVersion[1]) format.setProfile(QSurfaceFormat.CompatibilityProfile) format.setOption(QSurfaceFormat.DebugContext) QSurfaceFormat.setDefaultFormat(format) else: info( "OPENGL MODULE TYPE", "Unknown or LibGLES <--- this is likely to cause problems down the line" ) self.debugMembers = False self.mainWin = QWidget() if glWidget == QOpenGLWidget: # Only hard code size if we're not using a canvas self.mainWin.resize(600, 600) self.mainWin.setWindowTitle('TestApplication') self.mainWidget = glWidget() self.layout = QHBoxLayout(self.mainWin) self.layout.addWidget(self.mainWidget) self.mainWin.show() ctx = QOpenGLContext.currentContext() info("GL CURRENT CONTEXT", ctx) format = ctx.format() info("EFFECTIVE GL VERSION", ctx.format().version()) self.aboutToQuit.connect(self.applicationClosing)
int(self.height()*0.125), Qt.AlignCenter, text) painter.setRenderHint(QPainter.TextAntialiasing) painter.fillRect(QRect(0, 0, self.width(), rect.height() + 2*border), QColor(0, 0, 0, 127)) painter.setPen(Qt.white) painter.fillRect(QRect(0, 0, self.width(), rect.height() + 2*border), QColor(0, 0, 0, 127)) painter.drawText((self.width() - rect.width())/2, border, rect.width(), rect.height(), Qt.AlignCenter | Qt.TextWordWrap, text) if __name__ == '__main__': import sys app = QApplication(sys.argv) format = QSurfaceFormat() format.setSamples(4) format.setDepthBufferSize(24) format.setOption(QSurfaceFormat.DebugContext) window = WaterWindow() window.setFormat(format) window.resize(640, 480) window.showMaximized() window.setAnimating(True) sys.exit(app.exec_())