本文整理汇总了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);
}