private void InitD3D() { _dxDevice = new Device(DriverType.Hardware, DeviceCreationFlags.Debug | DeviceCreationFlags.BgraSupport, FeatureLevel.Level_10_0); EnsureOutputBuffers(); FontDescription fontDesc = new FontDescription { Height = 24, Width = 0, Weight = 0, MipLevels = 1, IsItalic = false, CharacterSet = FontCharacterSet.Default, Precision = FontPrecision.Default, Quality = FontQuality.Default, PitchAndFamily = FontPitchAndFamily.Default | FontPitchAndFamily.DontCare, FaceName = "Times New Roman" }; _dxFont = new Font(_dxDevice, fontDesc); _textureManager = new DxTextureManager(_dxDevice); // _dxEffect = new DxEffect(_dxDevice); _dxCube = new DxCube(_dxDevice); CrateKinectPointsRenderer(KinectPointsRendererType.Billboard); ShaderResourceView texArray = _textureManager.CreateTexArray("flares", @"Assets\flare0.dds"); _fire = new DxParticleSystemRenderer(_dxDevice, texArray, 500); _dxDevice.Flush(); }
public void Render(int arg) { D3DDevice.OutputMerger.SetTargets(SampleDepthView, SampleRenderView); D3DDevice.Rasterizer.SetViewports(new Viewport(0, 0, WindowWidth, WindowHeight, 0.0f, 1.0f)); D3DDevice.ClearDepthStencilView(SampleDepthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0); float c = ((float)(arg % 1000)) / 999.0f; D3DDevice.ClearRenderTargetView(SampleRenderView, new SlimDX.Color4(1.0f, c, c, c)); D3DDevice.InputAssembler.SetInputLayout(SampleLayout); D3DDevice.InputAssembler.SetPrimitiveTopology(PrimitiveTopology.TriangleList); D3DDevice.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(SampleVertices, 32, 0)); EffectTechnique technique = SampleEffect.GetTechniqueByIndex(0); EffectPass pass = technique.GetPassByIndex(0); for (int i = 0; i < technique.Description.PassCount; ++i) { pass.Apply(); D3DDevice.Draw(3, 0); } D3DDevice.Flush(); }
private void EndScene() { _dxDevice.Flush(); }
void InitD3D() { D3DDevice = new Device(DriverType.Hardware, DeviceCreationFlags.Debug | DeviceCreationFlags.BgraSupport, FeatureLevel.Level_10_0); Texture2DDescription colordesc = new Texture2DDescription(); colordesc.BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource; colordesc.Format = Format.B8G8R8A8_UNorm; colordesc.Width = WindowWidth; colordesc.Height = WindowHeight; colordesc.MipLevels = 1; colordesc.SampleDescription = new SampleDescription(1, 0); colordesc.Usage = ResourceUsage.Default; colordesc.OptionFlags = ResourceOptionFlags.Shared; colordesc.CpuAccessFlags = CpuAccessFlags.None; colordesc.ArraySize = 1; Texture2DDescription depthdesc = new Texture2DDescription(); depthdesc.BindFlags = BindFlags.DepthStencil; depthdesc.Format = Format.D32_Float_S8X24_UInt; depthdesc.Width = WindowWidth; depthdesc.Height = WindowHeight; depthdesc.MipLevels = 1; depthdesc.SampleDescription = new SampleDescription(1, 0); depthdesc.Usage = ResourceUsage.Default; depthdesc.OptionFlags = ResourceOptionFlags.None; depthdesc.CpuAccessFlags = CpuAccessFlags.None; depthdesc.ArraySize = 1; SharedTexture = new Texture2D(D3DDevice, colordesc); DepthTexture = new Texture2D(D3DDevice, depthdesc); SampleRenderView = new RenderTargetView(D3DDevice, SharedTexture); SampleDepthView = new DepthStencilView(D3DDevice, DepthTexture); SampleEffect = Effect.FromFile(D3DDevice, "MiniTri.fx", "fx_4_0"); EffectTechnique technique = SampleEffect.GetTechniqueByIndex(0); ; EffectPass pass = technique.GetPassByIndex(0); SampleLayout = new InputLayout(D3DDevice, pass.Description.Signature, new[] { new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0) }); SampleStream = new DataStream(3 * 32, true, true); SampleStream.WriteRange(new[] { new Vector4(0.0f, 0.5f, 0.5f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), new Vector4(-0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f) }); SampleStream.Position = 0; SampleVertices = new Buffer(D3DDevice, SampleStream, new BufferDescription() { BindFlags = BindFlags.VertexBuffer, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None, SizeInBytes = 3 * 32, Usage = ResourceUsage.Default }); D3DDevice.Flush(); }
void InitD3D() { D3DDevice = new Device(DriverType.Hardware, DeviceCreationFlags.Debug | DeviceCreationFlags.BgraSupport, FeatureLevel.Level_10_0); Texture2DDescription colordesc = new Texture2DDescription(); colordesc.BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource; colordesc.Format = Format.B8G8R8A8_UNorm; colordesc.Width = WindowWidth; colordesc.Height = WindowHeight; colordesc.MipLevels = 1; colordesc.SampleDescription = new SampleDescription(1, 0); colordesc.Usage = ResourceUsage.Default; colordesc.OptionFlags = ResourceOptionFlags.Shared; colordesc.CpuAccessFlags = CpuAccessFlags.None; colordesc.ArraySize = 1; Texture2DDescription depthdesc = new Texture2DDescription(); depthdesc.BindFlags = BindFlags.DepthStencil; depthdesc.Format = Format.D32_Float_S8X24_UInt; depthdesc.Width = WindowWidth; depthdesc.Height = WindowHeight; depthdesc.MipLevels = 1; depthdesc.SampleDescription = new SampleDescription(1, 0); depthdesc.Usage = ResourceUsage.Default; depthdesc.OptionFlags = ResourceOptionFlags.None; depthdesc.CpuAccessFlags = CpuAccessFlags.None; depthdesc.ArraySize = 1; SharedTexture = new Texture2D(D3DDevice, colordesc); DepthTexture = new Texture2D(D3DDevice, depthdesc); SampleRenderView = new RenderTargetView(D3DDevice, SharedTexture); SampleDepthView = new DepthStencilView(D3DDevice, DepthTexture); SampleEffect = Effect.FromFile(D3DDevice, "MiniTri.fx", "fx_4_0"); EffectTechnique technique = SampleEffect.GetTechniqueByIndex(0);; EffectPass pass = technique.GetPassByIndex(0); SampleLayout = new InputLayout(D3DDevice, pass.Description.Signature, new[] { new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0) }); SampleStream = new DataStream(3 * 32, true, true); SampleStream.WriteRange(new[] { new Vector4(0.0f, 0.5f, 0.5f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), new Vector4(-0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f) }); SampleStream.Position = 0; SampleVertices = new Buffer(D3DDevice, SampleStream, new BufferDescription() { BindFlags = BindFlags.VertexBuffer, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None, SizeInBytes = 3 * 32, Usage = ResourceUsage.Default }); D3DDevice.Flush(); }