Commit f1998923 authored by Ian Romanick's avatar Ian Romanick

Use GLEW for vp / fp code instead of piglit "pgl" wrappers

parent c645c25d
......@@ -60,10 +60,10 @@ void piglit_init(int argc, char ** argv)
program_object = piglit_compile_program(GL_VERTEX_PROGRAM_ARB, program_text);
pglBindProgramARB(GL_VERTEX_PROGRAM_ARB, program_object);
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, program_object);
printf("Testing whether the following call crashes...\n");
pglGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &result);
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &result);
piglit_report_result(PIGLIT_SUCCESS);
}
......@@ -207,7 +207,7 @@ static void Init(void)
if (piglit_use_fragment_program()) {
UseFragmentProgram = 1;
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB,
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB,
piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, TextureFP));
}
......
......@@ -90,7 +90,7 @@ static void DoFrame(void)
glEnable(GL_FRAGMENT_PROGRAM_ARB);
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[0]);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[0]);
glBegin(GL_QUADS);
glVertex3f(0, 0, 0);
......@@ -99,7 +99,7 @@ static void DoFrame(void)
glVertex3f(0, 1, 1);
glEnd();
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[1]);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[1]);
glBegin(GL_QUADS);
glVertex2f(0, 1);
......@@ -108,7 +108,7 @@ static void DoFrame(void)
glVertex2f(0, 2);
glEnd();
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[2]);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[2]);
glBegin(GL_QUADS);
glVertex2f(1, 0);
......@@ -117,7 +117,7 @@ static void DoFrame(void)
glVertex2f(1, 1);
glEnd();
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[3]);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[3]);
glBegin(GL_QUADS);
glVertex2f(1, 1);
......
......@@ -156,7 +156,7 @@ static void TestInstance(struct testinstance* instance)
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg);
for(i = 0; i < Testcase.nrTexCoords; ++i)
glMultiTexCoord4fv(GL_TEXTURE0+i, instance->texcoords + 4*i);
......
......@@ -67,7 +67,7 @@ static void DoFrame(void)
glEnable(GL_FRAGMENT_PROGRAM_ARB);
for(i = 0; i < NUM_PROGRAMS; ++i) {
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[i]);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[i]);
glPushMatrix();
glTranslatef(i/2, i%2, 0);
......
......@@ -34,9 +34,7 @@ static int get_program_i(GLenum pname)
{
GLint val;
pglGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
pname,
&val);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, pname, &val);
return val;
}
......@@ -92,7 +90,7 @@ static char *gen_temporary_dest_indirections(int sample_count,
}
*progname = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, prog);
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, *progname);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, *progname);
return prog;
}
......@@ -151,7 +149,7 @@ static char *gen_temporary_source_indirections(int sample_count,
strcat(prog, post);
*progname = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, prog);
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, *progname);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, *progname);
return prog;
}
......
......@@ -176,13 +176,13 @@ static int test(unsigned int dim, unsigned int samples)
program_object = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, program_text);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, program_object);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, program_object);
draw_height = TEXTURE_SIZE;
piglit_draw_rect_tex(0, 0, TEXTURE_SIZE, draw_height, 0, 0, 1, 1);
glDisable(GL_FRAGMENT_PROGRAM_ARB);
pglDeleteProgramsARB(1, &program_object);
glDeleteProgramsARB(1, &program_object);
for(y = 0; y < draw_height; ++y) {
for(x = 0; x < TEXTURE_SIZE; ++x) {
......@@ -238,12 +238,12 @@ void piglit_init(int argc, char ** argv)
piglit_require_fragment_program();
pglGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB,
&max_native_tex_instructions);
pglGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB,
&max_native_tex_indirections);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB,
&max_native_tex_instructions);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB,
&max_native_tex_indirections);
printf("Max TEX instructions / TEX indirections: %i / %i\n",
max_native_tex_instructions,
......
......@@ -56,7 +56,7 @@ static void DoFrame(void)
glEnable(GL_FRAGMENT_PROGRAM_ARB);
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[0]);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[0]);
glColor3f(0.0, 1.0, 0.0);
glBegin(GL_QUADS);
......@@ -70,7 +70,7 @@ static void DoFrame(void)
glVertex2f(0, 1);
glEnd();
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[1]);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[1]);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
......
......@@ -51,7 +51,7 @@ static void DoFrame(void)
glEnable(GL_FRAGMENT_PROGRAM_ARB);
for(mask = 1; mask < 16; ++mask) {
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[mask-1]);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, FragProg[mask-1]);
glPushMatrix();
glTranslatef((mask % 4), (mask / 4), 0.0);
......
......@@ -107,12 +107,12 @@ static enum piglit_result test(unsigned int alu_depth)
program_object = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, program_text);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, program_object);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, program_object);
piglit_draw_rect(0, 0, 32, 32);
glDisable(GL_FRAGMENT_PROGRAM_ARB);
pglDeleteProgramsARB(1, &program_object);
glDeleteProgramsARB(1, &program_object);
expected[0] = (alu_depth % 16) * 0.0625;
expected[1] = ((alu_depth/16) % 16) * 0.0625;
......@@ -174,9 +174,9 @@ void piglit_init(int argc, char ** argv)
{
piglit_require_fragment_program();
pglGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB,
&max_alu_instructions);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB,
&max_alu_instructions);
printf("Max (native) ALU instructions: %i\n",
max_alu_instructions);
......
......@@ -88,7 +88,7 @@ static void DoFrame(void)
glEnable(GL_FRAGMENT_PROGRAM_ARB);
for(i = 0; i < 3; ++i)
pglProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i, Local[i]);
glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i, Local[i]);
glBegin(GL_QUADS);
glVertex2f(0.75, 0.75);
......@@ -99,7 +99,7 @@ static void DoFrame(void)
glEnable(GL_FRAGMENT_PROGRAM_ARB);
for(i = 0; i < 3; ++i)
pglProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i, Local2[i]);
glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i, Local2[i]);
glBegin(GL_QUADS);
glVertex2f(1.75, 0.75);
......
......@@ -56,10 +56,10 @@ piglit_display(void)
GLenum err;
/* Try the bad vertex program, and make sure we get an error */
pglProgramStringARB(GL_VERTEX_PROGRAM_ARB,
GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(badprog),
(const GLubyte *) badprog);
glProgramStringARB(GL_VERTEX_PROGRAM_ARB,
GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(badprog),
(const GLubyte *) badprog);
err = glGetError();
if (err != GL_INVALID_OPERATION) {
......@@ -75,7 +75,7 @@ piglit_display(void)
/* Check that we correctly produce GL_INVALID_OPERATION when rendering
* with an invalid/non-existant program.
*/
pglBindProgramARB(GL_VERTEX_PROGRAM_ARB, 99);
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 99);
glEnable(GL_VERTEX_PROGRAM_ARB);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
......
......@@ -95,7 +95,7 @@ struct ParameterLocal : TestParameter {
}
void setup() {
pglProgramLocalParameter4fvARB(target, index, data);
glProgramLocalParameter4fvARB(target, index, data);
}
GLenum target;
......@@ -203,13 +203,13 @@ bool TestGroup::run()
GLuint fragprog = piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, fragment_program_code.c_str());
glEnable(GL_FRAGMENT_PROGRAM_ARB);
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fragprog);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fragprog);
if (!nv_vertex_program) {
GLuint vertprog = piglit_compile_program(GL_VERTEX_PROGRAM_ARB, vertex_program_code.c_str());
glEnable(GL_VERTEX_PROGRAM_ARB);
pglBindProgramARB(GL_VERTEX_PROGRAM_ARB, vertprog);
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vertprog);
} else {
GLuint vertprog;
......
......@@ -132,7 +132,7 @@ piglit_report_result(enum piglit_result result)
void piglit_require_extension(const char *name)
{
if (!glutExtensionSupported(name)) {
if (!glewIsSupported(name)) {
piglit_report_result(PIGLIT_SKIP);
exit(1);
}
......@@ -205,46 +205,6 @@ int piglit_probe_pixel_rgb(int x, int y, const float* expected)
}
PFNGLGENPROGRAMSARBPROC pglGenProgramsARB = 0;
PFNGLPROGRAMSTRINGARBPROC pglProgramStringARB = 0;
PFNGLBINDPROGRAMARBPROC pglBindProgramARB = 0;
PFNGLISPROGRAMARBPROC pglIsProgramARB = 0;
PFNGLDELETEPROGRAMSARBPROC pglDeleteProgramsARB = 0;
PFNGLPROGRAMLOCALPARAMETER4FVARBPROC pglProgramLocalParameter4fvARB = 0;
PFNGLPROGRAMLOCALPARAMETER4DARBPROC pglProgramLocalParameter4dARB = 0;
PFNGLGETPROGRAMIVARBPROC pglGetProgramivARB = 0;
PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC pglGetProgramLocalParameterdvARB = 0;
static void get_program_functions(void)
{
pglGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) piglit_get_proc_address("glGenProgramsARB");
assert(pglGenProgramsARB);
pglProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) piglit_get_proc_address("glProgramStringARB");
assert(pglProgramStringARB);
pglBindProgramARB = (PFNGLBINDPROGRAMARBPROC) piglit_get_proc_address("glBindProgramARB");
assert(pglBindProgramARB);
pglIsProgramARB = (PFNGLISPROGRAMARBPROC) piglit_get_proc_address("glIsProgramARB");
assert(pglIsProgramARB);
pglDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC) piglit_get_proc_address("glDeleteProgramsARB");
assert(pglDeleteProgramsARB);
pglProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) piglit_get_proc_address("glProgramLocalParameter4fvARB");
assert(pglProgramLocalParameter4fvARB);
pglProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) piglit_get_proc_address("glProgramLocalParameter4dARB");
assert(pglProgramLocalParameter4dARB);
pglGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) piglit_get_proc_address("glGetProgramLocalParameterdvARB");
assert(pglGetProgramLocalParameterdvARB);
pglGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) piglit_get_proc_address("glGetProgramivARB");
assert(pglGetProgramivARB);
}
int piglit_use_fragment_program(void)
{
static const char source[] =
......@@ -253,11 +213,9 @@ int piglit_use_fragment_program(void)
"END\n"
;
if (!glutExtensionSupported("GL_ARB_fragment_program"))
if (!GLEW_ARB_fragment_program)
return 0;
get_program_functions();
piglit_ARBfp_pass_through =
piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, source);
......@@ -275,11 +233,7 @@ void piglit_require_fragment_program(void)
int piglit_use_vertex_program(void)
{
if (!glutExtensionSupported("GL_ARB_vertex_program"))
return 0;
get_program_functions();
return 1;
return GLEW_ARB_vertex_program;
}
void piglit_require_vertex_program(void)
......@@ -296,9 +250,9 @@ GLuint piglit_compile_program(GLenum target, const char* text)
GLuint program;
GLint errorPos;
pglGenProgramsARB(1, &program);
pglBindProgramARB(target, program);
pglProgramStringARB(
glGenProgramsARB(1, &program);
glBindProgramARB(target, program);
glProgramStringARB(
target,
GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(text),
......@@ -323,8 +277,8 @@ GLuint piglit_compile_program(GLenum target, const char* text)
fprintf(stderr, "\nin program:\n%s", text);
piglit_report_result(PIGLIT_FAILURE);
}
if (!pglIsProgramARB(program)) {
fprintf(stderr, "pglIsProgramARB failed\n");
if (!glIsProgramARB(program)) {
fprintf(stderr, "glIsProgramARB failed\n");
piglit_report_result(PIGLIT_FAILURE);
}
......
......@@ -73,28 +73,6 @@ void piglit_require_extension(const char *name);
int piglit_probe_pixel_rgb(int x, int y, const float* expected);
int piglit_probe_pixel_rgba(int x, int y, const float* expected);
#if defined(__APPLE__)
extern void (*pglGenProgramsARB)(GLsizei n, GLuint *programs);
extern void (*pglProgramStringARB)(GLenum target, GLenum format, GLsizei len, const GLvoid *string);
extern void (*pglBindProgramARB)(GLenum target, GLuint program);
extern GLboolean (*pglIsProgramARB)(GLuint program);
extern void (*pglDeleteProgramsARB)(GLsizei n, const GLuint *programs);
extern void (*pglProgramLocalParameter4fvARB)(GLenum target, GLuint index, const GLfloat *params);
extern void (*pglProgramLocalParameter4dARB)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
extern void (*pglGetProgramivARB)(GLenum target, GLenum pname, GLint *params);
extern void (*pglGetProgramLocalParameterdvARB)(GLenum target, GLuint index, GLdouble *params);
#else
extern PFNGLGENPROGRAMSARBPROC pglGenProgramsARB;
extern PFNGLPROGRAMSTRINGARBPROC pglProgramStringARB;
extern PFNGLBINDPROGRAMARBPROC pglBindProgramARB;
extern PFNGLISPROGRAMARBPROC pglIsProgramARB;
extern PFNGLDELETEPROGRAMSARBPROC pglDeleteProgramsARB;
extern PFNGLPROGRAMLOCALPARAMETER4FVARBPROC pglProgramLocalParameter4fvARB;
extern PFNGLPROGRAMLOCALPARAMETER4DARBPROC pglProgramLocalParameter4dARB;
extern PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC pglGetProgramLocalParameterdvARB;
extern PFNGLGETPROGRAMIVARBPROC pglGetProgramivARB;
#endif
int piglit_use_fragment_program(void);
int piglit_use_vertex_program(void);
void piglit_require_fragment_program(void);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment