No exception thrown when drawing RenderTarget2D to itself
An exception should be thrown when attempting to draw a RenderTarget2D to itself. Doing this is incompatible with some machines.
graphicsDevice.SetRenderTarget(renderTarget);
spriteBatch.Begin();
spriteBatch.Draw(renderTarget, Vector2.Zero, Color.White);
spriteBatch.End();
What version of MonoGame does the bug occur on:
- MonoGame 3.7
What operating system are you using:
- Windows
What MonoGame platform are you using:
- DesktopGL
I would say this is expected... its like doing a foreach loop on an array, and also modifying that array at the same time :/
In that case you get an exception though. We can check when a texture is set that it isn't the active RT and throw if it is.
Oh, I misread, I though an exception was being thrown... silly me.
I spent 2 days meticulusly picking away at lines of code and trying to figure out why are my shaders breaking. Saving rendertargets to images after each line of code, asking for help on multiple discords, and finally decided to conglamorate that into one big github issue only to find the solution is so godamn simple.
For the love of everything holy, this is 4 years old, please fix this to save some other poor soul hours of time.
i had a similar issue...took me 9 days to clip a texture to a polygon shape... i messed w stencils and alpha test but i wanted a custom shader and render target solution since ill need that skill later for other stuff and i dont have to look inside MG. anyways yea , old samples, windows only ones, and then trying to make it work on GL was a nightmare that ended in me changing a 1 to a 0... multisampling in GL , 0 means don't... i might add a bug that it should throw exception that on GL multsample unsupported on rendertargets. i had a 1 because i started with some old xna sample .. and result is just blank no exception... finally an unreleated comment by Kosmonaught had a 0 in his render target it worked.. so i posted this test rig, it will help anyone else save them teh trouble i went through.... anyways what u were doing is less common but i was doing something very basic i expected to take a couple hours. and it was 9 DAYS!!!!
https://github.com/damian-666/MGShadersXPlatform