Thanks to visit codestin.com
Credit goes to github.com

Skip to content

How to use named uniform blocks? #2125

@jjant

Description

@jjant

Hi, I have a question about using named interface blocks in Glium.

What I mean by that is GLSL syntax like this:

layout(std140) uniform Light {
  vec3 position
} light;

out vec4 color;

void main() {
  color = vec4(light.position, 1.0);
}

On the Rust side, I created a struct like:

#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct Light {
    pub position: [f32; 3],
    // Not sure if needed
    _padding0: i32,
}
implement_uniform_block!(Light, position);

And I tried calling draw with uniform! { light: Light {...} } and uniform! { Light: Light {...} }, without success:

  • The first one doesn't do anything (values in GLSL are all 0s)
  • The second one errors with UniformBlockLayoutMismatch { name: "Light", err: MissingField { name: "Light" } }

Does Glium support? If so, how do I use this correctly? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions