Original Post
Hi guys, my name is Tim and I am a new user. Sorry that my English is not perfekt(I come from Germany ;-)). I started with programming Managed DirectX, not the 2.0.0 assambly, the other. If I start my application, change the window with TAB and the ALT and try to remove to my fullscreen mode I get a exception. A indexbuffer, vertexbuffer or an other think is not in use. I have programmed following source: public void OnDeviceReset(object sender, EventArgs e) { currentDevice.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, (float)this.Width / this.Height, 1.0f, 1000.0f); currentDevice.Transform.View = Matrix.LookAtLH(new Vector3(0.0f, 9.5f, 17.0f), new Vector3(), new Vector3(0, 1, 0)); if ((currentDevice.DeviceCaps.VertexProcessingCaps.SupportsDirectionalLights) && (currentDevice.DeviceCaps.MaxActiveLights > 1)) { //First Light currentDevice.Lights[0].Type = LightType.Directional; currentDevice.Lights[0].Diffuse = Color.White; currentDevice.Lights[0].Direction = new Vector3(1, -1, -1); currentDevice.Lights[0].Enabled = true; //Second Light currentDevice.Lights[1].Type = LightType.Directional; currentDevice.Lights[1].Diffuse = Color.White; currentDevice.Lights[1].Direction = new Vector3(-1, 1, -1); currentDevice.Lights[1].Enabled = true; } else { currentDevice.RenderState.Ambient = Color.White; } } public void OnLostDevice(object sender, EventArgs e) { Console.Out.WriteLine("HH"); int result; int lostDeviceValue = (int)ResultCode.DeviceLost; currentDevice.CheckCooperativeLevel(out result); if (lostDeviceValue == (int)ResultCode.DeviceLost) { //Wait till the Device is ready to reset while (result == lostDeviceValue) { System.Threading.Thread.Sleep(100); currentDevice.CheckCooperativeLevel(out result); } //Okay, wie have an new State //If it is Device not Reset, we can reset it if (result == (int)ResultCode.DeviceNotReset) currentDevice.Reset(currentDeviceManager.PresentParameters); } } private void Game_Paint(object sender, PaintEventArgs e) { if (currentDevice.CheckCooperativeLevel()) { currentDevice.Clear(ClearFlags.Target, Color.Blue, 1.0f, 0); currentDevice.BeginScene(); { ; } currentDevice.EndScene(); currentDevice.Present(); } } if (caps.DeviceType == DeviceType.Hardware) { foreach(Format potentialBackBuffer in backBufferTypes) { if(fullscreen) displayFormat = potentialBackBuffer; else displayFormat = Manager.Adapters.Default.CurrentDisplayMode.Format; if(Manager.CheckDeviceFormat(selectedAdapter,DeviceType.Hardware,displayFormat,Usage.RenderTarget,ResourceType.Surface,potentialBackBuffer)) { if(Manager.CheckDeviceType(selectedAdapter,DeviceType.Hardware,displayFormat,potentialBackBuffer,fullscreen)) { bool fullscreencheck = false; if (fullscreen) { fullscreencheck = true; } else { if(Manager.CheckDeviceFormatConversion(selectedAdapter,DeviceType.Hardware,potentialBackBuffer,displayFormat)) fullscreencheck = true; } if(fullscreencheck) { foreach (DepthFormat potentialZBuffer in zBufferTypes) { if(Manager.CheckDeviceFormat(selectedAdapter,DeviceType.Hardware,potentialBackBuffer,Usage.DepthStencil,ResourceType.Surface,potentialZBuffer)) { //if(Manager.CheckDepthStencilMatch(selectedAdapter,DeviceType.Hardware,displayFormat,potentialBackBuffer,potentialZBuffer) //{ if(presentParameters == null) { presentParameters = new PresentParameters(); presentParameters.SwapEffect = SwapEffect.Discard; presentParameters.AutoDepthStencilFormat = potentialZBuffer; presentParameters.Windowed = !fullscreen; presentParameters.BackBufferHeight = DisplayMode.Height; presentParameters.BackBufferWidth = DisplayMode.Width; presentParameters.BackBufferFormat = potentialBackBuffer; presentParameters.EnableAutoDepthStencil = true; presentParameters.PresentationInterval = PresentInterval.Immediate; } //} } } } } } } }