summaryrefslogtreecommitdiff
path: root/tests/shaders/vp-bad-program.c
diff options
context:
space:
mode:
authorNicolai Haehnle <nhaehnle@gmail.com>2008-06-20 11:13:33 +0200
committerNicolai Haehnle <nhaehnle@gmail.com>2008-06-20 11:13:33 +0200
commitad03bd4dfe2030fc0b0fbfaad240e7d60b0d9b9f (patch)
tree8cab8a0a51304847205298215b478576bb1b2638 /tests/shaders/vp-bad-program.c
parent46c346ff3488c2edb3e734f4bec179c3f95bdc84 (diff)
Various fixes by Brian Paul.
Quote from his description: In fp-fragment-position.c the 4th fragment program uses fragment.position to index a 2D texture. Since all the fragment positions are integers > 1 the default GL_REPEAT texture wrap mode converts all the texcoords to zero. Actually, though, that's not true. Because of the way texcoords are processed, the fractional part of the coords is not always zero but some epsilon value. That caused us to sample with different texcoords than the test expects. I think it's more useful to scale the fragment position to put it into the nominal [0,1] range to get a color that varies per pixel. My patch does that, and adds some assorted comments to the code. --- In fp-list-mask.c and texrect-many.c and texdepth.c I added GLUT_ALPHA to glutInitDisplayMode(). We had failures because GLUT was sometimes choosing visuals without an alpha channel. --- < The logic in vp-bad-program.c was incorrect. When glProgramString() is called with an invalid program, we raise an error, but the previous program (if any) stays in effect. So the subsequent glBegin() would never raise an error. The proper way to check for glBegin raising an error with an invalid program is to simply bind a non-existant program. I made the same fix in glean a while ago. There's still some other failures I need to look into (and I'm not sure where the faults are) but I need to move onto some other things now.
Diffstat (limited to 'tests/shaders/vp-bad-program.c')
-rw-r--r--tests/shaders/vp-bad-program.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/shaders/vp-bad-program.c b/tests/shaders/vp-bad-program.c
index 2d06c7931..2e00cfa58 100644
--- a/tests/shaders/vp-bad-program.c
+++ b/tests/shaders/vp-bad-program.c
@@ -51,6 +51,7 @@ static int automatic = 0;
#define WIN_HEIGHT 128
static PFNGLPROGRAMSTRINGARBPROC pglProgramStringARB;
+static PFNGLBINDPROGRAMARBPROC pglBindProgramARB;
static void
display(void)
@@ -86,8 +87,11 @@ display(void)
}
/* Check that we correctly produce GL_INVALID_OPERATION when rendering
- * with the bad program string.
+ * with an invalid/non-existant program.
*/
+ pglBindProgramARB(GL_VERTEX_PROGRAM_ARB, 99);
+ glEnable(GL_VERTEX_PROGRAM_ARB);
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_POLYGON);
glTexCoord2f(0, 0); glVertex2f(-0.25, -0.25);
@@ -108,7 +112,7 @@ display(void)
}
/* Check that we correctly produce GL_INVALID_OPERATION when doing
- * glDrawArrays with the bad program string.
+ * glDrawArrays with an invalid/non-existant program.
*/
glVertexPointer(3, GL_FLOAT, 0, vertcoords);
@@ -154,6 +158,9 @@ main(int argc, char**argv)
pglProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) glutGetProcAddress("glProgramStringARB");
assert(pglProgramStringARB);
+ pglBindProgramARB = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress("glBindProgramARB");
+ assert(pglBindProgramARB);
+
glutMainLoop();
return 0;
}