summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2014-12-11 00:09:26 +1100
committerLeith Bade <leith@mapbox.com>2014-12-11 00:09:26 +1100
commitd599fc55043c60c282648ab7ef68b4f29d3ac35c (patch)
tree1b3bcd44e5fa3b384a62c1cdd6261977052fa150 /platform
parent6bb1a5a146bcffde0f5f25587413c5fb076890b5 (diff)
parent0c62cd06552597966adb99183eb5ca78901a6087 (diff)
downloadqtlocation-mapboxgl-d599fc55043c60c282648ab7ef68b4f29d3ac35c.tar.gz
Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-mason
Conflicts: platform/default/glfw_view.cpp platform/default/headless_view.cpp src/mbgl/renderer/painter.cpp src/mbgl/renderer/prerendered_texture.cpp
Diffstat (limited to 'platform')
-rw-r--r--platform/default/glfw_view.cpp28
-rw-r--r--platform/default/headless_view.cpp44
2 files changed, 40 insertions, 32 deletions
diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp
index d45dfec59b..cba1f9ba6a 100644
--- a/platform/default/glfw_view.cpp
+++ b/platform/default/glfw_view.cpp
@@ -1,5 +1,6 @@
#include <mbgl/platform/default/glfw_view.hpp>
#include <mbgl/platform/gl.hpp>
+#include <mbgl/platform/log.hpp>
GLFWView::GLFWView(bool fullscreen_) : fullscreen(fullscreen_) {
#ifdef NVIDIA
@@ -11,9 +12,16 @@ GLFWView::~GLFWView() {
glfwTerminate();
}
+void glfwError(int error, const char *description) {
+ mbgl::Log::Error(mbgl::Event::OpenGL, "GLFW error (%i): %s", error, description);
+ assert(false);
+}
+
void GLFWView::initialize(mbgl::Map *map_) {
View::initialize(map_);
+ glfwSetErrorCallback(glfwError);
+
if (!glfwInit()) {
fprintf(stderr, "Failed to initialize glfw\n");
exit(1);
@@ -65,7 +73,7 @@ void GLFWView::initialize(mbgl::Map *map_) {
glfwSetScrollCallback(window, scroll);
glfwSetKeyCallback(window, key);
- const std::string extensions = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
+ const std::string extensions = MBGL_CHECK_ERROR(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
{
using namespace mbgl;
@@ -349,9 +357,9 @@ void show_debug_image(std::string name, const char *data, size_t width, size_t h
glfwGetFramebufferSize(debug_window, &fb_width, &fb_height);
float scale = (float)fb_width / (float)width;
- glPixelZoom(scale, -scale);
- glRasterPos2f(-1.0f, 1.0f);
- glDrawPixels(width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
+ MBGL_CHECK_ERROR(glPixelZoom(scale, -scale));
+ MBGL_CHECK_ERROR(glRasterPos2f(-1.0f, 1.0f));
+ MBGL_CHECK_ERROR(glDrawPixels(width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data));
glfwSwapBuffers(debug_window);
glfwMakeContextCurrent(current_window);
@@ -381,13 +389,13 @@ void show_color_debug_image(std::string name, const char *data, size_t logical_w
float x_scale = (float)fb_width / (float)width;
float y_scale = (float)fb_height / (float)height;
- glClear(GL_COLOR_BUFFER_BIT);
- glEnable(GL_BLEND);
- glBlendFunc(GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT));
+ MBGL_CHECK_ERROR(glEnable(GL_BLEND));
+ MBGL_CHECK_ERROR(glBlendFunc(GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
- glPixelZoom(x_scale, -y_scale);
- glRasterPos2f(-1.0f, 1.0f);
- glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
+ MBGL_CHECK_ERROR(glPixelZoom(x_scale, -y_scale));
+ MBGL_CHECK_ERROR(glRasterPos2f(-1.0f, 1.0f));
+ MBGL_CHECK_ERROR(glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, data));
glfwSwapBuffers(debug_window);
glfwMakeContextCurrent(current_window);
diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp
index 5942f2c46e..fcf93c0e57 100644
--- a/platform/default/headless_view.cpp
+++ b/platform/default/headless_view.cpp
@@ -57,19 +57,19 @@ void HeadlessView::loadExtensions() {
if (usingGl3OrNewer) {
#ifdef GL_VERSION_3_0
GLuint num_extensions = 0;
- glGetIntegerv(GL_NUM_EXTENSIONS, reinterpret_cast<GLint *>(&num_extensions));
+ MBGL_CHECK_ERROR(glGetIntegerv(GL_NUM_EXTENSIONS, reinterpret_cast<GLint *>(&num_extensions)));
for (GLuint i = 0; i < num_extensions; i++) {
- extensions.append(reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i)));
+ std::string extension = MBGL_CHECK_ERROR(reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i)));
+ extensions.append(extension);
extensions.append(" ");
}
#else
throw std::runtime_error("Using GL 3.0+ context with out correct headers.\n");
#endif
} else {
- extensions = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
+ extensions = MBGL_CHECK_ERROR(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
}
-
#ifdef MBGL_USE_CGL
if (extensions.find("GL_APPLE_vertex_array_object") != std::string::npos) {
gl::BindVertexArray = (gl::PFNGLBINDVERTEXARRAYPROC)CGLGetProcAddress("glBindVertexArrayAPPLE");
@@ -229,23 +229,23 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) {
make_active();
// Create depth/stencil buffer
- glGenRenderbuffersEXT(1, &fboDepthStencil);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fboDepthStencil);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, w, h);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
+ MBGL_CHECK_ERROR(glGenRenderbuffersEXT(1, &fboDepthStencil));
+ MBGL_CHECK_ERROR(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fboDepthStencil));
+ MBGL_CHECK_ERROR(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, w, h));
+ MBGL_CHECK_ERROR(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0));
- glGenRenderbuffersEXT(1, &fboColor);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fboColor);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, w, h);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
+ MBGL_CHECK_ERROR(glGenRenderbuffersEXT(1, &fboColor));
+ MBGL_CHECK_ERROR(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fboColor));
+ MBGL_CHECK_ERROR(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, w, h));
+ MBGL_CHECK_ERROR(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0));
- glGenFramebuffersEXT(1, &fbo);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
+ MBGL_CHECK_ERROR(glGenFramebuffersEXT(1, &fbo));
+ MBGL_CHECK_ERROR(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo));
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, fboColor);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER_EXT, fboDepthStencil);
+ MBGL_CHECK_ERROR(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, fboColor));
+ MBGL_CHECK_ERROR(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER_EXT, fboDepthStencil));
- GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ GLenum status = MBGL_CHECK_ERROR(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
std::stringstream error("Couldn't create framebuffer: ");
@@ -272,7 +272,7 @@ std::unique_ptr<uint32_t[]> HeadlessView::readPixels() {
auto pixels = util::make_unique<uint32_t[]>(w * h);
make_active();
- glReadPixels(0, 0, width_, height_, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get());
+ MBGL_CHECK_ERROR(glReadPixels(0, 0, width_, height_, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get()));
make_inactive();
const int stride = w * 4;
@@ -290,20 +290,20 @@ std::unique_ptr<uint32_t[]> HeadlessView::readPixels() {
void HeadlessView::clear_buffers() {
make_active();
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ MBGL_CHECK_ERROR(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
if (fbo) {
- glDeleteFramebuffersEXT(1, &fbo);
+ MBGL_CHECK_ERROR(glDeleteFramebuffersEXT(1, &fbo));
fbo = 0;
}
if (fboColor) {
- glDeleteTextures(1, &fboColor);
+ MBGL_CHECK_ERROR(glDeleteTextures(1, &fboColor));
fboColor = 0;
}
if (fboDepthStencil) {
- glDeleteRenderbuffersEXT(1, &fboDepthStencil);
+ MBGL_CHECK_ERROR(glDeleteRenderbuffersEXT(1, &fboDepthStencil));
fboDepthStencil = 0;
}