Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier way to specify attributes #12

Open
perey opened this issue Apr 18, 2022 · 0 comments
Open

Easier way to specify attributes #12

perey opened this issue Apr 18, 2022 · 0 comments
Assignees
Milestone

Comments

@perey
Copy link
Owner

perey commented Apr 18, 2022

Specifying attributes (for Config, Context, Display, Image, Surface, and Sync objects) is currently pretty verbose, e.g.

cfg.create_pbuffer_surface({SurfaceAttrib.GL_COLORSPACE: GLColorspace.SRGB,
                            SurfaceAttrib.WIDTH: 256,
                            SurfaceAttrib.HEIGHT: 256,
                            SurfaceAttrib.LARGEST_PBUFFER: True})

It should be possible for Pegl to identify the relevant enums and build the attribs dict itself, given just the names. The above example might be rewritten like so:

cfg.create_pbuffer_surface({'GL_COLORSPACE': 'SRGB', 'WIDTH': 256,
                            'HEIGHT': 256, 'LARGEST_PBUFFER': True})

Other things to consider are:

  • Keep the names as ALL_CAPS? Or accept them in lower_case, which is more consistent with instance properties?
  • Keep everything in a dict? Or take keyword arguments?

Using keyword arguments, the example might instead look like this:

cfg.create_pbuffer_surface(gl_colorspace='SRGB', width=256, height=256,
                           largest_pbuffer=True)
@perey perey added this to the 0.3 milestone Apr 18, 2022
@perey perey self-assigned this Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant