當前位置: 首頁>>代碼示例>>C#>>正文


C# Direct3D9.Device類代碼示例

本文整理匯總了C#中SharpDX.Direct3D9.Device的典型用法代碼示例。如果您正苦於以下問題:C# Device類的具體用法?C# Device怎麽用?C# Device使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Device類屬於SharpDX.Direct3D9命名空間,在下文中一共展示了Device類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的SharpDX.Direct3D9.Device類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。