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
21 * DEALINGS IN THE SOFTWARE.
24 * Ben Holmes <shranzel@hotmail.com>
27 /* This test draws to the screen using glDrawPixels with data formats of GL_RED
28 * and GL_RG and tests for the correct color output.
31 #include "piglit-util-gl.h"
33 PIGLIT_GL_TEST_CONFIG_BEGIN
35 config
.supports_gl_compat_version
= 10;
37 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
38 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
40 PIGLIT_GL_TEST_CONFIG_END
43 piglit_init(int argc
, char **argv
)
45 piglit_require_extension("GL_ARB_texture_rg");
46 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);
48 glEnable(GL_TEXTURE_2D
);
49 glClearColor(0.2, 0.2, 0.2, 1.0);
55 static const GLfloat red
[3] = {1.0, 0.0, 0.0};
56 static const GLfloat rg
[3] = {1.0, 1.0, 0.0};
57 static const GLfloat black
[3] = {0.0, 0.0, 0.0};
61 GLfloat texData
[width
][height
][4];
62 GLboolean pass
= GL_TRUE
;
64 glClear(GL_COLOR_BUFFER_BIT
);
67 for (i
=0; i
< width
; ++i
) {
68 for (j
=0; j
< height
; ++j
) {
70 texData
[i
][j
][0] = 1.0;
71 texData
[i
][j
][1] = 1.0;
72 texData
[i
][j
][2] = 1.0;
73 texData
[i
][j
][3] = 1.0;
76 texData
[i
][j
][0] = 0.0;
77 texData
[i
][j
][1] = 0.0;
78 texData
[i
][j
][2] = 0.0;
79 texData
[i
][j
][3] = 0.0;
84 /* The image consists of alternating patterns of 4 0.0 values followed
85 * by 4 1.0 values. When drawn as GL_RED, this results in 4x4 pixel
86 * blocks of black and red. When drawn as GL_RG, this results in 2x2
87 * pixel blocks of gold (full green and full red).
90 glDrawPixels(width
,height
,GL_RED
,GL_FLOAT
,texData
);
93 glDrawPixels(width
,height
,GL_RG
,GL_FLOAT
,texData
);
95 pass
= pass
&& piglit_probe_pixel_rgb(0,0,black
);
96 pass
= pass
&& piglit_probe_pixel_rgb(2,0,black
);
97 pass
= pass
&& piglit_probe_pixel_rgb(4,0,red
);
98 pass
= pass
&& piglit_probe_pixel_rgb(6,0,red
);
100 pass
= pass
&& piglit_probe_pixel_rgb(18,0,black
);
101 pass
= pass
&& piglit_probe_pixel_rgb(19,0,black
);
102 pass
= pass
&& piglit_probe_pixel_rgb(20,0,rg
);
103 pass
= pass
&& piglit_probe_pixel_rgb(21,0,rg
);
105 piglit_present_results();
107 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;