Add support for multisample antialiasing
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)
Doesn’t it already allow you provide either a solid color or buffer? Agreed that passing an object is more future-proof though.
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)
BTW, al_set_new_bitmap_samples is Allegro 5.2 I think - up to you if that's an issue.
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.
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?