summaryrefslogtreecommitdiff
path: root/progs/tests
diff options
context:
space:
mode:
Diffstat (limited to 'progs/tests')
-rw-r--r--progs/tests/.gitignore6
-rw-r--r--progs/tests/Makefile53
-rw-r--r--progs/tests/antialias.c12
-rw-r--r--progs/tests/cva.c8
-rw-r--r--progs/tests/dinoshade.c6
-rw-r--r--progs/tests/exactrast.c200
-rw-r--r--progs/tests/fbotexture.c70
-rw-r--r--progs/tests/lineclip.c175
-rw-r--r--progs/tests/multipal.c6
-rw-r--r--progs/tests/shader_api.c337
-rw-r--r--progs/tests/stencil_twoside.c299
-rw-r--r--progs/tests/texline.c12
-rw-r--r--progs/tests/unfilledclip.c205
13 files changed, 1332 insertions, 57 deletions
diff --git a/progs/tests/.gitignore b/progs/tests/.gitignore
index 40cb6850fb..c5b9e28dab 100644
--- a/progs/tests/.gitignore
+++ b/progs/tests/.gitignore
@@ -26,6 +26,7 @@ cva
dinoshade
drawbuffers
extfuncs.h
+exactrast
fbotest1
fbotest2
fbotexture
@@ -40,6 +41,7 @@ getproclist.h
interleave
invert
jkrahntest
+lineclip
manytex
minmag
mipmap_limits
@@ -56,6 +58,9 @@ readtex.c
readtex.h
seccolor
sharedtex
+shader_api
+stencil_twoside
+stencil_wrap
stencilwrap
stencil_wrap
subtex
@@ -69,6 +74,7 @@ texline
texobjshare
texrect
texwrap
+unfilledclip
vao-01
vao-02
vparray
diff --git a/progs/tests/Makefile b/progs/tests/Makefile
index 7e8c0c8e34..b111154512 100644
--- a/progs/tests/Makefile
+++ b/progs/tests/Makefile
@@ -8,7 +8,7 @@ TOP = ../..
include $(TOP)/configs/current
-LIBS = $(APP_LIB_DEPS)
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
SOURCES = \
afsmultiarb.c \
@@ -37,6 +37,7 @@ SOURCES = \
cva.c \
dinoshade.c \
drawbuffers.c \
+ exactrast.c \
floattex.c \
fbotest1.c \
fbotest2.c \
@@ -50,6 +51,7 @@ SOURCES = \
interleave.c \
invert.c \
jkrahntest.c \
+ lineclip.c \
manytex.c \
minmag.c \
mipmap_limits.c \
@@ -63,7 +65,9 @@ SOURCES = \
random.c \
readrate.c \
seccolor.c \
+ shader_api.c \
sharedtex.c \
+ stencil_twoside.c \
stencilwrap.c \
stencil_wrap.c \
subtex \
@@ -75,6 +79,7 @@ SOURCES = \
texobjshare.c \
texrect.c \
texwrap.c \
+ unfilledclip.c \
vao-01.c \
vao-02.c \
vparray.c \
@@ -96,13 +101,22 @@ INCLUDES = -I. -I$(TOP)/include
UTIL_FILES = readtex.h readtex.c
+##### TARGETS #####
+
+default: $(UTIL_FILES) $(PROGS)
+
+clean:
+ -rm -f $(PROGS)
+ -rm -f *.o
+ -rm -f getproclist.h
+
##### RULES #####
.SUFFIXES:
.SUFFIXES: .c
.c:
- $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@
+ $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
@@ -110,17 +124,6 @@ UTIL_FILES = readtex.h readtex.c
.S.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
-
-##### TARGETS #####
-
-default: $(UTIL_FILES) $(PROGS)
-
-clean:
- rm -f $(PROGS)
- rm -f *.o
- rm -f getproclist.h
-
-
# auto code generation
getprocaddress: getprocaddress.c getproclist.h
@@ -131,37 +134,37 @@ arraytexture: arraytexture.o readtex.o
$(CC) $(CFLAGS) arraytexture.o readtex.o $(LIBS) -o $@
arraytexture.o: arraytexture.c readtex.h
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) arraytexture.c -o $@
afsmultiarb: afsmultiarb.o readtex.o
- $(CC) $(CFLAGS) afsmultiarb.o readtex.o $(LIBS) -o $@
+ $(CC) $(CFLAGS) $(LDFLAGS) afsmultiarb.o readtex.o $(LIBS) -o $@
afsmultiarb.o: afsmultiarb.c readtex.h
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) afsmultiarb.c -o $@
drawbuffers: drawbuffers.o
- $(CC) $(CFLAGS) drawbuffers.o $(LIBS) -o $@
+ $(CC) $(CFLAGS) $(LDFLAGS) drawbuffers.o $(LIBS) -o $@
drawbuffers.o: drawbuffers.c extfuncs.h
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) drawbuffers.c -o $@
texrect: texrect.o readtex.o
- $(CC) $(CFLAGS) texrect.o readtex.o $(LIBS) -o $@
+ $(CC) $(CFLAGS) $(LDFLAGS) texrect.o readtex.o $(LIBS) -o $@
texrect.o: texrect.c readtex.h
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) texrect.c -o $@
bug_3195: bug_3195.o readtex.o
- $(CC) $(CFLAGS) bug_3195.o readtex.o $(LIBS) -o $@
+ $(CC) $(CFLAGS) $(LDFLAGS) bug_3195.o readtex.o $(LIBS) -o $@
bug_3195.o: bug_3195.c readtex.h
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) bug_3195.c -o $@
invert: invert.o readtex.o
- $(CC) $(CFLAGS) invert.o readtex.o $(LIBS) -o $@
+ $(CC) $(CFLAGS) $(LDFLAGS) invert.o readtex.o $(LIBS) -o $@
invert.o: invert.c readtex.h
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) invert.c -o $@
mipmap_view: mipmap_view.o readtex.o
$(CC) $(CFLAGS) mipmap_view.o readtex.o $(LIBS) -o $@
@@ -179,7 +182,7 @@ fillrate.o: fillrate.c readtex.h
readtex.o: readtex.c
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) readtex.c -o $@
readtex.h: $(TOP)/progs/util/readtex.h
diff --git a/progs/tests/antialias.c b/progs/tests/antialias.c
index 3a83c34b8d..f23b5aff32 100644
--- a/progs/tests/antialias.c
+++ b/progs/tests/antialias.c
@@ -15,6 +15,7 @@
static GLfloat Zrot = 0;
static GLboolean Anim = GL_TRUE;
static GLboolean HaveMultisample = GL_TRUE;
+static GLboolean DoMultisample = GL_TRUE;
static void
@@ -85,7 +86,10 @@ Display( void )
glColor3f(1, 1, 1);
if (HaveMultisample) {
glRasterPos2f(-3.1, -1.6);
- PrintString("MULTISAMPLE");
+ if (DoMultisample)
+ PrintString("MULTISAMPLE");
+ else
+ PrintString("MULTISAMPLE (off)");
}
glRasterPos2f(-0.8, -1.6);
PrintString("No antialiasing");
@@ -95,7 +99,8 @@ Display( void )
/* multisample */
if (HaveMultisample) {
glEnable(GL_DEPTH_TEST);
- glEnable(GL_MULTISAMPLE_ARB);
+ if (DoMultisample)
+ glEnable(GL_MULTISAMPLE_ARB);
glPushMatrix();
glTranslatef(-2.5, 0, 0);
glPushMatrix();
@@ -172,6 +177,9 @@ Key( unsigned char key, int x, int y )
else
glutIdleFunc(NULL);
break;
+ case 'm':
+ DoMultisample = !DoMultisample;
+ break;
case 'z':
Zrot = (int) (Zrot - step);
break;
diff --git a/progs/tests/cva.c b/progs/tests/cva.c
index a47b2a9319..a9393aef0c 100644
--- a/progs/tests/cva.c
+++ b/progs/tests/cva.c
@@ -10,17 +10,13 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#ifdef __VMS
-# include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
-#else
-# include <malloc.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
-#endif
+#include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
#ifdef _WIN32
#include <windows.h>
#endif
#define GL_GLEXT_LEGACY
#include <GL/glut.h>
-
+#include <GL/glext.h>
GLfloat verts[][4] = {
{ -0.5, -0.5, -2.0, 0.0 },
diff --git a/progs/tests/dinoshade.c b/progs/tests/dinoshade.c
index ed7b879bc7..504b4af526 100644
--- a/progs/tests/dinoshade.c
+++ b/progs/tests/dinoshade.c
@@ -38,11 +38,7 @@
#include <stdlib.h>
#include <string.h>
#include <math.h> /* for cos(), sin(), and sqrt() */
-#ifdef __VMS
-# include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
-#else
-# include <malloc.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
-#endif
+#include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
#ifdef _WIN32
#include <windows.h>
#endif
diff --git a/progs/tests/exactrast.c b/progs/tests/exactrast.c
new file mode 100644
index 0000000000..56c0c79c3f
--- /dev/null
+++ b/progs/tests/exactrast.c
@@ -0,0 +1,200 @@
+/**
+ * Test for exact point/line/polygon rasterization, or at least rasterization
+ * that fits the tolerance of the OpenGL spec.
+ *
+ * Brian Paul
+ * 9 Nov 2007
+ */
+
+/*
+ * Notes:
+ * - 'm' to cycle through point, hline, vline and quad drawing
+ * - Use cursor keys to translate coordinates (z to reset)
+ * - Resize window to check for proper rasterization
+ * - Make sure your LCD is running in its native resolution
+ *
+ * If translation is (0,0):
+ * a point will be drawn where x%2==0 and y%2==0,
+ * a horizontal line will be drawn where x%2==0,
+ * a vertical line will be drawn where y%2==0,
+ * for quads, pixels will be set where (x%4)!=3 and (y%4)!=3
+ *
+ * XXX todo: do glReadPixels and test that the results are what's expected.
+ * Upon failure, iterate over sub-pixel translations to find the ideal offset.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+static int Width = 400, Height = 400;
+static int Win;
+static float Xtrans = 0, Ytrans = 0;
+static float Step = 0.125;
+
+enum {
+ POINTS,
+ HLINES,
+ VLINES,
+ QUADS,
+ NUM_MODES
+};
+
+static int Mode = POINTS;
+
+
+static void
+Draw(void)
+{
+ /* See the OpenGL Programming Guide, Appendix H, "OpenGL Correctness Tips"
+ * for information about the 0.375 translation factor.
+ */
+ float tx = 0.375, ty = 0.375;
+ int i, j;
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glPushMatrix();
+ glTranslatef(tx + Xtrans, ty + Ytrans, 0);
+
+ if (Mode == POINTS) {
+ glBegin(GL_POINTS);
+ for (j = 0; j < Height; j += 2) {
+ for (i = 0; i < Width; i += 2) {
+ glVertex2f(i, j);
+ }
+ }
+ glEnd();
+ }
+ else if (Mode == HLINES) {
+ glBegin(GL_LINES);
+ for (i = 0; i < Height; i += 2) {
+ glVertex2f(0, i);
+ glVertex2f(Width, i);
+ }
+ glEnd();
+ }
+ else if (Mode == VLINES) {
+ glBegin(GL_LINES);
+ for (i = 0; i < Width; i += 2) {
+ glVertex2f(i, 0 );
+ glVertex2f(i, Height);
+ }
+ glEnd();
+ }
+ else if (Mode == QUADS) {
+ glBegin(GL_QUADS);
+ for (j = 0; j < Height; j += 4) {
+ for (i = 0; i < Width; i += 4) {
+ glVertex2f(i, j );
+ glVertex2f(i + 3, j );
+ glVertex2f(i + 3, j + 3);
+ glVertex2f(i, j + 3);
+ }
+ }
+ glEnd();
+ }
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ Width = width;
+ Height = height;
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, width, 0, height, -1, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'm':
+ case 'M':
+ Mode = (Mode + 1) % NUM_MODES;
+ break;
+ case 'z':
+ case 'Z':
+ Xtrans = Ytrans = 0;
+ printf("Translation: %f, %f\n", Xtrans, Ytrans);
+ break;
+ case 27:
+ glutDestroyWindow(Win);
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+SpecialKey(int key, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Ytrans += Step;
+ break;
+ case GLUT_KEY_DOWN:
+ Ytrans -= Step;
+ break;
+ case GLUT_KEY_LEFT:
+ Xtrans -= Step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Xtrans += Step;
+ break;
+ }
+ glutPostRedisplay();
+ printf("Translation: %f, %f\n", Xtrans, Ytrans);
+}
+
+
+static void
+Init(void)
+{
+}
+
+
+static void
+Usage(void)
+{
+ printf("Keys:\n");
+ printf(" up/down/left/right - translate by %f\n", Step);
+ printf(" z - reset translation to zero\n");
+ printf(" m - change rendering mode (points, hlines, vlines, quads)\n");
+ printf(" Esc - exit\n");
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(Width, Height);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+ Win = glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutSpecialFunc(SpecialKey);
+ glutDisplayFunc(Draw);
+ Init();
+ Usage();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/fbotexture.c b/progs/tests/fbotexture.c
index aa9f617122..88d0549c80 100644
--- a/progs/tests/fbotexture.c
+++ b/progs/tests/fbotexture.c
@@ -38,6 +38,8 @@ static GLfloat Rot = 0.0;
static GLboolean UsePackedDepthStencil = GL_FALSE;
static GLuint TextureLevel = 1; /* which texture level to render to */
static GLenum TexIntFormat = GL_RGB; /* either GL_RGB or GL_RGBA */
+static GLboolean Cull = GL_FALSE;
+static GLboolean Wireframe = GL_FALSE;
static void
@@ -115,6 +117,22 @@ RenderTexture(void)
CheckError(__LINE__);
+ if (Wireframe) {
+ glPolygonMode(GL_FRONT, GL_LINE);
+ }
+ else {
+ glPolygonMode(GL_FRONT, GL_FILL);
+ }
+
+ if (Cull) {
+ /* cull back */
+ glCullFace(GL_BACK);
+ glEnable(GL_CULL_FACE);
+ }
+ else {
+ glDisable(GL_CULL_FACE);
+ }
+
#if 0
glBegin(GL_POLYGON);
glColor3f(1, 0, 0);
@@ -129,7 +147,9 @@ RenderTexture(void)
glEnable(GL_LIGHT0);
glPushMatrix();
glRotatef(0.5 * Rot, 1.0, 0.0, 0.0);
+ glFrontFace(GL_CW); /* Teapot patches backward */
glutSolidTeapot(0.5);
+ glFrontFace(GL_CCW);
glPopMatrix();
glDisable(GL_LIGHTING);
/*
@@ -139,6 +159,8 @@ RenderTexture(void)
glDisable(GL_DEPTH_TEST);
glDisable(GL_STENCIL_TEST);
+ glDisable(GL_CULL_FACE);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
#if DRAW
/* Bind normal framebuffer */
@@ -245,25 +267,46 @@ Key(unsigned char key, int x, int y)
(void) x;
(void) y;
switch (key) {
- case 'a':
- Anim = !Anim;
- if (Anim)
- glutIdleFunc(Idle);
- else
- glutIdleFunc(NULL);
- break;
- case 's':
- Rot += 2.0;
- break;
- case 27:
- CleanUp();
- break;
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'c':
+ Cull = !Cull;
+ break;
+ case 'w':
+ Wireframe = !Wireframe;
+ break;
+ case 's':
+ Rot += 2.0;
+ break;
+ case 'S':
+ Rot -= 2.0;
+ break;
+ case 27:
+ CleanUp();
+ break;
}
glutPostRedisplay();
}
static void
+Usage(void)
+{
+ printf("Usage:\n");
+ printf(" a Toggle animation\n");
+ printf(" s/s Step/rotate\n");
+ printf(" c Toggle back-face culling\n");
+ printf(" w Toggle wireframe mode (front-face only)\n");
+ printf(" Esc Exit\n");
+}
+
+
+static void
Init(int argc, char *argv[])
{
static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 };
@@ -402,6 +445,7 @@ main(int argc, char *argv[])
if (Anim)
glutIdleFunc(Idle);
Init(argc, argv);
+ Usage();
glutMainLoop();
return 0;
}
diff --git a/progs/tests/lineclip.c b/progs/tests/lineclip.c
new file mode 100644
index 0000000000..098f5e92eb
--- /dev/null
+++ b/progs/tests/lineclip.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#include <stdlib.h>
+#include <GL/glut.h>
+
+static int win_width, win_height;
+
+static void
+line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
+{
+ glBegin(GL_LINES);
+ glVertex2f(x1, y1);
+ glVertex2f(x2, y2);
+ glEnd();
+}
+
+static void
+line3(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2, GLfloat y2, GLfloat z2)
+{
+ glBegin(GL_LINES);
+ glVertex3f(x1, y1, z1);
+ glVertex3f(x2, y2, z2);
+ glEnd();
+}
+
+static void
+display(void)
+{
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glColor3f(1.0, 0.0, 0.0);
+ /* 2 lines clipped along xmin */
+ line(-20, win_height / 2 - 20,
+ 20, win_height / 2 - 20);
+ line( 20, win_height / 2 + 20,
+ -20, win_height / 2 + 20);
+
+ glColor3f(0.0, 1.0, 0.0);
+ /* 2 lines clipped along ymax */
+ line(win_width / 2 - 20, win_height + 20,
+ win_width / 2 - 20, win_height - 20);
+ line(win_width / 2 + 20, win_height - 20,
+ win_width / 2 + 20, win_height + 20);
+
+ glColor3f(0.0, 0.0, 1.0);
+ /* 2 lines clipped along xmax */
+ line(win_width - 20, win_height / 2 - 20,
+ win_width + 20, win_height / 2 - 20);
+ line(win_width + 20, win_height / 2 + 20,
+ win_width - 20, win_height / 2 + 20);
+
+ glColor3f(1.0, 1.0, 1.0);
+ /* 2 lines clipped along ymin */
+ line(win_width / 2 - 20, 20,
+ win_width / 2 - 20, -20);
+ line(win_width / 2 + 20, -20,
+ win_width / 2 + 20, 20);
+
+ /* 2 lines clipped along near */
+ glColor3f(1.0, 0.0, 1.0);
+ line3(win_width / 2 - 20 - 20, win_height / 2, 0.5,
+ win_width / 2 - 20 + 20, win_height / 2, -0.5);
+ line3(win_width / 2 - 20, win_height / 2 - 20, -0.5,
+ win_width / 2 - 20, win_height / 2 + 20, 0.5);
+
+ /* 2 lines clipped along far */
+ glColor3f(0.0, 1.0, 1.0);
+ line3(win_width / 2 + 20 - 20, win_height / 2, 1.5,
+ win_width / 2 + 20 + 20, win_height / 2, 0.5);
+ line3(win_width / 2 + 20, win_height / 2 - 20, 0.5,
+ win_width / 2 + 20, win_height / 2 + 20, 1.5);
+
+ /* entirely clipped along near/far */
+ glColor3f(.5, .5, .5);
+ line3(win_width / 2, win_height / 2 - 20, -0.5,
+ win_width / 2, win_height / 2 + 20, -0.5);
+ glColor3f(.5, .5, .5);
+ line3(win_width / 2, win_height / 2 - 20, 1.5,
+ win_width / 2, win_height / 2 + 20, 1.5);
+
+ glColor3f(1.0, 1.0, 0.0);
+ /* lines clipped along both x and y limits */
+ line(-5, 20,
+ 20, -5); /* xmin, ymin */
+ line(-5, win_height - 20,
+ 20, win_height + 5); /* xmin, ymax */
+ line(win_width - 20, -5,
+ win_width + 5, 20); /* xmax, ymin */
+ line(win_width - 20, win_height + 5,
+ win_width + 5, win_height - 20); /* xmax, ymax */
+
+ glutSwapBuffers();
+}
+
+static void
+reshape(int width, int height)
+{
+ win_width = width;
+ win_height = height;
+ glViewport(0, 0, width, height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, win_width, 0, win_height, 0.0, -1.0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(.25, .25, 0);
+}
+
+static void key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+
+ switch (key) {
+ case 27: /* esc */
+ exit(0);
+ break;
+ }
+
+ glutPostRedisplay();
+}
+
+static void
+init(void)
+{
+}
+
+int
+main(int argc, char *argv[])
+{
+ win_width = 200;
+ win_height = 200;
+
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(win_width, win_height);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc(reshape);
+ glutKeyboardFunc(key);
+ glutDisplayFunc(display);
+
+ init();
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/multipal.c b/progs/tests/multipal.c
index 52818fca7e..7bd4473565 100644
--- a/progs/tests/multipal.c
+++ b/progs/tests/multipal.c
@@ -8,11 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifdef __VMS
-# include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
-#else
-# include <malloc.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
-#endif
+#include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
#ifdef _WIN32
#include <windows.h>
#endif
diff --git a/progs/tests/shader_api.c b/progs/tests/shader_api.c
new file mode 100644
index 0000000000..598f029a97
--- /dev/null
+++ b/progs/tests/shader_api.c
@@ -0,0 +1,337 @@
+/* Tests to validate fixes to various bugs in src/mesa/shader/shader_api.c
+ *
+ * Written by Bruce Merry
+ */
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static void assert_test(const char *file, int line, int cond, const char *msg)
+{
+ if (!cond)
+ fprintf(stderr, "%s:%d assertion \"%s\" failed\n", file, line, msg);
+}
+
+#undef assert
+#define assert(x) assert_test(__FILE__, __LINE__, (x), #x)
+
+static void assert_no_error_test(const char *file, int line)
+{
+ GLenum err;
+
+ err = glGetError();
+ if (err != GL_NO_ERROR)
+ fprintf(stderr, "%s:%d received error %s\n",
+ file, line, gluErrorString(err));
+}
+
+#define assert_no_error() assert_no_error_test(__FILE__, __LINE__)
+
+static void assert_error_test(const char *file, int line, GLenum expect)
+{
+ GLenum err;
+
+ err = glGetError();
+ if (err != expect)
+ fprintf(stderr, "%s:%d expected %s but received %s\n",
+ file, line, gluErrorString(expect), gluErrorString(err));
+ while (glGetError()); /* consume any following errors */
+}
+
+#define assert_error(err) assert_error_test(__FILE__, __LINE__, (err))
+
+static void check_status(GLuint id, GLenum pname, void (*query)(GLuint, GLenum, GLint *))
+{
+ GLint status;
+
+ query(id, pname, &status);
+ if (!status)
+ {
+ char info[65536];
+
+ fprintf(stderr, "Compilation/link failure:\n");
+ glGetInfoLogARB(id, sizeof(info), NULL, info);
+ fprintf(stderr, "%s\n", info);
+ exit(1);
+ }
+}
+
+static void check_compile_status(GLuint id)
+{
+ check_status(id, GL_COMPILE_STATUS, glGetShaderiv);
+}
+
+static void check_link_status(GLuint id)
+{
+ check_status(id, GL_LINK_STATUS, glGetProgramiv);
+}
+
+static GLuint make_shader(GLenum type, const char *src)
+{
+ GLuint id;
+
+ assert_no_error();
+ id = glCreateShader(type);
+ glShaderSource(id, 1, &src, NULL);
+ glCompileShader(id);
+ check_compile_status(id);
+ assert_no_error();
+ return id;
+}
+
+static GLuint make_program(const char *vs_src, const char *fs_src)
+{
+ GLuint id, vs, fs;
+
+ assert_no_error();
+ id = glCreateProgram();
+ if (vs_src) {
+ vs = make_shader(GL_VERTEX_SHADER, vs_src);
+ glAttachShader(id, vs);
+ glDeleteShader(vs);
+ }
+ if (fs_src) {
+ fs = make_shader(GL_FRAGMENT_SHADER, fs_src);
+ glAttachShader(id, fs);
+ glDeleteShader(fs);
+ }
+ glLinkProgram(id);
+ check_link_status(id);
+ glUseProgram(id);
+ glDeleteProgram(id);
+ assert_no_error();
+ return id;
+}
+
+static void test_uniform_size_type1(const char *glslType, GLenum glType, const char *el)
+{
+ char buffer[1024];
+ GLuint program;
+ GLint active, i;
+ GLenum type;
+ GLint size;
+
+ printf(" Running subtest %s\n", glslType); fflush(stdout);
+ sprintf(buffer, "#version 120\nuniform %s m[60];\nvoid main() { gl_Position[0] = m[59]%s; }\n",
+ glslType, el);
+
+ program = make_program(buffer, NULL);
+ glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &active);
+ assert_no_error();
+ for (i = 0; i < active; i++) {
+ size = -1;
+ type = 0;
+ glGetActiveUniform(program, i, sizeof(buffer), NULL, &size, &type, buffer);
+ assert_no_error();
+ if (strncmp(buffer, "m", 1) == 0)
+ break;
+ }
+ assert(i < active); /* Otherwise the compiler optimised it out */
+ assert(type == glType);
+ assert(size == 60);
+}
+
+static void test_uniform_size_type(void)
+{
+ test_uniform_size_type1("float", GL_FLOAT, "");
+ test_uniform_size_type1("vec2", GL_FLOAT_VEC2, "[0]");
+ test_uniform_size_type1("vec3", GL_FLOAT_VEC3, "[0]");
+ test_uniform_size_type1("vec4", GL_FLOAT_VEC4, "[0]");
+
+ test_uniform_size_type1("bool", GL_BOOL, " ? 1.0 : 0.0");
+ test_uniform_size_type1("bvec2", GL_BOOL_VEC2, "[0] ? 1.0 : 0.0");
+ test_uniform_size_type1("bvec3", GL_BOOL_VEC3, "[0] ? 1.0 : 0.0");
+ test_uniform_size_type1("bvec4", GL_BOOL_VEC4, "[0] ? 1.0 : 0.0");
+
+ test_uniform_size_type1("int", GL_INT, "");
+ test_uniform_size_type1("ivec2", GL_INT_VEC2, "[0]");
+ test_uniform_size_type1("ivec3", GL_INT_VEC3, "[0]");
+ test_uniform_size_type1("ivec4", GL_INT_VEC4, "[0]");
+
+ test_uniform_size_type1("mat2", GL_FLOAT_MAT2, "[0][0]");
+ test_uniform_size_type1("mat3", GL_FLOAT_MAT3, "[0][0]");
+ test_uniform_size_type1("mat4", GL_FLOAT_MAT4, "[0][0]");
+ test_uniform_size_type1("mat2x3", GL_FLOAT_MAT2x3, "[0][0]");
+ test_uniform_size_type1("mat2x4", GL_FLOAT_MAT2x4, "[0][0]");
+ test_uniform_size_type1("mat3x2", GL_FLOAT_MAT3x2, "[0][0]");
+ test_uniform_size_type1("mat3x4", GL_FLOAT_MAT3x4, "[0][0]");
+ test_uniform_size_type1("mat4x2", GL_FLOAT_MAT4x2, "[0][0]");
+ test_uniform_size_type1("mat4x3", GL_FLOAT_MAT4x3, "[0][0]");
+}
+
+static void test_attrib_size_type1(const char *glslType, GLenum glType, const char *el)
+{
+ char buffer[1024];
+ GLuint program;
+ GLint active, i;
+ GLenum type;
+ GLint size;
+
+ printf(" Running subtest %s\n", glslType); fflush(stdout);
+ sprintf(buffer, "#version 120\nattribute %s m;\nvoid main() { gl_Position[0] = m%s; }\n",
+ glslType, el);
+
+ program = make_program(buffer, NULL);
+ glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &active);
+ assert_no_error();
+ for (i = 0; i < active; i++) {
+ size = -1;
+ type = -1;
+ glGetActiveAttrib(program, i, sizeof(buffer), NULL, &size, &type, buffer);
+ assert_no_error();
+ if (strncmp(buffer, "m", 1) == 0)
+ break;
+ }
+ assert(i < active); /* Otherwise the compiler optimised it out */
+ assert(type == glType);
+ assert(size == 1);
+}
+
+static void test_attrib_size_type(void)
+{
+ test_attrib_size_type1("float", GL_FLOAT, "");
+ test_attrib_size_type1("vec2", GL_FLOAT_VEC2, "[0]");
+ test_attrib_size_type1("vec3", GL_FLOAT_VEC3, "[0]");
+ test_attrib_size_type1("vec4", GL_FLOAT_VEC4, "[0]");
+
+ test_attrib_size_type1("mat2", GL_FLOAT_MAT2, "[0][0]");
+ test_attrib_size_type1("mat3", GL_FLOAT_MAT3, "[0][0]");
+ test_attrib_size_type1("mat4", GL_FLOAT_MAT4, "[0][0]");
+ test_attrib_size_type1("mat2x3", GL_FLOAT_MAT2x3, "[0][0]");
+ test_attrib_size_type1("mat2x4", GL_FLOAT_MAT2x4, "[0][0]");
+ test_attrib_size_type1("mat3x2", GL_FLOAT_MAT3x2, "[0][0]");
+ test_attrib_size_type1("mat3x4", GL_FLOAT_MAT3x4, "[0][0]");
+ test_attrib_size_type1("mat4x2", GL_FLOAT_MAT4x2, "[0][0]");
+ test_attrib_size_type1("mat4x3", GL_FLOAT_MAT4x3, "[0][0]");
+}
+
+static void test_uniform_array_overflow(void)
+{
+ GLuint program;
+ GLint location;
+ GLfloat data[128];
+
+ program = make_program("#version 120\nuniform vec2 x[10];\nvoid main() { gl_Position.xy = x[9]; }\n", NULL);
+ location = glGetUniformLocation(program, "x");
+ assert_no_error();
+ glUniform2fv(location, 64, data);
+ assert_no_error();
+}
+
+static void test_uniform_scalar_count(void)
+{
+ GLuint program;
+ GLint location;
+ GLfloat data[128];
+
+ program = make_program("#version 110\nuniform vec2 x;\nvoid main() { gl_Position.xy = x; }\n", NULL);
+ location = glGetUniformLocation(program, "x");
+ assert_no_error();
+ glUniform2fv(location, 64, data);
+ assert_error(GL_INVALID_OPERATION);
+}
+
+static void test_uniform_query_matrix(void)
+{
+ GLuint program;
+ GLfloat data[18];
+ GLint i, r, c;
+ GLint location;
+
+ program = make_program("#version 110\nuniform mat3 m[2];\nvoid main() { gl_Position.xyz = m[1][2]; }\n", NULL);
+ location = glGetUniformLocation(program, "m");
+ for (i = 0; i < 9; i++)
+ data[i] = i;
+ for (i = 9; i < 18; i++)
+ data[i] = 321.0;
+ glUniformMatrix3fv(location, 1, GL_TRUE, data);
+
+ for (i = 0; i < 18; i++)
+ data[i] = 123.0;
+ glGetUniformfv(program, location, data);
+ for (c = 0; c < 3; c++)
+ for (r = 0; r < 3; r++)
+ assert(data[c * 3 + r] == r * 3 + c);
+ for (i = 9; i < 18; i++)
+ assert(data[i] == 123.0);
+}
+
+static void test_uniform_neg_location(void)
+{
+ GLuint program;
+ GLfloat data[4];
+
+ program = make_program("#version 110\nvoid main() { gl_Position = vec4(1.0, 1.0, 1.0, 1.0); }\n", NULL);
+ assert_no_error();
+ glUniform1i(-1, 1);
+ assert_no_error();
+ glUniform1i(-200, 1);
+ assert_error(GL_INVALID_OPERATION);
+ glUniformMatrix2fv(-1, 1, GL_FALSE, data);
+ assert_no_error();
+ glUniformMatrix2fv(-200, 1, GL_FALSE, data);
+ assert_error(GL_INVALID_OPERATION);
+}
+
+static void test_uniform_bool_conversion(void)
+{
+ GLuint program;
+ GLint location;
+ GLint value[16]; /* in case glGetUniformiv goes nuts on the stack */
+
+ assert_no_error();
+ program = make_program("uniform bool b;\nvoid main() { gl_Position.x = b ? 1.5 : 0.5; }\n", NULL);
+ location = glGetUniformLocation(program, "b");
+ assert(location != -1);
+ assert_no_error();
+ glUniform1i(location, 5);
+ assert_no_error();
+ glGetUniformiv(program, location, &value[0]);
+ assert_no_error();
+ assert(value[0] == 1);
+}
+
+static void test_uniform_multiple_samplers(void)
+{
+ GLuint program;
+ GLint location;
+ GLint values[2] = {0, 1};
+
+ assert_no_error();
+ program = make_program(NULL, "uniform sampler2D s[2];\nvoid main() { gl_FragColor = texture2D(s[1], vec2(0.0, 0.0)); }\n");
+ location = glGetUniformLocation(program, "s[0]");
+ if (location == -1) /* Mesa doesn't currently support indexing */
+ location = glGetUniformLocation(program, "s");
+ assert(location != -1);
+ assert_no_error();
+ glUniform1iv(location, 2, values);
+ assert_no_error();
+}
+
+static void run_test(const char *name, void (*callback)(void))
+{
+ printf("Running %s\n", name);
+ fflush(stdout);
+ callback();
+}
+
+#define RUN_TEST(name) run_test(#name, (name))
+
+int main(int argc, char **argv)
+{
+ glutInit(&argc, argv);
+ glutCreateWindow("Mesa bug demo");
+
+ RUN_TEST(test_uniform_size_type);
+ RUN_TEST(test_attrib_size_type);
+ RUN_TEST(test_uniform_array_overflow);
+ RUN_TEST(test_uniform_scalar_count);
+ RUN_TEST(test_uniform_query_matrix);
+ RUN_TEST(test_uniform_neg_location);
+ RUN_TEST(test_uniform_bool_conversion);
+ /* Leave this one at the end, since it crashes Mesa's shader compiler */
+ RUN_TEST(test_uniform_multiple_samplers);
+ return 0;
+}
diff --git a/progs/tests/stencil_twoside.c b/progs/tests/stencil_twoside.c
new file mode 100644
index 0000000000..be9d9a776a
--- /dev/null
+++ b/progs/tests/stencil_twoside.c
@@ -0,0 +1,299 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file stencil_twoside.c
+ *
+ * Simple test of GL_ATI_separate_stencil (or the OGL 2.0 equivalent) functionality.
+ * Four squares are drawn
+ * with different stencil modes, but all should be rendered with the same
+ * final color.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+static int use20syntax = 1;
+static int Width = 550;
+static int Height = 200;
+static const GLfloat Near = 5.0, Far = 25.0;
+
+
+static PFNGLSTENCILFUNCSEPARATEPROC stencil_func_separate = NULL;
+static PFNGLSTENCILFUNCSEPARATEATIPROC stencil_func_separate_ati = NULL;
+static PFNGLSTENCILOPSEPARATEPROC stencil_op_separate = NULL;
+
+static void Display( void )
+{
+ GLint max_stencil;
+ GLint stencil_bits;
+ unsigned i;
+
+
+ glGetIntegerv( GL_STENCIL_BITS, & stencil_bits );
+ max_stencil = (1U << stencil_bits) - 1;
+ printf( "Stencil bits = %u, maximum stencil value = 0x%08x\n",
+ stencil_bits, max_stencil );
+
+ glClearStencil( 1 );
+ glClearColor( 0.2, 0.2, 0.8, 0 );
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
+ | GL_STENCIL_BUFFER_BIT );
+
+
+ glPushMatrix();
+
+ /* This is the "reference" square.
+ */
+
+ glDisable(GL_STENCIL_TEST);
+ glTranslatef(-6.0, 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+ glEnable(GL_STENCIL_TEST);
+
+ /* Draw the first two squares using incr for the affected face
+ */
+
+ if (use20syntax) {
+ stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
+ stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
+ }
+ else {
+ stencil_func_separate_ati(GL_ALWAYS, GL_ALWAYS, 0, ~0);
+ }
+ stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_INCR);
+ stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_DECR);
+
+ glTranslatef(3.0, 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.9, 0.9, 0.9 );
+ /* this should be front facing */
+ for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ }
+ glEnd();
+
+ glStencilFunc(GL_EQUAL, max_stencil, ~0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+
+ if (use20syntax) {
+ stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
+ stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
+ }
+ else {
+ stencil_func_separate_ati(GL_ALWAYS, GL_ALWAYS, 0, ~0);
+ }
+ stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR);
+ stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR);
+
+ glTranslatef(3.0, 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.9, 0.9, 0.9 );
+
+ /* this should be back facing */
+ for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+ glVertex2f(-1, -1);
+ glVertex2f(-1, 1);
+ glVertex2f( 1, 1);
+ glVertex2f( 1, -1);
+ }
+ glEnd();
+
+ glStencilFunc(GL_EQUAL, max_stencil, ~0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+ if (use20syntax) {
+ stencil_func_separate(GL_FRONT, GL_NEVER, 0, ~0);
+ stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
+ }
+ else {
+ stencil_func_separate_ati(GL_NEVER, GL_ALWAYS, 0, ~0);
+ }
+ stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR);
+ stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR);
+
+ glTranslatef(3.0, 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.9, 0.9, 0.9 );
+
+ /* this should be back facing */
+ for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+ /* this should be back facing */
+ glVertex2f(-1, -1);
+ glVertex2f(-1, 1);
+ glVertex2f( 1, 1);
+ glVertex2f( 1, -1);
+ /* this should be front facing */
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ }
+ glEnd();
+
+ glStencilFunc(GL_EQUAL, max_stencil, ~0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+ if (use20syntax) {
+ stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
+ stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
+ }
+ else {
+ stencil_func_separate_ati(GL_ALWAYS, GL_ALWAYS, 0, ~0);
+ }
+ stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR);
+ stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR);
+
+ glTranslatef(3.0, 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.9, 0.9, 0.9 );
+
+ /* this should be back facing */
+ for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+ /* this should be back facing */
+ glVertex2f(-1, -1);
+ glVertex2f(-1, 1);
+ glVertex2f( 1, 1);
+ glVertex2f( 1, -1);
+ /* this should be front facing */
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ }
+ glEnd();
+
+ glStencilFunc(GL_EQUAL, 1, ~0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.5, 0.5, 0.5 );
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ GLfloat ar = (float) width / (float) height;
+ Width = width;
+ Height = height;
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -ar, ar, -1.0, 1.0, Near, Far );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ const char * const ver_string = (const char * const)
+ glGetString( GL_VERSION );
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_VERSION = %s\n", ver_string);
+
+ if ( !glutExtensionSupported("GL_ATI_separate_stencil")
+ && (atof( ver_string ) < 2.0) ) {
+ printf("Sorry, this program requires either GL_ATI_separate_stencil or OpenGL 2.0.\n");
+ exit(1);
+ }
+ if (atof( ver_string ) < 2.0) {
+ use20syntax = 0;
+ }
+ stencil_func_separate = glutGetProcAddress( "glStencilFuncSeparate" );
+ stencil_func_separate_ati = glutGetProcAddress( "glStencilFuncSeparateATI" );
+ stencil_op_separate = glutGetProcAddress( "glStencilOpSeparate" );
+
+ printf("\nAll 5 squares should be the same color.\n");
+ glEnable( GL_BLEND );
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( Width, Height );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL );
+ glutCreateWindow( "GL_ATI_separate_stencil test" );
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/texline.c b/progs/tests/texline.c
index ee16ed40df..76dfccd9b1 100644
--- a/progs/tests/texline.c
+++ b/progs/tests/texline.c
@@ -6,7 +6,6 @@
* September 2000
*/
-
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -210,7 +209,9 @@ static void SpecialKey( int key, int x, int y )
static void Init( int argc, char *argv[] )
{
+ GLfloat r[2];
GLuint u;
+
for (u = 0; u < 2; u++) {
glActiveTextureARB(GL_TEXTURE0_ARB + u);
glBindTexture(GL_TEXTURE_2D, 10+u);
@@ -241,6 +242,15 @@ static void Init( int argc, char *argv[] )
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
}
+
+ glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, r);
+ printf("Non-smooth point size range: %g .. %g\n", r[0], r[1]);
+ glGetFloatv(GL_POINT_SIZE_RANGE, r);
+ printf("Smoothed point size range: %g .. %g\n", r[0], r[1]);
+ glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, r);
+ printf("Non-smooth line width range: %g .. %g\n", r[0], r[1]);
+ glGetFloatv(GL_LINE_WIDTH_RANGE, r);
+ printf("Smoothed line width range: %g .. %g\n", r[0], r[1]);
}
diff --git a/progs/tests/unfilledclip.c b/progs/tests/unfilledclip.c
new file mode 100644
index 0000000000..f25e52616a
--- /dev/null
+++ b/progs/tests/unfilledclip.c
@@ -0,0 +1,205 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#include <stdlib.h>
+#include <GL/glut.h>
+
+static int win_width, win_height;
+
+static void
+line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
+{
+ glBegin(GL_LINES);
+ glVertex2f(x1, y1);
+ glVertex2f(x2, y2);
+ glEnd();
+}
+
+static void
+line3(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2, GLfloat y2, GLfloat z2)
+{
+ glBegin(GL_LINES);
+ glVertex3f(x1, y1, z1);
+ glVertex3f(x2, y2, z2);
+ glEnd();
+}
+
+static void
+display(void)
+{
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glColor3f(1.0, 0.0, 0.0);
+ /* clipped along xmin */
+ glBegin(GL_TRIANGLES);
+ glVertex2f(-20, win_height / 2 - 20);
+ glVertex2f(20, win_height / 2);
+ glVertex2f(-20, win_height / 2 + 20);
+ glEnd();
+
+ glColor3f(0.0, 1.0, 0.0);
+ /* clipped along ymax */
+ glBegin(GL_TRIANGLES);
+ glVertex2f(win_height / 2 - 20, win_height + 20);
+ glVertex2f(win_height / 2, win_height - 20);
+ glVertex2f(win_height / 2 + 20, win_height + 20);
+ glEnd();
+
+ glColor3f(0.0, 0.0, 1.0);
+ /* clipped along xmax */
+ glBegin(GL_TRIANGLES);
+ glVertex2f(win_height + 20, win_height / 2 - 20);
+ glVertex2f(win_height - 20, win_height / 2);
+ glVertex2f(win_height + 20, win_height / 2 + 20);
+ glEnd();
+
+ glColor3f(1.0, 1.0, 1.0);
+ /* clipped along ymin */
+ glBegin(GL_TRIANGLES);
+ glVertex2f(win_height / 2 - 20, -20);
+ glVertex2f(win_height / 2, 20);
+ glVertex2f(win_height / 2 + 20, -20);
+ glEnd();
+
+ /* clipped along near */
+ glColor3f(1.0, 0.0, 1.0);
+ glBegin(GL_TRIANGLES);
+ glVertex3f(win_width / 2 - 20, win_height / 2 - 20, 0.5);
+ glVertex3f(win_width / 2 - 40, win_height / 2, -0.5);
+ glVertex3f(win_width / 2 - 20, win_height / 2 + 20, 0.5);
+ glEnd();
+
+ /* clipped along far */
+ glColor3f(0.0, 1.0, 1.0);
+ glBegin(GL_TRIANGLES);
+ glVertex3f(win_width / 2 + 20, win_height / 2 - 20, 0.5);
+ glVertex3f(win_width / 2 + 40, win_height / 2, 1.5);
+ glVertex3f(win_width / 2 + 20, win_height / 2 + 20, 0.5);
+ glEnd();
+
+ /* entirely clipped along near/far */
+ glColor3f(.5, .5, .5);
+ glBegin(GL_TRIANGLES);
+ glVertex3f(win_width / 2 - 20, win_height / 2 + 20, -0.5);
+ glVertex3f(win_width / 2, win_height / 2 + 40, -0.5);
+ glVertex3f(win_width / 2 + 20, win_height / 2 + 20, -0.5);
+ glEnd();
+
+ glBegin(GL_TRIANGLES);
+ glVertex3f(win_width / 2 - 20, win_height / 2 - 20, 1.5);
+ glVertex3f(win_width / 2, win_height / 2 - 40, 1.5);
+ glVertex3f(win_width / 2 + 20, win_height / 2 - 20, 1.5);
+ glEnd();
+
+ glColor3f(.5, .5, .5);
+ line3(win_width / 2, win_height / 2 - 20, 1.5,
+ win_width / 2, win_height / 2 + 20, 1.5);
+
+ glColor3f(1.0, 1.0, 0.0);
+ /* clipped along both x and y limits */
+ glBegin(GL_TRIANGLES); /* xmin, ymin */
+ glVertex2f(-5, 20);
+ glVertex2f(20, 20);
+ glVertex2f(20, -5);
+ glEnd();
+ glBegin(GL_TRIANGLES); /* xmin, ymax */
+ glVertex2f(-5, win_height - 20);
+ glVertex2f(20, win_height - 20);
+ glVertex2f(20, win_height + 5);
+ glEnd();
+ glBegin(GL_TRIANGLES); /* xmax, ymax */
+ glVertex2f(win_width - 20, win_height + 5);
+ glVertex2f(win_width - 20, win_height - 20);
+ glVertex2f(win_width + 5, win_height - 20);
+ glEnd();
+ glBegin(GL_TRIANGLES); /* xmax, ymin */
+ glVertex2f(win_width + 5, 20);
+ glVertex2f(win_width - 20, 20);
+ glVertex2f(win_width - 20, -5);
+ glEnd();
+
+ glutSwapBuffers();
+}
+
+static void
+reshape(int width, int height)
+{
+ win_width = width;
+ win_height = height;
+ glViewport(0, 0, width, height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, win_width, 0, win_height, 0.0, -1.0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(.25, .25, 0);
+}
+
+static void key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+
+ switch (key) {
+ case 27: /* esc */
+ exit(0);
+ break;
+ }
+
+ glutPostRedisplay();
+}
+
+static void
+init(void)
+{
+}
+
+int
+main(int argc, char *argv[])
+{
+ win_width = 200;
+ win_height = 200;
+
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(win_width, win_height);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc(reshape);
+ glutKeyboardFunc(key);
+ glutDisplayFunc(display);
+
+ init();
+
+ glutMainLoop();
+ return 0;
+}