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


C# Material.LoadVertexShader方法代码示例

本文整理汇总了C#中Material.LoadVertexShader方法的典型用法代码示例。如果您正苦于以下问题:C# Material.LoadVertexShader方法的具体用法?C# Material.LoadVertexShader怎么用?C# Material.LoadVertexShader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Material的用法示例。


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

示例1: Start

        public void Start()
        {
            // Create an example triangle object.
            _triangleVertices = new List<Vertex>(6)
            {
                new Vertex(new Vector3(-0.25f, 0.25f, 0.0f), Colour.White, new Vector2(0.0f, 0.0f)),
                new Vertex(new Vector3(0.25f, -0.25f, 0.0f), Colour.White, new Vector2(1.0f, 64.0f)),
                new Vertex(new Vector3(-0.25f, -0.25f, 0.0f), Colour.White, new Vector2(0.0f, 64.0f)),

                new Vertex(new Vector3(-0.25f, 0.25f, 0.0f), Colour.White, new Vector2(0.0f, 0.0f)),
                new Vertex(new Vector3(0.25f, 0.25f, 0.0f), Colour.White, new Vector2(1.0f, 0.0f)),
                new Vertex(new Vector3(0.25f, -0.25f, 0.0f), Colour.White, new Vector2(1.0f, 64.0f))
            };

            _vertexBuffer = ResourceFactory.CreateVertexBufferInstance();
            _vertexBuffer.SetVertices(_triangleVertices);

            _pTexture = ResourceFactory.CreateTexture();
            _pTexture.Load(Helpers.GetRelativePath("Textures\\font.dds"));

            _pMaterial = ResourceFactory.CreateMaterial();
            _pMaterial.SetTexture(_pTexture);
            _pMaterial.LoadVertexShader(Helpers.GetRelativePath("Shaders\\DiffuseTexture.hlsl"), "VSMain", "vs_5_1");
            _pMaterial.LoadPixelShader(Helpers.GetRelativePath("Shaders\\DiffuseTexture.hlsl"), "PSMain", "ps_5_1");
            _pMaterial.Finalise(false);

            _pTriangle = new RenderObject("triangle");
            _pTriangle.SetVertexBuffer(_vertexBuffer);
            _pTriangle.SetMaterial(_pMaterial);

            // Create an example triangle object.
            _vertices2 = new List<Vertex>(4)
            {
                new Vertex(new Vector3(-0.25f, 0.25f, 0.0f), Colour.White, new Vector2(0.0f, 0.0f)),
                new Vertex(new Vector3(0.25f, -0.25f, 0.0f), Colour.White, new Vector2(1.0f, 1.0f)),
                new Vertex(new Vector3(0.25f, 0.25f, 0.0f), Colour.White, new Vector2(1.0f, 0.0f)),
                new Vertex(new Vector3(-0.25f, -0.25f, 0.0f), Colour.White, new Vector2(0.0f, 1.0f))
            };

            _indices = new List<int>(6)
            {
                1, 0, 2,
                0, 1, 3
            };

            _vertexBuffer2 = ResourceFactory.CreateVertexBufferInstance();
            _vertexBuffer2.SetVertices(_vertices2);

            _indexBuffer = ResourceFactory.CreateIndexBufferInstance();
            _indexBuffer.SetIndices(_indices);

            _pTexture2 = ResourceFactory.CreateTexture();
            _pTexture2.Load(Helpers.GetRelativePath("Textures\\test2.png"));

            _pMaterial2 = ResourceFactory.CreateMaterial();
            _pMaterial2.SetTexture(_pTexture2);
            _pMaterial2.LoadVertexShader(Helpers.GetRelativePath("Shaders\\DiffuseTexture.hlsl"), "VSMain", "vs_5_1");
            _pMaterial2.LoadPixelShader(Helpers.GetRelativePath("Shaders\\DiffuseTexture.hlsl"), "PSMain", "ps_5_1");
            _pMaterial2.Finalise(false);

            _pTriangle2 = new RenderObject("triangle2");
            _pTriangle2.SetIndexBuffer(_indexBuffer);
            _pTriangle2.SetVertexBuffer(_vertexBuffer2);
            _pTriangle2.SetMaterial(_pMaterial2);

            _pFont = FontManager.LoadFont("Myriad", Helpers.GetRelativePath("Textures\\myriad.dds"), Helpers.GetRelativePath("Textures\\myriad.txt"));
            _pText = new Text("text", _pFont);
            _pText.SetText("test");
            _pText.SetColour(Colour.Yellow);
            _pText.Transform.Position = new Vector3(0.0f, 0.0f, 0.0f);
            _pText2 = new Text("text2", _pFont);
            _pText2.SetText("Hello world!");
            _pText2.Transform.Position = new Vector3(0.0f, 20.0f, 0.0f);
            _pText2.EnableWorldSpace(true);
        }
开发者ID:JJJohan,项目名称:DX12Engine,代码行数:75,代码来源:App.cs


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