summaryrefslogtreecommitdiffstats
path: root/progs/tests
diff options
context:
space:
mode:
Diffstat (limited to 'progs/tests')
-rw-r--r--progs/tests/.gitignore17
-rw-r--r--progs/tests/Makefile2
-rw-r--r--progs/tests/SConscript3
-rw-r--r--progs/tests/antialias.c71
-rw-r--r--progs/tests/arraytexture.c2
-rw-r--r--progs/tests/cva_huge.c232
-rw-r--r--progs/tests/fbotest1.c6
-rw-r--r--progs/tests/fbotest2.c52
-rw-r--r--progs/tests/fbotest3.c6
-rw-r--r--progs/tests/stencil_twoside.c85
-rw-r--r--progs/tests/stencilreaddraw.c187
-rw-r--r--progs/tests/vao-01.c2
-rw-r--r--progs/tests/vao-02.c2
-rw-r--r--progs/tests/zreaddraw.c70
14 files changed, 641 insertions, 96 deletions
diff --git a/progs/tests/.gitignore b/progs/tests/.gitignore
index d905fab6117..37be27fff24 100644
--- a/progs/tests/.gitignore
+++ b/progs/tests/.gitignore
@@ -1,4 +1,3 @@
-.cvsignore
afsmultiarb
antialias
arbfpspec
@@ -17,6 +16,7 @@ auxbuffer
blendminmax
blendsquare
blendxor
+blitfb
bufferobj
bug_3050
bug_3101
@@ -28,12 +28,16 @@ condrender
copypixrate
crossbar
cva
+cva_huge
+cylwrap
drawbuffers
drawbuffers2
-extfuncs.h
exactrast
+ext422square
+extfuncs.h
fbotest1
fbotest2
+fbotest3
fillrate
floattex
fog
@@ -58,10 +62,12 @@ mipmap_comp_tests
mipmap_limits
mipmap_view
multipal
+multitexarray
+multiwindow
no_s3tc
packedpixels
-persp_hint
pbo
+persp_hint
prim
prog_parameter
quads
@@ -77,6 +83,7 @@ shader_api
shaderutil.c
shaderutil.h
sharedtex
+stencilreaddraw
stencil_twoside
stencilwrap
stencil_wrap
@@ -84,10 +91,13 @@ streaming_rect
subtex
subtexrate
tex1d
+texcmp
texcompress2
texcompsub
texdown
texfilt
+texgenmix
+texleak
texline
texobj
texobjshare
@@ -97,6 +107,7 @@ unfilledclip
vao-01
vao-02
vparray
+vpeval
vptest1
vptest2
vptest3
diff --git a/progs/tests/Makefile b/progs/tests/Makefile
index 67efc3b7a9c..0f938f9b0c1 100644
--- a/progs/tests/Makefile
+++ b/progs/tests/Makefile
@@ -41,6 +41,7 @@ SOURCES = \
copypixrate.c \
crossbar.c \
cva.c \
+ cva_huge.c \
cylwrap.c \
drawbuffers.c \
drawbuffers2.c \
@@ -89,6 +90,7 @@ SOURCES = \
seccolor.c \
shader_api.c \
sharedtex.c \
+ stencilreaddraw.c \
stencil_twoside.c \
stencilwrap.c \
stencil_wrap.c \
diff --git a/progs/tests/SConscript b/progs/tests/SConscript
index 3580ba914db..429d3bb957c 100644
--- a/progs/tests/SConscript
+++ b/progs/tests/SConscript
@@ -9,7 +9,6 @@ glx_progs = [
'getprocaddress',
'jkrahntest',
'sharedtex',
- 'texcompress2',
'texobjshare',
]
@@ -45,6 +44,7 @@ progs = [
'copypixrate',
'crossbar',
'cva',
+ 'cva_huge',
'cylwrap',
'drawbuffers',
'drawbuffers2',
@@ -89,6 +89,7 @@ progs = [
'scissor-viewport',
'seccolor',
'shader_api',
+ 'stencilreaddraw',
'stencil_twoside',
'stencil_wrap',
'stencilwrap',
diff --git a/progs/tests/antialias.c b/progs/tests/antialias.c
index 656bf2471fe..a6456a52181 100644
--- a/progs/tests/antialias.c
+++ b/progs/tests/antialias.c
@@ -30,15 +30,17 @@ PrintString(const char *s)
static void
-doPolygon( GLint verts, GLfloat radius, GLfloat z )
+doPolygon( GLenum mode, GLint verts, GLfloat radius, GLfloat z )
{
int i;
+ glBegin(mode);
for (i = 0; i < verts; i++) {
float a = (i * 2.0 * 3.14159) / verts;
float x = radius * cos(a);
float y = radius * sin(a);
glVertex3f(x, y, z);
}
+ glEnd();
}
@@ -47,35 +49,23 @@ DrawObject( void )
{
glLineWidth(3.0);
glColor3f(1, 1, 1);
- glBegin(GL_LINE_LOOP);
- doPolygon(12, 1.2, 0);
- glEnd();
+ doPolygon(GL_LINE_LOOP, 12, 1.2, 0);
glLineWidth(1.0);
glColor3f(1, 1, 1);
- glBegin(GL_LINE_LOOP);
- doPolygon(12, 1.1, 0);
- glEnd();
+ doPolygon(GL_LINE_LOOP, 12, 1.1, 0);
glColor3f(1, 0, 0);
- glBegin(GL_POLYGON);
- doPolygon(12, 0.4, 0.3);
- glEnd();
+ doPolygon(GL_POLYGON, 12, 0.4, 0.3);
glColor3f(0, 1, 0);
- glBegin(GL_POLYGON);
- doPolygon(12, 0.6, 0.2);
- glEnd();
+ doPolygon(GL_POLYGON, 12, 0.6, 0.2);
glColor3f(0, 0, 1);
- glBegin(GL_POLYGON);
- doPolygon(12, 0.8, 0.1);
- glEnd();
+ doPolygon(GL_POLYGON, 12, 0.8, 0.1);
glColor3f(1, 1, 1);
- glBegin(GL_POLYGON);
- doPolygon(12, 1.0, 0);
- glEnd();
+ doPolygon(GL_POLYGON, 12, 1.0, 0);
}
@@ -85,43 +75,46 @@ Display( void )
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glColor3f(1, 1, 1);
+
+ glRasterPos2f(-3.1, -1.6);
+ PrintString("No antialiasing");
+
+ glRasterPos2f(-0.8, -1.6);
if (HaveMultisample) {
- glRasterPos2f(-3.1, -1.6);
if (DoMultisample)
- PrintString("MULTISAMPLE");
+ PrintString(" MULTISAMPLE");
else
PrintString("MULTISAMPLE (off)");
}
- glRasterPos2f(-0.8, -1.6);
- PrintString("No antialiasing");
+ else
+ PrintString("MULTISAMPLE (N/A)");
+
glRasterPos2f(1.6, -1.6);
PrintString("GL_POLYGON_SMOOTH");
- /* multisample */
- if (HaveMultisample) {
- glEnable(GL_DEPTH_TEST);
- if (DoMultisample)
- glEnable(GL_MULTISAMPLE_ARB);
- glPushMatrix();
- glTranslatef(-2.5, 0, 0);
- glPushMatrix();
- glRotatef(Zrot, 0, 0, 1);
- DrawObject();
- glPopMatrix();
- glPopMatrix();
- glDisable(GL_MULTISAMPLE_ARB);
- glDisable(GL_DEPTH_TEST);
- }
-
/* non-aa */
glEnable(GL_DEPTH_TEST);
glPushMatrix();
+ glTranslatef(-2.5, 0, 0);
+ glPushMatrix();
+ glRotatef(Zrot, 0, 0, 1);
+ DrawObject();
+ glPopMatrix();
+ glPopMatrix();
+ glDisable(GL_DEPTH_TEST);
+
+ /* multisample */
+ glEnable(GL_DEPTH_TEST);
+ if (HaveMultisample && DoMultisample)
+ glEnable(GL_MULTISAMPLE_ARB);
+ glPushMatrix();
glTranslatef(0, 0, 0);
glPushMatrix();
glRotatef(Zrot, 0, 0, 1);
DrawObject();
glPopMatrix();
glPopMatrix();
+ glDisable(GL_MULTISAMPLE_ARB);
glDisable(GL_DEPTH_TEST);
/* polygon smooth */
diff --git a/progs/tests/arraytexture.c b/progs/tests/arraytexture.c
index e4e86b9b4ce..94adf478d90 100644
--- a/progs/tests/arraytexture.c
+++ b/progs/tests/arraytexture.c
@@ -249,7 +249,7 @@ static void require_extension(const char *ext)
static void Init(void)
{
- const char *const ver_string = (const char *const) glGetString(GL_VERSION);
+ const char *const ver_string = (const char *) glGetString(GL_VERSION);
unsigned i;
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
diff --git a/progs/tests/cva_huge.c b/progs/tests/cva_huge.c
new file mode 100644
index 00000000000..88ec2af2a84
--- /dev/null
+++ b/progs/tests/cva_huge.c
@@ -0,0 +1,232 @@
+/*
+ * Copyright © 2010 Pauli Nieminen
+ *
+ * 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.
+ */
+
+
+/*
+ * Test case for huge cva arrays. Mesa code has to split this to multiple VBOs
+ * which had memory access error.
+ * This test case doesn't render incorrectly but valgrind showed the memory
+ * access error.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#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>
+
+GLfloat *verts;
+
+GLubyte *color;
+
+GLuint *indices;
+
+#define rows 1000 /* Create 1000x1000 vertex grid */
+#define row_width 5000.0
+#define grid_depth -50.0
+GLuint nr_verts_in_row = rows;
+GLuint nr_indices_in_strip = rows * 2;
+
+GLboolean double_buffer;
+GLboolean compiled = GL_TRUE;
+
+static void generate_verts( void )
+{
+ unsigned x, y;
+ GLfloat step = row_width /(GLfloat)(nr_verts_in_row - 1);
+ verts = malloc(sizeof(verts[0]) * 4 * nr_verts_in_row * nr_verts_in_row);
+
+ for (y = 0; y < nr_verts_in_row; ++y) {
+ for (x = 0; x < nr_verts_in_row; ++x) {
+ unsigned idx = 4*(x + y * nr_verts_in_row);
+ verts[idx + 0] = step * x - row_width/2.0;
+ verts[idx + 1] = step * y - row_width/2.0;
+ /* deep enough not to be vissible */
+ verts[idx + 2] = grid_depth;
+ verts[idx + 3] = 0.0;
+ }
+ }
+ glVertexPointer( 3, GL_FLOAT, sizeof(verts[0])*4, verts );
+}
+
+static void generate_colors( void )
+{
+ unsigned x, y;
+ GLfloat step = 255.0/(GLfloat)(nr_verts_in_row - 1);
+ color = malloc(sizeof(color[0]) * 4 * nr_verts_in_row * nr_verts_in_row);
+
+ for (y = 0; y < nr_verts_in_row; ++y) {
+ for (x = 0; x < nr_verts_in_row; ++x) {
+ unsigned idx = 4*(x + y * nr_verts_in_row);
+ color[idx + 0] = (GLubyte)(step * x);
+ color[idx + 1] = 0x00;
+ color[idx + 2] = (GLubyte)(step * y);
+ color[idx + 3] = 0x00;
+ }
+ }
+ glColorPointer( 4, GL_UNSIGNED_BYTE, 0, color );
+}
+
+static void generate_indices( void )
+{
+ unsigned strip, i;
+
+ /* indice size * number of strips * number of indices in strip */
+ indices = malloc(sizeof(indices[0]) * (nr_verts_in_row - 1) *
+ (nr_indices_in_strip));
+
+ for (strip = 0; strip < nr_verts_in_row - 1; strip += 2) {
+ for (i = 0; i < nr_indices_in_strip; i+=2) {
+ unsigned idx = i + strip * nr_indices_in_strip;
+ unsigned idx2 = (nr_indices_in_strip - i - 2) + (strip +
+ 1) * (nr_indices_in_strip);
+ indices[idx + 1] = i/2 + strip*nr_verts_in_row;
+ indices[idx] = i/2 + (strip + 1)*nr_verts_in_row;
+ if (strip + 1 < nr_verts_in_row - 1) {
+ indices[idx2] = i/2 + (strip + 1)*nr_verts_in_row;
+ indices[idx2 + 1] = i/2 + (strip + 2)*nr_verts_in_row;
+ }
+ }
+ }
+}
+
+static void init( void )
+{
+
+
+ generate_verts();
+ generate_colors();
+ generate_indices();
+
+ glClearColor( 0.0, 0.0, 0.0, 0.0 );
+ glShadeModel( GL_SMOOTH );
+
+ glEnableClientState( GL_VERTEX_ARRAY );
+ glEnableClientState( GL_COLOR_ARRAY );
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -100.0, 100.0, -100.0, 100.0, 1.0, 100.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+
+#ifdef GL_EXT_compiled_vertex_array
+ if ( compiled ) {
+ glLockArraysEXT( 0, rows * rows );
+ }
+#endif
+}
+
+static void display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glDrawElements( GL_TRIANGLE_STRIP, nr_indices_in_strip * (nr_verts_in_row - 1) , GL_UNSIGNED_INT, indices );
+
+ if ( double_buffer )
+ glutSwapBuffers();
+ else
+ glFlush();
+}
+
+static void keyboard( unsigned char key, int x, int y )
+{
+ switch ( key ) {
+ case 27:
+ exit( 0 );
+ break;
+ }
+
+ glutPostRedisplay();
+}
+
+static GLboolean args( int argc, char **argv )
+{
+ GLint i;
+
+ double_buffer = GL_TRUE;
+
+ for ( i = 1 ; i < argc ; i++ ) {
+ if ( strcmp( argv[i], "-sb" ) == 0 ) {
+ double_buffer = GL_FALSE;
+ } else if ( strcmp( argv[i], "-db" ) == 0 ) {
+ double_buffer = GL_TRUE;
+ } else {
+ fprintf( stderr, "%s (Bad option).\n", argv[i] );
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main( int argc, char **argv )
+{
+ GLenum type;
+ char *string;
+ double version;
+
+ glutInit( &argc, argv );
+
+ if ( args( argc, argv ) == GL_FALSE ) {
+ exit( 1 );
+ }
+
+ type = GLUT_RGB | GLUT_DEPTH;
+ type |= ( double_buffer ) ? GLUT_DOUBLE : GLUT_SINGLE;
+
+ glutInitDisplayMode( type );
+ glutInitWindowSize( 250, 250 );
+ glutInitWindowPosition( 100, 100 );
+ glutCreateWindow( "CVA Test" );
+
+ /* Make sure the server supports GL 1.2 vertex arrays.
+ */
+ string = (char *) glGetString( GL_VERSION );
+
+ version = atof(string);
+ if ( version < 1.2 ) {
+ fprintf( stderr, "This program requires OpenGL 1.2 vertex arrays.\n" );
+ exit( -1 );
+ }
+
+ /* See if the server supports compiled vertex arrays.
+ */
+ string = (char *) glGetString( GL_EXTENSIONS );
+
+ if ( !strstr( string, "GL_EXT_compiled_vertex_array" ) ) {
+ fprintf( stderr, "Compiled vertex arrays not supported by this renderer.\n" );
+ compiled = GL_FALSE;
+ }
+
+ init();
+
+ glutDisplayFunc( display );
+ glutKeyboardFunc( keyboard );
+ glutMainLoop();
+
+ return 0;
+}
diff --git a/progs/tests/fbotest1.c b/progs/tests/fbotest1.c
index 0cd7f95c355..a95fdff74c3 100644
--- a/progs/tests/fbotest1.c
+++ b/progs/tests/fbotest1.c
@@ -36,8 +36,8 @@ Display( void )
/* draw to user framebuffer */
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
- glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
- glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
+ glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+ glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
@@ -161,7 +161,7 @@ Init( void )
assert(i == MyFB);
CheckError(__LINE__);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, MyRB);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
diff --git a/progs/tests/fbotest2.c b/progs/tests/fbotest2.c
index f9c506193f6..faf0dd87484 100644
--- a/progs/tests/fbotest2.c
+++ b/progs/tests/fbotest2.c
@@ -33,15 +33,16 @@ CheckError(int line)
static void
Display( void )
{
- GLubyte *buffer = malloc(Width * Height * 4);
+ GLboolean copyPix = GL_FALSE;
+ GLboolean blitPix = GL_FALSE;
GLenum status;
CheckError(__LINE__);
/* draw to user framebuffer */
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
- glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
- glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
+ glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+ glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
@@ -63,16 +64,43 @@ Display( void )
glutSolidTeapot(2.0);
glPopMatrix();
- /* read from user framebuffer */
- glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+ if (copyPix) {
+ glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, MyFB);
+ glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
+ glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
+ glDrawBuffer(GL_BACK);
- /* draw to window */
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glDisable(GL_DEPTH_TEST); /* in case window has depth buffer */
- glWindowPos2iARB(0, 0);
- glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+ glDisable(GL_DEPTH_TEST); /* in case window has depth buffer */
+
+ glWindowPos2iARB(0, 0);
+ glCopyPixels(0, 0, Width, Height, GL_COLOR);
+ }
+ else if (blitPix) {
+ glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, MyFB);
+ glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
+ glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
+ glDrawBuffer(GL_BACK);
+
+ glDisable(GL_DEPTH_TEST); /* in case window has depth buffer */
+
+ glBlitFramebufferEXT(0, 0, Width, Height,
+ 0, 0, Width, Height,
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);
+ }
+ else {
+ GLubyte *buffer = malloc(Width * Height * 4);
+ /* read from user framebuffer */
+ glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+
+ /* draw to window */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glDisable(GL_DEPTH_TEST); /* in case window has depth buffer */
+ glWindowPos2iARB(0, 0);
+ glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+
+ free(buffer);
+ }
- free(buffer);
glutSwapBuffers();
CheckError(__LINE__);
}
@@ -163,7 +191,7 @@ Init( void )
glGenRenderbuffersEXT(1, &ColorRb);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, ColorRb);
assert(glIsRenderbufferEXT(ColorRb));
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, ColorRb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
diff --git a/progs/tests/fbotest3.c b/progs/tests/fbotest3.c
index 8e288b38b83..c176f82d2ba 100644
--- a/progs/tests/fbotest3.c
+++ b/progs/tests/fbotest3.c
@@ -50,8 +50,8 @@ Display( void )
/* draw to user framebuffer */
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
- glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
- glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
+ glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+ glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
@@ -189,7 +189,7 @@ Init( void )
glGenRenderbuffersEXT(1, &ColorRb);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, ColorRb);
assert(glIsRenderbufferEXT(ColorRb));
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_RENDERBUFFER_EXT, ColorRb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
diff --git a/progs/tests/stencil_twoside.c b/progs/tests/stencil_twoside.c
index 7d871e5877f..1010139a20e 100644
--- a/progs/tests/stencil_twoside.c
+++ b/progs/tests/stencil_twoside.c
@@ -26,7 +26,7 @@
* \file stencil_twoside.c
*
* Simple test of GL_ATI_separate_stencil (or the OGL 2.0 equivalent) functionality.
- * Four squares are drawn
+ * Five squares (or six if stencil wrap is available) are drawn
* with different stencil modes, but all should be rendered with the same
* final color.
*/
@@ -37,7 +37,7 @@
#include <GL/glut.h>
static int use20syntax = 1;
-static int Width = 550;
+static int Width = 650;
static int Height = 200;
static const GLfloat Near = 5.0, Far = 25.0;
@@ -70,7 +70,7 @@ static void Display( void )
*/
glDisable(GL_STENCIL_TEST);
- glTranslatef(-6.0, 0, 0);
+ glTranslatef(-7.0, 0, 0);
glBegin(GL_QUADS);
glColor3f( 0.5, 0.5, 0.5 );
glVertex2f(-1, -1);
@@ -85,6 +85,9 @@ static void Display( void )
/* Draw the first two squares using incr for the affected face
*/
+ /*************************************************************************
+ * 2nd square
+ */
if (use20syntax) {
stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
@@ -98,8 +101,8 @@ static void Display( void )
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++ ) {
+ /* this should be front facing */
glVertex2f(-1, -1);
glVertex2f( 1, -1);
glVertex2f( 1, 1);
@@ -107,6 +110,7 @@ static void Display( void )
}
glEnd();
+ /* stencil vals should be equal to max_stencil */
glStencilFunc(GL_EQUAL, max_stencil, ~0);
glBegin(GL_QUADS);
glColor3f( 0.5, 0.5, 0.5 );
@@ -116,6 +120,9 @@ static void Display( void )
glVertex2f(-1, 1);
glEnd();
+ /*************************************************************************
+ * 3rd square
+ */
if (use20syntax) {
stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
@@ -129,9 +136,8 @@ static void Display( void )
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);
@@ -139,6 +145,7 @@ static void Display( void )
}
glEnd();
+ /* stencil vals should be equal to max_stencil */
glStencilFunc(GL_EQUAL, max_stencil, ~0);
glBegin(GL_QUADS);
glColor3f( 0.5, 0.5, 0.5 );
@@ -148,6 +155,9 @@ static void Display( void )
glVertex2f(-1, 1);
glEnd();
+ /*************************************************************************
+ * 4th square
+ */
if (use20syntax) {
stencil_func_separate(GL_FRONT, GL_NEVER, 0, ~0);
stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
@@ -161,15 +171,13 @@ static void Display( void )
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 */
+ /* this should be back facing */
glVertex2f(-1, -1);
glVertex2f(-1, 1);
glVertex2f( 1, 1);
glVertex2f( 1, -1);
- /* this should be front facing */
+ /* this should be front facing */
glVertex2f(-1, -1);
glVertex2f( 1, -1);
glVertex2f( 1, 1);
@@ -177,6 +185,7 @@ static void Display( void )
}
glEnd();
+ /* stencil vals should be equal to max_stencil */
glStencilFunc(GL_EQUAL, max_stencil, ~0);
glBegin(GL_QUADS);
glColor3f( 0.5, 0.5, 0.5 );
@@ -186,6 +195,9 @@ static void Display( void )
glVertex2f(-1, 1);
glEnd();
+ /*************************************************************************
+ * 5th square
+ */
if (use20syntax) {
stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
@@ -193,21 +205,19 @@ static void Display( void )
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);
+ 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 back facing */
for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
- /* this should be back facing */
+ /* this should be back facing */
glVertex2f(-1, -1);
glVertex2f(-1, 1);
glVertex2f( 1, 1);
glVertex2f( 1, -1);
- /* this should be front facing */
+ /* this should be front facing */
glVertex2f(-1, -1);
glVertex2f( 1, -1);
glVertex2f( 1, 1);
@@ -224,6 +234,47 @@ static void Display( void )
glVertex2f(-1, 1);
glEnd();
+ /*************************************************************************
+ * 6th square
+ */
+ if (glutExtensionSupported("GL_EXT_stencil_wrap")) {
+ 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_KEEP);
+ stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR_WRAP);
+
+ glTranslatef(3.0, 0, 0);
+ glBegin(GL_QUADS);
+ glColor3f( 0.9, 0.9, 0.9 );
+ 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, 260 - 255, ~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();
@@ -278,7 +329,7 @@ static void Init( void )
stencil_func_separate_ati = (PFNGLSTENCILFUNCSEPARATEATIPROC) glutGetProcAddress( "glStencilFuncSeparateATI" );
stencil_op_separate = (PFNGLSTENCILOPSEPARATEPROC) glutGetProcAddress( "glStencilOpSeparate" );
- printf("\nAll 5 squares should be the same color.\n");
+ printf("\nAll 5 (or 6) squares should be the same color.\n");
}
diff --git a/progs/tests/stencilreaddraw.c b/progs/tests/stencilreaddraw.c
new file mode 100644
index 00000000000..84a5a922a0e
--- /dev/null
+++ b/progs/tests/stencilreaddraw.c
@@ -0,0 +1,187 @@
+/*
+ * Test glRead/DrawPixels for GL_STENCIL_INDEX, with pixelzoom.
+ *
+ * Brian Paul
+ * 8 April 2010
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+static GLint WinWidth = 500, WinHeight = 500;
+static GLboolean TestPacking = GL_FALSE;
+static GLboolean TestList = GL_FALSE;
+
+
+static GLuint StencilValue = 192;
+
+static void Display(void)
+{
+ GLubyte stencil[100 * 100 * 2];
+ GLubyte stencil2[400 * 400]; /* *2 to test pixelstore stuff */
+ GLuint list;
+
+ glClearColor(0.5, 0.5, 0.5, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+
+ glEnable(GL_DEPTH_TEST);
+
+ glStencilOp(GL_INVERT, GL_KEEP, GL_REPLACE);
+ glStencilFunc(GL_ALWAYS, StencilValue, ~0);
+ glEnable(GL_STENCIL_TEST);
+
+ /* draw a sphere */
+ glViewport(0, 0, 100, 100);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1, 1, -1, 1, -1, 0); /* clip away back half of sphere */
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glutSolidSphere(1.0, 20, 10);
+
+ glDisable(GL_STENCIL_TEST);
+
+ if (TestPacking) {
+ glPixelStorei(GL_PACK_ROW_LENGTH, 120);
+ glPixelStorei(GL_PACK_SKIP_PIXELS, 5);
+ }
+
+ /* read the stencil image */
+ glReadPixels(0, 0, 100, 100, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencil);
+ {
+ GLubyte min, max;
+ int i;
+ min = max = stencil[0];
+ for (i = 1; i < 100 * 100; i++) {
+ if (stencil[i] < min)
+ min = stencil[i];
+ if (stencil[i] > max)
+ max = stencil[i];
+ }
+ printf("Stencil value range: [%u, %u]\n", min, max);
+ if (max != StencilValue) {
+ printf("Error: expected max stencil val of %u, found %u\n",
+ StencilValue, max);
+ }
+ }
+
+ /* Draw the Z image as luminance above original rendering */
+ glWindowPos2i(0, 100);
+ glDrawPixels(100, 100, GL_LUMINANCE, GL_UNSIGNED_BYTE, stencil);
+
+ if (1) {
+ if (TestPacking) {
+ glPixelStorei(GL_PACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 120);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, 5);
+ }
+
+ /* draw stencil image with scaling (into stencil buffer) */
+ glPixelZoom(4.0, 4.0);
+ glColor4f(1, 0, 0, 0);
+ glWindowPos2i(100, 0);
+
+ if (TestList) {
+ list = glGenLists(1);
+ glNewList(list, GL_COMPILE);
+ glDrawPixels(100, 100, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencil);
+ glEndList();
+ glCallList(list);
+ glDeleteLists(list, 1);
+ }
+ else {
+ glDrawPixels(100, 100, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencil);
+ }
+
+ if (TestPacking) {
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+ }
+
+ /* read back scaled stencil image */
+ glReadPixels(100, 0, 400, 400, GL_STENCIL_INDEX,
+ GL_UNSIGNED_BYTE, stencil2);
+ /* draw as luminance */
+ glPixelZoom(1.0, 1.0);
+ glWindowPos2i(100, 0);
+ glDrawPixels(400, 400, GL_LUMINANCE, GL_UNSIGNED_BYTE, stencil2);
+ }
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape(int width, int height)
+{
+ WinWidth = width;
+ WinHeight = height;
+ glViewport(0, 0, width, height);
+}
+
+
+static void Key(unsigned char key, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'p':
+ TestPacking = !TestPacking;
+ printf("Test pixel pack/unpack: %d\n", TestPacking);
+ break;
+ case 'l':
+ TestList = !TestList;
+ printf("Test dlist: %d\n", TestList);
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init(void)
+{
+ const GLfloat blue[4] = {.1, .1, 1.0, 1.0};
+ const GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0};
+ const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0};
+ const GLfloat pos[4] = {0, 0, 10, 0};
+ GLint bits;
+
+ printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+ glGetIntegerv(GL_STENCIL_BITS, &bits);
+ printf("Stencil bits: %d\n", bits);
+
+ assert(bits >= 8);
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, blue);
+ glLightfv(GL_LIGHT0, GL_AMBIENT, gray);
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, white);
+ glLightfv(GL_LIGHT0, GL_POSITION, pos);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+}
+
+
+int main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(WinWidth, WinHeight);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL | GLUT_DOUBLE);
+ glutCreateWindow(argv[0]);
+ glewInit();
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Display);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/vao-01.c b/progs/tests/vao-01.c
index e4a89cb19db..ee528d22439 100644
--- a/progs/tests/vao-01.c
+++ b/progs/tests/vao-01.c
@@ -30,7 +30,7 @@
* it (via \c glPopClientAttrib). After popping, the state of the VAO is
* examined.
*
- * According the the APPLE_vertex_array_object spec, the contents of the VAO
+ * According to the APPLE_vertex_array_object spec, the contents of the VAO
* should be restored to the values that they had when pushed.
*
* \author Ian Romanick <[email protected]>
diff --git a/progs/tests/vao-02.c b/progs/tests/vao-02.c
index 9f7f5c27792..c23b4ab05a6 100644
--- a/progs/tests/vao-02.c
+++ b/progs/tests/vao-02.c
@@ -30,7 +30,7 @@
* it (via \c glPopClientAttrib). After popping, the state of the VAO is
* examined.
*
- * According the the APPLE_vertex_array_object spec, the contents of the VAO
+ * According to the APPLE_vertex_array_object spec, the contents of the VAO
* should be restored to the values that they had when pushed.
*
* \author Ian Romanick <[email protected]>
diff --git a/progs/tests/zreaddraw.c b/progs/tests/zreaddraw.c
index 7740695bb66..0910eaaa799 100644
--- a/progs/tests/zreaddraw.c
+++ b/progs/tests/zreaddraw.c
@@ -11,7 +11,16 @@
#include <GL/glew.h>
#include <GL/glut.h>
-static GLint WinWidth = 500, WinHeight = 500;
+
+#define ZWIDTH 100
+#define ZHEIGHT 100
+
+#define ZOOM 4
+
+#define ZWIDTH2 (ZOOM * ZWIDTH)
+#define ZHEIGHT2 (ZOOM * ZHEIGHT)
+
+static GLint WinWidth = ZWIDTH + ZWIDTH2, WinHeight = ZHEIGHT + ZHEIGHT2;
static GLboolean Invert = GL_FALSE;
static GLboolean TestPacking = GL_FALSE;
static GLboolean TestList = GL_FALSE;
@@ -19,8 +28,8 @@ static GLboolean TestList = GL_FALSE;
static void Display(void)
{
- GLfloat depth[100 * 100 * 2];
- GLfloat depth2[400 * 400]; /* *2 to test pixelstore stuff */
+ GLfloat depth[ZWIDTH * ZHEIGHT * 2];
+ GLfloat depth2[ZWIDTH2 * ZHEIGHT2]; /* *2 to test pixelstore stuff */
GLuint list;
GLenum depthType = GL_FLOAT;
@@ -30,7 +39,7 @@ static void Display(void)
glEnable(GL_DEPTH_TEST);
/* draw a sphere */
- glViewport(0, 0, 100, 100);
+ glViewport(0, 0, ZWIDTH, ZHEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1, 1, -1, 1, -1, 0); /* clip away back half of sphere */
@@ -44,12 +53,12 @@ static void Display(void)
}
/* read the depth image */
- glReadPixels(0, 0, 100, 100, GL_DEPTH_COMPONENT, depthType, depth);
+ glReadPixels(0, 0, ZWIDTH, ZHEIGHT, GL_DEPTH_COMPONENT, depthType, depth);
if (depthType == GL_FLOAT) {
GLfloat min, max;
int i;
min = max = depth[0];
- for (i = 1; i < 100 * 100; i++) {
+ for (i = 1; i < ZWIDTH * ZHEIGHT; i++) {
if (depth[i] < min)
min = depth[i];
if (depth[i] > max)
@@ -58,9 +67,22 @@ static void Display(void)
printf("Depth value range: [%f, %f]\n", min, max);
}
+ /* debug */
+ if (0) {
+ int i;
+ float *z = depth + ZWIDTH * 50;
+ printf("z at y=50:\n");
+ for (i = 0; i < ZWIDTH; i++) {
+ printf("%5.3f ", z[i]);
+ if ((i + 1) % 12 == 0)
+ printf("\n");
+ }
+ printf("\n");
+ }
+
/* Draw the Z image as luminance above original rendering */
- glWindowPos2i(0, 100);
- glDrawPixels(100, 100, GL_LUMINANCE, depthType, depth);
+ glWindowPos2i(0, ZHEIGHT);
+ glDrawPixels(ZWIDTH, ZHEIGHT, GL_LUMINANCE, depthType, depth);
if (TestPacking) {
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
@@ -70,9 +92,9 @@ static void Display(void)
}
/* draw depth image with scaling (into z buffer) */
- glPixelZoom(4.0, 4.0);
+ glPixelZoom(ZOOM, ZOOM);
glColor4f(1, 0, 0, 0);
- glWindowPos2i(100, 0);
+ glWindowPos2i(ZWIDTH, 0);
if (Invert) {
glPixelTransferf(GL_DEPTH_SCALE, -1.0);
glPixelTransferf(GL_DEPTH_BIAS, 1.0);
@@ -80,13 +102,13 @@ static void Display(void)
if (TestList) {
list = glGenLists(1);
glNewList(list, GL_COMPILE);
- glDrawPixels(100, 100, GL_DEPTH_COMPONENT, depthType, depth);
+ glDrawPixels(ZWIDTH, ZHEIGHT, GL_DEPTH_COMPONENT, depthType, depth);
glEndList();
glCallList(list);
glDeleteLists(list, 1);
}
else {
- glDrawPixels(100, 100, GL_DEPTH_COMPONENT, depthType, depth);
+ glDrawPixels(ZWIDTH, ZHEIGHT, GL_DEPTH_COMPONENT, depthType, depth);
}
if (Invert) {
glPixelTransferf(GL_DEPTH_SCALE, 1.0);
@@ -101,11 +123,25 @@ static void Display(void)
glDisable(GL_DEPTH_TEST);
/* read back scaled depth image */
- glReadPixels(100, 0, 400, 400, GL_DEPTH_COMPONENT, GL_FLOAT, depth2);
+ glReadPixels(ZWIDTH, 0, ZWIDTH2, ZHEIGHT2, GL_DEPTH_COMPONENT, GL_FLOAT, depth2);
+
+ /* debug */
+ if (0) {
+ int i;
+ float *z = depth2 + ZWIDTH2 * 200;
+ printf("z at y=200:\n");
+ for (i = 0; i < ZWIDTH2; i++) {
+ printf("%5.3f ", z[i]);
+ if ((i + 1) % 12 == 0)
+ printf("\n");
+ }
+ printf("\n");
+ }
+
/* draw as luminance */
glPixelZoom(1.0, 1.0);
- glWindowPos2i(100, 0);
- glDrawPixels(400, 400, GL_LUMINANCE, GL_FLOAT, depth2);
+ glWindowPos2i(ZWIDTH, 0);
+ glDrawPixels(ZWIDTH2, ZHEIGHT2, GL_LUMINANCE, GL_FLOAT, depth2);
glutSwapBuffers();
}
@@ -149,9 +185,13 @@ static void Init(void)
const GLfloat gray[4] = {0.2, 0.2, 0.2, 1.0};
const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0};
const GLfloat pos[4] = {0, 0, 10, 0};
+ GLint z;
+
+ glGetIntegerv(GL_DEPTH_BITS, &z);
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ printf("GL_DEPTH_BITS = %d\n", z);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, blue);
glLightfv(GL_LIGHT0, GL_AMBIENT, gray);