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


C# ShaderProgram.GetAttributeLocation方法代码示例

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


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

示例1: SetupShaderProgram

        private void SetupShaderProgram(ref Matrix4 projection, ShaderProgram program)
        {
            IGraphicsContext context = program.GraphicsContext;
            context.UseShaderProgram(program);

            program.SetUniform(PROJ_MAT, ref projection);
            program.SetUniform(FORCES, ref this.settings.Forces);

            program.SetUniform(START_COLOR, settings.StartColor);
            program.SetUniform(END_COLOR, settings.EndColor);
            program.SetUniform(START_SIZE, settings.StartSize);
            program.SetUniform(END_SIZE, settings.EndSize);
            program.SetUniform(START_ANGULAR_VELOCITY, settings.StartAngularVelocity);
            program.SetUniform(END_ANGULAR_VELOCITY, settings.EndAngularVelocity);
            program.SetUniform(COLOR_VARIANCE, settings.ColorVariance);
            program.SetUniform(SIZE_VARIANCE, settings.SizeVariance);

            Vector3 g = new Vector3(500,500, -0);
            program.SetUniform("gravity_well_1", ref g);
            g = new Vector3(1550, 500, 0);
            program.SetUniform("gravity_well_2", ref g);

            program.SetUniform(START_ALPHA, 1.5f);
            program.SetUniform(END_ALPHA, 0f);

            program.SetUniform(LIFE_TIME, settings.LifeTime);
            program.SetUniform(CURRENT_TIME, this.currentTime);

            program.SetUniform(TEXTURE, 0);

            GL.BindVertexArray(this.vba);

            int posIndex = program.GetAttributeLocation(IN_POS);
            int veloIndex = program.GetAttributeLocation(IN_VEL);
            int randomIndex = program.GetAttributeLocation(IN_RANDOM);
            int offsetIndex = program.GetAttributeLocation(IN_OFFSET);
            int coordIndex = program.GetAttributeLocation(IN_COORDS);
            int timeIndex = program.GetAttributeLocation(IN_TIME);

            context.BindVertexBuffer(this.vertexBuffer);

            context.EnableVertexAttribArray(posIndex);
            context.EnableVertexAttribArray(veloIndex);
            context.EnableVertexAttribArray(randomIndex);
            context.EnableVertexAttribArray(offsetIndex);
            context.EnableVertexAttribArray(coordIndex);
            context.EnableVertexAttribArray(timeIndex);

            context.VertexAttribPointer(posIndex, 2, VertexAttribPointerType.Float,
                                             false, this.queue[0].SizeInBytes, 0);

            context.VertexAttribPointer(veloIndex, 2, VertexAttribPointerType.Float,
                                             false, this.queue[0].SizeInBytes, Vector2.SizeInBytes);

            context.VertexAttribPointer(randomIndex, 2, VertexAttribPointerType.Float,
                                            false, this.queue[0].SizeInBytes, Vector2.SizeInBytes * 2);

            context.VertexAttribPointer(offsetIndex, 2, VertexAttribPointerType.Float,
                                            false, this.queue[0].SizeInBytes, Vector2.SizeInBytes * 3);

            context.VertexAttribPointer(coordIndex, 2, VertexAttribPointerType.Float,
                                false, this.queue[0].SizeInBytes, Vector2.SizeInBytes * 4);

            context.VertexAttribPointer(timeIndex, 1, VertexAttribPointerType.Float,
                                             false, this.queue[0].SizeInBytes, Vector2.SizeInBytes * 5);

            GL.BindVertexArray(0);
        }
开发者ID:TheFlyingFiddle,项目名称:Project-Monocle,代码行数:68,代码来源:ParticleSystem.cs


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