Add more structure constructor tests.
[piglit/hramrach.git] / tests / general / scissor-many.c
blobd899539697ada85b3b91111db6ffe9f441785315
1 /*
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
13 * Software.
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
21 * IN THE SOFTWARE.
23 * Authors:
24 * Eric Anholt <eric@anholt.net>
28 /** @file many-scissors.c
30 * Tests drawing to each individual pixel in the drawable using glScissor.
32 * The desire here is to stress the cache management in the i965
33 * driver, where each scissor state is in a separate BO.
36 #include "piglit-util.h"
38 int piglit_width = 100, piglit_height = 100;
39 int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL;
41 enum piglit_result
42 piglit_display(void)
44 GLboolean pass = GL_TRUE;
45 int x, y;
46 static float green[] = {0.0, 1.0, 0.0, 0.0};
48 glClearColor(1.0, 0.0, 0.0, 0.0);
49 glClear(GL_COLOR_BUFFER_BIT);
51 glColor4fv(green);
52 glEnable(GL_SCISSOR_TEST);
53 for (y = 0; y < piglit_height; y++) {
54 for (x = 0; x < piglit_width; x++) {
55 glScissor(x, y, 1, 1);
56 piglit_draw_rect(0, 0, piglit_width, piglit_height);
60 for (y = 0; y < piglit_height; y++) {
61 for (x = 0; x < piglit_width; x++) {
62 pass &= piglit_probe_pixel_rgb(x, y, green);
66 glutSwapBuffers();
68 return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
72 static void reshape(int width, int height)
74 piglit_width = width;
75 piglit_height = height;
77 glViewport(0, 0, width, height);
78 glMatrixMode(GL_PROJECTION);
79 glLoadIdentity();
81 glOrtho(0.0, width, 0.0, height, -1.0, 1.0);
82 glMatrixMode(GL_MODELVIEW);
83 glLoadIdentity();
86 void
87 piglit_init(int argc, char **argv)
89 reshape(piglit_width, piglit_height);