switched openGL to es

This commit is contained in:
k-a-z-u
2018-04-04 10:09:22 +02:00
parent 15f15b4599
commit 479f58e7e3
2 changed files with 20 additions and 22 deletions

View File

@@ -101,8 +101,9 @@ MapView3D::MapView3D(QWidget *parent) : QOpenGLWidget(parent) {
grabGesture(Qt::PanGesture);
grabGesture(Qt::PinchGesture);
auto format = QSurfaceFormat();
format.setVersion(3,3);
auto format = QSurfaceFormat();
format.setRenderableType(QSurfaceFormat::OpenGLES);
format.setVersion(3, 0);
//format.setSamples(2);
auto ver = format.version();

View File

@@ -4,16 +4,15 @@
Shader::Shader() {
addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, R"(
#version 330
in highp vec3 a_vertex;
in highp vec3 a_normal;
in lowp vec4 a_color;
attribute highp vec3 a_vertex;
attribute highp vec3 a_normal;
attribute lowp vec4 a_color;
uniform highp mat4 M;
uniform highp mat4 V;
uniform highp mat4 P;
out highp vec3 v_normal;
out lowp vec4 v_color;
out lowp vec4 v_vertex;
varying highp vec3 v_normal;
varying lowp vec4 v_color;
varying lowp vec4 v_vertex;
void main() {
gl_Position = P * V * M * vec4(a_vertex, 1.0);
v_normal = (V * M * vec4(a_normal, 0.0)).xyz;
@@ -23,26 +22,24 @@ Shader::Shader() {
)");
addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, R"(
#version 330
uniform vec4 color;
uniform lowp vec4 color;
uniform bool useNormal;
uniform bool useVertexColor;
in highp vec3 v_normal;
in lowp vec4 v_color;
in lowp vec4 v_vertex;
layout(location=1) out vec4 fragColor;
varying highp vec3 v_normal;
varying lowp vec4 v_color;
varying lowp vec4 v_vertex;
void main() {
vec3 lightPos = vec3(0,0,0); // camera
mediump vec3 lightPos = vec3(0,0,0); // camera
//vec3 lightVec = normalize(vec3(0,0,1));
vec3 lightVec = normalize(lightPos - v_vertex.xyz);
float intensity = useNormal ? 0.3 + 0.7 * dot( normalize(v_normal), lightVec ) : 1.0; // light at camera pos
vec4 col = useVertexColor ? v_color : color;
fragColor.rgb = col.rgb * intensity;
fragColor.a = col.a;
mediump vec3 lightVec = normalize(lightPos - v_vertex.xyz);
lowp float intensity = useNormal ? 0.3 + 0.7 * dot( normalize(v_normal), lightVec ) : 1.0; // light at camera pos
lowp vec4 col = useVertexColor ? v_color : color;
gl_FragColor.rgb = col.rgb * intensity;
gl_FragColor.a = col.a;
}
)");
//bindAttributeLocation("vertices", 0);
if (!link()) {