Hey everyone,
in my Windows Forms application, I use a InvalidationControl (from MonoGame.Forms.Controls) to display geometric objects. Now I want to use multisampling.
Without it, the drawed lines (stretched 1 x 1 pixel textures) look really unusable when zoomed out (these are 4 lines):
Some things I know:
I can make multisampling work in another application when I inherit from Game (from Microsoft.Xna.Framework), create a GraphicsDeviceManager and set PreferMultiSampling to true. But in my InvalidationControl, I have no access such a GraphicsDeviceManager because it takes a Game as construction parameter.
public class Game1 : Game {
public Game1() {
new GraphicsDeviceManager(this) { PreferMultiSampling = true };
The following lines in my InvalidationControl (called in Initialize) did not enable Multisampling:
You need to enable Multisampling on the SwapChainRendertTarget control.
But I think that was broken on 3.8, if it doesn’t work try the latest develop build.
Thanks for the answer. What do you mean exactly by enable Multisampling? SwapChainRenderTarget.MultiSampleCount is read only. Do I need to use the SwapChainRenderTarget.GraphicsDevice for my SpriteBatch like this? (currently not working out but I’m gonna try the develop build)
SwapChainRenderTarget.GraphicsDevice.PresentationParameters.MultiSampleCount = 8;
SwapChainRenderTarget.GraphicsDevice.RasterizerState = new RasterizerState()
{
MultiSampleAntiAlias = true,
};
spriteBatch = new SpriteBatch(SwapChainRenderTarget.GraphicsDevice);
I suppose the SwapChainRendertTarget is wrapped in the InvalidationControl.
I am not sure if [MonoGame.Forms] exposes multisampling setting. You would need to look in the code/documentation or ask @BlizzCrafter .
Thank you so, so much!
It’s working perfectly now.
And one thing I found out: Editor.EndAntialising() must be called after the spriteBatch.End() method in order to work.
Very glad to find such fast and great help in this board!