2 * Copyright © 2009 Intel Corporation
3 * Copyright © 2010 Red Hat, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27 * Test fragment programs sampling from different texture formats.
28 * (currently just alpha-only textures)
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
;
39 PIGLIT_GL_TEST_CONFIG_END
42 * Modulate the primary color with the alpha channel of the texture
44 static const char alpha_source
[] =
47 "TEX texel0,fragment.texcoord[0],texture[0],2D;\n"
48 "MOV result.color, texel0.abgr;\n"
52 static GLint progs
[1];
53 static GLuint textures
[1];
58 enum piglit_result result
= PIGLIT_PASS
;
60 const GLfloat expected
[4] = { 0.5, 0.0, 0.0, 0.0 };
62 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, progs
[0]);
64 glClear(GL_COLOR_BUFFER_BIT
);
65 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
67 piglit_draw_rect(0, 0, piglit_width
, piglit_height
);
69 if (!piglit_probe_pixel_rgb(piglit_width
/ 2,
74 piglit_present_results();
80 piglit_init(int argc
, char **argv
)
82 const GLfloat alpha_data
[] = { 0.5 };
87 piglit_require_fragment_program();
88 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);
90 progs
[0] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB
,
93 glGenTextures(1, textures
);
95 glActiveTexture(GL_TEXTURE0
);
96 glBindTexture(GL_TEXTURE_2D
, textures
[0]);
97 glTexImage2D(GL_TEXTURE_2D
, 0, GL_ALPHA
, 1, 1, 0, GL_ALPHA
, GL_FLOAT
, alpha_data
);
98 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
99 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
101 glClearColor(1.0, 1.0, 1.0, 1.0);