# Use clip and cull distances. Clip triangle 0 between vertices 0 and # 1, cull triangle 0. [require] GLSL >= 1.30 GL_ARB_cull_distance [vertex shader] #version 130 #extension GL_ARB_cull_distance: enable out float gl_CullDistance[1]; out float gl_ClipDistance[1]; void main(void) { gl_Position = gl_Vertex; gl_CullDistance[0] = gl_VertexID - 3; gl_ClipDistance[0] = gl_VertexID - 1; } [fragment shader] #version 130 void main(void) { gl_FragColor = vec4(0, 0, 1, 1); } [test] clear color 0.0 1.0 0.0 1.0 clear enable GL_CLIP_PLANE0 draw rect -1 -1 2 2 # Bottom left corner is green because triangle 0 was culled relative probe rgba (0.100, 0.100) (0.0, 1.0, 0.0, 1.0) # Top left corner is green below diagonal because triangle 0 was culled relative probe rgba (0.050, 0.900) (0.0, 1.0, 0.0, 1.0) # Top left corner is blue above diagonal because triangle 1 was not # culled or clipped. relative probe rgba (0.100, 0.950) (0.0, 0.0, 1.0, 1.0) # Top right corner is blue because triangle 1 was not culled or clipped relative probe rgba (0.900, 0.900) (0.0, 0.0, 1.0, 1.0)