protected override void OnCreateControl( ) { if (!this.DesignMode) { this.gDeviceService = GraphicsDeviceService.AddInstance(this.Handle, this.ClientSize.Width, this.ClientSize.Height, 8); // msaa this.services = new ServiceContainer( ); this.services.AddService <IGraphicsDeviceService>(this.gDeviceService); this.content = new ContentManager(this.services, @".\"); this.timer = Stopwatch.StartNew( ); this.Initialize( ); Application.Idle += delegate { this.Invalidate( ); }; } base.OnCreateControl( ); }
public Renderer(int bufferWidth, int bufferHeight, int msaa = 8) { this.control = new Control( ); ServiceContainer services = new ServiceContainer( ); this.gDeviceService = GraphicsDeviceService.AddInstance(this.control.Handle, bufferWidth, bufferHeight, msaa); services.AddService <IGraphicsDeviceService>(this.gDeviceService); this.gDevice = this.gDeviceService.GraphicsDevice; this.content = new ContentManager(services, @".\content"); this.renderTarget = new RenderTarget2D( this.gDevice, bufferWidth, bufferHeight, false, this.gDevice.PresentationParameters.BackBufferFormat, this.gDevice.PresentationParameters.DepthStencilFormat, msaa, RenderTargetUsage.DiscardContents); }