当前位置: 首页>>代码示例>>C#>>正文


C# SharpDX类代码示例

本文整理汇总了C#中SharpDX的典型用法代码示例。如果您正苦于以下问题:C# SharpDX类的具体用法?C# SharpDX怎么用?C# SharpDX使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SharpDX类属于命名空间,在下文中一共展示了SharpDX类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TileLoader

        public TileLoader(string filePath, SharpDX.Direct3D11.SubResourceTiling[] tilingInfo, bool border)
        {
            _filePath = filePath;
            _tilingInfo = tilingInfo;
            _border = border;

            var fileInfo = new FileInfo(_filePath);

            // precompute the tile offsets in the file for each cube face
            var numTilesPerFace = (fileInfo.Length / SampleSettings.TileSizeInBytes / 6);
            var tilesForSingleFaceMostDetailedMip = tilingInfo[1].StartTileIndexInOverallResource;
            _subresourcesPerFaceInResource = tilingInfo.Length / 6;

            for (var face = 0; face < 6; face++)
            {
                var tileIndexInFace = 0;
                var tilesInSubresource = tilesForSingleFaceMostDetailedMip;
                _subresourcesPerFaceInFile = 0;
                while (tileIndexInFace < numTilesPerFace)
                {
                    var offset = (face * numTilesPerFace) + tileIndexInFace;
                    _subresourceTileOffsets.Add(offset);
                    tileIndexInFace += tilesInSubresource;
                    tilesInSubresource = Math.Max(1, tilesInSubresource / 4);
                    _subresourcesPerFaceInFile++;
                }
            }
        }
开发者ID:nhowells,项目名称:SharpDX-Samples,代码行数:28,代码来源:TileLoader.cs

示例2: FormatInfo

        public static IFormatInfo FormatInfo(SharpDX.DXGI.Format dxgiFormat)
        {
            int numColors;
            int colorBits;
            FormatElementType colorFormatType;
            int alphaBits;
            FormatElementType alphaFormatType;
            int totalBits;
            ColorAlphaFormatFlags flags;

            Utility.Helpers.FormatHelper.GetExplicitColorAlphaFormatInfo((ExplicitFormat)dxgiFormat,
                out numColors, out colorBits, out colorFormatType, out alphaBits, out alphaFormatType, out totalBits, out flags);

            return new FormatInfo
            {
                ID = (int)dxgiFormat,
                Description = dxgiFormat.ToString(),
                ExplicitFormat = (ExplicitFormat)dxgiFormat,
                NumColors = numColors,
                ColorBits = colorBits,
                ColorFormatType = colorFormatType,
                AlphaBits = alphaBits,
                AlphaFormatType = alphaFormatType,
                TotalBits = totalBits,
                Flags = flags
            };
        }
开发者ID:Zulkir,项目名称:Beholder,代码行数:27,代码来源:CtBeholder.cs

示例3: Draw

        public static void Draw(RenderContext11 renderContext, PositionColoredTextured[] points, int count, Texture11 texture, SharpDX.Direct3D.PrimitiveTopology primitiveType, float opacity = 1.0f)
        {
            if (VertexBuffer == null)
            {
                VertexBuffer = new Buffer(renderContext.Device, System.Runtime.InteropServices.Marshal.SizeOf(points[0]) * 2500, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, System.Runtime.InteropServices.Marshal.SizeOf(points[0]));
                VertexBufferBinding = new VertexBufferBinding(VertexBuffer, System.Runtime.InteropServices.Marshal.SizeOf((points[0])), 0);

            }
            renderContext.devContext.InputAssembler.PrimitiveTopology = primitiveType;
            renderContext.BlendMode = BlendMode.Alpha;
            renderContext.setRasterizerState(TriangleCullMode.Off);
            SharpDX.Matrix mat = (renderContext.World * renderContext.View * renderContext.Projection).Matrix11;
            mat.Transpose();

            WarpOutputShader.MatWVP = mat;
            WarpOutputShader.Use(renderContext.devContext, texture != null, opacity);

            renderContext.SetVertexBuffer(VertexBufferBinding);

            DataBox box = renderContext.devContext.MapSubresource(VertexBuffer, 0, MapMode.WriteDiscard, MapFlags.None);
            Utilities.Write(box.DataPointer, points, 0, count);

            renderContext.devContext.UnmapSubresource(VertexBuffer, 0);
            if (texture != null)
            {
                renderContext.devContext.PixelShader.SetShaderResource(0, texture.ResourceView);
            }
            else
            {
                renderContext.devContext.PixelShader.SetShaderResource(0, null);
            }
            renderContext.devContext.Draw(count, 0);
        }
