Skip to content

Commit

Permalink
CLEANUP FORMATTING Minor cleanup and formatting from ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfletch committed Oct 2, 2024
1 parent 36d2c5c commit ac2acc3
Show file tree
Hide file tree
Showing 18 changed files with 2,159 additions and 1,556 deletions.
15 changes: 8 additions & 7 deletions OpenGL/EGL/debug.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Debug utilities for EGL operations"""

from OpenGL.EGL import *
import itertools

Expand Down Expand Up @@ -29,7 +30,7 @@ def eglErrorName(value):

def write_ppm(buf, filename):
"""Write height * width * 3-component buffer as ppm to filename
This lets us write a simple image format without
using any libraries that can be viewed on most
linux workstations.
Expand Down Expand Up @@ -188,11 +189,11 @@ def render(value):

def format_debug_configs(debug_configs, formats=CONFIG_FORMAT):
"""Format config for compact debugging display
Produces a config summary display for a set of
Produces a config summary display for a set of
debug_configs as a text-mode table.
Uses `formats` (default `CONFIG_FORMAT`) to determine
Uses `formats` (default `CONFIG_FORMAT`) to determine
which fields are extracted and how they are formatted
along with the column/subcolum set to be rendered in
the overall header.
Expand All @@ -201,7 +202,7 @@ def format_debug_configs(debug_configs, formats=CONFIG_FORMAT):
logs or utilities
"""
columns = []
for (key, format, subcol, col) in formats:
for key, format, subcol, col in formats:
column = []
max_width = 0
for row in debug_configs:
Expand Down Expand Up @@ -231,8 +232,8 @@ def format_debug_configs(debug_configs, formats=CONFIG_FORMAT):
headers = []
subheaders = []
rows = [headers, subheaders]
last_column = None
last_column_width = 0
# last_column = None
# last_column_width = 0
for header, subcols in itertools.groupby(columns, lambda x: x["col"]):
subcols = list(subcols)
width = sum([col["width"] for col in subcols]) + (len(subcols) - 1)
Expand Down
64 changes: 34 additions & 30 deletions OpenGL/GL/ARB/texture_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,52 +65,54 @@
The official definition of this extension is available here:
http://www.opengl.org/registry/specs/ARB/texture_compression.txt
'''

from OpenGL import platform, constant, arrays
from OpenGL import extensions, wrapper
import ctypes
from OpenGL.raw.GL import _types, _glgets
from OpenGL.raw.GL.ARB.texture_compression import *
from OpenGL.raw.GL.ARB.texture_compression import _EXTENSION_NAME


def glInitTextureCompressionARB():
'''Return boolean indicating whether this extension is available'''
from OpenGL import extensions
return extensions.hasGLExtension( _EXTENSION_NAME )

return extensions.hasGLExtension(_EXTENSION_NAME)


# INPUT glCompressedTexImage3DARB.data size not checked against imageSize
glCompressedTexImage3DARB=wrapper.wrapper(glCompressedTexImage3DARB).setInputArraySize(
'data', None
)
glCompressedTexImage3DARB = wrapper.wrapper(
glCompressedTexImage3DARB
).setInputArraySize('data', None)
# INPUT glCompressedTexImage2DARB.data size not checked against imageSize
glCompressedTexImage2DARB=wrapper.wrapper(glCompressedTexImage2DARB).setInputArraySize(
'data', None
)
glCompressedTexImage2DARB = wrapper.wrapper(
glCompressedTexImage2DARB
).setInputArraySize('data', None)
# INPUT glCompressedTexImage1DARB.data size not checked against imageSize
glCompressedTexImage1DARB=wrapper.wrapper(glCompressedTexImage1DARB).setInputArraySize(
'data', None
)
glCompressedTexImage1DARB = wrapper.wrapper(
glCompressedTexImage1DARB
).setInputArraySize('data', None)
# INPUT glCompressedTexSubImage3DARB.data size not checked against imageSize
glCompressedTexSubImage3DARB=wrapper.wrapper(glCompressedTexSubImage3DARB).setInputArraySize(
'data', None
)
glCompressedTexSubImage3DARB = wrapper.wrapper(
glCompressedTexSubImage3DARB
).setInputArraySize('data', None)
# INPUT glCompressedTexSubImage2DARB.data size not checked against imageSize
glCompressedTexSubImage2DARB=wrapper.wrapper(glCompressedTexSubImage2DARB).setInputArraySize(
'data', None
)
glCompressedTexSubImage2DARB = wrapper.wrapper(
glCompressedTexSubImage2DARB
).setInputArraySize('data', None)
# INPUT glCompressedTexSubImage1DARB.data size not checked against imageSize
glCompressedTexSubImage1DARB=wrapper.wrapper(glCompressedTexSubImage1DARB).setInputArraySize(
'data', None
)
# OUTPUT glGetCompressedTexImageARB.img COMPSIZE(target, level)
glCompressedTexSubImage1DARB = wrapper.wrapper(
glCompressedTexSubImage1DARB
).setInputArraySize('data', None)
# OUTPUT glGetCompressedTexImageARB.img COMPSIZE(target, level)
### END AUTOGENERATED SECTION
from OpenGL.GL import images

for dimensions in (1,2,3):
for function in ('glCompressedTexImage%sDARB','glCompressedTexSubImage%sDARB'):
name = function%(dimensions,)
globals()[ name ] = images.compressedImageFunction(
globals()[ name ]
)
for dimensions in (1, 2, 3):
for function in ('glCompressedTexImage%sDARB', 'glCompressedTexSubImage%sDARB'):
name = function % (dimensions,)
globals()[name] = images.compressedImageFunction(globals()[name])
try:
del name, function
except NameError as err:
Expand All @@ -121,12 +123,14 @@ def glInitTextureCompressionARB():
pass

if glGetCompressedTexImageARB:
def glGetCompressedTexImageARB( target, level, img=None ):

def glGetCompressedTexImageARB(target, level, img=None):
"""Retrieve a compressed texture image"""
if img is None:
length = glget.glGetTexLevelParameteriv(
target, 0,
target,
0,
GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB,
)
img = arrays.ArrayDataType.zeros( (length,), GL_1_0.GL_UNSIGNED_BYTE )
return glGetCompressedTexImageARB(target, 0, img);
img = arrays.ArrayDataType.zeros((length,), GL_1_0.GL_UNSIGNED_BYTE)
return glGetCompressedTexImageARB(target, 0, img)
136 changes: 54 additions & 82 deletions OpenGL/GL/VERSION/GL_1_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,121 +7,91 @@
The official definition of this extension is available here:
http://www.opengl.org/registry/specs/VERSION/GL_1_3.txt
'''

