summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-08-14 18:24:53 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-08-14 18:30:45 +0200
commitd6bfb4be651d512708d953a26f27907c4f7940d7 (patch)
tree9bef6e8fe99e9b00087a3dee94408aa899c3f1ae
parent1799c1b04c7123fa66fe333bdabf0ba575c9c54c (diff)
downloadqtlocation-mapboxgl-d6bfb4be651d512708d953a26f27907c4f7940d7.tar.gz
fix binding to vaos
-rw-r--r--include/mbgl/geometry/elements_buffer.hpp3
-rw-r--r--include/mbgl/geometry/vao.hpp5
-rw-r--r--include/mbgl/platform/gl.hpp9
-rw-r--r--include/mbgl/renderer/fill_bucket.hpp5
-rw-r--r--include/mbgl/renderer/line_bucket.hpp4
-rw-r--r--include/mbgl/renderer/symbol_bucket.hpp7
-rw-r--r--src/map/transform.cpp6
-rw-r--r--src/renderer/fill_bucket.cpp6
-rw-r--r--src/renderer/line_bucket.cpp4
-rw-r--r--src/renderer/symbol_bucket.cpp10
10 files changed, 34 insertions, 25 deletions
diff --git a/include/mbgl/geometry/elements_buffer.hpp b/include/mbgl/geometry/elements_buffer.hpp
index ed60338e08..ce07c9fa67 100644
--- a/include/mbgl/geometry/elements_buffer.hpp
+++ b/include/mbgl/geometry/elements_buffer.hpp
@@ -6,8 +6,9 @@
namespace mbgl {
+template <int count>
struct ElementGroup {
- VertexArrayObject array;
+ std::array<VertexArrayObject, count> array;
uint32_t vertex_length;
uint32_t elements_length;
diff --git a/include/mbgl/geometry/vao.hpp b/include/mbgl/geometry/vao.hpp
index e27e2c58a4..1023fc118d 100644
--- a/include/mbgl/geometry/vao.hpp
+++ b/include/mbgl/geometry/vao.hpp
@@ -22,7 +22,7 @@ public:
if (shader_ptr != &shader) {
if (shader_ptr != nullptr) {
- fprintf(stderr, "shader rebind!");
+ throw std::runtime_error("shader rebind!");
}
#endif
vertex_buffer.bind();
@@ -55,6 +55,9 @@ public:
}
if (shader_ptr != &shader) {
+ if (shader_ptr != nullptr) {
+ throw std::runtime_error("shader rebind!");
+ }
#endif
vertex_buffer.bind();
elements_buffer.bind();
diff --git a/include/mbgl/platform/gl.hpp b/include/mbgl/platform/gl.hpp
index a29b230dbf..cc2a681d42 100644
--- a/include/mbgl/platform/gl.hpp
+++ b/include/mbgl/platform/gl.hpp
@@ -26,9 +26,12 @@
#elif TARGET_OS_MAC
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
- #define glGenVertexArrays glGenVertexArraysAPPLE
- #define glBindVertexArray glBindVertexArrayAPPLE
- #define glDeleteVertexArrays glDeleteVertexArraysAPPLE
+ #if GL_APPLE_vertex_array_object
+ #define GL_ARB_vertex_array_object 1
+ #define glGenVertexArrays glGenVertexArraysAPPLE
+ #define glBindVertexArray glBindVertexArrayAPPLE
+ #define glDeleteVertexArrays glDeleteVertexArraysAPPLE
+ #endif
#else
#error Unsupported Apple platform
#endif
diff --git a/include/mbgl/renderer/fill_bucket.hpp b/include/mbgl/renderer/fill_bucket.hpp
index e9340cce68..e8d6bf99e1 100644
--- a/include/mbgl/renderer/fill_bucket.hpp
+++ b/include/mbgl/renderer/fill_bucket.hpp
@@ -34,9 +34,8 @@ class FillBucket : public Bucket {
static void *realloc(void *data, void *ptr, unsigned int size);
static void free(void *userData, void *ptr);
-
- typedef ElementGroup triangle_group_type;
- typedef ElementGroup line_group_type;
+ typedef ElementGroup<2> triangle_group_type;
+ typedef ElementGroup<1> line_group_type;
public:
FillBucket(FillVertexBuffer& vertexBuffer,
TriangleElementsBuffer& triangleElementsBuffer,
diff --git a/include/mbgl/renderer/line_bucket.hpp b/include/mbgl/renderer/line_bucket.hpp
index f65ca35605..a33dde34e0 100644
--- a/include/mbgl/renderer/line_bucket.hpp
+++ b/include/mbgl/renderer/line_bucket.hpp
@@ -20,8 +20,8 @@ class LinejoinShader;
struct pbf;
class LineBucket : public Bucket {
- typedef ElementGroup triangle_group_type;
- typedef ElementGroup point_group_type;
+ typedef ElementGroup<1> triangle_group_type;
+ typedef ElementGroup<1> point_group_type;
public:
LineBucket(LineVertexBuffer& vertexBuffer,
TriangleElementsBuffer& triangleElementsBuffer,
diff --git a/include/mbgl/renderer/symbol_bucket.hpp b/include/mbgl/renderer/symbol_bucket.hpp
index e890274238..fb1678fc8b 100644
--- a/include/mbgl/renderer/symbol_bucket.hpp
+++ b/include/mbgl/renderer/symbol_bucket.hpp
@@ -50,6 +50,9 @@ typedef std::vector<Symbol> Symbols;
class SymbolBucket : public Bucket {
+ typedef ElementGroup<1> TextElementGroup;
+ typedef ElementGroup<1> IconElementGroup;
+
public:
SymbolBucket(const StyleBucketSymbol &properties, Collision &collision);
@@ -94,13 +97,13 @@ private:
struct {
TextVertexBuffer vertices;
TriangleElementsBuffer triangles;
- std::vector<ElementGroup> groups;
+ std::vector<TextElementGroup> groups;
} text;
struct {
IconVertexBuffer vertices;
TriangleElementsBuffer triangles;
- std::vector<ElementGroup> groups;
+ std::vector<IconElementGroup> groups;
} icon;
};
diff --git a/src/map/transform.cpp b/src/map/transform.cpp
index a68cffdc7e..6c5e70cc2f 100644
--- a/src/map/transform.cpp
+++ b/src/map/transform.cpp
@@ -128,9 +128,9 @@ void Transform::getLonLat(double &lon, double &lat) const {
}
void Transform::getLonLatZoom(double &lon, double &lat, double &zoom) const {
- uv::readlock lock(mtx);
-
getLonLat(lon, lat);
+
+ uv::readlock lock(mtx);
zoom = getZoom();
}
@@ -192,7 +192,7 @@ void Transform::setZoom(const double zoom, const timestamp duration) {
double Transform::getZoom() const {
uv::readlock lock(mtx);
- return log(final.scale) / M_LN2;
+ return std::log(final.scale) / M_LN2;
}
double Transform::getScale() const {
diff --git a/src/renderer/fill_bucket.cpp b/src/renderer/fill_bucket.cpp
index 4b4000ce97..875cc279b9 100644
--- a/src/renderer/fill_bucket.cpp
+++ b/src/renderer/fill_bucket.cpp
@@ -216,7 +216,7 @@ void FillBucket::drawElements(PlainShader& shader) {
char *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize);
char *elements_index = BUFFER_OFFSET(triangle_elements_start * triangleElementsBuffer.itemSize);
for (triangle_group_type& group : triangleGroups) {
- group.array.bind(shader, vertexBuffer, triangleElementsBuffer, vertex_index);
+ group.array[0].bind(shader, vertexBuffer, triangleElementsBuffer, vertex_index);
glDrawElements(GL_TRIANGLES, group.elements_length * 3, GL_UNSIGNED_SHORT, elements_index);
vertex_index += group.vertex_length * vertexBuffer.itemSize;
elements_index += group.elements_length * triangleElementsBuffer.itemSize;
@@ -227,7 +227,7 @@ void FillBucket::drawElements(PatternShader& shader) {
char *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize);
char *elements_index = BUFFER_OFFSET(triangle_elements_start * triangleElementsBuffer.itemSize);
for (triangle_group_type& group : triangleGroups) {
- group.array.bind(shader, vertexBuffer, triangleElementsBuffer, vertex_index);
+ group.array[1].bind(shader, vertexBuffer, triangleElementsBuffer, vertex_index);
glDrawElements(GL_TRIANGLES, group.elements_length * 3, GL_UNSIGNED_SHORT, elements_index);
vertex_index += group.vertex_length * vertexBuffer.itemSize;
elements_index += group.elements_length * triangleElementsBuffer.itemSize;
@@ -238,7 +238,7 @@ void FillBucket::drawVertices(OutlineShader& shader) {
char *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize);
char *elements_index = BUFFER_OFFSET(line_elements_start * lineElementsBuffer.itemSize);
for (line_group_type& group : lineGroups) {
- group.array.bind(shader, vertexBuffer, lineElementsBuffer, vertex_index);
+ group.array[0].bind(shader, vertexBuffer, lineElementsBuffer, vertex_index);
glDrawElements(GL_LINES, group.elements_length * 2, GL_UNSIGNED_SHORT, elements_index);
vertex_index += group.vertex_length * vertexBuffer.itemSize;
elements_index += group.elements_length * lineElementsBuffer.itemSize;
diff --git a/src/renderer/line_bucket.cpp b/src/renderer/line_bucket.cpp
index 949d71e134..e089d7f61b 100644
--- a/src/renderer/line_bucket.cpp
+++ b/src/renderer/line_bucket.cpp
@@ -367,7 +367,7 @@ void LineBucket::drawLines(LineShader& shader) {
if (!group.elements_length) {
continue;
}
- group.array.bind(shader, vertexBuffer, triangleElementsBuffer, vertex_index);
+ group.array[0].bind(shader, vertexBuffer, triangleElementsBuffer, vertex_index);
glDrawElements(GL_TRIANGLES, group.elements_length * 3, GL_UNSIGNED_SHORT, elements_index);
vertex_index += group.vertex_length * vertexBuffer.itemSize;
elements_index += group.elements_length * triangleElementsBuffer.itemSize;
@@ -381,7 +381,7 @@ void LineBucket::drawPoints(LinejoinShader& shader) {
if (!group.elements_length) {
continue;
}
- group.array.bind(shader, vertexBuffer, pointElementsBuffer, vertex_index);
+ group.array[0].bind(shader, vertexBuffer, pointElementsBuffer, vertex_index);
glDrawElements(GL_POINTS, group.elements_length, GL_UNSIGNED_SHORT, elements_index);
vertex_index += group.vertex_length * vertexBuffer.itemSize;
elements_index += group.elements_length * pointElementsBuffer.itemSize;
diff --git a/src/renderer/symbol_bucket.cpp b/src/renderer/symbol_bucket.cpp
index 459c235da7..7f79455a14 100644
--- a/src/renderer/symbol_bucket.cpp
+++ b/src/renderer/symbol_bucket.cpp
@@ -348,7 +348,7 @@ void SymbolBucket::addSymbols(Buffer &buffer, const PlacedGlyphs &symbols, float
// We're generating triangle fans, so we always start with the first
// coordinate in this polygon.
- ElementGroup &triangleGroup = buffer.groups.back();
+ TextElementGroup &triangleGroup = buffer.groups.back();
uint32_t triangleIndex = triangleGroup.vertex_length;
// coordinates (2 triangles)
@@ -373,8 +373,8 @@ void SymbolBucket::addSymbols(Buffer &buffer, const PlacedGlyphs &symbols, float
void SymbolBucket::drawGlyphs(TextShader &shader) {
char *vertex_index = BUFFER_OFFSET(0);
char *elements_index = BUFFER_OFFSET(0);
- for (ElementGroup &group : text.groups) {
- group.array.bind(shader, text.vertices, text.triangles, vertex_index);
+ for (TextElementGroup &group : text.groups) {
+ group.array[0].bind(shader, text.vertices, text.triangles, vertex_index);
glDrawElements(GL_TRIANGLES, group.elements_length * 3, GL_UNSIGNED_SHORT, elements_index);
vertex_index += group.vertex_length * text.vertices.itemSize;
elements_index += group.elements_length * text.triangles.itemSize;
@@ -384,8 +384,8 @@ void SymbolBucket::drawGlyphs(TextShader &shader) {
void SymbolBucket::drawIcons(IconShader &shader) {
char *vertex_index = BUFFER_OFFSET(0);
char *elements_index = BUFFER_OFFSET(0);
- for (ElementGroup &group : icon.groups) {
- group.array.bind(shader, icon.vertices, icon.triangles, vertex_index);
+ for (IconElementGroup &group : icon.groups) {
+ group.array[0].bind(shader, icon.vertices, icon.triangles, vertex_index);
glDrawElements(GL_TRIANGLES, group.elements_length * 3, GL_UNSIGNED_SHORT, elements_index);
vertex_index += group.vertex_length * icon.vertices.itemSize;
elements_index += group.elements_length * icon.triangles.itemSize;