From 15d43272290901fd7ddd8a67c5e2197adc8c15b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 20 Jan 2014 11:35:29 +0100 Subject: [PATCH] rename + move to c++ --- include/llmr/map/tile.hpp | 2 +- include/llmr/map/transform.hpp | 2 +- include/llmr/util/{mat4.h => mat4.hpp} | 26 ++++++++++++------------- include/llmr/util/{vec2.hpp => vec.hpp} | 0 src/CMakeLists.txt | 3 ++- src/map/map.cpp | 2 +- src/map/tile.cpp | 1 - src/map/transform.cpp | 16 +++++++-------- src/renderer/painter.cpp | 6 +++--- src/util/{mat4.c => mat4.cpp} | 20 ++++++++++--------- 10 files changed, 39 insertions(+), 39 deletions(-) rename include/llmr/util/{mat4.h => mat4.hpp} (63%) rename include/llmr/util/{vec2.hpp => vec.hpp} (100%) rename src/util/{mat4.c => mat4.cpp} (91%) diff --git a/include/llmr/map/tile.hpp b/include/llmr/map/tile.hpp index 63ea1e5ef..851b95553 100644 --- a/include/llmr/map/tile.hpp +++ b/include/llmr/map/tile.hpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include namespace llmr { diff --git a/include/llmr/map/transform.hpp b/include/llmr/map/transform.hpp index cee9d32a6..62b1b1fa0 100644 --- a/include/llmr/map/transform.hpp +++ b/include/llmr/map/transform.hpp @@ -2,7 +2,7 @@ #define LLMR_MAP_TRANSFORM -#include +#include #include #include diff --git a/include/llmr/util/mat4.h b/include/llmr/util/mat4.hpp similarity index 63% rename from include/llmr/util/mat4.h rename to include/llmr/util/mat4.hpp index 484b4b082..05c1b7b16 100644 --- a/include/llmr/util/mat4.h +++ b/include/llmr/util/mat4.hpp @@ -20,23 +20,21 @@ // // 3. This notice may not be removed or altered from any source distribution. -#ifndef llmr_util_mat4_ -#define llmr_util_mat4_ +#ifndef LLMR_UTIL_MAT4 +#define LLMR_UTIL_MAT4 -#ifdef __cplusplus -extern "C" { -#endif +namespace llmr { +namespace mat4 { -void mat4_identity(float out[16]); -void mat4_ortho(float out[16], float left, float right, float bottom, float top, float near, float far); -void mat4_copy(float out[16], float a[16]); -void mat4_translate(float out[16], float a[16], float x, float y, float z); -void mat4_rotate_z(float out[16], float a[16], float rad); -void mat4_scale(float out[16], float a[16], float x, float y, float z); -void mat4_multiply(float out[16], float a[16], float b[16]); +void identity(float out[16]); +void ortho(float out[16], float left, float right, float bottom, float top, float near, float far); +void copy(float out[16], float a[16]); +void translate(float out[16], float a[16], float x, float y, float z); +void rotate_z(float out[16], float a[16], float rad); +void scale(float out[16], float a[16], float x, float y, float z); +void multiply(float out[16], float a[16], float b[16]); -#ifdef __cplusplus } -#endif +} #endif diff --git a/include/llmr/util/vec2.hpp b/include/llmr/util/vec.hpp similarity index 100% rename from include/llmr/util/vec2.hpp rename to include/llmr/util/vec.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 55cd4b657..ab5129cdf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,7 +11,7 @@ SET(llmr_SOURCES renderer/shader.cpp shader/shaders.cpp util/animation.cpp - util/mat4.c + util/mat4.cpp ) SET(llmr_HEADERS @@ -31,6 +31,7 @@ SET(llmr_HEADERS ../include/llmr/shader/shaders.hpp ../include/llmr/util/animation.hpp ../include/llmr/util/math.hpp + ../include/llmr/util/mat4.hpp ../include/llmr/util/vec2.hpp ) diff --git a/src/map/map.cpp b/src/map/map.cpp index 0fff04d75..c6940f71c 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1,6 +1,6 @@ #include #include -#include +//#include #include #include diff --git a/src/map/tile.cpp b/src/map/tile.cpp index 292b04528..3a2c5ce0b 100644 --- a/src/map/tile.cpp +++ b/src/map/tile.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include diff --git a/src/map/transform.cpp b/src/map/transform.cpp index e314bcd3a..941fa0c3d 100644 --- a/src/map/transform.cpp +++ b/src/map/transform.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -149,19 +149,19 @@ void transform::matrixFor(float matrix[16], const vec3& id) const { const double tile_scale = pow(2, id.z); const double tile_size = scale * size / tile_scale; - mat4_identity(matrix); + mat4::identity(matrix); - mat4_translate(matrix, matrix, 0.5f * (float)width, 0.5f * (float)height, 0); - mat4_rotate_z(matrix, matrix, angle); - mat4_translate(matrix, matrix, -0.5f * (float)width, -0.5f * (float)height, 0); + mat4::translate(matrix, matrix, 0.5f * (float)width, 0.5f * (float)height, 0); + mat4::rotate_z(matrix, matrix, angle); + mat4::translate(matrix, matrix, -0.5f * (float)width, -0.5f * (float)height, 0); - mat4_translate(matrix, matrix, pixel_x() + id.x * tile_size, pixel_y() + id.y * tile_size, 0); + mat4::translate(matrix, matrix, pixel_x() + id.x * tile_size, pixel_y() + id.y * tile_size, 0); // TODO: Get rid of the 8 (scaling from 4096 to 512 px tile size); - mat4_scale(matrix, matrix, scale / tile_scale / 8, scale / tile_scale / 8, 1); + mat4::scale(matrix, matrix, scale / tile_scale / 8, scale / tile_scale / 8, 1); // Clipping plane - mat4_translate(matrix, matrix, 0, 0, -1); + mat4::translate(matrix, matrix, 0, 0, -1); } int32_t transform::getZoom() const { diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index f055761b0..70e405ec1 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include @@ -88,12 +88,12 @@ void painter::changeMatrix(const tile::ptr& tile) { // Initialize projection matrix float projMatrix[16]; - mat4_ortho(projMatrix, 0, transform->width, transform->height, 0, 1, 10); + mat4::ortho(projMatrix, 0, transform->width, transform->height, 0, 1, 10); float mvMatrix[16]; transform->matrixFor(mvMatrix, tile->id); - mat4_multiply(matrix, projMatrix, mvMatrix); + mat4::multiply(matrix, projMatrix, mvMatrix); } void painter::drawClippingMask() { diff --git a/src/util/mat4.c b/src/util/mat4.cpp similarity index 91% rename from src/util/mat4.c rename to src/util/mat4.cpp index ef74fc3f1..861ad5c03 100644 --- a/src/util/mat4.c +++ b/src/util/mat4.cpp @@ -20,11 +20,13 @@ // // 3. This notice may not be removed or altered from any source distribution. -#include +#include -#include +#include -void mat4_identity(float out[16]) { +using namespace llmr; + +void mat4::identity(float out[16]) { out[0] = 1.0f; out[1] = 0.0f; out[2] = 0.0f; @@ -43,7 +45,7 @@ void mat4_identity(float out[16]) { out[15] = 1.0f; } -void mat4_ortho(float out[16], float left, float right, float bottom, float top, float near, float far) { +void mat4::ortho(float out[16], float left, float right, float bottom, float top, float near, float far) { float lr = 1.0f / (left - right), bt = 1.0f / (bottom - top), nf = 1.0f / (near - far); @@ -65,7 +67,7 @@ void mat4_ortho(float out[16], float left, float right, float bottom, float top, out[15] = 1.0f; } -void mat4_copy(float out[16], float a[16]) { +void mat4::copy(float out[16], float a[16]) { out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; @@ -84,7 +86,7 @@ void mat4_copy(float out[16], float a[16]) { out[15] = a[15]; } -void mat4_translate(float out[16], float a[16], float x, float y, float z) { +void mat4::translate(float out[16], float a[16], float x, float y, float z) { float a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23; @@ -110,7 +112,7 @@ void mat4_translate(float out[16], float a[16], float x, float y, float z) { } } -void mat4_rotate_z(float out[16], float a[16], float rad) { +void mat4::rotate_z(float out[16], float a[16], float rad) { float s = sin(rad), c = cos(rad), a00 = a[0], @@ -144,7 +146,7 @@ void mat4_rotate_z(float out[16], float a[16], float rad) { out[7] = a13 * c - a03 * s; } -void mat4_scale(float out[16], float a[16], float x, float y, float z) { +void mat4::scale(float out[16], float a[16], float x, float y, float z) { out[0] = a[0] * x; out[1] = a[1] * x; out[2] = a[2] * x; @@ -163,7 +165,7 @@ void mat4_scale(float out[16], float a[16], float x, float y, float z) { out[15] = a[15]; } -void mat4_multiply(float out[16], float a[16], float b[16]) { +void mat4::multiply(float out[16], float a[16], float b[16]) { float a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],