2 * Copyright (c) The Piglit project 2007
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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * According to the ARB_fragment_program spec, section 3.11.6,
26 * sampling an incomplete texture image yields (0,0,0,1).
29 #include "piglit-util.h"
31 int piglit_width
= 100, piglit_height
= 100;
32 int piglit_window_mode
= GLUT_RGBA
| GLUT_ALPHA
| GLUT_DOUBLE
| GLUT_DEPTH
;
34 #define NUM_PROGRAMS 5
36 static GLuint FragProg
[NUM_PROGRAMS
];
38 static const char* const ProgramText
[NUM_PROGRAMS
] = {
40 "TEX result.color, fragment.color, texture[0], 2D;\n"
44 "TEX result.color, fragment.color, texture[0], 3D;\n"
48 "TEX result.color, fragment.color, texture[0], 1D;\n"
52 "TEX result.color, fragment.color, texture[0], CUBE;\n"
56 "TEX result.color, fragment.color, texture[0], RECT;\n"
60 static void DoFrame(void)
64 glClearColor(0.3, 0.3, 0.3, 0.3);
65 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
67 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
69 for(i
= 0; i
< NUM_PROGRAMS
; ++i
) {
70 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, FragProg
[i
]);
73 glTranslatef(i
/2, i
%2, 0);
131 static int DoTest( void )
136 glReadBuffer( GL_FRONT
);
140 while(Probes
[idx
].name
) {
145 glReadPixels((int)(Probes
[idx
].x
* piglit_width
/ 3),
146 (int)(Probes
[idx
].y
* piglit_height
/ 2),
148 GL_RGBA
, GL_FLOAT
, probe
);
150 printf("%20s (%3.1f,%3.1f): %f,%f,%f,%f",
152 Probes
[idx
].x
, Probes
[idx
].y
,
153 probe
[0], probe
[1], probe
[2], probe
[3]);
155 for(i
= 0; i
< 4; ++i
) {
156 delta
[i
] = probe
[i
] - Probes
[idx
].expected
[i
];
158 if (delta
[i
] > dmax
) dmax
= delta
[i
];
159 else if (-delta
[i
] > dmax
) dmax
= -delta
[i
];
162 printf(" Delta: %f,%f,%f,%f\n", delta
[0], delta
[1], delta
[2], delta
[3]);
167 printf("Max delta: %f\n", dmax
);
184 return pass
? PIGLIT_SUCCESS
: PIGLIT_FAILURE
;
188 static void Reshape(int width
, int height
)
190 piglit_width
= width
;
191 piglit_height
= height
;
192 glViewport(0, 0, width
, height
);
193 glMatrixMode(GL_PROJECTION
);
195 glOrtho(0.0, 3.0, 0.0, 2.0, -2.0, 6.0);
196 glScalef(1.0, 1.0, -1.0); // flip z-axis
197 glMatrixMode(GL_MODELVIEW
);
202 piglit_init(int argc
, char **argv
)
206 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
208 glutReshapeFunc(Reshape
);
210 piglit_require_fragment_program();
212 for(i
= 0; i
< NUM_PROGRAMS
; ++i
)
213 FragProg
[i
] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB
, ProgramText
[i
]);
215 Reshape(piglit_width
, piglit_height
);