aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-12-20 17:59:48 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-12-20 17:59:48 +0000
commitcc35bb2471c6d3fd695e3f8985ef168cda3fb39c (patch)
tree2cf90c623fdb75086e486b368c5d65f35a839c10
parent1fcd6a0fe38a8db2c6d317c2735419aa04e9cd83 (diff)
parentb885965a6375f98d6bec63a43233461f9f42006d (diff)
downloadYAGE-cc35bb2471c6d3fd695e3f8985ef168cda3fb39c.tar.gz
YAGE-cc35bb2471c6d3fd695e3f8985ef168cda3fb39c.zip
Merge branch 'develop'
-rw-r--r--.travis.yml93
-rw-r--r--CMakeLists.txt2
-rw-r--r--README.md19
-rw-r--r--docs/Doxyfile2
-rwxr-xr-xscripts/add_version_headers27
-rwxr-xr-xscripts/update_version38
-rw-r--r--tests/activetest.cpp4
-rw-r--r--tests/logtest.cpp6
-rw-r--r--tests/matrixtest.cpp6
-rw-r--r--tests/particlebodytest.cpp6
-rw-r--r--tests/rendertest.cpp14
-rw-r--r--tests/rendertest.h6
-rw-r--r--tests/simplegame.cpp12
-rw-r--r--tests/spritesheettest.cpp6
-rw-r--r--tests/structtest.cpp14
-rw-r--r--tests/syncqueuetest.cpp4
-rw-r--r--tests/threadtest.cpp8
-rw-r--r--tests/vector3test.cpp38
-rw-r--r--tests/vector4test.cpp32
-rw-r--r--tests/windowtest.cpp8
-rw-r--r--tests/yagetest.cpp12
-rw-r--r--yage/core/camera2d.cpp5
-rw-r--r--yage/core/camera2d.h16
-rw-r--r--yage/core/glslprogram.cpp99
-rw-r--r--yage/core/glslprogram.h14
-rw-r--r--yage/core/imageloader.cpp8
-rw-r--r--yage/core/imageloader.h8
-rw-r--r--yage/core/inputmanager.cpp4
-rw-r--r--yage/core/inputmanager.h6
-rw-r--r--yage/core/iomanager.cpp4
-rw-r--r--yage/core/iomanager.h4
-rw-r--r--yage/core/logger.cpp6
-rw-r--r--yage/core/logger.h7
-rw-r--r--yage/core/loglevel.h4
-rw-r--r--yage/core/logmessage.cpp4
-rw-r--r--yage/core/logmessage.h4
-rw-r--r--yage/core/logsink.cpp4
-rw-r--r--yage/core/logsink.h7
-rw-r--r--yage/core/picopng.h4
-rw-r--r--yage/core/resourcemanager.cpp4
-rw-r--r--yage/core/resourcemanager.h12
-rw-r--r--yage/core/sprite.cpp4
-rw-r--r--yage/core/sprite.h4
-rw-r--r--yage/core/spritebatch.cpp4
-rw-r--r--yage/core/spritebatch.h8
-rw-r--r--yage/core/spritesheet.cpp37
-rw-r--r--yage/core/spritesheet.h11
-rw-r--r--yage/core/texture.h4
-rw-r--r--yage/core/texturecache.cpp4
-rw-r--r--yage/core/texturecache.h4
-rw-r--r--yage/core/vertex.h4
-rw-r--r--yage/core/window.cpp4
-rw-r--r--yage/core/window.h4
-rw-r--r--yage/math/math.h14
-rw-r--r--yage/math/matrix.h4
-rw-r--r--yage/physics/body.cpp4
-rw-r--r--yage/physics/body.h4
-rw-r--r--yage/physics/collider.h4
-rw-r--r--yage/physics/collisionbody.h4
-rw-r--r--yage/physics/particlebody.cpp4
-rw-r--r--yage/physics/particlebody.h4
-rw-r--r--yage/physics/physics.h4
-rw-r--r--yage/physics/rectanglecollider.cpp4
-rw-r--r--yage/physics/rectanglecollider.h4
-rw-r--r--yage/physics/rigidbody.cpp4
-rw-r--r--yage/physics/rigidbody.h4
-rw-r--r--yage/util/active.cpp4
-rw-r--r--yage/util/active.h4
-rw-r--r--yage/util/syncqueue.h4
-rw-r--r--yage/yage.cpp4
-rw-r--r--yage/yage.h4
71 files changed, 431 insertions, 324 deletions
diff --git a/.travis.yml b/.travis.yml
index 399ab0d8..7a43043e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,23 +1,23 @@
----
-before_install:
+---
+before_install:
- "eval \"${MATRIX_EVAL}\""
-branches:
- only:
+branches:
+ only:
- master
- develop
dist: trusty
-env:
- global:
+env:
+ global:
secure: NGWn7hJAd/iYfJQmr8oDjTlwttldj8zB+X0gk2TqDhAJ2gLiZ2+b8Bp5FSzBlNIyhcbuhzRU+rzkbo03XSwXZXFRZK/gyPMGaB75ay8MLQBrN3L7THXbjQm1SZg2mO17/MKT+rJH/NvhmqPoUoJaYnoki1G6AZfhnDx+3bW4MNp5/g3u8trk1HNvXWTvjdqS99OH36bvoq8BsOi53Po1veeCIWza6JO61n2nRHzCC2sYWtsZyTQSi3B//iie5zF3gvuRorbzjA/ayc8lLmhUsTmoA1t9HJP52fKzv/q3mxllXzyzpWNRmUJCzf7I1wY9jp1FVwojfl0umofzYPCCjwSrKlRtmwQfi0peg7VOJVCCJx7Eh/i0hamGUnDEu0aZnfhgwzkqDDIgO1AwcEv5i9egt/73kK4mdm22sEDa3dWVu37tnj5dItaQesMm6TXKMy9+r7v0aaVJbQB2atvBaf3RlW71P9iy8mOZ+geKNwVFRuBdu5g3oQe5QrqXRi4inMv0bjN8HwOVs/f8ZTGZePnbHnxOnYRErxLnha/bsu7btfDT8Q8nmZ/Rhcu7QkMRNTm5L3+YHFUngiIygOs8wrH6HECtSYwmi9WejRuPgU2GnYR0Rzyi5dyaFok1iN+jsYsY9YFx5tRgxuX4H9CnUlfDabdFSLzqbmKRlbP79as=
-git:
+git:
depth: 1
language: cpp
-matrix:
- include:
- -
- addons:
- apt:
- packages:
+matrix:
+ include:
+ -
+ addons:
+ apt:
+ packages:
- g++-5
- libegl1-mesa-dev
- libgles2-mesa-dev
@@ -25,16 +25,16 @@ matrix:
- xorg-dev
- libglu1-mesa-dev
- doxygen
- sources:
+ sources:
- ubuntu-toolchain-r-test
compiler: g++-5
- env:
+ env:
- "MATRIX_EVAL=\"CC=gcc-5 && CXX=g++-5\""
os: linux
- -
- addons:
- apt:
- packages:
+ -
+ addons:
+ apt:
+ packages:
- g++-6
- libegl1-mesa-dev
- libgles2-mesa-dev
@@ -42,16 +42,16 @@ matrix:
- xorg-dev
- libglu1-mesa-dev
- doxygen
- sources:
+ sources:
- ubuntu-toolchain-r-test
compiler: g++-6
- env:
+ env:
- "MATRIX_EVAL=\"CC=gcc-6 && CXX=g++-6\""
os: linux
- -
- addons:
- apt:
- packages:
+ -
+ addons:
+ apt:
+ packages:
- g++-7
- libegl1-mesa-dev
- libgles2-mesa-dev
@@ -59,15 +59,15 @@ matrix:
- xorg-dev
- libglu1-mesa-dev
- doxygen
- sources:
+ sources:
- ubuntu-toolchain-r-test
compiler: g++-7
- env:
+ env:
- "MATRIX_EVAL=\"CC=gcc-7 && CXX=g++-7\""
os: linux
- -
- addons:
- apt:
+ -
+ addons:
+ apt:
packages:
- g++-7
- clang-4.0
@@ -77,16 +77,16 @@ matrix:
- xorg-dev
- libglu1-mesa-dev
- doxygen
- sources:
+ sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
compiler: clang++-4.0
- env:
+ env:
- "MATRIX_EVAL=\"CC=clang-4.0 && CXX=clang++-4.0\""
os: linux
- -
- addons:
- apt:
+ -
+ addons:
+ apt:
packages:
- g++-7
- clang-5.0
@@ -96,31 +96,16 @@ matrix:
- xorg-dev
- libglu1-mesa-dev
- doxygen
- sources:
+ sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
compiler: clang++-5.0
- env:
+ env:
- "MATRIX_EVAL=\"CC=clang-5.0 && CXX=clang++-5.0\""
os: linux
-# -
-# env:
-# - "MATRIX_EVAL=\"rvm install ruby-2.3.3 && rvm use 2.3.3 && brew update && brew install gcc5 && CC=gcc-5 && CXX=g++-5\""
-# os: osx
-# osx_image: xcode8
-# -
-# env:
-# - "MATRIX_EVAL=\"rvm install ruby-2.3.3 && rvm use 2.3.3 && brew update && brew install gcc6 && CC=gcc-6 && CXX=g++-6\""
-# os: osx
-# osx_image: xcode8
-# -
-# env:
-# - "MATRIX_EVAL=\"rvm install ruby-2.3.3 && rvm use 2.3.3 && brew update && brew install gcc && CC=gcc-7 && CXX=g++-7\""
-# os: osx
-# osx_image: xcode8
-notifications:
+notifications:
email: false
-script:
+script:
- "$CC --version"
- "$CXX --version"
- "cd $TRAVIS_BUILD_DIR"
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 957224a5..0ea75fa1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
# yage library cmakelists.txt
project(yage
- VERSION 0.3.1.0
+ VERSION 0.1.3.0
LANGUAGES CXX)
if(NOT DEFINED UNIT_TESTS)
diff --git a/README.md b/README.md
index 724e5e5a..882f37dd 100644
--- a/README.md
+++ b/README.md
@@ -5,9 +5,15 @@ YAGE {#mainpage}
Introduction
------------
-YAGE stands for Yet Another Game Engine. It is a game engine that I am
-developing for a game called [Arider](https://github.com/ymherklotz/Arider).
+YAGE stands for Yet Another Game Engine. It is a game engine that is being
+developed for a game called [Arider](https://github.com/ymherklotz/Arider).
It uses OpenGL and GLFW for the window creation and management and graphics.
+It is also going to be a general game engine for use with other games in the
+similar style.
+
+The inspiration for this game engine is to learn about OpenGL and create an
+optimised 2D game engine with a simple API that can be used to easily create
+simple 2D games.
The full documentation can be seen [here](https://www.yannherklotz.com/YAGE).
@@ -15,7 +21,9 @@ Installation and usage
----------------------
To use YAGE for your own game, you should link it as a static library and
-include the [yage.h](/include/YAGE/yage.h) header in your project.
+include the [yage.h](/include/YAGE/yage.h) header in your project. To link the
+project using cmake, the library has to be added as a subdirectory and then linked
+with the name `yage`.
Build and Testing
-----------------
@@ -23,11 +31,12 @@ Build and Testing
To compile YAGE, create a build directory from the base directory. Then call
cmake and point it to the directory containing.
[CMakeLists.txt](/CMakeLists.txt).
+For example, one can use the following commands
``` shell
-mkdir build
+mkdir -p build
cd build
-cmake .. -DENABLE_TESTING=1
+cmake -DENABLE_TESTING=1 ..
```
You can then run google test on YAGE.
diff --git a/docs/Doxyfile b/docs/Doxyfile
index 3e499988..10422fba 100644
--- a/docs/Doxyfile
+++ b/docs/Doxyfile
@@ -38,7 +38,7 @@ PROJECT_NAME = "YAGE"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = v0.3.1
+PROJECT_NUMBER = v0.1.3
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/scripts/add_version_headers b/scripts/add_version_headers
index c4fd3ffc..cf1531b0 100755
--- a/scripts/add_version_headers
+++ b/scripts/add_version_headers
@@ -24,10 +24,12 @@ import os
import re
import sys
+from subprocess import call
-header = """/* ---------------------------------------------------------------\
--------------
- * {0}
+
+header = """/** ---------------------------------------------------------------\
+------------
+ * @file: {0}
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -38,7 +40,7 @@ header = """/* ---------------------------------------------------------------\
lic_regex = re.compile(
- "\/\* -+\n \* ([a-z]+\.(?:cpp|h)|\{0\})\n(?: \*[ a-zA-Z0-9_.,\-()<>@]*\n)+ \* -+\n \*/", re.MULTILINE)
+ "\/(?:\*|\*\*) -+\n \* ((?:@file: )?[a-z0-9]+\.(?:cpp|h)|\{0\})\n(?: \*[ a-zA-Z0-9_.,\-()<>@]*\n)+ \* -+\n \*/\n\n", re.MULTILINE)
class HeaderUpdate(object):
@@ -75,11 +77,13 @@ class HeaderUpdate(object):
src = f.read()
f.seek(0)
if lic_regex.match(src):
- print("Updating {}: ".format(
- os.path.basename(filePath)), end="")
- src = lic_regex.sub(header.format(
+ other_src = lic_regex.sub(header.format(
os.path.basename(filePath)), src)
- print("done")
+ if other_src != src:
+ print("Updating {}: ".format(
+ os.path.basename(filePath)), end="")
+ src = other_src
+ print("done")
else:
print("Adding {}: ".format(
os.path.basename(filePath)), end="")
@@ -102,12 +106,19 @@ class HeaderUpdate(object):
not re.match(self.exclude_re, fileName)):
fileOperation(os.path.join(subdir, fileName))
+ def runClangFormat(self):
+ def clangFormatFileOpration(filePath):
+ call(["clang-format", "-i", filePath])
+
+ self._traverseDir(self.starting_dir, clangFormatFileOpration)
+
def main(argv):
update = HeaderUpdate(exclude_re="^picopng\.cpp",
match_dir=".*yage|.*tests",
exclude_dir=".*lib.*|.*build.*")
update.updateHeader()
+ update.runClangFormat()
if __name__ == "__main__":
diff --git a/scripts/update_version b/scripts/update_version
new file mode 100755
index 00000000..9c618fa6
--- /dev/null
+++ b/scripts/update_version
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# -----------------------------------------------------------------------------
+# @file: add_version_headers
+#
+# Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
+# MIT License, see LICENSE file for more details.
+# -----------------------------------------------------------------------------
+
+
+import os
+import re
+import sys
+
+
+def main(argv):
+ cwd = os.path.join(os.getcwd(), argv[2])
+ cmake = os.path.join(cwd, "CMakeLists.txt")
+ doxyfile = os.path.join(cwd, "docs", "Doxyfile")
+
+ with open(cmake, "r+") as f_:
+ src = f_.read()
+ f_.seek(0)
+ src = re.sub(r"(project\(\w+\s+VERSION\s+)[0-9.]+", r"\g<1>{0}.0".format(argv[1]), src, re.MULTILINE)
+ f_.write(src)
+ f_.truncate()
+
+ with open(doxyfile, "r+") as f_:
+ src = f_.read()
+ f_.seek(0)
+ src = re.sub(r"(PROJECT_NUMBER\s+=\s+v)[0-9.]+", r"\g<1>{0}".format(argv[1]), src, re.MULTILINE)
+ f_.write(src)
+ f_.truncate()
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))
diff --git a/tests/activetest.cpp b/tests/activetest.cpp
index cebf90d3..3d561283 100644
--- a/tests/activetest.cpp
+++ b/tests/activetest.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * activetest.cpp
+/** ---------------------------------------------------------------------------
+ * @file: activetest.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/tests/logtest.cpp b/tests/logtest.cpp
index 74a71057..e1010754 100644
--- a/tests/logtest.cpp
+++ b/tests/logtest.cpp
@@ -1,13 +1,11 @@
-/* ----------------------------------------------------------------------------
- * logtest.cpp
+/** ---------------------------------------------------------------------------
+ * @file: logtest.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-
-
#include <yage.h>
#include <iostream>
diff --git a/tests/matrixtest.cpp b/tests/matrixtest.cpp
index be2ca186..1e316502 100644
--- a/tests/matrixtest.cpp
+++ b/tests/matrixtest.cpp
@@ -1,13 +1,11 @@
-/* ----------------------------------------------------------------------------
- * matrixtest.cpp
+/** ---------------------------------------------------------------------------
+ * @file: matrixtest.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-
-
#include <gtest/gtest.h>
#include <yage/yage.h>
diff --git a/tests/particlebodytest.cpp b/tests/particlebodytest.cpp
index 511e3ef5..09277826 100644
--- a/tests/particlebodytest.cpp
+++ b/tests/particlebodytest.cpp
@@ -1,13 +1,11 @@
-/* ----------------------------------------------------------------------------
- * particlebodytest.cpp
+/** ---------------------------------------------------------------------------
+ * @file: particlebodytest.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-
-
#include <gtest/gtest.h>
#include <yage/yage.h>
diff --git a/tests/rendertest.cpp b/tests/rendertest.cpp
index a0452ab4..74476ef8 100644
--- a/tests/rendertest.cpp
+++ b/tests/rendertest.cpp
@@ -1,19 +1,13 @@
-/* ----------------------------------------------------------------------------
- * rendertest.cpp
+/** ---------------------------------------------------------------------------
+ * @file: rendertest.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-
-
#include "rendertest.h"
-RenderTest::RenderTest(std::string sprite) : sprite_(sprite)
-{
-}
+RenderTest::RenderTest(std::string sprite) : sprite_(sprite) {}
-void RenderTest::render()
-{
-}
+void RenderTest::render() {}
diff --git a/tests/rendertest.h b/tests/rendertest.h
index f6ed36c6..db0e06e2 100644
--- a/tests/rendertest.h
+++ b/tests/rendertest.h
@@ -1,13 +1,11 @@
-/* ----------------------------------------------------------------------------
- * rendertest.h
+/** ---------------------------------------------------------------------------
+ * @file: rendertest.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-
-
#include <string>
class RenderTest
diff --git a/tests/simplegame.cpp b/tests/simplegame.cpp
index 99796f08..d4c7b266 100644
--- a/tests/simplegame.cpp
+++ b/tests/simplegame.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * simplegame.cpp
+/** ---------------------------------------------------------------------------
+ * @file: simplegame.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -22,13 +22,7 @@ int main()
window.create("Simple Game", 800, 640);
SpriteBatch sp;
- program.compileShaders(
- "/home/yannherklotz/Github/YAGE/resources/defaultshader.vert",
- "/home/yannherklotz/Github/YAGE/resources/defaultshader.frag");
- program.addAttribute("vertex_position");
- program.addAttribute("vertex_colour");
- program.addAttribute("vertex_uv");
- program.linkShaders();
+ program.defaultSetup();
Texture fountain =
ResourceManager::getTexture("/home/yannherklotz/Github/YAGE/tests/"
diff --git a/tests/spritesheettest.cpp b/tests/spritesheettest.cpp
index 2ece61bf..fcfc842c 100644
--- a/tests/spritesheettest.cpp
+++ b/tests/spritesheettest.cpp
@@ -1,13 +1,11 @@
-/* ----------------------------------------------------------------------------
- * spritesheettest.cpp
+/** ---------------------------------------------------------------------------
+ * @file: spritesheettest.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-
-
/** @file */
#include <gtest/gtest.h>
diff --git a/tests/structtest.cpp b/tests/structtest.cpp
index 13a2c591..99752abb 100644
--- a/tests/structtest.cpp
+++ b/tests/structtest.cpp
@@ -1,8 +1,16 @@
-#include <yage/yage.h>
+/** ---------------------------------------------------------------------------
+ * @file: structtest.cpp
+ *
+ * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
+ * MIT License, see LICENSE file for more details.
+ * ----------------------------------------------------------------------------
+ */
+
#include <gtest/gtest.h>
+#include <yage/yage.h>
-#include <ctime>
#include <cstdlib>
+#include <ctime>
TEST(StructTest, ColourDefault)
{
@@ -15,7 +23,7 @@ TEST(StructTest, ColourDefault)
TEST(StructTest, ColourConstructor)
{
- int r = rand()%255, g = rand()%255, b = rand() % 255, a = rand() % 255;
+ int r = rand() % 255, g = rand() % 255, b = rand() % 255, a = rand() % 255;
yage::Colour c(r, g, b, a);
ASSERT_EQ(c.r, r);
diff --git a/tests/syncqueuetest.cpp b/tests/syncqueuetest.cpp
index db347854..1d7d8037 100644
--- a/tests/syncqueuetest.cpp
+++ b/tests/syncqueuetest.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * syncqueuetest.cpp
+/** ---------------------------------------------------------------------------
+ * @file: syncqueuetest.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/tests/threadtest.cpp b/tests/threadtest.cpp
index 9ea46e62..0527665a 100644
--- a/tests/threadtest.cpp
+++ b/tests/threadtest.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * threadtest.cpp
+/** ---------------------------------------------------------------------------
+ * @file: threadtest.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -17,9 +17,7 @@ int main()
std::cout << "n before: " << n << "\n";
- auto f = [&] () {
- n = 8;
- };
+ auto f = [&]() { n = 8; };
std::thread t1(f);
diff --git a/tests/vector3test.cpp b/tests/vector3test.cpp
index daab02af..570a5c10 100644
--- a/tests/vector3test.cpp
+++ b/tests/vector3test.cpp
@@ -1,13 +1,37 @@
-/* ----------------------------------------------------------------------------
- * vector3test.cpp
+/** ---------------------------------------------------------------------------
+ * @file: vector3test.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-/* ----------------------------------------------------------------------------
- * vector3test.cpp
+/** ---------------------------------------------------------------------------
+ * @file: vector3test.cpp
+ *
+ * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
+ * MIT License, see LICENSE file for more details.
+ * ----------------------------------------------------------------------------
+ */
+
+/** ---------------------------------------------------------------------------
+ * @file: vector3test.cpp
+ *
+ * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
+ * MIT License, see LICENSE file for more details.
+ * ----------------------------------------------------------------------------
+ */
+
+/** ---------------------------------------------------------------------------
+ * @file: vector3test.cpp
+ *
+ * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
+ * MIT License, see LICENSE file for more details.
+ * ----------------------------------------------------------------------------
+ */
+
+/** ---------------------------------------------------------------------------
+ * @file: vector3test.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -17,8 +41,8 @@
#include <gtest/gtest.h>
#include <yage/yage.h>
-#include <ctime>
#include <cstdlib>
+#include <ctime>
using namespace yage;
@@ -60,9 +84,7 @@ TEST(Vector3, Assigning_z)
ASSERT_EQ(vec.z, vec[2]);
}
-TEST(Vector3, Addition)
-{
-}
+TEST(Vector3, Addition) {}
int main(int argc, char **argv)
{
diff --git a/tests/vector4test.cpp b/tests/vector4test.cpp
index fd67d802..53554a25 100644
--- a/tests/vector4test.cpp
+++ b/tests/vector4test.cpp
@@ -1,13 +1,37 @@
-/* ----------------------------------------------------------------------------
- * vector4test.cpp
+/** ---------------------------------------------------------------------------
+ * @file: vector4test.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-/* ----------------------------------------------------------------------------
- * vector4test.cpp
+/** ---------------------------------------------------------------------------
+ * @file: vector4test.cpp
+ *
+ * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
+ * MIT License, see LICENSE file for more details.
+ * ----------------------------------------------------------------------------
+ */
+
+/** ---------------------------------------------------------------------------
+ * @file: vector4test.cpp
+ *
+ * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
+ * MIT License, see LICENSE file for more details.
+ * ----------------------------------------------------------------------------
+ */
+
+/** ---------------------------------------------------------------------------
+ * @file: vector4test.cpp
+ *
+ * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
+ * MIT License, see LICENSE file for more details.
+ * ----------------------------------------------------------------------------
+ */
+
+/** ---------------------------------------------------------------------------
+ * @file: vector4test.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/tests/windowtest.cpp b/tests/windowtest.cpp
index 53ff3e9c..40b7e664 100644
--- a/tests/windowtest.cpp
+++ b/tests/windowtest.cpp
@@ -1,15 +1,13 @@
-/* ----------------------------------------------------------------------------
- * windowtest.cpp
+/** ---------------------------------------------------------------------------
+ * @file: windowtest.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-
-
-#include <yage/yage.h>
#include <gtest/gtest.h>
+#include <yage/yage.h>
TEST(Window, Open)
{
diff --git a/tests/yagetest.cpp b/tests/yagetest.cpp
index 2e961327..a599eba2 100644
--- a/tests/yagetest.cpp
+++ b/tests/yagetest.cpp
@@ -1,23 +1,21 @@
-/* ----------------------------------------------------------------------------
- * yagetest.cpp
+/** ---------------------------------------------------------------------------
+ * @file: yagetest.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-
-
-#include <yage/yage.h>
#include <gtest/gtest.h>
+#include <yage/yage.h>
TEST(YAGE, InitQuit)
{
try {
yage::init();
yage::quit();
- } catch(std::runtime_error e) {
-// ASSERT_TRUE(false);
+ } catch (std::runtime_error e) {
+ // ASSERT_TRUE(false);
}
}
diff --git a/yage/core/camera2d.cpp b/yage/core/camera2d.cpp
index d5640c3f..89d41ab5 100644
--- a/yage/core/camera2d.cpp
+++ b/yage/core/camera2d.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * camera2d.cpp
+/** ---------------------------------------------------------------------------
+ * @file: camera2d.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -7,6 +7,7 @@
*/
#include "camera2d.h"
+#include "glslprogram.h"
#include <glad/glad.h>
diff --git a/yage/core/camera2d.h b/yage/core/camera2d.h
index 333f907d..db941aee 100644
--- a/yage/core/camera2d.h
+++ b/yage/core/camera2d.h
@@ -1,13 +1,5 @@
-/* ----------------------------------------------------------------------------
- * camera2d.h
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-/* ----------------------------------------------------------------------------
- * camera2d.h
+/** ---------------------------------------------------------------------------
+ * @file: camera2d.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -17,14 +9,14 @@
#ifndef YAGE_CAMERA2D_H
#define YAGE_CAMERA2D_H
-#include "glslprogram.h"
-
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
namespace yage
{
+class GlslProgram;
+
class Camera2D
{
private:
diff --git a/yage/core/glslprogram.cpp b/yage/core/glslprogram.cpp
index 4772d50e..c47de808 100644
--- a/yage/core/glslprogram.cpp
+++ b/yage/core/glslprogram.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * glslprogram.cpp
+/** ---------------------------------------------------------------------------
+ * @file: glslprogram.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -17,7 +17,7 @@ namespace yage
GlslProgram::~GlslProgram()
{
- // cleanup all the shaders and the program
+ /// cleans up all the shaders and the program
if (fragment_shader_id_ != 0) {
glDeleteShader(fragment_shader_id_);
}
@@ -31,26 +31,11 @@ GlslProgram::~GlslProgram()
}
}
-void GlslProgram::compileShader(const GLuint &shader,
- const std::string &file_path)
+void GlslProgram::compileShader(GLuint shader, const std::string &shaderContent)
{
- // get a string with the input from the shader file
- std::ifstream file(file_path);
- if (!file.is_open()) {
- throw std::runtime_error("Failed to open '" + file_path + "'");
- }
-
- std::string content = "";
- std::string line;
-
- while (std::getline(file, line)) {
- content += line + "\n";
- }
- file.close();
-
// cast source to a c string to get the address of it and input it for
// compilation
- const auto *vertex_source = (const GLchar *)content.c_str();
+ const auto *vertex_source = (const GLchar *)shaderContent.c_str();
glShaderSource(shader, 1, &vertex_source, nullptr);
glCompileShader(shader);
@@ -67,13 +52,38 @@ void GlslProgram::compileShader(const GLuint &shader,
glGetShaderInfoLog(shader, max_length, &max_length, &error_log[0]);
std::string error_log_str((const char *)&error_log[0]);
- throw std::runtime_error("Couldn't compile " + file_path + " : " +
+ std::string shaderName;
+ if (shader == vertex_shader_id_)
+ shaderName = "vertex shader";
+ else
+ shaderName = "fragment shader";
+
+ throw std::runtime_error("Couldn't compile the " + shaderName + " : " +
error_log_str);
}
}
-void GlslProgram::compileShaders(const std::string &vertex_shader_path,
- const std::string &fragment_shader_path)
+void GlslProgram::compileShaderFromFile(GLuint shader,
+ const std::string &file_path)
+{
+ // get a string with the input from the shader file
+ std::ifstream file(file_path);
+ if (!file.is_open()) {
+ throw std::runtime_error("Failed to open '" + file_path + "'");
+ }
+
+ std::string content = "";
+ std::string line;
+
+ while (std::getline(file, line)) {
+ content += line + "\n";
+ }
+ file.close();
+
+ compileShader(shader, content);
+}
+
+void GlslProgram::initShaderId()
{
// create the program that will be run on GPU
program_id_ = glCreateProgram();
@@ -89,10 +99,26 @@ void GlslProgram::compileShaders(const std::string &vertex_shader_path,
if (fragment_shader_id_ == 0) {
throw std::runtime_error("Fragment shader failed to be created");
}
+}
+
+void GlslProgram::compileShaders(const std::string &vertexShader,
+ const std::string fragmentShader)
+{
+ initShaderId();
+
+ compileShader(vertex_shader_id_, vertexShader);
+ compileShader(fragment_shader_id_, fragmentShader);
+}
+
+void GlslProgram::compileShadersFromFile(
+ const std::string &vertex_shader_path,
+ const std::string &fragment_shader_path)
+{
+ initShaderId();
// compile the two shaders
- compileShader(vertex_shader_id_, vertex_shader_path);
- compileShader(fragment_shader_id_, fragment_shader_path);
+ compileShaderFromFile(vertex_shader_id_, vertex_shader_path);
+ compileShaderFromFile(fragment_shader_id_, fragment_shader_path);
}
void GlslProgram::linkShaders()
@@ -161,6 +187,29 @@ void GlslProgram::unuse()
void GlslProgram::defaultSetup()
{
+ std::string vertexShader =
+ "#version 130\n\nin vec2 vertex_position;\nin vec4 vertex_colour;\nin "
+ "vec2 vertex_uv;\n\nout vec2 fragment_position;\nout vec4 "
+ "fragment_colour;\nout vec2 fragment_uv;\n\nuniform mat4 P;\n\nvoid "
+ "main()\n{\n gl_Position.xy = (P*vec4(vertex_position, 0.0, "
+ "1.0)).xy;\n gl_Position.z = 0.0;\n gl_Position.w = 1.0;\n\n "
+ "fragment_position = vertex_position;\n fragment_colour = "
+ "vertex_colour;\n fragment_uv = vec2(vertex_uv.x, "
+ "1-vertex_uv.y);\n\n}";
+
+ std::string fragmentShader =
+ "#version 130\n\nin vec2 fragment_position;\nin vec4 "
+ "fragment_colour;\nin vec2 fragment_uv;\n\nout vec4 colour;\n\nuniform "
+ "sampler2D texture_sampler;\n\nvoid main()\n{\n vec4 texture_color "
+ "= texture(texture_sampler, fragment_uv);\n\n colour = "
+ "texture_color;\n}";
+
+ compileShaders(vertexShader, fragmentShader);
+ addAttribute("vertex_position");
+ addAttribute("vertex_colour");
+ addAttribute("vertex_uv");
+
+ linkShaders();
}
} // namespace yage
diff --git a/yage/core/glslprogram.h b/yage/core/glslprogram.h
index 50b2a7de..9e49d329 100644
--- a/yage/core/glslprogram.h
+++ b/yage/core/glslprogram.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * glslprogram.h
+/** ---------------------------------------------------------------------------
+ * @file: glslprogram.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -28,8 +28,10 @@ public:
GlslProgram &operator=(GlslProgram &&) = delete;
/// compiles vertex and fragment shader
- void compileShaders(const std::string &vertex_shader_path,
- const std::string &fragment_shader_path);
+ void compileShaders(const std::string &vertexShader,
+ const std::string fragmentShader);
+ void compileShadersFromFile(const std::string &vertex_shader_path,
+ const std::string &fragment_shader_path);
void linkShaders();
void addAttribute(const std::string &attribute_name);
GLint getUniformLocation(const std::string &uniform_name);
@@ -46,7 +48,9 @@ private:
int attribute_index_ = 0;
/// compiles one shader
- void compileShader(const GLuint &shader, const std::string &file_path);
+ void compileShader(GLuint shader, const std::string &shaderContent);
+ void compileShaderFromFile(GLuint shader, const std::string &file_path);
+ void initShaderId();
};
} // namespace yage
diff --git a/yage/core/imageloader.cpp b/yage/core/imageloader.cpp
index ae67a94a..fb4d1e44 100644
--- a/yage/core/imageloader.cpp
+++ b/yage/core/imageloader.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * imageloader.cpp
+/** ---------------------------------------------------------------------------
+ * @file: imageloader.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -7,11 +7,9 @@
*/
#include "imageloader.h"
+#include "texture.h"
-#ifndef UNIT_TESTS
#include <glad/glad.h>
-#endif
-
#include <yage/core/iomanager.h>
#include <yage/core/picopng.h>
diff --git a/yage/core/imageloader.h b/yage/core/imageloader.h
index ab9f9e4d..bc041dc6 100644
--- a/yage/core/imageloader.h
+++ b/yage/core/imageloader.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * imageloader.h
+/** ---------------------------------------------------------------------------
+ * @file: imageloader.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -9,13 +9,13 @@
#ifndef IMAGE_LOADER_H
#define IMAGE_LOADER_H
-#include "texture.h"
-
#include <string>
namespace yage
{
+class Texture;
+
class ImageLoader
{
public:
diff --git a/yage/core/inputmanager.cpp b/yage/core/inputmanager.cpp
index 7f4e121a..1f324b9e 100644
--- a/yage/core/inputmanager.cpp
+++ b/yage/core/inputmanager.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * inputmanager.cpp
+/** ---------------------------------------------------------------------------
+ * @file: inputmanager.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/inputmanager.h b/yage/core/inputmanager.h
index 9fabd997..e8dd153a 100644
--- a/yage/core/inputmanager.h
+++ b/yage/core/inputmanager.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * inputmanager.h
+/** ---------------------------------------------------------------------------
+ * @file: inputmanager.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -24,5 +24,7 @@ public:
void keyReleased(unsigned key);
bool isKeyPressed(unsigned key) const;
};
+
} // namespace yage
+
#endif
diff --git a/yage/core/iomanager.cpp b/yage/core/iomanager.cpp
index 33286d5d..3d9ea7cb 100644
--- a/yage/core/iomanager.cpp
+++ b/yage/core/iomanager.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * iomanager.cpp
+/** ---------------------------------------------------------------------------
+ * @file: iomanager.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/iomanager.h b/yage/core/iomanager.h
index 14ad2d16..6c623adf 100644
--- a/yage/core/iomanager.h
+++ b/yage/core/iomanager.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * iomanager.h
+/** ---------------------------------------------------------------------------
+ * @file: iomanager.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/logger.cpp b/yage/core/logger.cpp
index 7a58efb6..4690fadc 100644
--- a/yage/core/logger.cpp
+++ b/yage/core/logger.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * logger.cpp
+/** ---------------------------------------------------------------------------
+ * @file: logger.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -10,6 +10,8 @@
#include "logmessage.h"
#include "logsink.h"
+#include <yage/util/active.h>
+
#include <algorithm>
#include <iostream>
#include <string>
diff --git a/yage/core/logger.h b/yage/core/logger.h
index 76f38641..95af73b0 100644
--- a/yage/core/logger.h
+++ b/yage/core/logger.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * logger.h
+/** ---------------------------------------------------------------------------
+ * @file: logger.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -9,8 +9,6 @@
#ifndef YAGE_CORE_LOGGER_H
#define YAGE_CORE_LOGGER_H
-#include <yage/util/active.h>
-
#include <memory>
#include <string>
#include <vector>
@@ -18,6 +16,7 @@
namespace yage
{
+class Active;
class LogMessage;
class LogSink;
diff --git a/yage/core/loglevel.h b/yage/core/loglevel.h
index ca763321..eb9ff5f8 100644
--- a/yage/core/loglevel.h
+++ b/yage/core/loglevel.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * loglevel.h
+/** ---------------------------------------------------------------------------
+ * @file: loglevel.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/logmessage.cpp b/yage/core/logmessage.cpp
index 172cef4b..1ae16fba 100644
--- a/yage/core/logmessage.cpp
+++ b/yage/core/logmessage.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * logmessage.cpp
+/** ---------------------------------------------------------------------------
+ * @file: logmessage.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/logmessage.h b/yage/core/logmessage.h
index 75a8cf47..ef7fd8a5 100644
--- a/yage/core/logmessage.h
+++ b/yage/core/logmessage.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * logmessage.h
+/** ---------------------------------------------------------------------------
+ * @file: logmessage.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/logsink.cpp b/yage/core/logsink.cpp
index 2f59d620..36d7038b 100644
--- a/yage/core/logsink.cpp
+++ b/yage/core/logsink.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * logsink.cpp
+/** ---------------------------------------------------------------------------
+ * @file: logsink.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/logsink.h b/yage/core/logsink.h
index 064abc63..63f95655 100644
--- a/yage/core/logsink.h
+++ b/yage/core/logsink.h
@@ -1,14 +1,17 @@
-/* ----------------------------------------------------------------------------
- * logsink.h
+/** ---------------------------------------------------------------------------
+ * @file: logsink.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
+/// @file
+
#ifndef YAGE_CORE_LOGSINK_H
#define YAGE_CORE_LOGSINK_H
+/// @todo remove the include to make compilation faster
#include "logmessage.h"
#include <memory>
diff --git a/yage/core/picopng.h b/yage/core/picopng.h
index 9b2cb081..d868fa43 100644
--- a/yage/core/picopng.h
+++ b/yage/core/picopng.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * picopng.h
+/** ---------------------------------------------------------------------------
+ * @file: picopng.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/resourcemanager.cpp b/yage/core/resourcemanager.cpp
index 3fefc4f5..f841222b 100644
--- a/yage/core/resourcemanager.cpp
+++ b/yage/core/resourcemanager.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * resourcemanager.cpp
+/** ---------------------------------------------------------------------------
+ * @file: resourcemanager.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/resourcemanager.h b/yage/core/resourcemanager.h
index 8fc6a16e..369bf40f 100644
--- a/yage/core/resourcemanager.h
+++ b/yage/core/resourcemanager.h
@@ -1,16 +1,16 @@
-/* ----------------------------------------------------------------------------
- * resourcemanager.h
+/** ---------------------------------------------------------------------------
+ * @file: resourcemanager.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-/* ----------------------------------------------------------------------------
- * resourcemanager.h
+/** ---------------------------------------------------------------------------
+ * @file: resourcemanager.h
*
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License
- * See file LICENSE for more details
+ * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
+ * MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
diff --git a/yage/core/sprite.cpp b/yage/core/sprite.cpp
index 041281d3..a663c379 100644
--- a/yage/core/sprite.cpp
+++ b/yage/core/sprite.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * sprite.cpp
+/** ---------------------------------------------------------------------------
+ * @file: sprite.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/sprite.h b/yage/core/sprite.h
index 9cba1daf..0287fe10 100644
--- a/yage/core/sprite.h
+++ b/yage/core/sprite.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * sprite.h
+/** ---------------------------------------------------------------------------
+ * @file: sprite.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/spritebatch.cpp b/yage/core/spritebatch.cpp
index 98213467..2159aeec 100644
--- a/yage/core/spritebatch.cpp
+++ b/yage/core/spritebatch.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * spritebatch.cpp
+/** ---------------------------------------------------------------------------
+ * @file: spritebatch.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/spritebatch.h b/yage/core/spritebatch.h
index d90d6d05..fa93c5cb 100644
--- a/yage/core/spritebatch.h
+++ b/yage/core/spritebatch.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * spritebatch.h
+/** ---------------------------------------------------------------------------
+ * @file: spritebatch.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
@@ -94,8 +94,8 @@ public:
// adds a sprite to the sprite batch to be rendered later
void draw(const yage::Vector4f &destination_rect,
- const yage::Vector4f &uv_rect, GLuint texture, const Colour &colour,
- float depth);
+ const yage::Vector4f &uv_rect, GLuint texture,
+ const Colour &colour, float depth);
// render the batch
void render();
diff --git a/yage/core/spritesheet.cpp b/yage/core/spritesheet.cpp
index e18d7fe8..7fbd19e9 100644
--- a/yage/core/spritesheet.cpp
+++ b/yage/core/spritesheet.cpp
@@ -1,32 +1,31 @@
-/* ----------------------------------------------------------------------------
- * spritesheet.cpp
+/** ---------------------------------------------------------------------------
+ * @file: spritesheet.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-/** @file
- */
+/// @file
#include "spritesheet.h"
+#include <rapidjson/document.h>
+#include <yage/core/imageloader.h>
+
#include <cassert>
#include <fstream>
#include <sstream>
#include <stdexcept>
-#include <rapidjson/document.h>
-#include <yage/core/imageloader.h>
-
-using namespace std;
-using namespace rapidjson;
-using namespace yage::details;
+using rapidjson::Document;
+using yage::details::Coordinate;
+using yage::details::SpriteMap;
namespace yage
{
-SpriteSheet::SpriteSheet(string pngFileName, string jsonFileName)
+SpriteSheet::SpriteSheet(std::string pngFileName, std::string jsonFileName)
{
int jsonWidth, jsonHeight;
fileLocations_ =
@@ -34,23 +33,23 @@ SpriteSheet::SpriteSheet(string pngFileName, string jsonFileName)
texture_ = ImageLoader::loadPng(pngFileName);
if (texture_.width != jsonWidth)
- throw runtime_error("JSON width does not match texture width");
+ throw std::runtime_error("JSON width does not match texture width");
if (texture_.height != jsonHeight)
- throw runtime_error("JSON height does not match texture height");
+ throw std::runtime_error("JSON height does not match texture height");
}
-string SpriteSheet::fileContent(string jsonFileName) const
+std::string SpriteSheet::fileContent(std::string jsonFileName) const
{
- ifstream inputFile(jsonFileName);
+ std::ifstream inputFile(jsonFileName);
- stringstream stream;
+ std::stringstream stream;
stream << inputFile.rdbuf();
return stream.str();
}
SpriteMap SpriteSheet::parseJson(int &width, int &height,
- string jsonContent) const
+ std::string jsonContent) const
{
SpriteMap spriteMap;
Document jsonAtlas;
@@ -62,7 +61,7 @@ SpriteMap SpriteSheet::parseJson(int &width, int &height,
for (auto &texture : jsonAtlas["sprites"].GetObject()) {
Coordinate coord;
for (auto &value : texture.value.GetObject()) {
- string keyName{value.value.GetString()};
+ std::string keyName{value.value.GetString()};
int keyValue{value.value.GetInt()};
if (keyName == "x") {
coord.x = keyValue;
@@ -73,7 +72,7 @@ SpriteMap SpriteSheet::parseJson(int &width, int &height,
} else if (keyName == "height") {
coord.height = keyValue;
} else {
- throw runtime_error("JSON key incorrect: " + keyName);
+ throw std::runtime_error("JSON key incorrect: " + keyName);
}
}
spriteMap[texture.name.GetString()] = coord;
diff --git a/yage/core/spritesheet.h b/yage/core/spritesheet.h
index 2ead0ba1..7d7c2fcf 100644
--- a/yage/core/spritesheet.h
+++ b/yage/core/spritesheet.h
@@ -1,17 +1,20 @@
-/* ----------------------------------------------------------------------------
- * spritesheet.h
+/** ---------------------------------------------------------------------------
+ * @file: spritesheet.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
-/** @file
- */
+/// @file
#ifndef YAGE_SPRITESHEET_H
#define YAGE_SPRITESHEET_H
+/** @todo think of removing this, by, for example, using a pointer
+ * This could be more efficient when copying the texture out of the
+ * spritesheet.
+ */
#include "texture.h"
#include <rapidjson/reader.h>
diff --git a/yage/core/texture.h b/yage/core/texture.h
index 85f74647..2eae8bf4 100644
--- a/yage/core/texture.h
+++ b/yage/core/texture.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * texture.h
+/** ---------------------------------------------------------------------------
+ * @file: texture.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/texturecache.cpp b/yage/core/texturecache.cpp
index d94340ff..f9468dbb 100644
--- a/yage/core/texturecache.cpp
+++ b/yage/core/texturecache.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * texturecache.cpp
+/** ---------------------------------------------------------------------------
+ * @file: texturecache.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/texturecache.h b/yage/core/texturecache.h
index a9a18693..58dcd4eb 100644
--- a/yage/core/texturecache.h
+++ b/yage/core/texturecache.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * texturecache.h
+/** ---------------------------------------------------------------------------
+ * @file: texturecache.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/vertex.h b/yage/core/vertex.h
index f81b4f42..4cd095a9 100644
--- a/yage/core/vertex.h
+++ b/yage/core/vertex.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * vertex.h
+/** ---------------------------------------------------------------------------
+ * @file: vertex.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/window.cpp b/yage/core/window.cpp
index 3508e835..9696f2bb 100644
--- a/yage/core/window.cpp
+++ b/yage/core/window.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * window.cpp
+/** ---------------------------------------------------------------------------
+ * @file: window.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/core/window.h b/yage/core/window.h
index 57e21ae4..c350955e 100644
--- a/yage/core/window.h
+++ b/yage/core/window.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * window.h
+/** ---------------------------------------------------------------------------
+ * @file: window.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/math/math.h b/yage/math/math.h
deleted file mode 100644
index 87f1af6c..00000000
--- a/yage/math/math.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* ----------------------------------------------------------------------------
- * math.h
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#ifndef YAGE_MATH_H
-#define YAGE_MATH_H
-
-#include "matrix.h"
-
-#endif
diff --git a/yage/math/matrix.h b/yage/math/matrix.h
index 90a763cf..ac612385 100644
--- a/yage/math/matrix.h
+++ b/yage/math/matrix.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * matrix.h
+/** ---------------------------------------------------------------------------
+ * @file: matrix.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/physics/body.cpp b/yage/physics/body.cpp
index b5283d76..d04eecfd 100644
--- a/yage/physics/body.cpp
+++ b/yage/physics/body.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * body.cpp
+/** ---------------------------------------------------------------------------
+ * @file: body.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/physics/body.h b/yage/physics/body.h
index 312ceb58..0a6bbe42 100644
--- a/yage/physics/body.h
+++ b/yage/physics/body.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * body.h
+/** ---------------------------------------------------------------------------
+ * @file: body.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/physics/collider.h b/yage/physics/collider.h
index fe070fa6..220c785d 100644
--- a/yage/physics/collider.h
+++ b/yage/physics/collider.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * collider.h
+/** ---------------------------------------------------------------------------
+ * @file: collider.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/physics/collisionbody.h b/yage/physics/collisionbody.h
index 62f12ade..c779feae 100644
--- a/yage/physics/collisionbody.h
+++ b/yage/physics/collisionbody.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * collisionbody.h
+/** ---------------------------------------------------------------------------
+ * @file: collisionbody.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/physics/particlebody.cpp b/yage/physics/particlebody.cpp
index 91078d45..dc950ae6 100644
--- a/yage/physics/particlebody.cpp
+++ b/yage/physics/particlebody.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * particlebody.cpp
+/** ---------------------------------------------------------------------------
+ * @file: particlebody.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/physics/particlebody.h b/yage/physics/particlebody.h
index 336c0bd0..2e7a4f88 100644
--- a/yage/physics/particlebody.h
+++ b/yage/physics/particlebody.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * particlebody.h
+/** ---------------------------------------------------------------------------
+ * @file: particlebody.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/physics/physics.h b/yage/physics/physics.h
index fb42b257..64dcd95f 100644
--- a/yage/physics/physics.h
+++ b/yage/physics/physics.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * physics.h
+/** ---------------------------------------------------------------------------
+ * @file: physics.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/physics/rectanglecollider.cpp b/yage/physics/rectanglecollider.cpp
index ea70611f..e1b3adff 100644
--- a/yage/physics/rectanglecollider.cpp
+++ b/yage/physics/rectanglecollider.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * rectanglecollider.cpp
+/** ---------------------------------------------------------------------------
+ * @file: rectanglecollider.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/physics/rectanglecollider.h b/yage/physics/rectanglecollider.h
index 62d1033c..ba3bdead 100644
--- a/yage/physics/rectanglecollider.h
+++ b/yage/physics/rectanglecollider.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * rectanglecollider.h
+/** ---------------------------------------------------------------------------
+ * @file: rectanglecollider.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/physics/rigidbody.cpp b/yage/physics/rigidbody.cpp
index ea58efeb..1a7ae2ec 100644
--- a/yage/physics/rigidbody.cpp
+++ b/yage/physics/rigidbody.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * rigidbody.cpp
+/** ---------------------------------------------------------------------------
+ * @file: rigidbody.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/physics/rigidbody.h b/yage/physics/rigidbody.h
index cbf01109..dae9f8e5 100644
--- a/yage/physics/rigidbody.h
+++ b/yage/physics/rigidbody.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * rigidbody.h
+/** ---------------------------------------------------------------------------
+ * @file: rigidbody.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/util/active.cpp b/yage/util/active.cpp
index 1516b7d3..0eaeeb80 100644
--- a/yage/util/active.cpp
+++ b/yage/util/active.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * active.cpp
+/** ---------------------------------------------------------------------------
+ * @file: active.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/util/active.h b/yage/util/active.h
index b7137a47..d1d9ba4c 100644
--- a/yage/util/active.h
+++ b/yage/util/active.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * active.h
+/** ---------------------------------------------------------------------------
+ * @file: active.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/util/syncqueue.h b/yage/util/syncqueue.h
index ab9204e3..f1c7d65d 100644
--- a/yage/util/syncqueue.h
+++ b/yage/util/syncqueue.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * syncqueue.h
+/** ---------------------------------------------------------------------------
+ * @file: syncqueue.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/yage.cpp b/yage/yage.cpp
index 80333766..597a4613 100644
--- a/yage/yage.cpp
+++ b/yage/yage.cpp
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * yage.cpp
+/** ---------------------------------------------------------------------------
+ * @file: yage.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
diff --git a/yage/yage.h b/yage/yage.h
index 630bc1be..3dd27eb8 100644
--- a/yage/yage.h
+++ b/yage/yage.h
@@ -1,5 +1,5 @@
-/* ----------------------------------------------------------------------------
- * yage.h
+/** ---------------------------------------------------------------------------
+ * @file: yage.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.