2 * Copyright © 2013 LunarG, Inc.
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
23 * Author: Jon Ashburn <jon@lunarg.com>
26 #include "piglit-util-gl.h"
29 const GLubyte Colors
[][8] = {
30 {127, 0, 0, 255, 0, 10, 20, 0},
31 { 0, 127, 0, 255, 0, 0, 80, 90},
32 { 0, 0, 127, 255, 25, 0, 0, 60},
33 { 0, 127, 127, 255, 15, 15, 0, 0},
34 {127, 0, 127, 255, 0, 2, 50, 0},
35 {127, 127, 0, 255, 80, 10, 70, 20},
36 {255, 0, 0, 255, 60, 0, 40, 30},
37 { 0, 255, 0, 255, 50, 20, 2, 40},
38 { 0, 0, 255, 255, 40, 0, 1, 0},
39 { 0, 255, 255, 255, 30, 5, 3, 8},
40 {255, 0, 255, 255, 20, 18, 4, 7},
41 {255, 255, 0, 255, 10, 24, 77, 67},
42 {255, 255, 255, 255, 5, 33, 88, 44}
46 * Create a single-color image. Up to 64 bits per pixel depending upon bytes
49 create_solid_image(GLint w
, GLint h
, GLint d
, const unsigned int bytes
,
50 const unsigned int idx
)
52 GLubyte
*buf
= (GLubyte
*) malloc(w
* h
* d
* bytes
);
55 if (buf
== NULL
|| idx
> (sizeof(Colors
) / bytes
- 1)) {
59 for (i
= 0; i
< w
* h
* d
; i
++) {
60 for (j
= 0; j
< bytes
; j
++) {
61 buf
[i
*bytes
+j
] = Colors
[idx
][j
];
68 * This function takes an array of valid and invalid GLenums. The invalid
69 * enums array starts fully populated and the valid array is empty.
70 * It adds the varargs GLenum values to the valid array and removes them
71 * from the invalid array.
72 * @param numInvalid the size of array invalid
73 * An variable argument equal to zero will signal the end of
74 * the variable parameters.
77 update_valid_arrays(GLenum
*valid
, GLenum
*invalid
, unsigned int numInvalid
,
84 va_start(args
, numInvalid
);
85 val
= va_arg(args
, GLenum
);
89 /* remove the valid enum from the invalid array */
90 for (j
= 0; j
< numInvalid
; j
++) {
91 if (invalid
[j
] == val
)
94 val
= va_arg(args
, GLenum
);
101 * Draw a textured quad, sampling only the given depth of the 3D texture.
102 * Use shader pipeline.
105 draw_3d_depth(float x
, float y
, float w
, float h
, int depth
)
107 const GLfloat vertices
[16] = {x
, y
, depth
, 0.0,
110 x
+w
, y
+h
, depth
, 0.0};
111 const GLfloat texcoords
[8] = {0.0, 0.0,
116 piglit_draw_rect_from_arrays(vertices
, texcoords
, false, 1);