protected override void LoadContent() { base.LoadContent(); ContentWrapper.Initialize(this); _spriteBatch = new SpriteBatch(GraphicsDevice); _lineBatch = new LineBatch(GraphicsDevice); _quadRenderer = new QuadRenderer(GraphicsDevice); _input.LoadContent(GraphicsDevice.Viewport); #if WINDOWS _counter.LoadContent(); #endif // Create rendertarget for transitions PresentationParameters pp = GraphicsDevice.PresentationParameters; _transitions.Add(new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, false, SurfaceFormat.Color, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents)); _menuScreen = new MenuScreen(); List <Type> DemosToLoad = new List <Type>(); Assembly samplesFramework = Assembly.GetExecutingAssembly(); foreach (Type sampleType in samplesFramework.GetTypes()) { if (sampleType.IsSubclassOf(typeof(PhysicsDemoScreen))) { DemosToLoad.Add(sampleType); } } DemosToLoad.Add(DemosToLoad[0]); // HACK: Load the first sample two times, since some delayed creation stuff with the rendertargets always breaks the first preview picture. bool firstPreview = true; foreach (Type sampleType in DemosToLoad) { PhysicsDemoScreen demoScreen = samplesFramework.CreateInstance(sampleType.ToString()) as PhysicsDemoScreen; #if WINDOWS if (!firstPreview) { Console.WriteLine("Loading demo: " + demoScreen.GetTitle()); } #endif RenderTarget2D preview = new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth / 2, pp.BackBufferHeight / 2, false, SurfaceFormat.Color, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents); demoScreen.Framework = this; demoScreen.IsExiting = false; demoScreen.Sprites = _spriteBatch; demoScreen.Lines = _lineBatch; demoScreen.Quads = _quadRenderer; demoScreen.LoadContent(); // "Abuse" transition rendertarget to render screen preview GraphicsDevice.SetRenderTarget(_transitions[0]); GraphicsDevice.Clear(Color.Transparent); _quadRenderer.Begin(); _quadRenderer.Render(Vector2.Zero, new Vector2(_transitions[0].Width, _transitions[0].Height), null, true, ContentWrapper.Grey, Color.White * 0.3f); _quadRenderer.End(); // Update ensures that the screen is fully visible, we "cover" it so that no physics are run demoScreen.Update(new GameTime(demoScreen.TransitionOnTime, demoScreen.TransitionOnTime), true, false); demoScreen.Draw(new GameTime()); demoScreen.Draw(new GameTime()); GraphicsDevice.SetRenderTarget(preview); GraphicsDevice.Clear(Color.Transparent); _spriteBatch.Begin(); _spriteBatch.Draw(_transitions[0], preview.Bounds, Color.White); _spriteBatch.End(); GraphicsDevice.SetRenderTarget(null); demoScreen.ExitScreen(); demoScreen.Update(new GameTime(demoScreen.TransitionOffTime, demoScreen.TransitionOffTime), true, false); if (!firstPreview) { _menuScreen.AddMenuItem(demoScreen, preview); } else { firstPreview = false; } } AddScreen(new BackgroundScreen()); AddScreen(_menuScreen); //TODO: This can't be called at this point in time in MonoGame //ResetElapsedTime(); }