from OpenGL import platform, constant, arrays
from OpenGL import extensions, wrapper
import ctypes
from OpenGL.raw.GL import _types, _glgets
from OpenGL.raw.GL.VERSION.GL_1_3 import *
from OpenGL.raw.GL.VERSION.GL_1_3 import _EXTENSION_NAME


def glInitGl13VERSION():
'''Return boolean indicating whether this extension is available'''
from OpenGL import extensions
return extensions.hasGLExtension( _EXTENSION_NAME )

return extensions.hasGLExtension(_EXTENSION_NAME)


# INPUT glCompressedTexImage3D.data size not checked against imageSize
glCompressedTexImage3D=wrapper.wrapper(glCompressedTexImage3D).setInputArraySize(
glCompressedTexImage3D = wrapper.wrapper(glCompressedTexImage3D).setInputArraySize(
'data', None
)
# INPUT glCompressedTexImage2D.data size not checked against imageSize
glCompressedTexImage2D=wrapper.wrapper(glCompressedTexImage2D).setInputArraySize(
glCompressedTexImage2D = wrapper.wrapper(glCompressedTexImage2D).setInputArraySize(
'data', None
)
# INPUT glCompressedTexImage1D.data size not checked against imageSize
glCompressedTexImage1D=wrapper.wrapper(glCompressedTexImage1D).setInputArraySize(
glCompressedTexImage1D = wrapper.wrapper(glCompressedTexImage1D).setInputArraySize(
'data', None
)
# INPUT glCompressedTexSubImage3D.data size not checked against imageSize
glCompressedTexSubImage3D=wrapper.wrapper(glCompressedTexSubImage3D).setInputArraySize(
'data', None
)
glCompressedTexSubImage3D = wrapper.wrapper(
glCompressedTexSubImage3D
).setInputArraySize('data', None)
# INPUT glCompressedTexSubImage2D.data size not checked against imageSize
glCompressedTexSubImage2D=wrapper.wrapper(glCompressedTexSubImage2D).setInputArraySize(
'data', None
)
glCompressedTexSubImage2D = wrapper.wrapper(
glCompressedTexSubImage2D
).setInputArraySize('data', None)
# INPUT glCompressedTexSubImage1D.data size not checked against imageSize
glCompressedTexSubImage1D=wrapper.wrapper(glCompressedTexSubImage1D).setInputArraySize(
'data', None
)
# OUTPUT glGetCompressedTexImage.img COMPSIZE(target, level)
glMultiTexCoord1dv=wrapper.wrapper(glMultiTexCoord1dv).setInputArraySize(
'v', 1
)
glMultiTexCoord1fv=wrapper.wrapper(glMultiTexCoord1fv).setInputArraySize(
'v', 1
)
glMultiTexCoord1iv=wrapper.wrapper(glMultiTexCoord1iv).setInputArraySize(
'v', 1
)
glMultiTexCoord1sv=wrapper.wrapper(glMultiTexCoord1sv).setInputArraySize(
'v', 1
)
glMultiTexCoord2dv=wrapper.wrapper(glMultiTexCoord2dv).setInputArraySize(
'v', 2
)
glMultiTexCoord2fv=wrapper.wrapper(glMultiTexCoord2fv).setInputArraySize(
'v', 2
)
glMultiTexCoord2iv=wrapper.wrapper(glMultiTexCoord2iv).setInputArraySize(
'v', 2
)
glMultiTexCoord2sv=wrapper.wrapper(glMultiTexCoord2sv).setInputArraySize(
'v', 2
)
glMultiTexCoord3dv=wrapper.wrapper(glMultiTexCoord3dv).setInputArraySize(
'v', 3
)
glMultiTexCoord3fv=wrapper.wrapper(glMultiTexCoord3fv).setInputArraySize(
'v', 3
)
glMultiTexCoord3iv=wrapper.wrapper(glMultiTexCoord3iv).setInputArraySize(
'v', 3
)
glMultiTexCoord3sv=wrapper.wrapper(glMultiTexCoord3sv).setInputArraySize(
'v', 3
)
glMultiTexCoord4dv=wrapper.wrapper(glMultiTexCoord4dv).setInputArraySize(
'v', 4
)
glMultiTexCoord4fv=wrapper.wrapper(glMultiTexCoord4fv).setInputArraySize(
'v', 4
)
glMultiTexCoord4iv=wrapper.wrapper(glMultiTexCoord4iv).setInputArraySize(
'v', 4
)
glMultiTexCoord4sv=wrapper.wrapper(glMultiTexCoord4sv).setInputArraySize(
'v', 4
)
glLoadTransposeMatrixf=wrapper.wrapper(glLoadTransposeMatrixf).setInputArraySize(
glCompressedTexSubImage1D = wrapper.wrapper(
glCompressedTexSubImage1D
).setInputArraySize('data', None)
# OUTPUT glGetCompressedTexImage.img COMPSIZE(target, level)
glMultiTexCoord1dv = wrapper.wrapper(glMultiTexCoord1dv).setInputArraySize('v', 1)
glMultiTexCoord1fv = wrapper.wrapper(glMultiTexCoord1fv).setInputArraySize('v', 1)
glMultiTexCoord1iv = wrapper.wrapper(glMultiTexCoord1iv).setInputArraySize('v', 1)
glMultiTexCoord1sv = wrapper.wrapper(glMultiTexCoord1sv).setInputArraySize('v', 1)
glMultiTexCoord2dv = wrapper.wrapper(glMultiTexCoord2dv).setInputArraySize('v', 2)
glMultiTexCoord2fv = wrapper.wrapper(glMultiTexCoord2fv).setInputArraySize('v', 2)
glMultiTexCoord2iv = wrapper.wrapper(glMultiTexCoord2iv).setInputArraySize('v', 2)
glMultiTexCoord2sv = wrapper.wrapper(glMultiTexCoord2sv).setInputArraySize('v', 2)
glMultiTexCoord3dv = wrapper.wrapper(glMultiTexCoord3dv).setInputArraySize('v', 3)
glMultiTexCoord3fv = wrapper.wrapper(glMultiTexCoord3fv).setInputArraySize('v', 3)
glMultiTexCoord3iv = wrapper.wrapper(glMultiTexCoord3iv).setInputArraySize('v', 3)
glMultiTexCoord3sv = wrapper.wrapper(glMultiTexCoord3sv).setInputArraySize('v', 3)
glMultiTexCoord4dv = wrapper.wrapper(glMultiTexCoord4dv).setInputArraySize('v', 4)
glMultiTexCoord4fv = wrapper.wrapper(glMultiTexCoord4fv).setInputArraySize('v', 4)
glMultiTexCoord4iv = wrapper.wrapper(glMultiTexCoord4iv).setInputArraySize('v', 4)
glMultiTexCoord4sv = wrapper.wrapper(glMultiTexCoord4sv).setInputArraySize('v', 4)
glLoadTransposeMatrixf = wrapper.wrapper(glLoadTransposeMatrixf).setInputArraySize(
'm', 16
)
glLoadTransposeMatrixd=wrapper.wrapper(glLoadTransposeMatrixd).setInputArraySize(
glLoadTransposeMatrixd = wrapper.wrapper(glLoadTransposeMatrixd).setInputArraySize(
'm', 16
)
glMultTransposeMatrixf=wrapper.wrapper(glMultTransposeMatrixf).setInputArraySize(
glMultTransposeMatrixf = wrapper.wrapper(glMultTransposeMatrixf).setInputArraySize(
'm', 16
)
glMultTransposeMatrixd=wrapper.wrapper(glMultTransposeMatrixd).setInputArraySize(
glMultTransposeMatrixd = wrapper.wrapper(glMultTransposeMatrixd).setInputArraySize(
'm', 16
)
### END AUTOGENERATED SECTION
GL_SRC0_ALPHA = GL_SOURCE0_ALPHA # alias
GL_SRC0_RGB = GL_SOURCE0_RGB # alias
GL_SRC1_ALPHA = GL_SOURCE1_ALPHA # alias
GL_SRC1_RGB = GL_SOURCE1_RGB # alias
GL_SRC2_ALPHA = GL_SOURCE2_ALPHA # alias
GL_SRC2_RGB = GL_SOURCE2_RGB # alias
GL_SRC0_ALPHA = GL_SOURCE0_ALPHA # alias
GL_SRC0_RGB = GL_SOURCE0_RGB # alias
GL_SRC1_ALPHA = GL_SOURCE1_ALPHA # alias
GL_SRC1_RGB = GL_SOURCE1_RGB # alias
GL_SRC2_ALPHA = GL_SOURCE2_ALPHA # alias
GL_SRC2_RGB = GL_SOURCE2_RGB # alias

from OpenGL import wrapper
from OpenGL.raw.GL.VERSION import GL_1_3 as _simple
from OpenGL.GL import images, glget

for dimensions in (1,2,3):
for function in ('glCompressedTexImage%sD','glCompressedTexSubImage%sD'):
name = function%(dimensions,)
globals()[ name ] = images.compressedImageFunction(
getattr( _simple, name )
)
for dimensions in (1, 2, 3):
for function in ('glCompressedTexImage%sD', 'glCompressedTexSubImage%sD'):
name = function % (dimensions,)
globals()[name] = images.compressedImageFunction(getattr(_simple, name))
try:
del name, function
except NameError as err:
Expand All @@ -132,12 +102,14 @@ def glInitGl13VERSION():
pass

if _simple.glGetCompressedTexImage:
def glGetCompressedTexImage( target, level, img=None ):

def glGetCompressedTexImage(target, level, img=None):
"""Retrieve a compressed texture image"""
if img is None:
length = glget.glGetTexLevelParameteriv(
target, 0,
target,
0,
_simple.GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB,
)
img = arrays.ArrayDataType.zeros( (length,), constants.GL_UNSIGNED_BYTE )
return _simple.glGetCompressedTexImage(target, 0, img);
img = arrays.ArrayDataType.zeros((length,), constants.GL_UNSIGNED_BYTE)
return _simple.glGetCompressedTexImage(target, 0, img)
Loading

0 comments on commit ac2acc3

Please sign in to comment.