开发者ID:china-vo,项目名称:wwt-windows-client,代码行数:33,代码来源:Sprite2d.cs

示例4: Render

        internal static async Task Render(CompositionEngine compositionEngine, SharpDX.Direct2D1.RenderTarget renderTarget, FrameworkElement rootElement, Line line)
        {
            var rect = line.GetBoundingRect(rootElement).ToSharpDX();
            //var fill = line.Fill.ToSharpDX(renderTarget, rect);
            var stroke = await line.Stroke.ToSharpDX(renderTarget, rect);

            if (stroke == null ||
                line.StrokeThickness <= 0)
            {
                return;
            }

            //var layer = new Layer(renderTarget);
            //var layerParameters = new LayerParameters();
            //layerParameters.ContentBounds = rect;
            //renderTarget.PushLayer(ref layerParameters, layer);

            renderTarget.DrawLine(
                new DrawingPointF(
                    rect.Left + (float)line.X1,
                    rect.Top + (float)line.Y1),
                new DrawingPointF(
                    rect.Left + (float)line.X2,
                    rect.Top + (float)line.Y2),
                    stroke,
                    (float)line.StrokeThickness,
                    line.GetStrokeStyle(compositionEngine.D2DFactory));

            //renderTarget.PopLayer();
        }
开发者ID:prabaprakash,项目名称:Visual-Studio-2013,代码行数:30,代码来源:LineRenderer.cs

示例5: MyBackbuffer

 internal MyBackbuffer(SharpDX.Direct3D11.Resource swapChainBB)
 {
     m_resource = swapChainBB;
     m_resource.DebugName = m_debugName;
     m_rtv = new RenderTargetView(MyRender11.Device, swapChainBB);
     m_rtv.DebugName = m_debugName;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyBackbuffer.cs

示例6: GetTexture

        public override void GetTexture(SharpDX.Size2F surfaceSize, out DrawingSurfaceSynchronizedTexture synchronizedTexture, out SharpDX.RectangleF textureSubRectangle)
        {
            if (_synchronizedTexture == null)
            {
                _synchronizedTexture = _host.CreateSynchronizedTexture(_controller.GetTexture());
            }
            
            // Set output parameters.
            _textureSubRectangle.Left = 0.0f;
            _textureSubRectangle.Top = 0.0f;
            _textureSubRectangle.Right = surfaceSize.Width;
            _textureSubRectangle.Bottom = surfaceSize.Height;


            //HOW DO YOU DO A Microsoft::WRL::ComPtr<T>   CopyTo ?????
            //m_synchronizedTexture.CopyTo(synchronizedTexture);
            synchronizedTexture = _synchronizedTexture;

            textureSubRectangle = _textureSubRectangle;     

            //something is going wrong here as the second time thru the BeginDraw consumes 
            //the call and controlnever returns back to this method, thus GetTexture 
            //(the call after begindraw) never fires again... ??????
            synchronizedTexture.BeginDraw();

            _controller.GetTexture(surfaceSize, synchronizedTexture, textureSubRectangle);

            synchronizedTexture.EndDraw();
        }
开发者ID:numo16,项目名称:SharpDX,代码行数:29,代码来源:SharpDXContentProvider.cs

示例7: VertexBuffer

        /// <summary>
        /// Initializes a new instance of <see cref="VertexBuffer"/> class.
        /// </summary>
        /// <param name="context">Instance of an effect context</param>
        /// <param name="resourceId"></param>
        /// <param name="vertexBufferProperties"></param>
        /// <param name="customVertexBufferProperties"></param>
        public VertexBuffer(EffectContext context, System.Guid resourceId, SharpDX.Direct2D1.VertexBufferProperties vertexBufferProperties, CustomVertexBufferProperties customVertexBufferProperties) : base(IntPtr.Zero)
        {
            unsafe {            
                var customVertexBufferPropertiesNative = new CustomVertexBufferProperties.__Native();
                customVertexBufferProperties.__MarshalTo(ref customVertexBufferPropertiesNative);

                var inputElementsNative = new InputElement.__Native[customVertexBufferProperties.InputElements.Length];
                try
                {
                    for (int i = 0; i < customVertexBufferProperties.InputElements.Length; i++)
                        customVertexBufferProperties.InputElements[i].__MarshalTo(ref inputElementsNative[i]);

                    fixed (void* pInputElements = inputElementsNative)
                    {
                        customVertexBufferPropertiesNative.InputElementsPointer = (IntPtr)pInputElements;
                        customVertexBufferPropertiesNative.ElementCount = customVertexBufferProperties.InputElements.Length;
                        fixed (void* pInputSignature = customVertexBufferProperties.InputSignature)
                        {
                            customVertexBufferPropertiesNative.ShaderBufferSize = customVertexBufferProperties.InputSignature.Length;
                            customVertexBufferPropertiesNative.ShaderBufferWithInputSignature = (IntPtr)pInputSignature;

                            context.CreateVertexBuffer(vertexBufferProperties, resourceId, new IntPtr(&customVertexBufferPropertiesNative), this);
                        }
                    }
                }
                finally
                {
                    for (int i = 0; i < inputElementsNative.Length; i++)
                        inputElementsNative[i].__MarshalFree();
                }
            }
        }
开发者ID:QuantumDeveloper,项目名称:SharpDX,代码行数:39,代码来源:VertexBuffer.cs

示例8: Draw

 public override void Draw(SharpDX.Toolkit.GameTime gameTime)
 {
     Vector2 p1=new Vector2(RodeData.Node1.Position.Item1,RodeData.Node1.Position.Item2),
         p2=new Vector2(RodeData.Node2.Position.Item1,RodeData.Node2.Position.Item2);
     DrawLine(p1, p2, line, Game, Color, RodeData.RoadDisplayMode);
     base.Draw(gameTime);
 }
开发者ID:TPDT,项目名称:TPDT.LogicGraph,代码行数:7,代码来源:Road.cs

示例9: CreateSwapChain

 protected override SharpDX.DXGI.SwapChain2 CreateSwapChain(SharpDX.DXGI.Factory2 factory, SharpDX.Direct3D11.Device1 device, SharpDX.DXGI.SwapChainDescription1 desc)
 {
     // Creates a SwapChain from a CoreWindow pointer
     using (var comWindow = new ComObject(window))
     using (var swapChain1 = new SwapChain1(factory, device, comWindow, ref desc))
         return swapChain1.QueryInterface<SwapChain2>();
 }
开发者ID:SickheadGames,项目名称:SharpDX,代码行数:7,代码来源:CoreWindowTarget.cs

示例10: Joy_JoystickStateChanged

        void Joy_JoystickStateChanged(object sender, SharpDX.DirectInput.JoystickState state)
        {

            if (buttonPanel != null && buttonPanel.Controls.Count > 0)
            {
                for (int i = 0; i < buttonPanel.Controls.Count; i++)
                {
                    bool[] buttons = state.Buttons;
                    var b = (JoyButton)buttonPanel.Controls[i];
                    b.State = buttons[i];
                }
            }
            if (povsPanel != null && povsPanel.Controls.Count > 0)
            {
                int[] povs = state.PointOfViewControllers;
                for (int i = 0; i < povsPanel.Controls.Count; i++)
                {
                    var p = (JoyPov)povsPanel.Controls[i];
                    p.State = povs[i];
                }
            }
            if (sliderPanel != null && sliderPanel.Controls.Count > 0)
            {
                for(int i=0; i<sliderPanel.Controls.Count; i++){
                    var c = (JoySlider)sliderPanel.Controls[i];
                    c.State = state.Sliders[i];
                }
            }
        }
开发者ID:kmpm,项目名称:MoJ,代码行数:29,代码来源:MainForm.cs

示例11: Form1

 public Form1(Factory factory, SharpDX.Direct3D11.Device device, Object renderLock)
 {
     InitializeComponent();
     this.factory = factory;
     this.device = device;
     this.renderLock = renderLock;
 }
开发者ID:Dallemanden,项目名称:RoomAliveToolkit,代码行数:7,代码来源:Form1.cs

示例12: Update

        public override void Update(double secondsElapsed, ExternalUtilsCSharp.KeyUtils keyUtils, SharpDX.Vector2 cursorPoint, bool checkMouse = false)
        {
            base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse);
            Framework fw = WithOverlay.Framework;
            if (fw.LocalPlayer == null)
                return;
            if (!fw.LocalPlayer.IsValid())
                return;

            if(fw.LocalPlayer.m_iTeamNum == (int)Team.Terrorists)
            {
                this.AlliesColor = Color.Red;
                this.EnemiesColor = Color.LightBlue;
            }
            else
            {
                this.AlliesColor = Color.LightBlue;
                this.EnemiesColor = Color.Red;
            }

            this.RotationDegrees = fw.ViewAngles.Y + 90;
            this.CenterCoordinate = new SharpDX.Vector2(fw.LocalPlayer.m_vecOrigin.X, fw.LocalPlayer.m_vecOrigin.Y);

            var enemies = fw.Players.Where(x => x.Item2.IsValid() && x.Item2.m_iHealth > 0 && x.Item2.m_iTeamNum != fw.LocalPlayer.m_iTeamNum);
            this.Enemies = enemies.Select(x => new Vector2(x.Item2.m_vecOrigin.X, x.Item2.m_vecOrigin.Y)).ToArray();

            var allies = fw.Players.Where(x => x.Item2.IsValid() && x.Item2.m_iHealth > 0 && x.Item2.m_iTeamNum == fw.LocalPlayer.m_iTeamNum);
            this.Allies = allies.Select(x => new Vector2(x.Item2.m_vecOrigin.X, x.Item2.m_vecOrigin.Y)).ToArray();
        }
