1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
# This test verifies that the homogeneous coordinate of gl_ClipVertex
# is properly respected, by doubling all the coordinates of
# gl_ClipVertex (including the homogeneous coordinate) and verifying
# that the clipped shape is still correct.
#
# In addition, this test:
# - uses all 6 clip planes to clip a rectangle to a hexagon shape.
# - sets gl_Position and gl_ClipVertex to different values, to verify
# that gl_Position determines screen position and gl_ClipVertex
# determines clipping.
[require]
GLSL >= 1.20
[vertex shader]
#version 120
void main(void)
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
// Transform gl_ClipVertex in an arbitrary way so that
// we can verify it is being used for clipping instead of
// gl_Position. The x and y coordinates are multiplied by 5,
// and the homogeneous coordinate is multiplied by 0.5, so the
// net result should be that x and y are scaled by a factor of
// 10.
gl_ClipVertex = gl_Vertex * vec4(5.0, 5.0, 1.0, 0.5);
}
[fragment shader]
#version 120
void main(void)
{
gl_FragColor = vec4(1, 1, 1, 1);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho 0 1 0 1
clip plane 0 0 1 0 -2.5
clip plane 1 -1 1 0 4
clip plane 2 -1 -1 0 14
clip plane 3 0 -1 0 7.5
clip plane 4 1 -1 0 4
clip plane 5 1 1 0 -6
enable GL_CLIP_PLANE0
enable GL_CLIP_PLANE1
enable GL_CLIP_PLANE2
enable GL_CLIP_PLANE3
enable GL_CLIP_PLANE4
enable GL_CLIP_PLANE5
draw rect 0.1 0.1 0.8 0.8
# Test points inside each hexagon edge
relative probe rgba (0.3, 0.4) (1.0, 1.0, 1.0, 1.0)
relative probe rgba (0.5, 0.3) (1.0, 1.0, 1.0, 1.0)
relative probe rgba (0.7, 0.4) (1.0, 1.0, 1.0, 1.0)
relative probe rgba (0.7, 0.6) (1.0, 1.0, 1.0, 1.0)
relative probe rgba (0.5, 0.7) (1.0, 1.0, 1.0, 1.0)
relative probe rgba (0.3, 0.6) (1.0, 1.0, 1.0, 1.0)
# Test points outside each hexagon edge
relative probe rgba (0.2, 0.3) (0.0, 0.0, 0.0, 0.0)
relative probe rgba (0.5, 0.2) (0.0, 0.0, 0.0, 0.0)
relative probe rgba (0.8, 0.3) (0.0, 0.0, 0.0, 0.0)
relative probe rgba (0.8, 0.7) (0.0, 0.0, 0.0, 0.0)
relative probe rgba (0.5, 0.8) (0.0, 0.0, 0.0, 0.0)
relative probe rgba (0.2, 0.7) (0.0, 0.0, 0.0, 0.0)
|