Possible to create a camera without specifying parameters
@@ -13,23 +13,32 @@ pub struct Camera {
impl Camera
{
- pub fn new(gl: &Gl, position: Vec3, target: Vec3, up: Vec3) -> Camera
+ pub fn new(gl: &Gl) -> Camera
{
- let mut camera = Camera {matrix_buffer: UniformBuffer::new(gl, &vec![16, 16, 16, 3]).unwrap(), position, target, up, view: Mat4::identity(), projection: Mat4::identity(), screen2ray: Mat4::identity()};
+ let mut camera = Camera {matrix_buffer: UniformBuffer::new(gl, &vec![16, 16, 16, 3]).unwrap(),
+ position: vec3(0.0, 0.0, 5.0), target: vec3(0.0, 0.0, 0.0), up: vec3(0.0, 1.0, 0.0),
+ view: Mat4::identity(), projection: Mat4::identity(), screen2ray: Mat4::identity()};
+ camera.set_view(camera.position, camera.target, camera.up);
+ camera
+ }
+
+ pub fn with_orientation(gl: &Gl, position: Vec3, target: Vec3, up: Vec3) -> Camera
+ {
+ let mut camera = Camera::new(gl);
camera.set_view(position, target, up);
camera
}
pub fn new_orthographic(gl: &Gl, position: Vec3, target: Vec3, up: Vec3, width: f32, height: f32, depth: f32) -> Camera
{
- let mut camera = Camera::new(gl, position, target, up);
+ let mut camera = Camera::with_orientation(gl, position, target, up);
camera.set_orthographic_projection(width, height, depth);
camera
}
pub fn new_perspective(gl: &Gl, position: Vec3, target: Vec3, up: Vec3, fovy: Degrees, aspect: f32, z_near: f32, z_far: f32) -> Camera
{
- let mut camera = Camera::new(gl, position, target, up);
+ let mut camera = Camera::with_orientation(gl, position, target, up);
camera.set_perspective_projection(fovy, aspect, z_near, z_far);
camera
}
