Commit 973a5a30 authored by Chris Forbes's avatar Chris Forbes Committed by Chad Versace

Get rid of reshape funcs

Converts most of the custom reshape funcs to set the projection
in either piglit_init or piglit_display, depending on whether
it depends on the size.

V2: dont introduce unrelated projection changes
Reviewed-by: default avatarChad Versace <chad.versace@linux.intel.com>
parent 5db62cb5
......@@ -109,26 +109,9 @@ piglit_display(void)
return result;
}
static void
reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 50.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -25.0);
}
void
piglit_init(int argc, char **argv)
{
glutReshapeFunc(reshape);
reshape(piglit_width, piglit_height);
piglit_frustum_projection(GL_FALSE, -1.0, 1.0, -1.0, 1.0, 5.0, 50.0);
glTranslatef(0.0, 0.0, -25.0);
}
......@@ -194,23 +194,12 @@ static void test(void)
enum piglit_result
piglit_display(void)
{
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
test();
return PIGLIT_PASS;
}
static void Reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
piglit_ortho_projection(width, height, GL_FALSE);
}
void piglit_init(int argc, char **argv)
{
glutReshapeFunc(Reshape);
Reshape(piglit_width, piglit_height);
}
......@@ -139,6 +139,7 @@ piglit_display(void)
{
int test_pass;
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
test_pass = do_test(0.0f, 0);
......@@ -149,25 +150,11 @@ piglit_display(void)
return test_pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void Reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
piglit_ortho_projection(width, height, GL_FALSE);
}
void
piglit_init(int argc, char **argv)
{
GLint query_bits;
glutReshapeFunc(Reshape);
Reshape(piglit_width, piglit_height);
glClearColor(0.0, 0.2, 0.3, 0.0);
glClearDepth(1.0);
......
......@@ -417,6 +417,8 @@ piglit_display(void)
{
GLboolean pass = GL_TRUE;
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
glClear(GL_COLOR_BUFFER_BIT);
pass = test_lines_no_culling() && pass;
......@@ -431,20 +433,7 @@ piglit_display(void)
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void
reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
piglit_ortho_projection(width, height, GL_FALSE);
}
void
piglit_init(int argc, char **argv)
{
glutReshapeFunc(reshape);
reshape(piglit_width, piglit_height);
}
......@@ -47,25 +47,13 @@ PIGLIT_GL_TEST_MAIN(
} \
} while (0)
static void
reshape(int width, int height)
{
glViewport(0, 0, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
glMatrixMode(GL_MODELVIEW);
}
void
piglit_init(int argc, char **argv)
{
glutReshapeFunc(reshape);
piglit_require_extension("GL_ARB_sync");
glClearColor(0.1, 0.1, 0.3, 0.0);
piglit_gen_ortho_projection(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0, GL_FALSE);
}
GLboolean
......
......@@ -189,20 +189,6 @@ piglit_display(void)
}
}
static void Reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
static void Key(unsigned char key, int x, int y)
{
(void) x;
......@@ -251,7 +237,6 @@ void piglit_init(int argc, char *argv[])
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, GL_FLOAT, TextureData);
glEnable(GL_TEXTURE_2D);
glutReshapeFunc(Reshape);
Reshape(piglit_width, piglit_height);
piglit_ortho_projection(1.0, 1.0, GL_FALSE);
}
......@@ -65,6 +65,8 @@ piglit_display(void)
GLfloat blue[3] = {0.0, 0.0, 1.0};
GLfloat black[3] = {0.0, 0.0, 0.0};
piglit_ortho_projection(1.0, 1.0, GL_FALSE);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
......@@ -130,21 +132,7 @@ piglit_display(void)
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void Reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void
piglit_init(int argc, char *argv[])
{
glutReshapeFunc(Reshape);
}
......@@ -60,6 +60,8 @@ piglit_display(void)
int pass = 1;
unsigned i;
piglit_ortho_projection(2.0, 2.0, GL_FALSE);
glClear(GL_COLOR_BUFFER_BIT);
pglFogCoordf(0.3);
......@@ -112,28 +114,11 @@ piglit_display(void)
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void Reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 2.0, 0.0, 2.0, -2.0, 6.0);
glScalef(1.0, 1.0, -1.0); // flip z-axis
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void
piglit_init(int argc, char **argv)
{
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
glutReshapeFunc(Reshape);
glClearColor(0.3, 0.3, 0.3, 0.3);
if (piglit_get_gl_version() >= 14) {
......@@ -151,6 +136,4 @@ piglit_init(int argc, char **argv)
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog);
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
Reshape(piglit_width, piglit_height);
}
......@@ -184,20 +184,6 @@ piglit_display(void)
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void Reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 3.0, 0.0, 2.0, -2.0, 6.0);
glScalef(1.0, 1.0, -1.0); // flip z-axis
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void
piglit_init(int argc, char **argv)
{
......@@ -205,13 +191,11 @@ piglit_init(int argc, char **argv)
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
glutReshapeFunc(Reshape);
piglit_require_fragment_program();
for(i = 0; i < NUM_PROGRAMS; ++i)
FragProg[i] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, ProgramText[i]);
Reshape(piglit_width, piglit_height);
piglit_gen_ortho_projection(0.0, 3.0, 0.0, 2.0, -2.0, 6.0, GL_FALSE);
}
......@@ -251,6 +251,8 @@ piglit_display(void)
{
int pass;
piglit_gen_ortho_projection(0.0, 2.0, 0.0, 2.0, -2.0, 6.0, GL_FALSE);
DoFrame();
pass = DoTest();
piglit_present_results();
......@@ -258,28 +260,12 @@ piglit_display(void)
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void Reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 2.0, 0.0, 2.0, -2.0, 6.0);
glScalef(1.0, 1.0, -1.0); // flip z-axis
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void
piglit_init(int argc, char **argv)
{
int i, x, y;
GLubyte tex[4][4][4];
glutReshapeFunc(Reshape);
if (piglit_get_gl_version() < 13) {
printf("Requires OpenGL 1.3\n");
piglit_report_result(PIGLIT_SKIP);
......@@ -315,6 +301,4 @@ piglit_init(int argc, char **argv)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
Reshape(piglit_width, piglit_height);
}
......@@ -119,25 +119,10 @@ piglit_display(void)
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void Reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 4.0, 0.0, 4.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void piglit_init(int argc, char **argv)
{
int mask;
glutReshapeFunc(Reshape);
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
piglit_require_fragment_program();
......@@ -159,5 +144,5 @@ void piglit_init(int argc, char **argv)
FragProg[mask-1] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, programText);
}
Reshape(piglit_width, piglit_height);
piglit_ortho_projection(4.0, 4.0, GL_FALSE);
}
......@@ -113,25 +113,10 @@ piglit_display(void)
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void Reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 4.0, 0.0, 4.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void piglit_init(int argc, char **argv)
{
int mask;
glutReshapeFunc(Reshape);
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
piglit_require_fragment_program();
......@@ -153,5 +138,5 @@ void piglit_init(int argc, char **argv)
FragProg[mask-1] = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, programText);
}
Reshape(piglit_width, piglit_height);
piglit_ortho_projection(4.0, 4.0, GL_FALSE);
}
......@@ -374,20 +374,6 @@ extern "C" piglit_result piglit_display(void)
return tests.run() ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void Reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
extern "C" void piglit_init(int argc, char **argv)
{
int i;
......@@ -421,6 +407,5 @@ extern "C" void piglit_init(int argc, char **argv)
if (tests.nv_vertex_program)
piglit_require_extension("GL_NV_vertex_program");
glutReshapeFunc(Reshape);
Reshape(piglit_width, piglit_height);
piglit_ortho_projection(1.0, 1.0, GL_FALSE);
}
......@@ -159,11 +159,6 @@ piglit_display(void)
piglit_present_results();
printf("\nSecond frame\n------------\n");
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( 0, 3*(NUM_TESTS+1), -1.5, 1.5, -1, 1 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
DoFrame();
retry = DoTest();
......@@ -176,20 +171,6 @@ piglit_display(void)
}
}
static void Reshape( int width, int height )
{
piglit_width = width;
piglit_height = height;
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( 0, 3*(NUM_TESTS+1), -1.5, 1.5, -1, 1 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}
void piglit_init(int argc, char **argv)
{
const char * const ver_string = (const char * const)
......@@ -198,7 +179,7 @@ void piglit_init(int argc, char **argv)
GLint tex_units;
GLint temp[ 256 ];
glutReshapeFunc(Reshape);
piglit_gen_ortho_projection( 0, 3*(NUM_TESTS+1), -1.5, 1.5, -1, 1, GL_FALSE );
if ( (!piglit_is_extension_supported("GL_ARB_multitexture")
&& (ver < 1.3))
......
......@@ -501,6 +501,8 @@ piglit_display(void)
{
GLboolean pass;
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
if (piglit_automatic) {
pass = test_all_formats();
}
......@@ -520,21 +522,6 @@ piglit_display(void)
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void
reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, piglit_width, 0, piglit_height, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void
piglit_init(int argc, char **argv)
{
......@@ -548,11 +535,6 @@ piglit_init(int argc, char **argv)
fbo_formats_init(argc, argv, 0);
(void) fbo_formats_display;
glutReshapeFunc(reshape);
/*glutKeyboardFunc(key);*/
reshape(piglit_width, piglit_height);
glGenTextures(1, &t);
glBindTexture(GL_TEXTURE_2D, t);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
......
......@@ -66,25 +66,10 @@ piglit_display(void)
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void Reshape(int width, int height)
{
piglit_width = width;
piglit_height = height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -2.0, 6.0);
glScalef(1.0, 1.0, -1.0); // flip z-axis
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void piglit_init(int argc, char **argv)
{
int i;
glutReshapeFunc(Reshape);
for(i = 0; i < 4096; ++i)
data[i] = rand() & 0xff;
......@@ -92,5 +77,5 @@ void piglit_init(int argc, char **argv)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
Reshape(piglit_width, piglit_height);
piglit_gen_ortho_projection(0.0, 1.0, 0.0, 1.0, -2.0, 6.0, GL_FALSE);
}
......@@ -93,6 +93,8 @@ piglit_display(void)
float c1[4] = {0.25, 0.25, 0.25, 1.0};
float c2[4] = {0.75, 0.75, 0.75, 1.0};
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &maxsize);
/* Create the texture. */
......@@ -184,14 +186,6 @@ piglit_display(void)
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
static void Reshape(int width, int height)
{
glViewport(0, 0, piglit_width, piglit_height);
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
}
void piglit_init(int argc, char **argv)
{
if (piglit_get_gl_version() < 12) {
......@@ -199,8 +193,6 @@ void piglit_init(int argc, char **argv)
piglit_report_result(PIGLIT_SKIP);
}
glutReshapeFunc(Reshape);
glDisable(GL_DITHER);
Reshape(piglit_width, piglit_height);
}
......@@ -200,6 +200,8 @@ piglit_display(void)
GLenum formats[] = { GL_RGBA, GL_RGB, GL_ALPHA };
int w, h, d, fmt;
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
for(fmt = 0; fmt < sizeof(formats)/sizeof(formats[0]); ++fmt) {
for(w = 3; w <= 15; w++) {
if (w != 4 && w != 8) {
......@@ -219,25 +221,14 @@ piglit_display(void)
return PIGLIT_PASS;
}
static void Reshape(int width, int height)
{
glViewport(0, 0, piglit_width, piglit_height);
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
}
void
piglit_init(int argc, char **argv)
{
piglit_automatic = GL_TRUE;
piglit_require_extension("GL_ARB_texture_non_power_of_two");
glutReshapeFunc(Reshape);
glDisable(GL_DITHER);
glGenTextures(1, &Texture);
glBindTexture(GL_TEXTURE_3D, Texture);