I am trying to draw a camera preview on Android via openGL. Preview texture is obtain as external EGL image through SurfaceTexture and then I draw it using a fairly simple shader:
#extension GL_OES_EGL_image_external : require
precision mediump float;
uniform samplerExternalOES sTexture;
varying vec2 texCoord;
void main() {
gl_FragColor = texture2D(sTexture,texCoord);
}
On nexus 5 it's working for all the preview images up to 1280x960. However for the biggest 2: 1920x1080 and 1600x1200 the screen is just blank. I set preview size in my camera obtained via camera.getSupportedPreviewSizes, so I am not trying to set anything which is unsupported by the camera.
public List<Camera.Size> getSupportedResolutions()
{
List<Camera.Size> previewSizes = mCamera.getParameters().getSupportedPreviewSizes();
List<Camera.Size> pictureSizes = mCamera.getParameters().getSupportedPictureSizes();
pictureSizes.retainAll(previewSizes);
return pictureSizes;
}
private void setResolution(int position)
{
List<Camera.Size> res = getSupportedResolutions();
Camera.Parameters p = mCamera.getParameters();
p.setPictureSize(res.get(position).width, res.get(position).height);
p.setPreviewSize(res.get(position).width, res.get(position).height);
mCamera.setParameters(p);
}
any suggestion what might go be wrong with those resolutions? maybe some kind of size limit in opengl?