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

Add support for multisample antialiasing #319

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

postcasio
Copy link
Contributor

Adds a new signature for texture constructors that accepts an object for the third argument so that textures can be constructed with a color or buffer and multisampling.

new Texture(width, height[, options]); [NEW]

    Constructs a new Texture with the specified options. `width` and `height`
    specify the size in pixels of the surface.

    The following are all optional:

    options.color
        A `Color` with which the texture will be filled. The default is
        `Color.Transparent`.

    options.content:
        A buffer object holding the RGBA pixel data to use to initialize the
        image. The pixel data should not be padded (i.e. stride equal to
        width).

    options.multisample
        The number of samples to use for multisample antialiasing. The default
        value is 0, which means multisampling is not enabled. A value of 1
        would mean one sample per pixel, effectively the same as not being
        enabled. Normal values would be multiples of 2.

        This effectively multiplies the resolution of the texture by the value
        you choose internally, so can have a large effect on performance and
        texture size.

    If `content` is specified, both `color` and `multisample` will be ignored.

Multisampling has to be ignored if content is provided because the underlying buffer seems to change. (I got graphical glitches when I tried)

Free memory for int and float array uniforms when the uniform or shader is destroyed.
Adds a new signature for texture constructors that accepts an object for the third argument.
@fatcerberus
Copy link
Member

Doesn’t it already allow you provide either a solid color or buffer? Agreed that passing an object is more future-proof though.

@postcasio
Copy link
Contributor Author

postcasio commented Nov 19, 2020

Yeah, I think this is the point where it gets unwieldy to have many signatures, and this is easier to have different combinations, so I made sure it replicated the existing functionality for constructing a new surface (except for textures loaded from file, which multisampling doesn't work/make sense for anyway)

@postcasio
Copy link
Contributor Author

postcasio commented Nov 19, 2020

BTW, al_set_new_bitmap_samples is Allegro 5.2 I think - up to you if that's an issue.

@fatcerberus
Copy link
Member

fatcerberus commented Nov 19, 2020

I was recently told the current Ubuntu LTS includes 5.2.x, and I'm pretty sure homebrew has 5.2 also, so that shouldn't be an issue.

@fatcerberus
Copy link
Member

Does multisample make sense as an option for new Texture()? The intention of the API design is that Texture is read-only, while Surface is what you use if you need to render-to-texture. MSAA doesn't really make sense to set on something that will never be used as a render target, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants