Skip to content

Commit

Permalink
use anisotropic filtering for raster tiles #1064 (#4443)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewharvey authored and lucaswoj committed Mar 21, 2017
1 parent c189bbf commit e0a66fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ class Painter {
rasterBoundsArray.emplaceBack(EXTENT, EXTENT, 32767, 32767);
this.rasterBoundsBuffer = Buffer.fromStructArray(rasterBoundsArray, Buffer.BufferType.VERTEX);
this.rasterBoundsVAO = new VertexArrayObject();

this.extTextureFilterAnisotropic = (
gl.getExtension('EXT_texture_filter_anisotropic') ||
gl.getExtension('MOZ_EXT_texture_filter_anisotropic') ||
gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic')
);
if (this.extTextureFilterAnisotropic) {
this.extTextureFilterAnisotropicMax = gl.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
}
}

/*
Expand Down
5 changes: 5 additions & 0 deletions src/source/raster_tile_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ class RasterTileSource extends Evented {
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);

if (this.map.painter.extTextureFilterAnisotropic) {
gl.texParameterf(gl.TEXTURE_2D, this.map.painter.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT, this.map.painter.extTextureFilterAnisotropicMax);
}

gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img);
tile.texture.size = img.width;
}
Expand Down

0 comments on commit e0a66fb

Please sign in to comment.