• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Direct3D9.Device类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Initialise

        public bool Initialise(Device device)
        {
            Debug.Assert(!_initialised);
            if (_initialising)
                return false;

            _initialising = true;

            try
            {

                _device = device;

                _sprite = ToDispose(new Sprite(_device));

                // Initialise any resources required for overlay elements
                IntialiseElementResources();

                _initialised = true;
                return true;
            }
            finally
            {
                _initialising = false;
            }
        }
开发者ID:Fujimuji,项目名称:Direct3DHook,代码行数:26,代码来源:DXOverlayEngine.cs


示例2: FromScene

        public static Model FromScene(Scene scene, Device device)
        {
            VertexDeclaration vertexDeclaration = new VertexDeclaration(device,
                VertexPositionNormalTexture.VertexElements);
            Model result = new Model(scene, device, vertexDeclaration);
            foreach (Mesh mesh in scene.Meshes.Where(x => x.Positions.Any()))
            {
                VertexBuffer vertexBuffer = new VertexBuffer(device,
                    mesh.Positions.Count * VertexPositionNormalTexture.SizeInBytes,
                    Usage.WriteOnly, VertexFormat.None, Pool.Default);
                DataStream vertexDataStream = vertexBuffer.Lock(0,
                    mesh.Positions.Count * VertexPositionNormalTexture.SizeInBytes,
                    LockFlags.None);
                VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[mesh.Positions.Count];
                for (int i = 0; i < vertices.Length; ++i)
                    vertices[i] = new VertexPositionNormalTexture(mesh.Positions[i],
                        (mesh.Normals.Count > i) ? mesh.Normals[i] : Vector3D.Zero,
                        (mesh.TextureCoordinates.Count > i) ? mesh.TextureCoordinates[i].Xy : Point2D.Zero);
                vertexDataStream.WriteRange(vertices);
                vertexBuffer.Unlock();

                IndexBuffer indexBuffer = new IndexBuffer(device, mesh.Indices.Count * sizeof(int),
                    Usage.WriteOnly, Pool.Default, false);
                DataStream indexDataStream = indexBuffer.Lock(0, mesh.Indices.Count * sizeof(int), LockFlags.None);
                indexDataStream.WriteRange(mesh.Indices.ToArray());
                indexBuffer.Unlock();

                ModelMesh modelMesh = new ModelMesh(mesh, device, vertexBuffer,
                    mesh.Positions.Count, indexBuffer, mesh.PrimitiveCount,
                    Matrix3D.Identity, mesh.Material);
                result.Meshes.Add(modelMesh);
            }
            return result;
        }
开发者ID:tgjones,项目名称:meshellator,代码行数:34,代码来源:ModelConverter.cs


示例3: Generate

 unsafe static Tuple<CUDADevice, IntPtr> Generate(D3D9Device d3d9Device)
 {
     var cuContext = IntPtr.Zero;
     var cuDevice = -1;
     CUDAInterop.cuSafeCall(CUDAInterop.cuD3D9CtxCreate(&cuContext, &cuDevice, 0u, d3d9Device.NativePointer));
     return (new Tuple<CUDADevice, IntPtr>(CUDADevice.DeviceDict[cuDevice], cuContext));
 }
开发者ID:magoroku15,项目名称:AleaGPUTutorial,代码行数:7,代码来源:SimpleD3D9.cs


示例4: RecursiveSetViewportImage

 internal void RecursiveSetViewportImage(ViewportImage viewportImage)
 {
     if (viewportImage == null)
     {
         this.DisposeDisposables();
         this.viewportImage = null;
         this.graphicsDevice = null;
         this.layer2D = null;
         Children.viewportImage = null;
     }
     else
     {                
         this.graphicsDevice = viewportImage.GraphicsDevice;
         this.layer2D = viewportImage.Layer2D;
         OnViewportImageChanged(viewportImage);
         BindToViewportImage();
         Children.viewportImage = viewportImage;
         this.RecreateDisposables();
     }
     foreach (Model3D model in this.Children)
     {
         model.RecursiveSetViewportImage(viewportImage);
     }
     // TODO Set target on all children, checking for maximum depth or
     // circular dependencies
 }
开发者ID:goutkannan,项目名称:ironlab,代码行数:26,代码来源:Model3D.cs


示例5: SpriteBatch

        public SpriteBatch(Device d, ContentManager c)
        {
            Device = d;

            cubeVert = new VertexBuffer(Device, 4 * 28, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
            cubeVert.Lock(0, 0, LockFlags.None).WriteRange(new[]
            {
                new VertexPositionTextureColor() { Color = Color.White.ToArgb(), Position = new Vector4f(0, 0, 0.0f, 1.0f), TexCoord = new Vector2f(0.0f, 1.0f) },
                new VertexPositionTextureColor() { Color = Color.White.ToArgb(), Position = new Vector4f(0, 1, 0.0f, 1.0f), TexCoord = new Vector2f(0.0f, 0.0f) },
                new VertexPositionTextureColor() { Color = Color.White.ToArgb(), Position = new Vector4f(1, 0, 0.0f, 1.0f), TexCoord = new Vector2f(1.0f, 1.0f) },
                new VertexPositionTextureColor() { Color = Color.White.ToArgb(), Position = new Vector4f(1, 1, 0.0f, 1.0f), TexCoord = new Vector2f(1.0f, 0.0f) }
            });
            cubeVert.Unlock();

            var cubeElems = new[]
            {
                new VertexElement(0, 0, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Position, 0),
                new VertexElement(0, 16, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
                new VertexElement(0, 24, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0),
                VertexElement.VertexDeclarationEnd
            };

            cubeDecl = new VertexDeclaration(Device, cubeElems);

            renderEffect = c.LoadString<Content.Effect>("float4 c;Texture b;sampler s=sampler_state{texture=<b>;magfilter=LINEAR;minfilter=LINEAR;mipfilter=LINEAR;AddressU=wrap;AddressV=wrap;};float4 f(float2 t:TEXCOORD0):COLOR{return tex2D(s, t) * c;}technique t{pass p{PixelShader = compile ps_2_0 f();}}");
        }
开发者ID:Naronco,项目名称:Rekd-Sharp,代码行数:26,代码来源:SpriteBatch.cs


示例6: GBuffer

        public GBuffer(IKernel kernel)
        {
            IDeviceProvider provider = kernel.Get<IDeviceProvider>();

            _device = provider.Device;
            _form = provider.RenderForm;
        }
开发者ID:nydehi,项目名称:openuo,代码行数:7,代码来源:GBuffer.cs


示例7: Render

 public void Render(Device device, float w, float h, float scale)
 {
     if (_handle != IntPtr.Zero)
     {
         AnimatedModel_Render(_handle, device.NativePointer, w, h, scale);
     }
 }
开发者ID:ema29,项目名称:TemplePlus,代码行数:7,代码来源:AnimatedModel.cs


示例8: Main

        static void Main()
        {
            var form = new RenderForm("SlimDX2 - MiniTri Direct3D9 Sample");
            var device = new Device(new Direct3D(), 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters(form.ClientSize.Width,form.ClientSize.Height));

            var vertices = new VertexBuffer(device, 3 * 20, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
            vertices.Lock(0, 0, LockFlags.None).WriteRange(new[] {
                new Vertex() { Color = Color.Red, Position = new Vector4(400.0f, 100.0f, 0.5f, 1.0f) },
                new Vertex() { Color = Color.Blue, Position = new Vector4(650.0f, 500.0f, 0.5f, 1.0f) },
                new Vertex() { Color = Color.Green, Position = new Vector4(150.0f, 500.0f, 0.5f, 1.0f) }
            });
            vertices.Unlock();

            var vertexElems = new[] {
        		new VertexElement(0, 0, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.PositionTransformed, 0),
        		new VertexElement(0, 16, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0),
				VertexElement.VertexDeclarationEnd
        	};

            var vertexDecl = new VertexDeclaration(device, vertexElems);

            RenderLoop.Run(form, () =>
            {
                device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
                device.BeginScene();

                device.SetStreamSource(0, vertices, 0, 20);
                device.VertexDeclaration = vertexDecl;
                device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);

                device.EndScene();
                device.Present();
            });
        }
开发者ID:pH200,项目名称:SharpDX,代码行数:34,代码来源:Program.cs


示例9: Render

        public void Render(Device device, float w, float h, float xTrans, float yTrans, float scale)
        {
            ParticleSystem_SetObjPos(ScreenPosition.X, ScreenPosition.Y);
            ParticleSystem_SetPos(_handle, ScreenPosition.X, ScreenPosition.Y);

            ParticleSystem_Render(device.NativePointer, _handle, w, h, xTrans, yTrans, scale);
        }
开发者ID:ema29,项目名称:TemplePlus,代码行数:7,代码来源:ParticleSystem.cs


示例10: RenderVideo

        public bool RenderVideo(Device device, Color background, string fileName)
        {
            ParticleSystem_SetObjPos(ScreenPosition.X, ScreenPosition.Y);
            ParticleSystem_SetPos(_handle, ScreenPosition.X, ScreenPosition.Y);

            return ParticleSystem_RenderVideo(device.NativePointer, _handle, background.ToArgb(), fileName, 60);
        }
开发者ID:ema29,项目名称:TemplePlus,代码行数:7,代码来源:ParticleSystem.cs


示例11: ModelMesh

        internal ModelMesh(Mesh sourceMesh, Device device, VertexBuffer vertexBuffer, int numVertices,
			IndexBuffer indexBuffer, int primitiveCount,
			Matrix3D world, Material material)
        {
            SourceMesh = sourceMesh;
            _device = device;
            _vertexBuffer = vertexBuffer;
            _numVertices = numVertices;
            _indexBuffer = indexBuffer;
            _primitiveCount = primitiveCount;

            _effect = new SimpleEffect(device)
            {
                World = world,
                AmbientLightColor = new ColorRgbF(0.1f, 0.1f, 0.1f),
                DiffuseColor = material.DiffuseColor,
                SpecularColor = material.SpecularColor,
                SpecularPower = material.Shininess,
                Alpha = material.Transparency
            };
            if (!string.IsNullOrEmpty(material.DiffuseTextureName))
                _effect.DiffuseTexture = Texture.FromFile(device, material.DiffuseTextureName, Usage.None, Pool.Default);
            _effect.CurrentTechnique = "RenderScene";
            Opaque = (material.Transparency == 1.0f);
        }
开发者ID:tgjones,项目名称:meshellator,代码行数:25,代码来源:ModelMesh.cs


示例12: CreateFullScreenQuad

        /// <summary>
        /// Creates the VertexBuffer for the quad
        /// </summary>
        /// <param name="graphicsDevice">The GraphicsDevice to use</param>
        public void CreateFullScreenQuad(Device graphicsDevice)
        {
            // Create a vertex buffer for the quad, and fill it in
            m_vertexBuffer = new VertexBuffer(graphicsDevice, MyVertexFormatFullScreenQuad.Stride * 4, Usage.WriteOnly, VertexFormat.None, Pool.Default);
            m_vertexBuffer.DebugName = "FullScreenQuad";
            MyVertexFormatFullScreenQuad[] vbData = new MyVertexFormatFullScreenQuad[4];

            // Upper right
            vbData[0].Position = new Vector3(1, 1, 1);
            vbData[0].TexCoordAndCornerIndex = new Vector3(1, 0, 1);

            // Lower right
            vbData[1].Position = new Vector3(1, -1, 1);
            vbData[1].TexCoordAndCornerIndex = new Vector3(1, 1, 2);

            // Upper left
            vbData[2].Position = new Vector3(-1, 1, 1);
            vbData[2].TexCoordAndCornerIndex = new Vector3(0, 0, 0);

            // Lower left
            vbData[3].Position = new Vector3(-1, -1, 1);
            vbData[3].TexCoordAndCornerIndex = new Vector3(0, 1, 3);


            m_vertexBuffer.SetData(vbData);
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:30,代码来源:MyFullscreenQuad.cs


示例13: Poll

        public Poll(Device device, float height)
        {
            _height = height;
            Texture = Texture ?? Texture.FromFile(device, "Assets/Textures/poll.png");
            TextureTop = TextureTop ?? Texture.FromFile(device, "Assets/Textures/poll_top.png");

            _topFlagLocation = new Vector3(-0.5f, 0.25f + (height / 2 - 1.5f), 0);

            _flag = Add(new Sprite(device, "flag", 1));
            _flag.Translate(_topFlagLocation);

            Add(new GameObject
            {
                new MeshRenderer
                {
                    Mesh = new TexturedCube(device, 0.5f, 0.5f, 0.5f, DefaultUV, DefaultUV, DefaultUV, DefaultUV, DefaultUV, DefaultUV),
                    Material = new TextureMaterial(TextureTop, false)
                }
            }).Translate(0, 0.25f + (height / 2 - 0.5f), 0);

            Add(new GameObject
            {
                new MeshRenderer
                {
                    Mesh = new TexturedCube(device, 0.2f, height - 0.5f, 0.2f, DefaultUV, DefaultUV, DefaultUV, DefaultUV, DefaultUV, DefaultUV),
                    Material = new TextureMaterial(Texture, false)
                }
            }).Translate(0, -0.25f, 0);

            Add(new Trigger(SlideDown, 0.5f, height, 0.5f, Vector3.Zero));
        }
开发者ID:jvlppm,项目名称:pucpr-dx-cube_mario,代码行数:31,代码来源:Poll.cs


示例14: GetOrCreateDevice

        private Device GetOrCreateDevice(IntPtr devicePointer)
        {
            if (this.Device == null)
                this.Device = Device.FromPointer<Device>(devicePointer);

            return this.Device;
        }
开发者ID:jasonpang,项目名称:Starcraft2Hook,代码行数:7,代码来源:Direct3D9Hook.UtilityMethods.cs


示例15: BlurComponent

        public BlurComponent(Device graphics, int size)
        {
            _graphics = graphics;

            Dims = size;
            Format = Format.A8R8G8B8;

            _sampleOffsetsHoriz = new Vector4D[SampleCount];
            _sampleOffsetsVert = new Vector4D[SampleCount];

            _sampleWeightsHoriz = new float[SampleCount];
            _sampleWeightsVert = new float[SampleCount];

            int width = Dims - 5;
            int height = Dims - 5;

            SetBlurEffectParameters(1.0f / width, 0, ref _sampleOffsetsHoriz, ref _sampleWeightsHoriz);
            SetBlurEffectParameters(0, 1.0f / height, ref _sampleOffsetsVert, ref _sampleWeightsVert);

            _effect = new GaussianBlurEffect(_graphics);

            OutputTexture = new Texture(_graphics, Dims, Dims, 1, Usage.RenderTarget, Format, Pool.Default);
            _intermediateTexture = new Texture(_graphics, Dims, Dims, 1, Usage.RenderTarget, Format, Pool.Default);

            _sprite = new Sprite(_graphics);
        }
开发者ID:tgjones,项目名称:meshellator,代码行数:26,代码来源:BlurComponent.cs


示例16: GraphicsResource

        protected GraphicsResource(Device graphicsDevice, string name) : base(name)
        {
            if (graphicsDevice == null)
                throw new ArgumentNullException("graphicsDevice");

            GraphicsDevice = graphicsDevice;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:7,代码来源:GraphicsResource.cs


示例17: DeviceContext9

        /// <summary>
        /// Initializes a new instance of the <see cref="DeviceContext9"/> class.
        /// </summary>
        /// <param name="handle">The window handle to associate with the device.</param>
        /// <param name="settings">The settings used to configure the device.</param>
        internal DeviceContext9(IntPtr handle, DeviceSettings9 settings)
        {
            if (handle == IntPtr.Zero)
                throw new ArgumentException("Value must be a valid window handle.", "handle");
            if (settings == null)
                throw new ArgumentNullException("settings");

            this.settings = settings;

            PresentParameters = new PresentParameters
            {
                BackBufferFormat = Format.X8R8G8B8,
                BackBufferCount = 1,
                BackBufferWidth = settings.Width,
                BackBufferHeight = settings.Height,
                MultiSampleType = MultisampleType.None,
                SwapEffect = SwapEffect.Discard,
                EnableAutoDepthStencil = true,
                AutoDepthStencilFormat = Format.D16,
                PresentFlags = PresentFlags.DiscardDepthStencil,
                PresentationInterval = PresentInterval.Default,
                Windowed = true,
                DeviceWindowHandle = handle
            };
            direct3D = new Direct3D();
            Device = new Device(direct3D, settings.AdapterOrdinal, DeviceType.Hardware, handle, settings.CreationFlags, PresentParameters);
        }
开发者ID:nataliaheliova,项目名称:Diplomovka,代码行数:32,代码来源:DeviceContext9.cs


示例18: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            direct3dInterface = new Direct3D();

            PresentParameters[] paramters = new PresentParameters[1];

            paramters[0].Windowed = true;
            paramters[0].SwapEffect = SwapEffect.Discard;
            paramters[0].DeviceWindowHandle = this.Handle;

            direct3dDevice = new Device(direct3dInterface, 0, DeviceType.Hardware, this.Handle, CreateFlags.SoftwareVertexProcessing, paramters);

            if (direct3dDevice == null)
            {
                MessageBox.Show("Error: Can not initialize Direct3D Device", Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Vertex[] vertices = new Vertex[]
            {
                new Vertex(0.0f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f),
                new Vertex(0.5f, -.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f),
                new Vertex(-.5f, -.5f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f),
            };

            int bufferSize = 3 * Marshal.SizeOf<CustomVertex>();
            vertexBuffer = new VertexBuffer(direct3dDevice, bufferSize, Usage.None, vertexFormat, Pool.Managed);

            tmrUpdate.Start();
        }
开发者ID:oe2dlo,项目名称:GitProjects,代码行数:30,代码来源:Form1.cs


示例19: Menu

        public Menu(Device device, Point location, Orientation orientation, params MenuItem[] items)
        {
            Log.Trace("Menu()");
            this.Device = device;
            Items = new List <MenuItem>(items);
            Location = location;
            Orientation = orientation;
            ForeColor = Color.White;
            SelectedForeColor = Color.Red;
            Font = new Font ("Arial", 12, FontStyle.Bold);
            ItemPadding = 15;

            DrawingFont = new SharpDX.Direct3D9.Font (device, Font);

            IncrementMenuKey = new Key (Keys.OemCloseBrackets);
            DecrementMenuKey = new Key (Keys.OemOpenBrackets);
            IncrementValueKey = new Key (Keys.PageUp);
            DecrementValueKey = new Key (Keys.PageDown);
            ResetToZeroKey = new Key (Keys.End);

            IncrementMenuKey.OnJustPressed += (sender, args) => { SelectedIndex = (SelectedIndex + 1).Clamp(SelectedIndex, Items.Count - 1); };
            DecrementMenuKey.OnJustPressed += (sender, args) => { SelectedIndex = (SelectedIndex - 1).Clamp(0, SelectedIndex); };
            IncrementValueKey.OnHold += (sender, args) => Items[SelectedIndex].IncrementValue(2);
            DecrementValueKey.OnHold += (sender, args) => Items[SelectedIndex].DecrementValue(2);
            ResetToZeroKey.OnJustPressed += (sender, args) => { Items[SelectedIndex].Value = 0; };
        }
开发者ID:jasonpang,项目名称:Starcraft2Hook,代码行数:26,代码来源:Menu.cs


示例20: PointSpriteRenderer

        public PointSpriteRenderer(Device device, int size)
        {
            if (device == null)
                throw new ArgumentNullException("device");

            _device = device;
            _size = size;
            _vertexBuffer = new VertexBuffer(_device, _size * Particle.SizeInBytes, Usage.Dynamic | Usage.Points | Usage.WriteOnly, VertexFormat.None, Pool.Default);

            var vertexElements = new[]
            {
                new VertexElement(0, 0,     DeclarationType.Float1, DeclarationMethod.Default, DeclarationUsage.Color, 0),					// Age
                new VertexElement(1, 0,     DeclarationType.Float1, DeclarationMethod.Default, DeclarationUsage.Position, 0),				// X
                new VertexElement(2, 0,		DeclarationType.Float1, DeclarationMethod.Default, DeclarationUsage.Position, 1),				// Y
                new VertexElement(3, 0,		DeclarationType.Float1, DeclarationMethod.Default, DeclarationUsage.Color, 1),					// R
                new VertexElement(4, 0,		DeclarationType.Float1, DeclarationMethod.Default, DeclarationUsage.Color, 2),					// G
                new VertexElement(5, 0,		DeclarationType.Float1, DeclarationMethod.Default, DeclarationUsage.Color, 3),					// B
                new VertexElement(6, 0,		DeclarationType.Float1, DeclarationMethod.Default, DeclarationUsage.PointSize, 0),				// Size
                new VertexElement(7, 0,		DeclarationType.Float1, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),		// Rotation
                VertexElement.VertexDeclarationEnd
            };

            _effect = Effect.FromString(device, Resources.PointSpriteShader, ShaderFlags.PartialPrecision);

            _vertexDeclaration = new VertexDeclaration(device, vertexElements);
        }
开发者ID:BraveSirAndrew,项目名称:mercury-particle-engine,代码行数:26,代码来源:PointSpriteRenderer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Direct3D9.EffectHandle类代码示例发布时间:2022-05-26
下一篇:
C# Direct3D11.VertexShader类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap