diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-12-20 08:35:46 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-01-06 15:44:37 +0100 |
commit | 76337a15b48ae189ee244fe1475a6203d396eeae (patch) | |
tree | 6aa736fd136b419fe9c3a6078295efb0d25de0fa /examples/opengl/contextinfo | |
parent | 2156c0be5308ee9a8624769f6e949ce97df4be79 (diff) |
Use fully qualified enumerations in more examples, round 2
Complements 7189a4c5ec193d30c6bd4e68701038880cbc5982.
Pick-to: 6.8
Task-number: PYSIDE-1735
Change-Id: Ifbfd48e953e74c18c02fbe075ad51dfeb56b97c9
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/opengl/contextinfo')
-rw-r--r-- | examples/opengl/contextinfo/contextinfo.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/examples/opengl/contextinfo/contextinfo.py b/examples/opengl/contextinfo/contextinfo.py index 233636853..9770be634 100644 --- a/examples/opengl/contextinfo/contextinfo.py +++ b/examples/opengl/contextinfo/contextinfo.py @@ -74,7 +74,7 @@ colors = numpy.array([1, 0, 0, 0, 1, 0, 0, 0, 1], dtype=numpy.float32) def print_surface_format(surface_format): - if surface_format.profile() == QSurfaceFormat.CoreProfile: + if surface_format.profile() == QSurfaceFormat.OpenGLContextProfile.CoreProfile: profile_name = 'core' else: profile_name = 'compatibility' @@ -86,7 +86,7 @@ def print_surface_format(surface_format): class RenderWindow(QWindow): def __init__(self, fmt): super().__init__() - self.setSurfaceType(QWindow.OpenGLSurface) + self.setSurfaceType(QWindow.SurfaceType.OpenGLSurface) self.setFormat(fmt) self.context = QOpenGLContext(self) self.context.setFormat(self.requestedFormat()) @@ -102,22 +102,22 @@ class RenderWindow(QWindow): self.vbo = QOpenGLBuffer() fmt = self.context.format() - use_new_style_shader = fmt.profile() == QSurfaceFormat.CoreProfile + use_new_style_shader = fmt.profile() == QSurfaceFormat.OpenGLContextProfile.CoreProfile # Try to handle 3.0 & 3.1 that do not have the core/compatibility profile # concept 3.2+ has. This may still fail since version 150 (3.2) is # specified in the sources but it's worth a try. - if (fmt.renderableType() == QSurfaceFormat.OpenGL and fmt.majorVersion() == 3 + if (fmt.renderableType() == QSurfaceFormat.RenderableType.OpenGL and fmt.majorVersion() == 3 and fmt.minorVersion() <= 1): - use_new_style_shader = not fmt.testOption(QSurfaceFormat.DeprecatedFunctions) + use_new_style_shader = not fmt.testOption(QSurfaceFormat.FormatOption.DeprecatedFunctions) # noqa: E501 vertex_shader = vertex_shader_source if use_new_style_shader else vertex_shader_source_110 fragment_shader = (fragment_shader_source if use_new_style_shader else fragment_shader_source_110) - if not self.program.addShaderFromSourceCode(QOpenGLShader.Vertex, vertex_shader): + if not self.program.addShaderFromSourceCode(QOpenGLShader.ShaderTypeBit.Vertex, vertex_shader): # noqa: E501 log = self.program.log() raise Exception("Vertex shader could not be added: {log} ({vertexShader})") - if not self.program.addShaderFromSourceCode(QOpenGLShader.Fragment, fragment_shader): + if not self.program.addShaderFromSourceCode(QOpenGLShader.ShaderTypeBit.Fragment, fragment_shader): # noqa: E501 log = self.program.log() raise Exception(f"Fragment shader could not be added: {log} ({fragment_shader})") if not self.program.link(): @@ -254,11 +254,11 @@ if __name__ == '__main__': help='Use Desktop OpenGL') options = parser.parse_args() if options.gles: - QCoreApplication.setAttribute(Qt.AA_UseOpenGLES) + QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseOpenGLES) elif options.software: - QCoreApplication.setAttribute(Qt.AA_UseSoftwareOpenGL) + QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseSoftwareOpenGL) elif options.desktop: - QCoreApplication.setAttribute(Qt.AA_UseDesktopOpenGL) + QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseDesktopOpenGL) app = QApplication(sys.argv) main_window = MainWindow() |