faiface / pixel

A hand-crafted 2D game library in Go
MIT License
4.46k stars 245 forks source link

Add Multisample Anti-aliasing support #285

Closed cebarks closed 3 years ago

cebarks commented 3 years ago

This PR adds a new WindowConfig value: SamplesMSAA.

When this is set to a power of 2, it will enable MSAA for the window.

faiface commented 3 years ago

Question: does this work with canvases?

cebarks commented 3 years ago

Question: does this work with canvases?

Canvas is just a go abstraction for a gl target i think? and this is implemented at the opengl level, so I'm not 100% sure, but I think it should.

dusk125 commented 3 years ago

Last question, you mention that setting this to a power of 2 enables the multisampling, is it just a no-op if it's set to not-a-power-of-2?

cebarks commented 3 years ago

Last question, you mention that setting this to a power of 2 enables the multisampling, is it just a no-op if it's set to not-a-power-of-2?

Not sure honestly? Maybe would be worth having some vars in the package with various presets.

dusk125 commented 3 years ago

Yeah I think that would be a good idea, suggest some reasonable values and if someone wants to do something else, they can.

cebarks commented 3 years ago

@dusk125 I added a check in NewWindow that will error out if you don't put in 0, 2, 4, 8, or 16.

Asday commented 3 years ago

Seeing as there's so much discussion about powers of two and only accepting them and erroring if not, why not just not let the user set an invalid value - accept an int and left shift 1 by that int, call it something like msaaLevel.

dusk125 commented 3 years ago

Seeing as there's so much discussion about powers of two and only accepting them and erroring if not, why not just not let the user set an invalid value - accept an int and left shift 1 by that int, call it something like msaaLevel.

That would certainly clear up the power of two problem; however, I think having a specific set of values is clearer to someone who may not be as experienced.

Asday commented 3 years ago

That would certainly clear up the power of two problem; however, I think having a specific set of values is clearer to someone who may not be as experienced.

I don't think that's too much to ask of a user, nor too high a price to pay for the nicer API. I'm just one dude though, I can be out of touch. I was floating the idea to see if it had a wider appeal.