Matrices
1218 ワード
https://github.com/glium/glium/blob/master/book/tuto-04-matrices.md
三角形へのジオメトリの追加 Scaling : position *= factor; Rotating : new_position = vec2(pos.x cos(angle) - pos.y sin(angle), pos.x sin(angle) + pos.y cos(angle)); Skewing : position.x += position.y * factor; 上記の演算を4 x 4マトリクスで一括処理する
頂点シェーダコードを修正するには
三角形へのジオメトリの追加
頂点シェーダコードを修正するには
let vertex_shader_src = r#"
#version 140
in vec2 position;
uniform mat4 matrix;
void main() {
gl_Position = matrix * vec4(position, 0.0, 1.0);
}
"#;
draw関数の変更let uniforms = uniform! {
matrix: [
[ t.cos(), t.sin(), 0.0, 0.0],
[-t.sin(), t.cos(), 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0f32],
]
};
target.draw(&vertex_buffer, &indices, &program, &uniforms,
&Default::default()).unwrap();
Reference
この問題について(Matrices), 我々は、より多くの情報をここで見つけました https://velog.io/@dunyazad/Matricesテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol