aboutsummaryrefslogtreecommitdiffstats
path: root/yage/core/camera.cpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-01-06 10:53:25 +0000
committerYann Herklotz <ymherklotz@gmail.com>2018-01-06 10:56:56 +0000
commit6b962c6c1409581923dfd04fcad3a0be90f71bbf (patch)
tree9e9b67f93dfe117775e3a6078c4ae9d6fa09842b /yage/core/camera.cpp
parentdb6480dccd9a3dbf4100a824930a36251f4e743c (diff)
downloadYAGE-6b962c6c1409581923dfd04fcad3a0be90f71bbf.tar.gz
YAGE-6b962c6c1409581923dfd04fcad3a0be90f71bbf.zip
[Docs] Adding documentaion to camera
Diffstat (limited to 'yage/core/camera.cpp')
-rw-r--r--yage/core/camera.cpp32
1 files changed, 31 insertions, 1 deletions
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 <glad/glad.h>
@@ -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;