ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_texture_rectangle / texrect-simple.c
blob817feee6038482b4965d9dc07291b5b61b2f1ff1
1 /* Copyright © 2013 Linaro Inc
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
23 /**
24 * Ported from glean ttexrect.cpp into piglit.
25 * Test the ARB_texture_rectangle extension
26 * Create a 255x127 texture of varying colors and bind it as a
27 * GL_ARB_texture_recangle target. Draw that rectangle to the window, and
28 * check that the texture was drawn correctly. The common failure to be
29 * caught with this test is not adjusting the non-normalized coordinates on
30 * hardware that expects normalized coordinates.
31 * \author: Eric Anholt <eric@anholt.net> (original)
32 * \author: Tom Gall <tom.gall@linaro.org> (port)
34 #include "piglit-util-gl.h"
36 #define TEXTURE_WIDTH 255
37 #define TEXTURE_HEIGHT 127
38 #define WINDOW_SIZE 256
40 float image[TEXTURE_WIDTH * TEXTURE_HEIGHT * 3];
42 PIGLIT_GL_TEST_CONFIG_BEGIN
44 config.supports_gl_compat_version = 10;
45 config.window_width = WINDOW_SIZE;
46 config.window_height = WINDOW_SIZE;
47 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DEPTH
48 | PIGLIT_GL_VISUAL_DOUBLE;
49 config.khr_no_error_support = PIGLIT_NO_ERRORS;
51 PIGLIT_GL_TEST_CONFIG_END
54 enum piglit_result
55 piglit_display(void)
57 enum piglit_result result = PIGLIT_FAIL;
59 /* Draw our texture to the window such that each texel should map
60 * to the corresponding pixel of the window.
62 glClear(GL_COLOR_BUFFER_BIT);
64 piglit_draw_rect_tex(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT,
65 0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT);
67 if (piglit_probe_image_rgb(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT,
68 (const float *) &image))
69 result = PIGLIT_PASS;
71 piglit_present_results();
73 return result;
77 void
78 piglit_init(int argc, char *argv[])
80 int x, y, i;
82 /* Set up a texture that it's color ramps with red to black top to
83 * bottom and green to black left to right.
85 for (y = 0; y < TEXTURE_HEIGHT; y++) {
86 for (x = 0; x < TEXTURE_WIDTH; x++) {
87 i = (y * TEXTURE_WIDTH + x) * 3;
89 image[i + 0] = (float)x / (TEXTURE_WIDTH - 1);
90 image[i + 1] = 1.0 - ((float) y / (TEXTURE_HEIGHT - 1));
91 image[i + 2] = 0.0;
95 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
97 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
98 TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, GL_RGB, GL_FLOAT, image);
99 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
100 GL_NEAREST);
101 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
102 GL_NEAREST);
103 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
104 glEnable(GL_TEXTURE_RECTANGLE_ARB);