From 27c1d4f2c4f55b67499d73fa7452a9a14a2aa948 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Mon, 3 Feb 2014 18:06:20 +0100 Subject: working symbol rendering based on point sprites This approach ahs several advantages compared to the old approach. There is no UNO involved anymore and we have a perfect shape defined by a mathematical formula. No need for anti-aliasing or complex calculations on the CPU. Change-Id: I5018eae516de3368037c4c293d937de66f38568d --- chart2/opengl/symbolFragmentShader.glsl | 61 ++++++++++++++++++++++++++++++--- chart2/opengl/symbolVertexShader.glsl | 3 +- 2 files changed, 58 insertions(+), 6 deletions(-) (limited to 'chart2/opengl') diff --git a/chart2/opengl/symbolFragmentShader.glsl b/chart2/opengl/symbolFragmentShader.glsl index a84d83cfba48..2837f958af29 100644 --- a/chart2/opengl/symbolFragmentShader.glsl +++ b/chart2/opengl/symbolFragmentShader.glsl @@ -6,17 +6,70 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -# + #version 120 varying vec4 fragmentColor; +uniform int shape; void main() { vec2 p = gl_PointCoord * 2.0 - vec2(1.0); // (0,0) in the center - if (abs(p.x) < abs(p.y)) - discard; - + if(shape == 0) + { + } + else if(shape == 1) //diamon + { + if (abs(p.x) + abs(p.y) > 1) + discard; + } + else if(shape == 2) // arrow + { + if(p.y < 0 && (abs(p.x) + abs(p.y)) > 1) + discard; + else if(p.y > 0 && abs(p.x) > 0.5) + discard; + } + else if(shape == 3) //arrow up + { + if(p.y > 0 && (abs(p.x) + abs(p.y)) > 1) + discard; + else if(p.y < 0 && abs(p.x) > 0.5) + discard; + } + else if(shape == 4) + { + if(p.x > 0 && (abs(p.x) + abs(p.y)) > 1) + discard; + else if(p.x < 0 && abs(p.y) > 0.5) + discard; + } + else if(shape == 5) + { + if(p.x < 0 && (abs(p.x) + abs(p.y)) > 1) + discard; + else if(p.x > 0 && abs(p.y) > 0.5) + discard; + } + else if(shape == 6) + { + if(abs(p.x) < abs(p.y)) + discard; + } + else if(shape == 7) + { + if(abs(p.y) < abs(p.x)) + discard; + } + else if(shape == 8) + { + if(dot(p.x, p.y) > 1) + discard; + } + else if(shape == 9) + { + } + gl_FragColor = fragmentColor; } diff --git a/chart2/opengl/symbolVertexShader.glsl b/chart2/opengl/symbolVertexShader.glsl index e1bbec9bc202..3cf9f41ef21b 100644 --- a/chart2/opengl/symbolVertexShader.glsl +++ b/chart2/opengl/symbolVertexShader.glsl @@ -16,9 +16,8 @@ varying vec4 fragmentColor; void main() { - gl_Position = MVP * vec4(vPosition, 1); + gl_Position = MVP * vec4(vPosition, 1); fragmentColor = vColor; - gl_PointSize = 10.0; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3