public void Render(DX11RenderContext context) { Device device = context.Device; if (!this.updateddevices.Contains(context)) { this.Update(null, context); } if (this.rendereddevices.Contains(context)) { return; } if (this.FInEnabled[0]) { renderer.EnableDepth = false; renderer.DepthStencil = null; renderer.DepthMode = eDepthBufferMode.None; renderer.SetRenderTargets(this.swapchain); renderer.SetTargets(); if (this.FInClear[0]) { //Remove Shader view if bound as is context.CurrentDeviceContext.ClearRenderTargetView(this.swapchain.RTV, this.FInBgColor[0].Color); } //Only call render if layer connected if (this.FInLayer.PluginIO.IsConnected) { float cw = (float)this.form.ClientSize.Width; float ch = (float)this.form.ClientSize.Height; settings.ViewportCount = 1; settings.ViewportIndex = 0; settings.View = Matrix.Identity; settings.Projection = Matrix.Identity; settings.ViewProjection = Matrix.Identity; settings.BackBuffer = this.swapchain; settings.RenderWidth = 1920; settings.RenderHeight = 1200; settings.ResourceSemantics.Clear(); settings.CustomSemantics.Clear(); //Call render on all layers for (int j = 0; j < this.FInLayer.SliceCount; j++) { this.FInLayer[j][context].Render(this.FInLayer.PluginIO, context, settings); } } renderer.CleanTargets(); } this.rendereddevices.Add(context); }
public void Update(IPluginIO pin, DX11RenderContext context) { Device device = context.Device; if (this.updateddevices.Contains(context)) { return; } SampleDescription sd = new SampleDescription(1, 0); if (this.FResized || this.FInvalidateSwapChain || this.swapchain == null) { if (this.swapchain != null) { this.swapchain.Dispose(); } this.swapchain = new DX11SwapChain(context, this.form.Handle, Format.R8G8B8A8_UNorm, sd, this.FInRate[0]); } if (this.renderer == null) { this.renderer = new DX11GraphicsRenderer(this.FHost, context); } this.updateddevices.Add(context); if (this.FInFullScreen[0] != this.swapchain.IsFullScreen) { if (this.FInFullScreen[0]) { this.prevx = this.form.Width; this.prevy = this.form.Height; /*Screen screen = Screen.FromControl(this.form);*/ this.form.FormBorderStyle = FormBorderStyle.None; this.form.Width = Convert.ToInt32(this.FInRes[0].X); this.form.Height = Convert.ToInt32(this.FInRes[0].Y); this.swapchain.Resize(); this.swapchain.SetFullScreen(true); this.setfull = false; } else { this.swapchain.SetFullScreen(false); this.form.FormBorderStyle = FormBorderStyle.Fixed3D; this.form.Width = this.prevx; this.form.Height = this.prevy; this.swapchain.Resize(); } } }
public void Render(DX11RenderContext context) { Device device = context.Device; if (!this.updateddevices.Contains(context)) { this.Update(context); } if (this.rendereddevices.Contains(context)) { return; } if (this.FInEnabled[0]) { renderer.DepthStencil = this.depthmanager.GetDepthStencil(context); renderer.EnableDepth = renderer.DepthStencil != null; renderer.DepthMode = this.depthmanager.Mode; renderer.SetRenderTargets(this.swapchain); renderer.SetTargets(); if (this.FInClear[0]) { //Remove Shader view if bound as is context.CurrentDeviceContext.ClearRenderTargetView(this.swapchain.RTV, this.FInBgColor[0].Color); this.depthmanager.Clear(context); } //Only call render if layer connected if (this.FInLayer.IsConnected) { float cw = (float)this.form.ClientSize.Width; float ch = (float)this.form.ClientSize.Height; settings.ViewportCount = 1; settings.ViewportIndex = 0; settings.View = Matrix.Identity; settings.Projection = Matrix.Identity; settings.ViewProjection = Matrix.Identity; settings.BackBuffer = this.swapchain; settings.RenderWidth = this.swapchain.Width; settings.RenderHeight = this.swapchain.Height; settings.ResourceSemantics.Clear(); settings.CustomSemantics.Clear(); this.FInLayer.RenderAll(context, settings); } renderer.CleanTargets(); } this.rendereddevices.Add(context); }
public TextBlockRenderer(SpriteRenderer sprite, String fontName, SlimDX.DirectWrite.FontWeight fontWeight, SlimDX.DirectWrite.FontStyle fontStyle, FontStretch fontStretch, float fontSize) { Sprite = sprite; FontSize = fontSize; D3DDevice11 = ModelEx.DeviceManager.Instance.device; System.Threading.Monitor.Enter(D3DDevice11); rtp = new RenderTargetProperties() { HorizontalDpi = 96, VerticalDpi = 96, Type = RenderTargetType.Default, PixelFormat = new PixelFormat(Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied), MinimumFeatureLevel = FeatureLevel.Direct3D10 }; Font = ModelEx.FontManager.Instance.WriteFactory.CreateTextFormat(fontName, fontWeight, fontStyle, fontStretch, fontSize, CultureInfo.CurrentCulture.Name); System.Threading.Monitor.Exit(D3DDevice11); CreateCharTable(0); }
public Frame(string name, IDecoder decoder, SlimDX.Direct3D11.Device device, MemoryPool memoryPool, VVVV.Core.Logging.ILogger logger) { needsDispose = false; Loaded = false; filename = name; this.decoder = decoder; sw = new System.Diagnostics.Stopwatch(); cts = new CancellationTokenSource(); token = cts.Token; streamLock = new object(); this.device = device; LoadingCompleted = (SlimDX.Direct3D11.Texture2DDescription Description) => { }; FMemoryPool = memoryPool; FLogger = logger; }
public static uint D3D11Adresse() { if (d3d11Adresse <= 0) { const int VMT_PRESENT = 8; using (RenderForm rf = new RenderForm()) { SwapChainDescription desc = new SwapChainDescription { BufferCount = 1, Flags = SwapChainFlags.None, IsWindowed = true, ModeDescription = new ModeDescription(100, 100, new Rational(60, 1), Format.R8G8B8A8_UNorm), OutputHandle = rf.Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }; Device tmpDevice; SwapChain sc; Result res = Device.CreateWithSwapChain(SlimDX.Direct3D11.DriverType.Hardware, SlimDX.Direct3D11.DeviceCreationFlags.None, desc, out tmpDevice, out sc); if (res.IsSuccess) { using (tmpDevice) { using (sc) { BlackMagic memory = new Magic.BlackMagic(System.Diagnostics.Process.GetCurrentProcess().Id); d3d11Adresse = memory.ReadUInt(memory.ReadUInt((uint)sc.ComPointer) + 4 * VMT_PRESENT); } } } } } return(d3d11Adresse); }
public void Render(DX11RenderContext context) { Device device = context.Device; if (this.FInEnabled[0]) { renderer.EnableDepth = false; renderer.DepthStencil = null; renderer.DepthMode = eDepthBufferMode.None; renderer.SetRenderTargets(this.swapchain); renderer.SetTargets(); if (this.FInClear[0]) { //Remove Shader view if bound as is context.CurrentDeviceContext.ClearRenderTargetView(this.swapchain.RTV, this.FInBgColor[0].Color); } //Only call render if layer connected if (this.FInLayer.IsConnected) { settings.ViewportCount = 1; settings.ViewportIndex = 0; settings.View = Matrix.Identity; settings.Projection = Matrix.Identity; settings.ViewProjection = Matrix.Identity; settings.BackBuffer = this.swapchain; settings.RenderWidth = (int)cw; settings.RenderHeight = (int)ch; settings.ResourceSemantics.Clear(); settings.CustomSemantics.Clear(); this.FInLayer.RenderAll(context, settings); } renderer.CleanTargets(); } }
public void Update(DX11RenderContext context) { Device device = context.Device; if (this.updateddevices.Contains(context)) { return; } int samplecount = Convert.ToInt32(FInAASamplesPerPixel[0].Name); SampleDescription sd = new SampleDescription(samplecount, 0); if (this.FResized || this.FInvalidateSwapChain || this.swapchain == null) { List <SampleDescription> sds = context.GetMultisampleFormatInfo(Format.R8G8B8A8_UNorm); int maxlevels = sds[sds.Count - 1].Count; if (sd.Count > maxlevels) { logger.Log(LogType.Warning, "Multisample count too high for this format, reverted to: " + maxlevels); sd.Count = maxlevels; } if (this.swapchain != null) { this.swapchain.Dispose(); } this.swapchain = new DX11SwapChain(context, this.form.Handle, Format.R8G8B8A8_UNorm, sd, this.FInRate[0], 2, this.FInFlipSequential[0]); this.FInvalidateSwapChain = false; } if (this.renderer == null) { this.renderer = new DX11GraphicsRenderer(context); } bool fs = this.swapchain.IsFullScreen; if (this.FInFullScreen[0] != fs) { if (this.FInFullScreen[0]) { this.prevx = this.form.Width; this.prevy = this.form.Height; /*Screen screen = Screen.FromControl(this.form);*/ this.form.FormBorderStyle = FormBorderStyle.None; this.form.Width = Convert.ToInt32(this.FInRes[0].X); this.form.Height = Convert.ToInt32(this.FInRes[0].Y); this.depthmanager.NeedReset = true; this.swapchain.Resize(); this.swapchain.SetFullScreen(true); } else { this.swapchain.SetFullScreen(false); this.form.FormBorderStyle = FormBorderStyle.Fixed3D; this.form.Width = this.prevx; this.form.Height = this.prevy; this.swapchain.Resize(); } } this.depthmanager.Update(context, this.swapchain.Width, this.swapchain.Height, sd); this.updateddevices.Add(context); this.FOutIsFullScreen[0] = fs; }
public override void CreateGrid(Device device, float width, float depth, int xVerts, int zVerts) { throw new System.NotImplementedException(); }
public override void CreateCylinder(Device device, float bottomRadius, float topRadius, float height, int sliceCount, int stackCount) { throw new System.NotImplementedException(); }
public override void CreateSphere(Device device, float radius, int slices, int stacks) { throw new System.NotImplementedException(); }
public override void CreateBox(Device device, float width, float height, float depth) { throw new System.NotImplementedException(); }
protected override void InitFromMeshData(Device device, GeometryGenerator.MeshData mesh) { throw new System.NotImplementedException(); }
public override void CreateGeosphere(Device device, float radius, GeometryGenerator.SubdivisionCount numSubdivisions) { throw new System.NotImplementedException(); }
public RotateVertices(SlimDX.Direct3D11.Device device, UVViewDrawProcess process, IEditParameter parameters) : base(process, new RotateController(process, device, parameters), parameters) { }
public void Dispose() { if (screenRenderTargetView != null) { screenRenderTargetView.Dispose(); screenRenderTargetView = null; } if (swapChain != null) { swapChain.Dispose(); swapChain = null; } if (deviceContext != null) { deviceContext.Dispose(); deviceContext = null; } if (device != null) { device.Dispose(); device = null; } if (form != null) { form.Dispose(); form = null; } }
public SkinnedModel(Device device, TextureManager texMgr, string filename, string texturePath, bool flipTexY = false) { var importer = new AssimpImporter(); #if DEBUG importer.AttachLogStream(new ConsoleLogStream()); importer.VerboseLoggingEnabled = true; #endif var model = importer.ImportFile(filename, PostProcessSteps.GenerateSmoothNormals | PostProcessSteps.CalculateTangentSpace); // Load animation data Animator = new SceneAnimator(); Animator.Init(model); // create our vertex-to-boneweights lookup var vertToBoneWeight = new Dictionary <uint, List <VertexWeight> >(); // create bounding box extents _min = new Vector3(float.MaxValue); _max = new Vector3(float.MinValue); foreach (var mesh in model.Meshes) { ExtractBoneWeightsFromMesh(mesh, vertToBoneWeight); var subset = new MeshGeometry.Subset { VertexCount = mesh.VertexCount, VertexStart = Vertices.Count, FaceStart = Indices.Count / 3, FaceCount = mesh.FaceCount }; Subsets.Add(subset); var verts = ExtractVertices(mesh, vertToBoneWeight, flipTexY); Vertices.AddRange(verts); // extract indices and shift them to the proper offset into the combined vertex buffer var indices = mesh.GetIndices().Select(i => (short)(i + (uint)subset.VertexStart)).ToList(); Indices.AddRange(indices); // extract materials var mat = model.Materials[mesh.MaterialIndex]; var material = mat.ToMaterial(); Materials.Add(material); // extract material textures var diffusePath = mat.GetTexture(TextureType.Diffuse, 0).FilePath; if (!string.IsNullOrEmpty(diffusePath)) { DiffuseMapSRV.Add(texMgr.CreateTexture(Path.Combine(texturePath, diffusePath))); } var normalPath = mat.GetTexture(TextureType.Normals, 0).FilePath; if (!string.IsNullOrEmpty(normalPath)) { NormalMapSRV.Add(texMgr.CreateTexture(Path.Combine(texturePath, normalPath))); } else { // for models created without a normal map baked, we'll check for a texture with the same // filename as the diffure texture, and _nmap suffixed // this lets us add our own normal maps easily var normalExt = Path.GetExtension(diffusePath); normalPath = Path.GetFileNameWithoutExtension(diffusePath) + "_nmap" + normalExt; if (File.Exists(Path.Combine(texturePath, normalPath))) { NormalMapSRV.Add(texMgr.CreateTexture(Path.Combine(texturePath, normalPath))); } } } BoundingBox = new BoundingBox(_min, _max); ModelMesh.SetSubsetTable(Subsets); ModelMesh.SetVertices(device, Vertices); ModelMesh.SetIndices(device, Indices); }