Using spritebatch in draw more than one

When i run the code, bear and rendertarget not visible, only background image shown and i think this is all about sorting stuff but how to fix this?

protected override void Draw(GameTime gameTime)

        GraphicsDevice.DepthStencilState = DepthStencilState.DepthRead;


        _spriteBatch.Draw(bear, Vector2.Zero, null, Color.White, 0f, Vector2.Zero ,1f, SpriteEffects.None, 0f);


        _spriteBatch.Draw(renderTarget, backBufferCenter, null, Color.White, 0f, new Vector2(renderTarget.Width/2,renderTarget.Height/2), scale, SpriteEffects.None, 1f);




It looks like you’re drawing the background last which puts it on top of everything else. I don’t know what the background looks like but is it filled or does it have transparency?

What does DrawPoints mean?

Drawpoint is useless it is not related with them. And background is cover the screen.

sorting/batching only happens in begin/end of each block, blocks of begin/end are fully independent from each other.

You “background” must have transparent parts in it, otherwise it would just overwrite everything. Not sure what default “BlendState” of SpriteBatch is, maybe make sure to set it to the desired value in Begin() - like AlphaBlend.

or paint the background first and overlay it with “renderTarget” - but then renderTarget has to be cleared with Color.Transparent or it will all be cornflowerblue (that would be the most regular approach to do things)

Thanks i will give a try.

Im not sure about this, because ive not used RenderTarget myself yet, but it looks like after you set it on the GraphicsDevice, you then set (null) GraphicsDevice.SetRenderTarget(null); at the end of the quoted code included here, so it could be the draw order but if that doesn’t fix it, look into that, you might want to run it with one of the draw calls completely commented out, such as your “bear” or your “renderTarget” call and see what you get. Hopefully you are able to figure it out, best of luck.