#version 130 attribute vec4 vPosition; out vec4 color; int Quadrant(float x, float y); uniform float theta = 0; void main() { float distance; float red = 0.0, green = 0.0, blue = 0.0; distance = sqrt(pow(vPosition.x,2.0)+pow(vPosition.y,2.0)); switch(Quadrant(vPosition.x, vPosition.y)) { case 1: red = distance; break; case 2: green = distance; break; case 3: blue = distance; break; case 4: red = distance; blue = distance; break; default: red = 1.0; green = 1.0; blue = 1.0; } color = vec4(red, green, blue, 1.0); gl_Position = vPosition * mat4( cos(theta), sin(theta), 0, 0, -sin(theta), cos(theta), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); gl_PointSize = 5.0; } int Quadrant(float x, float y) { int quadrant; if (x < 0.0 ) { if (y < 0.0) { quadrant = 3; } else { quadrant = 2; } } else { if (y < 0.0) { quadrant = 4; } else { quadrant = 1; } } return quadrant; }