From 6b962c6c1409581923dfd04fcad3a0be90f71bbf Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 6 Jan 2018 10:53:25 +0000 Subject: [Docs] Adding documentaion to camera --- yage/core/camera.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'yage/core/camera.cpp') diff --git a/yage/core/camera.cpp b/yage/core/camera.cpp index d52c8996..843224dd 100644 --- a/yage/core/camera.cpp +++ b/yage/core/camera.cpp @@ -8,7 +8,6 @@ #include "camera.h" #include "../render/shader.h" - #include "logger.h" #include @@ -17,6 +16,14 @@ namespace yage { +/** + * Creates a camera that looks onto the scene. The screen width and screen + * height should be the current size of the window that the camera is being used + * on so that is functions correctly. + * + * @param screen_width Current screen width of the Window. + * @param screen_height Current screen height of the Window. + */ Camera::Camera(int screen_width, int screen_height) : position_(0.f, 0.f), camera_matrix_(1.f), ortho_matrix_( @@ -24,6 +31,16 @@ Camera::Camera(int screen_width, int screen_height) { } +/** + * Updates the camera matrix value in the shader program that is passed to it. + * This must be a parameter `P` in the shader for this function to work. + * + * @param program Shader program to make changes to. + * + * @todo Make this function more general to be able to be able to use any + * parametre in then shader as the camera matrix and not make it dependent on it + * being `P`. + */ void Camera::update(Shader &program) { if (update_matrix_) { @@ -39,12 +56,25 @@ void Camera::update(Shader &program) program.setUniform("P", camera_matrix_); } +/** + * Moves the camera using a two-dimensional displacement vector to describe the + * movement. + * + * @param direction Two-dimensional vector to describe the displacement of the + * camera. + */ void Camera::move(const glm::vec2 &direction) { position_ += direction; update_matrix_ = true; } +/** + * Zooms the camera by an incremental amount. + * + * @param factor Factor by which the camera should zoom. This can also be a + * negative number for the camera to zoom out. + */ void Camera::zoom(float factor) { scale_ += factor; -- cgit