diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-01-20 11:35:29 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-01-20 11:35:29 +0100 |
commit | 15d43272290901fd7ddd8a67c5e2197adc8c15b7 (patch) | |
tree | d3f0b55d9aa4666a7ba10d20e0ce53d1e3040793 /src | |
parent | 5aa22b9c3248a235efb36a062d10e8a59fb434f9 (diff) | |
download | qtlocation-mapboxgl-15d43272290901fd7ddd8a67c5e2197adc8c15b7.tar.gz |
rename + move to c++
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/map/map.cpp | 2 | ||||
-rw-r--r-- | src/map/tile.cpp | 1 | ||||
-rw-r--r-- | src/map/transform.cpp | 16 | ||||
-rw-r--r-- | src/renderer/painter.cpp | 6 | ||||
-rw-r--r-- | src/util/mat4.cpp (renamed from src/util/mat4.c) | 20 |
6 files changed, 25 insertions, 23 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 55cd4b6571..ab5129cdf5 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 0fff04d75a..c6940f71ce 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1,6 +1,6 @@ #include <llmr/map/map.hpp> #include <llmr/map/tile.hpp> -#include <llmr/util/vec2.hpp> +//#include <llmr/util/vec2.hpp> #include <iostream> #include <thread> diff --git a/src/map/tile.cpp b/src/map/tile.cpp index 292b045283..3a2c5ce0be 100644 --- a/src/map/tile.cpp +++ b/src/map/tile.cpp @@ -6,7 +6,6 @@ #include <thread> #include <llmr/util/pbf.hpp> -#include <llmr/util/vec2.hpp> #include <llmr/util/string.hpp> #include <llmr/geometry/geometry.hpp> #include <cmath> diff --git a/src/map/transform.cpp b/src/map/transform.cpp index e314bcd3a8..941fa0c3db 100644 --- a/src/map/transform.cpp +++ b/src/map/transform.cpp @@ -1,5 +1,5 @@ #include <llmr/map/transform.hpp> -#include <llmr/util/mat4.h> +#include <llmr/util/mat4.hpp> #include <llmr/util/math.hpp> #include <cmath> #include <cstdio> @@ -149,19 +149,19 @@ void transform::matrixFor(float matrix[16], const vec3<int32_t>& 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 f055761b06..70e405ec1b 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -1,7 +1,7 @@ #include <llmr/renderer/painter.hpp> #include <iostream> #include <assert.h> -#include <llmr/util/mat4.h> +#include <llmr/util/mat4.hpp> #include <llmr/platform/platform.hpp> #include <llmr/map/transform.hpp> #include <llmr/map/tile.hpp> @@ -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 index ef74fc3f19..861ad5c035 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 <llmr/util/mat4.h> +#include <llmr/util/mat4.hpp> -#include <math.h> +#include <cmath> -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], |