better support for gles2

This commit is contained in:
Konstantin Käfer
2014-03-05 16:58:46 +01:00
parent b97a9778ea
commit 69a5c0e15f
4 changed files with 24 additions and 6 deletions

View File

@@ -40,6 +40,8 @@ public:
void renderLine(LineBucket& bucket, const std::string& layer_name, const Tile::ID& id);
void renderPoint(PointBucket& bucket, const std::string& layer_name, const Tile::ID& id);
void resize(int width, int height);
void prepareClippingMask();
void drawClippingMask(const mat4& matrix, uint8_t clip_id);
void finishClippingMask();

View File

@@ -1,8 +1,6 @@
#include <llmr/llmr.hpp>
#include <GLFW/glfw3.h>
#include <llmr/platform/platform.hpp>
#include <future>
#include <list>
#include "settings.hpp"
#include "request.hpp"
@@ -26,10 +24,24 @@ public:
exit(1);
}
GLFWmonitor *monitor = nullptr;
#ifdef GL_ES_VERSION_2_0
monitor = glfwGetPrimaryMonitor();
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
#endif
glfwWindowHint(GLFW_RED_BITS, 8);
glfwWindowHint(GLFW_GREEN_BITS, 8);
glfwWindowHint(GLFW_BLUE_BITS, 8);
glfwWindowHint(GLFW_ALPHA_BITS, 8);
glfwWindowHint(GLFW_STENCIL_BITS, 8);
glfwWindowHint(GLFW_DEPTH_BITS, 16);
window = glfwCreateWindow(1024, 768, "llmr", NULL, NULL);
window = glfwCreateWindow(1024, 768, "llmr", monitor, NULL);
if (!window) {
glfwTerminate();
fprintf(stderr, "Failed to initialize window\n");
@@ -47,9 +59,9 @@ public:
settings.load();
map.setup((double)fb_width / width);
resize(window, 0, 0);
settings.load();
glfwSwapInterval(1);
resize(window, 0, 0);
map.loadSettings();
@@ -60,7 +72,6 @@ public:
glfwSetScrollCallback(window, scroll);
glfwSetCharCallback(window, character);
glfwSetKeyCallback(window, key);
}
static void character(GLFWwindow *window, unsigned int codepoint) {

View File

@@ -57,6 +57,7 @@ void Map::resize(uint32_t width, uint32_t height, uint32_t fb_width, uint32_t fb
transform.fb_width = fb_width;
transform.fb_height = fb_height;
transform.pixelRatio = pixel_ratio;
painter.resize(fb_width, fb_height);
update();
}

View File

@@ -63,6 +63,10 @@ void Painter::setupShaders() {
pointShader = std::make_unique<PointShader>();
}
void Painter::resize(int width, int height) {
glViewport(0, 0, width, height);
}
void Painter::useProgram(uint32_t program) {
if (gl_program != program) {
glUseProgram(program);