Kaydet (Commit) 0ab9ddaf authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

android: LayerRenderer - use highp and flip in vertex shader

Change-Id: Ia517b0d94fdfb3f8fdd9b9c383c8fb337173932c
üst f789cd42
......@@ -99,6 +99,11 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
// The shaders run on the GPU directly, the vertex shader is only applying the
// matrix transform detailed above
// Note we flip the y-coordinate in the vertex shader from a
// coordinate system with (0,0) in the top left to one with (0,0) in
// the bottom left.
public static final String DEFAULT_VERTEX_SHADER =
"uniform mat4 uTMatrix;\n" +
"attribute vec4 vPosition;\n" +
......@@ -106,18 +111,21 @@ public class LayerRenderer implements GLSurfaceView.Renderer {
"varying vec2 vTexCoord;\n" +
"void main() {\n" +
" gl_Position = uTMatrix * vPosition;\n" +
" vTexCoord = aTexCoord;\n" +
" vTexCoord.x = aTexCoord.x;\n" +
" vTexCoord.y = 1.0 - aTexCoord.y;\n" +
"}\n";
// Note we flip the y-coordinate in the fragment shader from a
// coordinate system with (0,0) in the top left to one with (0,0) in
// the bottom left.
// We use highp because the screenshot textures
// we use are large and we stretch them alot
// so we need all the precision we can get.
// Unfortunately, highp is not required by ES 2.0
// so on GPU's like Mali we end up getting mediump
public static final String DEFAULT_FRAGMENT_SHADER =
"precision mediump float;\n" +
"precision highp float;\n" +
"varying vec2 vTexCoord;\n" +
"uniform sampler2D sTexture;\n" +
"void main() {\n" +
" gl_FragColor = texture2D(sTexture, vec2(vTexCoord.x, 1.0 - vTexCoord.y));\n" +
" gl_FragColor = texture2D(sTexture, vTexCoord);\n" +
"}\n";
public void setCheckerboardBitmap(Bitmap bitmap, float pageWidth, float pageHeight) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment