aboutsummaryrefslogtreecommitdiffstats
path: root/yage/core
diff options
context:
space:
mode:
Diffstat (limited to 'yage/core')
-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
32 files changed, 184 insertions, 132 deletions
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.