switched openGL to es
This commit is contained in:
@@ -102,7 +102,8 @@ MapView3D::MapView3D(QWidget *parent) : QOpenGLWidget(parent) {
|
|||||||
grabGesture(Qt::PinchGesture);
|
grabGesture(Qt::PinchGesture);
|
||||||
|
|
||||||
auto format = QSurfaceFormat();
|
auto format = QSurfaceFormat();
|
||||||
format.setVersion(3,3);
|
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
||||||
|
format.setVersion(3, 0);
|
||||||
//format.setSamples(2);
|
//format.setSamples(2);
|
||||||
auto ver = format.version();
|
auto ver = format.version();
|
||||||
|
|
||||||
|
|||||||
@@ -4,16 +4,15 @@
|
|||||||
Shader::Shader() {
|
Shader::Shader() {
|
||||||
|
|
||||||
addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, R"(
|
addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, R"(
|
||||||
#version 330
|
attribute highp vec3 a_vertex;
|
||||||
in highp vec3 a_vertex;
|
attribute highp vec3 a_normal;
|
||||||
in highp vec3 a_normal;
|
attribute lowp vec4 a_color;
|
||||||
in lowp vec4 a_color;
|
|
||||||
uniform highp mat4 M;
|
uniform highp mat4 M;
|
||||||
uniform highp mat4 V;
|
uniform highp mat4 V;
|
||||||
uniform highp mat4 P;
|
uniform highp mat4 P;
|
||||||
out highp vec3 v_normal;
|
varying highp vec3 v_normal;
|
||||||
out lowp vec4 v_color;
|
varying lowp vec4 v_color;
|
||||||
out lowp vec4 v_vertex;
|
varying lowp vec4 v_vertex;
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = P * V * M * vec4(a_vertex, 1.0);
|
gl_Position = P * V * M * vec4(a_vertex, 1.0);
|
||||||
v_normal = (V * M * vec4(a_normal, 0.0)).xyz;
|
v_normal = (V * M * vec4(a_normal, 0.0)).xyz;
|
||||||
@@ -23,26 +22,24 @@ Shader::Shader() {
|
|||||||
)");
|
)");
|
||||||
|
|
||||||
addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, R"(
|
addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, R"(
|
||||||
#version 330
|
uniform lowp vec4 color;
|
||||||
uniform vec4 color;
|
|
||||||
uniform bool useNormal;
|
uniform bool useNormal;
|
||||||
uniform bool useVertexColor;
|
uniform bool useVertexColor;
|
||||||
in highp vec3 v_normal;
|
varying highp vec3 v_normal;
|
||||||
in lowp vec4 v_color;
|
varying lowp vec4 v_color;
|
||||||
in lowp vec4 v_vertex;
|
varying lowp vec4 v_vertex;
|
||||||
|
|
||||||
layout(location=1) out vec4 fragColor;
|
|
||||||
void main() {
|
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(vec3(0,0,1));
|
||||||
vec3 lightVec = normalize(lightPos - v_vertex.xyz);
|
mediump 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
|
lowp float intensity = useNormal ? 0.3 + 0.7 * dot( normalize(v_normal), lightVec ) : 1.0; // light at camera pos
|
||||||
vec4 col = useVertexColor ? v_color : color;
|
lowp vec4 col = useVertexColor ? v_color : color;
|
||||||
fragColor.rgb = col.rgb * intensity;
|
gl_FragColor.rgb = col.rgb * intensity;
|
||||||
fragColor.a = col.a;
|
gl_FragColor.a = col.a;
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
|
|
||||||
|
|
||||||
//bindAttributeLocation("vertices", 0);
|
//bindAttributeLocation("vertices", 0);
|
||||||
|
|
||||||
if (!link()) {
|
if (!link()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user