est31 on master
Made UniformStorage implement C… Merge pull request #1915 from I… (compare)
est31 on master
Update rand to 0.8 Update cgmath to 0.18 Merge pull request #1914 from e… (compare)
est31 on master
Fix UniformBlockLayoutMismatch … Merge pull request #1913 from t… (compare)
impl AsUniformValue for &'a TextureType
for TextureType
? in the as_uniform_value()
, code is UniformValue(*self, None)
, self: &'a Texture
...
impl AsUniformValue for SrgbTexture2d {
fn as_uniform_value(&self) -> UniformValue {
UniformValue::SrgbTexture2d(self, None)
}
}
this can success compile, for what reason choose impl UniformValue for &'a TextureX
? Is to avoid memory safety issues in this code?Buffer
and a BufferView
? Intuition tells me a BufferView
is a subset of a Buffer
and so a BufferViewSlice
must be a subset of a BufferView
. This is the result I need but according to the documentation there seems to be no difference between the construction of a BufferView
versus a Buffer
at all.
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// At the start of your program
let instant = Instant::now()
// Later
instant.elapsed().as_secs() as f64 + instant.elapsed().subsec_nanos() as f64 * 1e-9) as f32
let buffer_material = glium::uniforms::UniformBuffer::new(&display, 1.0f32).expect("failed to create uniform buffer");
target.draw(&cube_vertex_buffer, &index_buffer, &program, &uniform! {
MyBlock: &buffer_material,
},
¶ms).expect("failed to draw");
#version 330
uniform layout(std140);
uniform MyBlock {
float test;
} myblock;
void main() {
FragColor = vec4(myblock.test, 1.0);
}
I also tried renaming everything to make the block work, it just won't do anything.
Following this: LearnOpenGL - Lighting - Materials
What would I want to do to get the data I need across ? should I use regular uniforms and not worry about structs ? Even though it won't be as organized ?
New issue now, it works but only partially !
here is the rust code (only part of it)
#[derive(Copy, Clone)]
struct Test {
color: [f32; 3],
color_two: [f32; 3],
};
implement_uniform_block!(Test, color, color_two);
let struct_uni_test = Test {
color: [0.5, 0.5, 0.5],
color_two: [0.2, 0.6, 0.1],
};
let uni_test = glium::uniforms::UniformBuffer::new(&display, struct_uni_test).expect("failed to create uniform buffer");
And the GLSL:
#version 330 core
uniform layout(std140);
uniform UniTest {
vec3 color;
vec3 color_two;
};
void main()
{
FragColor = vec4(color, 1.0);
}
And here is the error:
thread 'main' panicked at 'failed to draw: UniformBlockLayoutMismatch { name: "UniTest", err: MemberMismatch { member: "color_two", err: OffsetMismatch { expected: 16, obtained: 12 } } }', src\libcore\result.rs:906:4
what's the equivalent to: glEnable(GL_DEPTH_TEST);
just found the solution in : https://github.com/glium/glium/blob/master/book/tuto-09-depth.md