diff --git a/scwx-qt/gl/geo_line.vert b/scwx-qt/gl/geo_line.vert new file mode 100644 index 00000000..e232df95 --- /dev/null +++ b/scwx-qt/gl/geo_line.vert @@ -0,0 +1,39 @@ +#version 330 core + +#define DEGREES_MAX 360.0f +#define LATITUDE_MAX 85.051128779806604f +#define LONGITUDE_MAX 180.0f +#define PI 3.1415926535897932384626433f +#define RAD2DEG 57.295779513082320876798156332941f + +layout (location = 0) in vec2 aLatLong; +layout (location = 1) in vec2 aXYOffset; +layout (location = 2) in vec2 aTexCoord; +layout (location = 3) in vec4 aModulate; + +uniform mat4 uMVPMatrix; +uniform vec2 uMapScreenCoord; + +flat out vec2 texCoord; +flat out vec4 modulate; + +vec2 latLngToScreenCoordinate(in vec2 latLng) +{ + vec2 p; + latLng.x = clamp(latLng.x, -LATITUDE_MAX, LATITUDE_MAX); + p.xy = vec2(LONGITUDE_MAX + latLng.y, + -(LONGITUDE_MAX - RAD2DEG * log(tan(PI / 4 + latLng.x * PI / DEGREES_MAX)))); + return p; +} + +void main() +{ + // Pass the texture coordinate and color modulate to the fragment shader + texCoord = aTexCoord; + modulate = aModulate; + + vec2 p = latLngToScreenCoordinate(aLatLong) + aXYOffset - uMapScreenCoord; + + // Transform the position to screen coordinates + gl_Position = uMVPMatrix * vec4(p, 0.0f, 1.0f); +} diff --git a/scwx-qt/gl/texture2d.frag b/scwx-qt/gl/texture2d.frag new file mode 100644 index 00000000..3a41c720 --- /dev/null +++ b/scwx-qt/gl/texture2d.frag @@ -0,0 +1,16 @@ +#version 330 core + +// Lower the default precision to medium +precision mediump float; + +uniform sampler2D uTexture; + +flat in vec2 texCoord; +flat in vec4 modulate; + +layout (location = 0) out vec4 fragColor; + +void main() +{ + fragColor = texture(uTexture, texCoord) * modulate; +} diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 00abbaf4..90d3c574 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -122,12 +122,14 @@ set(RESOURCE_FILES scwx-qt.qrc) set(SHADER_FILES gl/color.frag gl/color.vert + gl/geo_line.vert gl/radar.frag gl/radar.vert gl/text.frag gl/text.vert gl/texture1d.frag - gl/texture1d.vert) + gl/texture1d.vert + gl/texture2d.frag) set(CMAKE_FILES scwx-qt.cmake) diff --git a/scwx-qt/scwx-qt.qrc b/scwx-qt/scwx-qt.qrc index d3386855..bf64e1fd 100644 --- a/scwx-qt/scwx-qt.qrc +++ b/scwx-qt/scwx-qt.qrc @@ -2,12 +2,14 @@ gl/color.frag gl/color.vert + gl/geo_line.vert gl/radar.frag gl/radar.vert gl/text.frag gl/text.vert gl/texture1d.frag gl/texture1d.vert + gl/texture2d.frag res/config/radar_sites.json res/fonts/din1451alt.ttf res/fonts/din1451alt_g.ttf