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


C# Buffer.SetData方法代码示例

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


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

示例1: SpriteRenderer

        public SpriteRenderer(SpriteSheet spriteSheet)
        {
            SpriteSheet = spriteSheet;

            m_program = SpriteProgram.Instance;
            m_instances = new List<SpriteInstance>();
            m_vao = new VertexArray();

            GL.BindVertexArray(m_vao);

            m_bufferSprite = new Buffer<SpriteData>();
            m_bufferQuad = new Buffer<Vector3>();

            m_bufferQuad.SetData(new Vector3[] {
                new Vector3(0f, 0f, 0f),
                new Vector3(0f, 1f, 0f),
                new Vector3(1f, 1f, 0f),
                new Vector3(1f, 0f, 0f)
            });

            GL.UseProgram(m_program);

            m_program.Position.SetValue(m_bufferQuad.GetView());

            m_program.Transform.SetValue(m_bufferSprite.GetView<Matrix4>("Transform"));
            m_program.Transform.SetDivisor(1);
            m_program.TextureOrigin.SetValue(m_bufferSprite.GetView<Vector2>("TextureOrigin"));
            m_program.TextureOrigin.SetDivisor(1);
            m_program.TextureTarget.SetValue(m_bufferSprite.GetView<Vector2>("TextureTarget"));
            m_program.TextureTarget.SetDivisor(1);

            GL.BindVertexArray(null);

            m_isDirty = true;
        }
开发者ID:nicolas-repiquet,项目名称:Granite,代码行数:35,代码来源:SpriteRenderer.cs

示例2: Graphics

        public Graphics(int queueCapacity = 1000)
        {
            m_queueCapacity = queueCapacity;
            m_queue = new QuadData[m_queueCapacity];
            m_textureQueue = new Texture2D[TEXTURE_QUEUE_CAPACITY];

            m_transformStack = new Stack<Matrix3x2>();

            m_verticesBuffer = new Buffer<Vector2>();
            m_verticesBuffer.SetData(new Vector2[] {
                new Vector2(0,0),
                new Vector2(0,1),
                new Vector2(1,1),
                new Vector2(1,0)
            });

            m_quadsBuffer = new Buffer<QuadData>();
            m_quadsBuffer.SetData(m_queueCapacity, GL.STREAM_DRAW);

            m_program = QuadProgram.Instance;
            m_vertexArray = new VertexArray();

            GL.UseProgram(m_program);
            GL.BindVertexArray(m_vertexArray);

            m_program.Vertex.SetValue(m_verticesBuffer.GetView());

            m_program.TextureCoordinates0.SetValue(m_quadsBuffer.GetView<Vector2>("TextureCoordinates0"));
            m_program.TextureCoordinates0.SetDivisor(1);

            m_program.TextureCoordinates1.SetValue(m_quadsBuffer.GetView<Vector2>("TextureCoordinates1"));
            m_program.TextureCoordinates1.SetDivisor(1);

            m_program.Transform.SetValue(m_quadsBuffer.GetView<Matrix3x2>("Transform"));
            m_program.Transform.SetDivisor(1);

            m_program.Color.SetValue(m_quadsBuffer.GetView<Color4ub>("Color"));
            m_program.Color.SetDivisor(1);

            m_program.Texture.SetValue(m_quadsBuffer.GetView<int>("Texture"));
            m_program.Texture.SetDivisor(1);

            GL.BindVertexArray(null);

            Clear();
        }
开发者ID:nicolas-repiquet,项目名称:Granite,代码行数:46,代码来源:Graphics.cs

示例3: SpriteRenderer

        public SpriteRenderer(SpriteSheet spriteSheet)
        {
            SpriteSheet = spriteSheet;
            textureFire = Texture2D.Load(typeof(Particle).Assembly.GetManifestResourceStream("Granite.Particle.Textures.fire_color.png"));

            m_program = SpriteProgram.Instance;
            m_instances = new List<SpriteInstance>();
            m_vao = new VertexArray();

            GL.BindVertexArray(m_vao);

            m_bufferSprite = new Buffer<SpriteData>();
            m_bufferQuad = new Buffer<Vector3>();

            m_bufferQuad.SetData(new Vector3[] {
                new Vector3(0f, 0f, 0f),
                new Vector3(0f, 1f, 0f),
                new Vector3(1f, 1f, 0f),
                new Vector3(1f, 0f, 0f)
            });

            GL.UseProgram(m_program);

            m_program.Position.SetValue(m_bufferQuad.GetView());

            //m_program.Color.SetValue(m_bufferSprite.GetView(s => s.Color));
            //m_program.Color.SetDivisor(1);
            m_program.Transform.SetValue(m_bufferSprite.GetView<Matrix4>("Transform"));
            m_program.Transform.SetDivisor(1);
            m_program.TextureOrigin.SetValue(m_bufferSprite.GetView<Vector2>("TextureOrigin"));
            m_program.TextureOrigin.SetDivisor(1);
            m_program.TextureTarget.SetValue(m_bufferSprite.GetView<Vector2>("TextureTarget"));
            m_program.TextureTarget.SetDivisor(1);
            m_program.Progress.SetValue(m_bufferSprite.GetView(s => s.Progress));
            m_program.Progress.SetDivisor(1);

            GL.BindVertexArray(null);

            m_isDirty = true;
        }
开发者ID:nicolas-repiquet,项目名称:Granite,代码行数:40,代码来源:SpriteRenderer.cs


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