2 # Verify that gl_ClipDistance works properly when accessed with a
5 # This test uses all 8 gl_ClipDistance values to clip a rectangle to
8 # The octagon is centered at (0.5, 0.5), and has a small radius
9 # (distance from center to perpendicular edge) of 0.4.
17 out float gl_ClipDistance[8];
21 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
23 // Compute 2D coordinates relative to a center point of (0.5,
25 vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5);
27 for (int i = 0; i < 8; ++i) {
30 // Compute a unit vector in the direction i*45deg from
32 float angle = i*(3.141592653589793/4);
33 vec2 u = vec2(cos(angle), sin(angle));
35 // Reject points whose 2D coordinate, projected onto
36 // that unit vector, is greater than 0.4.
37 gl_ClipDistance[j] = 0.4 - dot(u, coord);
45 gl_FragColor = vec4(1, 1, 1, 1);
49 clear color 0.0 0.0 0.0 0.0
60 draw rect 0.0 0.0 1.0 1.0
62 # Test points inside each hexagon edge
63 relative probe rgba (0.850, 0.500) (1.0, 1.0, 1.0, 1.0)
64 relative probe rgba (0.747, 0.747) (1.0, 1.0, 1.0, 1.0)
65 relative probe rgba (0.500, 0.850) (1.0, 1.0, 1.0, 1.0)
66 relative probe rgba (0.253, 0.747) (1.0, 1.0, 1.0, 1.0)
67 relative probe rgba (0.150, 0.500) (1.0, 1.0, 1.0, 1.0)
68 relative probe rgba (0.253, 0.253) (1.0, 1.0, 1.0, 1.0)
69 relative probe rgba (0.500, 0.150) (1.0, 1.0, 1.0, 1.0)
70 relative probe rgba (0.747, 0.253) (1.0, 1.0, 1.0, 1.0)
72 # Test points outside each hexagon edge
73 relative probe rgba (0.950, 0.500) (0.0, 0.0, 0.0, 0.0)
74 relative probe rgba (0.818, 0.818) (0.0, 0.0, 0.0, 0.0)
75 relative probe rgba (0.500, 0.950) (0.0, 0.0, 0.0, 0.0)
76 relative probe rgba (0.182, 0.818) (0.0, 0.0, 0.0, 0.0)
77 relative probe rgba (0.050, 0.500) (0.0, 0.0, 0.0, 0.0)
78 relative probe rgba (0.182, 0.182) (0.0, 0.0, 0.0, 0.0)
79 relative probe rgba (0.500, 0.050) (0.0, 0.0, 0.0, 0.0)
80 relative probe rgba (0.818, 0.182) (0.0, 0.0, 0.0, 0.0)