still not working

This commit is contained in:
Lauren Budorick
2014-08-07 12:49:04 -07:00
parent 560cc112e1
commit ec7f7de5c4
9 changed files with 59 additions and 19 deletions

View File

@@ -141,7 +141,6 @@ private:
void updateTiles();
void updateRenderState();
void updateRenderState(const mat4 vtxMatrix);
size_t countLayers(const std::vector<LayerDescription>& layers);

View File

@@ -29,6 +29,7 @@ private:
GLint previous_fbo = 0;
GLuint fbo = 0;
GLuint texture = 0;
GLuint fbo_depth_stencil = 0;
};
}

View File

@@ -28,8 +28,11 @@ public:
void drawRaster(RasterShader& shader, VertexBuffer &vertices, VertexArrayObject &array);
private:
void drawRaster(RasterShader& shader, VertexBuffer &vertices, VertexArrayObject &array, GLuint texture);
Raster raster;
private:
};
}

View File

@@ -4,6 +4,7 @@
#include <mbgl/util/transition.hpp>
#include <mbgl/util/texturepool.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/renderer/prerendered_texture.hpp>
#include <string>
#include <mutex>
@@ -25,6 +26,9 @@ public:
// bind current texture
void bind(bool linear = false);
// bind prerendered texture
void bind(const GLuint texture);
// loaded status
bool isLoaded() const;

View File

@@ -522,21 +522,6 @@ void Map::updateRenderState() {
}
}
void Map::updateRenderState(const mat4 vtxMatrix) {
std::forward_list<Tile::ID> ids;
for (const std::shared_ptr<StyleSource> &source : getActiveSources()) {
ids.splice_after(ids.before_begin(), source->source->getIDs());
source->source->updateMatrices(vtxMatrix, state);
}
const std::map<Tile::ID, ClipID> clipIDs = computeClipIDs(ids);
for (const std::shared_ptr<StyleSource> &source : getActiveSources()) {
source->source->updateClipIDs(clipIDs);
}
}
void Map::prepare() {
view.make_active();

View File

@@ -31,7 +31,7 @@ void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> lay
matrix::translate(vtxMatrix, vtxMatrix, 0, -4096, 0);
return vtxMatrix;
}();
map.renderLayers(layer_desc->layers);
if (bucket.properties.blur > 0) {
@@ -53,7 +53,12 @@ void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> lay
// rasterShader->setOpacity(properties.opacity * tile_data->raster->opacity); // TODO fix
glDepthRange(strata + strata_epsilon, 1.0f);
bucket.drawRaster(*rasterShader, tileStencilBuffer, coveringRasterArray);
if (!bucket.hasData()) {
bucket.drawRaster(*rasterShader, tileStencilBuffer, coveringRasterArray, bucket.texture.getTexture());
} else {
bucket.drawRaster(*rasterShader, tileStencilBuffer, coveringRasterArray);
}
depthMask(true);

View File

@@ -44,11 +44,25 @@ void PrerenderedTexture::bindFramebuffer() {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, properties.size, properties.size, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glBindTexture(GL_TEXTURE_2D, 0);
}
if (fbo_depth_stencil == 0) {
// Create depth/stencil buffer
glGenRenderbuffers(1, &fbo_depth_stencil);
glBindRenderbuffer(GL_RENDERBUFFER, fbo_depth_stencil);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, properties.size, properties.size);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
}
if (fbo == 0) {
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
#ifdef GL_ES_VERSION_2_0
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbo_depth_stencil);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fbo_depth_stencil);
#else
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fbo_depth_stencil);
#endif
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {

View File

@@ -24,6 +24,13 @@ void RasterBucket::drawRaster(RasterShader& shader, VertexBuffer &vertices, Vert
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.index());
}
void RasterBucket::drawRaster(RasterShader& shader, VertexBuffer &vertices, VertexArrayObject &array, GLuint texture) {
raster.bind(texture);
shader.setImage(0);
array.bind(shader, vertices, BUFFER_OFFSET(0));
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.index());
}
bool RasterBucket::hasData() const {
return raster.isLoaded();
}

View File

@@ -68,6 +68,28 @@ void Raster::bind(bool linear) {
}
}
// overload ::bind for prerendered raster textures
void Raster::bind(const GLuint texture) {
if (img && !textured) {
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img->getData());
img.reset();
textured = true;
} else if (textured) {
glBindTexture(GL_TEXTURE_2D, texture);
}
GLuint filter = GL_LINEAR;
if (filter != this->filter) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
this->filter = filter;
}
}
void Raster::beginFadeInTransition() {
timestamp start = util::now();
fade_transition = std::make_shared<util::ease_transition<double>>(opacity, 1.0, opacity, start, 250_milliseconds);