2 * Copyright © 2009 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Eric Anholt <eric@anholt.net>
28 /** @file glsl-fs-pointcoord.c
30 * Tests that gl_PointCoord produces the expected output in a fragment shader
31 * with point sprites enabled.
40 #define GL_GLEXT_PROTOTYPES
42 #if defined(__APPLE__)
43 #include <GLUT/glut.h>
48 #include "piglit-util.h"
50 int piglit_width
= 256;
51 int piglit_height
= 256;
52 int piglit_window_mode
= GLUT_DOUBLE
| GLUT_RGB
;
55 static GLint point_size
;
60 GLboolean pass
= GL_TRUE
;
61 const float red
[4] = {1, 0, 0, 0};
62 const float green
[4] = {0, 1, 0, 0};
63 const float yellow
[4] = {1, 1, 0, 0};
64 const float black
[4] = {0, 0, 0, 0};
66 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);
68 glClearColor(0.5, 0.5, 0.5, 0.5);
69 glClear(GL_COLOR_BUFFER_BIT
);
71 glPointSize(point_size
);
73 glVertex2f(point_size
/ 2, point_size
/ 2);
76 pass
= pass
&& piglit_probe_pixel_rgb(0, 0, green
);
77 pass
= pass
&& piglit_probe_pixel_rgb(point_size
- 1, 0, yellow
);
78 pass
= pass
&& piglit_probe_pixel_rgb(0, point_size
- 1, black
);
79 pass
= pass
&& piglit_probe_pixel_rgb(point_size
- 1, point_size
- 1, red
);
83 return pass
? PIGLIT_SUCCESS
: PIGLIT_FAILURE
;
86 void piglit_init(int argc
, char**argv
)
89 GLint point_size_limits
[2];
91 if (!GLEW_VERSION_2_0
) {
92 printf("Requires OpenGL 2.0\n");
93 piglit_report_result(PIGLIT_SKIP
);
96 piglit_require_extension("GL_ARB_point_sprite");
98 glGetIntegerv(GL_ALIASED_POINT_SIZE_RANGE
, point_size_limits
);
99 point_size
= point_size_limits
[1];
100 if (point_size
> piglit_width
)
101 point_size
= piglit_width
;
103 if (point_size
> piglit_width
)
104 point_size
= piglit_width
;
105 if (point_size
> piglit_height
)
106 point_size
= piglit_height
;
108 vs
= piglit_compile_shader(GL_VERTEX_SHADER
,
109 "shaders/glsl-fs-pointcoord.vert");
110 fs
= piglit_compile_shader(GL_FRAGMENT_SHADER
,
111 "shaders/glsl-fs-pointcoord.frag");
113 prog
= piglit_link_simple_program(vs
, fs
);
115 glEnable(GL_POINT_SPRITE
);