aboutsummaryrefslogtreecommitdiffstats
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
parentdb6480dccd9a3dbf4100a824930a36251f4e743c (diff)
downloadYAGE-6b962c6c1409581923dfd04fcad3a0be90f71bbf.tar.gz
YAGE-6b962c6c1409581923dfd04fcad3a0be90f71bbf.zip
[Docs] Adding documentaion to camera
-rw-r--r--README.md2
-rw-r--r--docs/Doxyfile.in4
-rw-r--r--docs/logger.dox43
-rw-r--r--yage/core/camera.cpp32
4 files changed, 77 insertions, 4 deletions
diff --git a/README.md b/README.md
index 8498be38..4f185586 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ with the name `yage`.
Build and Testing
-----------------
-To compile YAGE, create a build directory from the base directory. Then call
+To compile YAGE, create a build directory from the base dirqectory. Then call
cmake and point it to the directory containing.
[CMakeLists.txt](/CMakeLists.txt).
For example, one can use the following commands
diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in
index ebb324e2..9feb54a8 100644
--- a/docs/Doxyfile.in
+++ b/docs/Doxyfile.in
@@ -107,7 +107,7 @@ BRIEF_MEMBER_DESC = YES
# brief descriptions will be completely suppressed.
# The default value is: YES.
-REPEAT_BRIEF = NO
+REPEAT_BRIEF = YES
# This tag implements a quasi-intelligent brief description abbreviator that is
# used to form the text in various listings. Each string in this list, if found
@@ -441,7 +441,7 @@ EXTRACT_ALL = YES
# be included in the documentation.
# The default value is: NO.
-EXTRACT_PRIVATE = YES
+EXTRACT_PRIVATE = NO
# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
# scope will be included in the documentation.
diff --git a/docs/logger.dox b/docs/logger.dox
new file mode 100644
index 00000000..57f3a052
--- /dev/null
+++ b/docs/logger.dox
@@ -0,0 +1,43 @@
+/** @class yage::Logger
+
+## Logger
+
+Aynchronous logging is built into the YAGE library, which can be used to log events in the game
+and also debug the game by using the debug output that the game engine produces. This can help
+if for example, a texture is being loaded.
+
+### Log levels
+
+The logger has five different levels that can be assigned to a message. These are, from lowest to
+highest severity, `LogLevel::DEBUG`, `LogLevel::INFO`, `LogLevel::WARNING`, `LogLevel::ERROR`
+and `LogLevel::FATAL`. Messages that the developer then wants to write to the logs can take any
+of these severities and the developer can then decide what the minimum severity is that the logger
+should log. By default, the logger will log anything that is above `LogLevel::INFO`.
+
+### Using the Logger in your Game
+
+There are a few preprocessor definitions to make the use of the logger as simple as possible.
+First of all, there is a definition to get the instance of the current global logger, which
+can then be used to set a different minimum display level. This definition is `yLogger`, and an
+example of how to use it to change the default output level can be seen below
+
+``` c++
+yLogger.setLevel(yage::LogLevel::ERROR);
+```
+
+The above code changes the global logger so that it will only output things that are an error or
+fatal and make the engine crash.
+
+
+Other preprocessor definitions are `yLogDebug`, `yLogInfo`, `yLogWarning`, `yLogError` and
+`yLogFatal`. These return an object that is similar to a buffer, but belongs to the main
+global logger `yLogger`. These are the definitions that should be used to print somehting
+to the main logger. For example
+
+``` c++
+yLogWarning << "This is a warning";
+```
+
+will print the message "This is a warning" with the severity of `LogLevel::WARNING`.
+
+*/ \ No newline at end of file
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;