1、首先程序入口设置OpenGLES
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
QSurfaceFormat fmt;
fmt.setDepthBufferSize(16);
fmt.setVersion(2,0);
QSurfaceFormat::setDefaultFormat(fmt);
QGuiApplication::setAttribute(Qt::AA_DisableShaderDiskCache);
QApplication app( arg, argv );
注意: 使用OpenGLES了,渲染图像就不能使用8位单通道灰度图,否则渲染的颜色错误;
使用RGBA图像;
2、qml :ShaderEffect 的使用中fragmentShader 的值开始加判断
#ifdef GL_ES
precision mediump float;
#endif
fragmentShader:
"
#ifdef GL_ES
precision mediump float;
#endif
uniform highp vec2 rectSize;
uniform highp vec4 irisBgColor;
uniform highp float diameter;
varying highp vec2 qt_TexCoord0;
void main() {
....
"