aboutsummaryrefslogtreecommitdiffstats
path: root/examples/opengl
diff options
context:
space:
mode:
authorAdrian Herrmann <adrian.herrmann@qt.io>2023-12-05 13:00:27 +0100
committerAdrian Herrmann <adrian.herrmann@qt.io>2023-12-06 11:52:07 +0100
commit592c734e57b00040329b49dfbe11869980dff88a (patch)
tree79fa3498cb974e5026415971ec83107b92b65919 /examples/opengl
parentc0329cff9d7378b8bf6a17baeb97bf5a240977fc (diff)
Examples: Fix a number of flake8 errors (part 1)
First batch, including low-hanging fruit like Alignments, whitespaces, line length, indents, etc. Pick-to: 6.6 Change-Id: I55966876077f7fddfdc82cbe376677af9995f329 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples/opengl')
-rw-r--r--examples/opengl/contextinfo/contextinfo.py14
-rw-r--r--examples/opengl/textures/textures.py12
2 files changed, 15 insertions, 11 deletions
diff --git a/examples/opengl/contextinfo/contextinfo.py b/examples/opengl/contextinfo/contextinfo.py
index 8507fd9e7..311d5b765 100644
--- a/examples/opengl/contextinfo/contextinfo.py
+++ b/examples/opengl/contextinfo/contextinfo.py
@@ -22,8 +22,7 @@ try:
except ImportError:
app = QApplication(sys.argv)
message_box = QMessageBox(QMessageBox.Critical, "ContextInfo",
- "PyOpenGL must be installed to run this example.",
- QMessageBox.Close)
+ "PyOpenGL must be installed to run this example.", QMessageBox.Close)
message_box.setDetailedText("Run:\npip install PyOpenGL PyOpenGL_accelerate")
message_box.exec()
sys.exit(1)
@@ -74,7 +73,10 @@ colors = numpy.array([1, 0, 0, 0, 1, 0, 0, 0, 1], dtype=numpy.float32)
def print_surface_format(surface_format):
- profile_name = 'core' if surface_format.profile() == QSurfaceFormat.CoreProfile else 'compatibility'
+ if surface_format.profile() == QSurfaceFormat.CoreProfile:
+ profile_name = 'core'
+ else:
+ profile_name = 'compatibility'
major = surface_format.majorVersion()
minor = surface_format.minorVersion()
return f"{profile_name} version {major}.{minor}"
@@ -104,11 +106,13 @@ class RenderWindow(QWindow):
# 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
- and fmt.minorVersion() <= 1):
+ and fmt.minorVersion() <= 1):
use_new_style_shader = not fmt.testOption(QSurfaceFormat.DeprecatedFunctions)
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
+ fragment_shader = (fragment_shader_source
+ if use_new_style_shader
+ else fragment_shader_source_110)
if not self.program.addShaderFromSourceCode(QOpenGLShader.Vertex, vertex_shader):
log = self.program.log()
raise Exception("Vertex shader could not be added: {log} ({vertexShader})")
diff --git a/examples/opengl/textures/textures.py b/examples/opengl/textures/textures.py
index 79f7761a2..43edd4d58 100644
--- a/examples/opengl/textures/textures.py
+++ b/examples/opengl/textures/textures.py
@@ -32,12 +32,12 @@ class GLWidget(QOpenGLWidget):
refCount = 0
coords = (
- ( ( +1, -1, -1 ), ( -1, -1, -1 ), ( -1, +1, -1 ), ( +1, +1, -1 ) ),
- ( ( +1, +1, -1 ), ( -1, +1, -1 ), ( -1, +1, +1 ), ( +1, +1, +1 ) ),
- ( ( +1, -1, +1 ), ( +1, -1, -1 ), ( +1, +1, -1 ), ( +1, +1, +1 ) ),
- ( ( -1, -1, -1 ), ( -1, -1, +1 ), ( -1, +1, +1 ), ( -1, +1, -1 ) ),
- ( ( +1, -1, +1 ), ( -1, -1, +1 ), ( -1, -1, -1 ), ( +1, -1, -1 ) ),
- ( ( -1, -1, +1 ), ( +1, -1, +1 ), ( +1, +1, +1 ), ( -1, +1, +1 ) )
+ ((+1, -1, -1), (-1, -1, -1), (-1, +1, -1), (+1, +1, -1)),
+ ((+1, +1, -1), (-1, +1, -1), (-1, +1, +1), (+1, +1, +1)),
+ ((+1, -1, +1), (+1, -1, -1), (+1, +1, -1), (+1, +1, +1)),
+ ((-1, -1, -1), (-1, -1, +1), (-1, +1, +1), (-1, +1, -1)),
+ ((+1, -1, +1), (-1, -1, +1), (-1, -1, -1), (+1, -1, -1)),
+ ((-1, -1, +1), (+1, -1, +1), (+1, +1, +1), (-1, +1, +1))
)
clicked = Signal()