开发者ID:Healios,项目名称:ExternalUtilsCSharp,代码行数:29,代码来源:PlayerRadar.cs

示例13: OnDraw

 protected override void OnDraw(SharpDX.Direct2D1.WindowRenderTarget device)
 {
     if (Theme.ShadowColor != Color.Transparent)
         FillRectangle(device, Theme.ShadowColor, X, Y, Width, Height);
     if (Theme.BackColor != Color.Transparent)
         FillRectangle(device, Theme.BackColor, X, Y, Width, Height);
 }
开发者ID:nkarpey,项目名称:Zat-s-External-CSGO-Multihack,代码行数:7,代码来源:Panel.cs

示例14: LinearGradientBrushImpl

        public LinearGradientBrushImpl(
            Perspex.Media.LinearGradientBrush brush,
            SharpDX.Direct2D1.RenderTarget target,
            Size destinationSize)
        {
            if (brush != null)
            {
                var gradientStops = brush.GradientStops.Select(s => new SharpDX.Direct2D1.GradientStop { Color = s.Color.ToDirect2D(), Position = (float)s.Offset }).ToArray();

                Point startPoint = new Point(0, 0);
                Point endPoint = new Point(0, 0);

                switch (brush.MappingMode)
                {
                    case Perspex.Media.BrushMappingMode.Absolute:
                        // TODO:

                        break;
                    case Perspex.Media.BrushMappingMode.RelativeToBoundingBox:
                        startPoint = new Point(brush.StartPoint.X * destinationSize.Width, brush.StartPoint.Y * destinationSize.Height);
                        endPoint = new Point(brush.EndPoint.X * destinationSize.Width, brush.EndPoint.Y * destinationSize.Height);

                        break;
                }

                PlatformBrush = new SharpDX.Direct2D1.LinearGradientBrush(
                    target,
                    new SharpDX.Direct2D1.LinearGradientBrushProperties { StartPoint = startPoint.ToSharpDX(), EndPoint = endPoint.ToSharpDX() },
                    new SharpDX.Direct2D1.BrushProperties { Opacity = (float)brush.Opacity, Transform = target.Transform },
                    new SharpDX.Direct2D1.GradientStopCollection(target, gradientStops, brush.SpreadMethod.ToDirect2D())
                );
            }
        }
开发者ID:healtech,项目名称:Perspex,代码行数:33,代码来源:LinearGradientBrushImpl.cs

示例15: CreateBufferUAV

        public static UnorderedAccessView CreateBufferUAV(SharpDX.Direct3D11.Device device, Buffer buffer, UnorderedAccessViewBufferFlags flags = UnorderedAccessViewBufferFlags.None)
        {
            UnorderedAccessViewDescription uavDesc = new UnorderedAccessViewDescription
            {
                Dimension = UnorderedAccessViewDimension.Buffer,
                Buffer = new UnorderedAccessViewDescription.BufferResource { FirstElement = 0 }
            };
            if ((buffer.Description.OptionFlags & ResourceOptionFlags.BufferAllowRawViews) == ResourceOptionFlags.BufferAllowRawViews)
            {
                // A raw buffer requires R32_Typeless
                uavDesc.Format = Format.R32_Typeless;
                uavDesc.Buffer.Flags = UnorderedAccessViewBufferFlags.Raw | flags;
                uavDesc.Buffer.ElementCount = buffer.Description.SizeInBytes / 4;
            }
            else if ((buffer.Description.OptionFlags & ResourceOptionFlags.BufferStructured) == ResourceOptionFlags.BufferStructured)
            {
                uavDesc.Format = Format.Unknown;
                uavDesc.Buffer.Flags = flags;
                uavDesc.Buffer.ElementCount = buffer.Description.SizeInBytes / buffer.Description.StructureByteStride;
            }
            else
            {
                throw new ArgumentException("Buffer must be raw or structured", "buffer");
            }

            return new UnorderedAccessView(device, buffer, uavDesc);
        }
开发者ID:QamarWaqar,项目名称:Direct3D-Rendering-Cookbook,代码行数:27,代码来源:ParticleRenderer.cs


注:本文中的SharpDX类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。