From ea60f9f78bac505a5aeeb4d34b927f04ec3121b3 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sat, 11 Feb 2017 11:24:52 -0500 Subject: world bg, other fixes --- include/common.hpp | 3 +++ include/error.hpp | 7 +++++-- include/texture.hpp | 3 +++ include/vector2.hpp | 5 +++++ 4 files changed, 16 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/common.hpp b/include/common.hpp index b9be831..9ecd912 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -5,6 +5,9 @@ #ifndef COMMON_HPP_ #define COMMON_HPP_ +#include +#include + // windows stuff #ifdef __WIN32__ using uint = unsigned int; diff --git a/include/error.hpp b/include/error.hpp index ef61c91..c435889 100644 --- a/include/error.hpp +++ b/include/error.hpp @@ -4,9 +4,12 @@ #include #include -inline void UserError(const std::string& why) +#define UserError(w) _UserError(__FILE__, __LINE__, w) +#define UserAssert(c, e) if (!(c)) { UserError(e); } + +inline void _UserError(const char* file, int line, const std::string& why) { - std::cout << "User error: " << why << "!\n"; + std::cout << file << ':' << line << ": error: " << why << "!\n"; abort(); } diff --git a/include/texture.hpp b/include/texture.hpp index fb4e588..25f73a5 100644 --- a/include/texture.hpp +++ b/include/texture.hpp @@ -41,9 +41,12 @@ public: * @param file the path to the desired texture * @param t the GLuint for the texture, if known * @param v the size of the texture, if known + * @param hline if true, divides texture dim. by HLINE */ Texture(const std::string& file = "", const GLuint& t = 0xFFFFF, const vec2& v = vec2(0, 0)); + Texture(const std::string& file, bool hline); + /** * Gets the name (path) of the loaded texture. * @return the texture's name diff --git a/include/vector2.hpp b/include/vector2.hpp index d335a4b..c1148da 100644 --- a/include/vector2.hpp +++ b/include/vector2.hpp @@ -66,6 +66,11 @@ struct vector2 { return vector2(x / n, y / n); } + vector2 operator/=(const T& n) { + x /= n, y /= n; + return *this; + } + // compare bool operator==(const vector2& v) const { return (x == v.x) && (y == v.y); -- cgit v1.2.3