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 DEALINGS
24 * Chris Lord <chris@openedhand.com>
25 * Eric Anholt <eric@anholt.net>
29 /** @file fxt1-teximage.c
31 * Tests that a full 3DFX FXT1-compressed mipmap tree can be created
35 #include "piglit-util-gl.h"
37 PIGLIT_GL_TEST_CONFIG_BEGIN
39 config
.supports_gl_compat_version
= 10;
41 config
.window_width
= 300;
42 config
.window_height
= 300;
43 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
44 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
46 PIGLIT_GL_TEST_CONFIG_END
50 const float red
[4] = {1.0, 0.0, 0.0, 1.0};
51 const float green
[4] = {0.0, 1.0, 0.0, 1.0};
52 const float blue
[4] = {0.0, 0.0, 1.0, 1.0};
53 const float white
[4] = {1.0, 1.0, 1.0, 1.0};
56 display_mipmaps(int start_x
, int start_y
)
60 glEnable(GL_TEXTURE_2D
);
62 /* Display all the mipmap levels */
63 for (i
= SIZE
; i
> 0; i
/= 2) {
65 glTexCoord2f(0.0, 0.0); glVertex2f(start_x
+ 0, start_y
+ 0);
66 glTexCoord2f(1.0, 0.0); glVertex2f(start_x
+ i
, start_y
+ 0);
67 glTexCoord2f(1.0, 1.0); glVertex2f(start_x
+ i
, start_y
+ i
);
68 glTexCoord2f(0.0, 1.0); glVertex2f(start_x
+ 0, start_y
+ i
);
77 check_resulting_mipmaps(int x
, int y
)
79 GLboolean pass
= GL_TRUE
;
82 for (size
= SIZE
; size
> 0; size
/= 2) {
84 pass
= pass
&& piglit_probe_pixel_rgb(x
+ 2, y
+ 2,
87 pass
= pass
&& piglit_probe_pixel_rgb(x
+ 1, y
+ 1,
90 pass
= pass
&& piglit_probe_pixel_rgb(x
, y
,
93 pass
= pass
&& piglit_probe_pixel_rgb(x
+ size
/ 4,
96 pass
= pass
&& piglit_probe_pixel_rgb(x
+ size
* 3 / 4,
99 pass
= pass
&& piglit_probe_pixel_rgb(x
+ size
/ 4,
102 pass
= pass
&& piglit_probe_pixel_rgb(x
+ size
* 3 / 4,
116 GLboolean pass
= GL_TRUE
;
118 glClearColor(0, 0, 0, 0);
119 glClear(GL_COLOR_BUFFER_BIT
);
121 tex
= piglit_rgbw_texture(GL_COMPRESSED_RGB_FXT1_3DFX
, SIZE
, SIZE
,
122 GL_TRUE
, GL_FALSE
, GL_UNSIGNED_NORMALIZED
);
123 display_mipmaps(10, 10 + (10 + SIZE
) * 0);
124 glDeleteTextures(1, &tex
);
125 tex
= piglit_rgbw_texture(GL_COMPRESSED_RGBA_FXT1_3DFX
, SIZE
, SIZE
,
126 GL_TRUE
, GL_FALSE
, GL_UNSIGNED_NORMALIZED
);
127 display_mipmaps(10, 10 + (10 + SIZE
) * 1);
128 glDeleteTextures(1, &tex
);
130 pass
= pass
&& check_resulting_mipmaps(10, 10 + (10 + SIZE
) * 0);
131 pass
= pass
&& check_resulting_mipmaps(10, 10 + (10 + SIZE
) * 1);
133 piglit_present_results();
135 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
139 piglit_init(int argc
, char **argv
)
141 piglit_require_extension("GL_3DFX_texture_compression_FXT1");
143 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);