summaryrefslogtreecommitdiff
path: root/progs/tests
diff options
context:
space:
mode:
Diffstat (limited to 'progs/tests')
-rw-r--r--progs/tests/Makefile11
-rw-r--r--progs/tests/SConscript23
-rw-r--r--progs/tests/arbgpuprog.c4
-rw-r--r--progs/tests/arraytexture.c19
-rw-r--r--progs/tests/blitfb.c259
-rw-r--r--progs/tests/bug_texstore_i8.c2
-rw-r--r--progs/tests/condrender.c242
-rw-r--r--progs/tests/crossbar.c4
-rw-r--r--progs/tests/cva.c8
-rw-r--r--progs/tests/drawbuffers.c17
-rw-r--r--progs/tests/drawbuffers2.c364
-rw-r--r--progs/tests/fptest1.c2
-rw-r--r--progs/tests/getprocaddress.c4
-rw-r--r--progs/tests/getteximage.c20
-rw-r--r--progs/tests/invert.c4
-rw-r--r--progs/tests/minmag.c1
-rw-r--r--progs/tests/mipmap_comp.c6
-rw-r--r--progs/tests/packedpixels.c81
-rw-r--r--progs/tests/prog_parameter.c25
-rw-r--r--progs/tests/quads.c3
-rw-r--r--progs/tests/scissor-viewport.c4
-rw-r--r--progs/tests/scissor.c4
-rw-r--r--progs/tests/shader_api.c6
-rw-r--r--progs/tests/sharedtex.c8
-rw-r--r--progs/tests/stencil_twoside.c6
-rw-r--r--progs/tests/stencilwrap.c2
-rw-r--r--progs/tests/tex1d.c2
-rw-r--r--progs/tests/texcmp.c25
-rw-r--r--progs/tests/texcomp_image.h2
-rw-r--r--progs/tests/texcompsub.c8
-rw-r--r--progs/tests/texdown.c5
-rw-r--r--progs/tests/texleak.c140
-rw-r--r--progs/tests/unfilledclip.c2
-rw-r--r--progs/tests/vao-01.c8
-rw-r--r--progs/tests/vao-02.c8
-rw-r--r--progs/tests/vparray.c13
-rw-r--r--progs/tests/vpeval.c10
-rw-r--r--progs/tests/zreaddraw.c5
38 files changed, 1235 insertions, 122 deletions
diff --git a/progs/tests/Makefile b/progs/tests/Makefile
index 4d9b4e8388..836396b249 100644
--- a/progs/tests/Makefile
+++ b/progs/tests/Makefile
@@ -25,9 +25,11 @@ SOURCES = \
arbvptorus.c \
arbvpwarpmesh.c \
arraytexture.c \
+ auxbuffer.c \
blendminmax.c \
blendsquare.c \
blendxor.c \
+ blitfb.c \
bufferobj.c \
bumpmap.c \
bug_3050.c \
@@ -35,11 +37,14 @@ SOURCES = \
bug_3195.c \
bug_texstore_i8.c \
calibrate_rast.c \
+ condrender.c \
copypixrate.c \
crossbar.c \
cva.c \
drawbuffers.c \
+ drawbuffers2.c \
exactrast.c \
+ ext422square.c \
floattex.c \
fbotest1.c \
fbotest2.c \
@@ -65,6 +70,8 @@ SOURCES = \
mipmap_limits.c \
mipmap_view.c \
multipal.c \
+ multitexarray.c \
+ multiwindow.c \
no_s3tc.c \
packedpixels.c \
pbo.c \
@@ -87,10 +94,13 @@ SOURCES = \
subtex \
subtexrate.c \
tex1d.c \
+ texcmp.c \
texcompress2.c \
texcompsub.c \
texdown \
texfilt.c \
+ texgenmix.c \
+ texleak.c \
texline.c \
texobj.c \
texobjshare.c \
@@ -100,6 +110,7 @@ SOURCES = \
vao-01.c \
vao-02.c \
vparray.c \
+ vpeval.c \
vptest1.c \
vptest2.c \
vptest3.c \
diff --git a/progs/tests/SConscript b/progs/tests/SConscript
index bb6a1d2b8a..e2c6538288 100644
--- a/progs/tests/SConscript
+++ b/progs/tests/SConscript
@@ -1,23 +1,5 @@
Import('*')
-if not env['GLUT']:
- Return()
-
-env = env.Clone()
-
-env.Prepend(CPPPATH = [
- '../util',
-])
-
-env.Prepend(LIBS = [
- util,
- '$GLUT_LIB'
-])
-
-if env['platform'] == 'windows':
- env.Append(CPPDEFINES = ['NOMINMAX'])
- env.Prepend(LIBS = ['winmm'])
-
linux_progs = [
'api_speed',
]
@@ -52,16 +34,19 @@ progs = [
'blendminmax',
'blendsquare',
'blendxor',
+ 'blitfb',
'bufferobj',
'bug_3050',
'bug_3101',
'bug_3195',
'bug_texstore_i8',
'calibrate_rast',
+ 'condrender',
'copypixrate',
'crossbar',
'cva',
'drawbuffers',
+ 'drawbuffers2',
'exactrast',
'ext422square',
'fbotest1',
@@ -137,7 +122,7 @@ progs = [
]
for prog in progs:
- env.Program(
+ progs_env.Program(
target = prog,
source = prog + '.c',
)
diff --git a/progs/tests/arbgpuprog.c b/progs/tests/arbgpuprog.c
index 23aa899d96..6098dca787 100644
--- a/progs/tests/arbgpuprog.c
+++ b/progs/tests/arbgpuprog.c
@@ -134,6 +134,8 @@ static void Init( const char *vertProgFile,
}
len = fread(buf, 1, 10*1000,f);
+ fclose(f);
+
glProgramStringARB_func(GL_VERTEX_PROGRAM_ARB,
GL_PROGRAM_FORMAT_ASCII_ARB,
len,
@@ -170,6 +172,8 @@ static void Init( const char *vertProgFile,
}
len = fread(buf, 1, 10*1000,f);
+ fclose(f);
+
glProgramStringARB_func(GL_FRAGMENT_PROGRAM_ARB,
GL_PROGRAM_FORMAT_ASCII_ARB,
len,
diff --git a/progs/tests/arraytexture.c b/progs/tests/arraytexture.c
index 6c0484df0d..28252a354b 100644
--- a/progs/tests/arraytexture.c
+++ b/progs/tests/arraytexture.c
@@ -77,10 +77,6 @@ static GLfloat texZ = 0.0;
static GLfloat texZ_dir = 0.01;
static GLint num_layers;
-static PFNGLBINDPROGRAMARBPROC bind_program;
-static PFNGLPROGRAMSTRINGARBPROC program_string;
-static PFNGLGENPROGRAMSARBPROC gen_programs;
-
static void
PrintString(const char *s)
@@ -125,13 +121,13 @@ static void Display(void)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 0);
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
glColor3f(1,1,1);
glRasterPos3f(-0.9, -0.9, 0.0);
sprintf(str, "Texture Z coordinate = %4.1f", texZ);
PrintString(str);
- (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 1);
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 1);
GL_CHECK_ERROR();
glEnable(GL_TEXTURE_2D_ARRAY_EXT);
GL_CHECK_ERROR();
@@ -159,7 +155,7 @@ static void Display(void)
glDisable(GL_TEXTURE_2D_ARRAY_EXT);
GL_CHECK_ERROR();
- (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 0);
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
GL_CHECK_ERROR();
glutSwapBuffers();
@@ -226,8 +222,8 @@ compile_fragment_program(GLuint id, const char *prog)
int err;
err = glGetError();
- (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, id);
- (*program_string)(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, id);
+ glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(prog), (const GLubyte *) prog);
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
@@ -264,11 +260,6 @@ static void Init(void)
require_extension("GL_MESA_texture_array");
require_extension("GL_SGIS_generate_mipmap");
- bind_program = glutGetProcAddress("glBindProgramARB");
- program_string = glutGetProcAddress("glProgramStringARB");
- gen_programs = glutGetProcAddress("glGenProgramsARB");
-
-
for (num_layers = 0; textures[num_layers] != NULL; num_layers++)
/* empty */ ;
diff --git a/progs/tests/blitfb.c b/progs/tests/blitfb.c
new file mode 100644
index 0000000000..18c8380a5e
--- /dev/null
+++ b/progs/tests/blitfb.c
@@ -0,0 +1,259 @@
+/**
+ * Test glFramebufferBlit()
+ * Brian Paul
+ * 27 Oct 2009
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+
+static int Win;
+static int WinWidth = 1100, WinHeight = 600;
+
+static int SrcWidth = 512, SrcHeight = 512;
+static int DstWidth = 512, DstHeight = 512;
+
+static GLuint SrcFB, DstFB;
+static GLuint SrcTex, DstTex;
+
+#if 0
+static GLenum SrcTexTarget = GL_TEXTURE_2D, SrcTexFace = GL_TEXTURE_2D;
+#else
+static GLenum SrcTexTarget = GL_TEXTURE_CUBE_MAP, SrcTexFace = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+#endif
+
+static GLenum DstTexTarget = GL_TEXTURE_2D, DstTexFace = GL_TEXTURE_2D;
+
+static GLuint SrcTexLevel = 01, DstTexLevel = 0;
+
+
+static void
+Draw(void)
+{
+ GLboolean rp = GL_FALSE;
+ GLubyte *buf;
+ GLint srcWidth = SrcWidth >> SrcTexLevel;
+ GLint srcHeight = SrcHeight >> SrcTexLevel;
+ GLint dstWidth = DstWidth >> DstTexLevel;
+ GLint dstHeight = DstHeight >> DstTexLevel;
+ GLenum status;
+
+ /* clear window */
+ glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
+ glClearColor(0.5, 0.5, 0.5, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+
+ /* clear src buf */
+ glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB);
+ status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ assert(status == GL_FRAMEBUFFER_COMPLETE_EXT);
+ glClearColor(0, 1, 0, 0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* clear dst buf */
+ glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB);
+ status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ assert(status == GL_FRAMEBUFFER_COMPLETE_EXT);
+ glClearColor(1, 0, 0, 0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* blit src -> dst */
+ glBindFramebufferEXT(GL_READ_FRAMEBUFFER, SrcFB);
+ glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, DstFB);
+ glBlitFramebufferEXT(0, 0, srcWidth, srcHeight,
+ 0, 0, dstWidth, dstHeight,
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);
+
+#if 01
+ /* read src results */
+ buf = malloc(4 * srcWidth * srcHeight);
+ memset(buf, 0x88, 4 * srcWidth * srcHeight);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB);
+ if (rp)
+ glReadPixels(0, 0, srcWidth, srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+ else {
+ glBindTexture(SrcTexTarget, SrcTex);
+ glGetTexImage(SrcTexFace, SrcTexLevel, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+ }
+
+ /* draw dst in window */
+ glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
+ glWindowPos2i(0, 0);
+ glDrawPixels(srcWidth, srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+
+ printf("Src Pix[0] = %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]);
+ free(buf);
+#endif
+
+ glFinish();
+
+ /* read dst results */
+ buf = malloc(4 * dstWidth * dstHeight);
+ memset(buf, 0x88, 4 * dstWidth * dstHeight);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB);
+ if (rp)
+ glReadPixels(0, 0, dstWidth, dstHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+ else {
+ glBindTexture(DstTexTarget, DstTex);
+ glGetTexImage(DstTexFace, DstTexLevel, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+ }
+
+ /* draw dst in window */
+ glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
+ glWindowPos2i(srcWidth + 2, 0);
+ glDrawPixels(dstWidth, dstHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+
+ printf("Dst Pix[0] = %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]);
+ free(buf);
+
+ glFinish();
+
+ glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ WinWidth = width;
+ WinHeight = height;
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
+ 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:
+ glutDestroyWindow(Win);
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+SpecialKey(int key, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+InitFBOs(void)
+{
+ GLuint w, h, lvl;
+
+ /* Src */
+ glGenTextures(1, &SrcTex);
+ glBindTexture(SrcTexTarget, SrcTex);
+ w = SrcWidth;
+ h = SrcHeight;
+ lvl = 0;
+ for (lvl = 0; ; lvl++) {
+ if (SrcTexTarget == GL_TEXTURE_CUBE_MAP) {
+ GLuint f;
+ for (f = 0; f < 6; f++) {
+ glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, lvl, GL_RGBA8,
+ w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ }
+ }
+ else {
+ /* single face */
+ glTexImage2D(SrcTexFace, lvl, GL_RGBA8, w, h, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ }
+ if (w == 1 && h == 1)
+ break;
+ if (w > 1)
+ w /= 2;
+ if (h > 1)
+ h /= 2;
+ }
+
+ glGenFramebuffersEXT(1, &SrcFB);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ SrcTexFace, SrcTex, SrcTexLevel);
+
+ /* Dst */
+ glGenTextures(1, &DstTex);
+ glBindTexture(DstTexTarget, DstTex);
+ w = DstWidth;
+ h = DstHeight;
+ lvl = 0;
+ for (lvl = 0; ; lvl++) {
+ glTexImage2D(DstTexFace, lvl, GL_RGBA8, w, h, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ if (w == 1 && h == 1)
+ break;
+ if (w > 1)
+ w /= 2;
+ if (h > 1)
+ h /= 2;
+ }
+
+ glGenFramebuffersEXT(1, &DstFB);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ DstTexFace, DstTex, DstTexLevel);
+}
+
+
+static void
+Init(void)
+{
+ if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
+ fprintf(stderr, "This test requires GL_EXT_framebuffer_object\n");
+ exit(1);
+ }
+
+ if (!glutExtensionSupported("GL_EXT_framebuffer_blit")) {
+ fprintf(stderr, "This test requires GL_EXT_framebuffer_blit,\n");
+ exit(1);
+ }
+
+ InitFBOs();
+
+ printf("Left rect = src FBO, Right rect = dst FBO.\n");
+ printf("Both should be green.\n");
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowSize(WinWidth, WinHeight);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ Win = glutCreateWindow(argv[0]);
+ glewInit();
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutSpecialFunc(SpecialKey);
+ glutDisplayFunc(Draw);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/bug_texstore_i8.c b/progs/tests/bug_texstore_i8.c
index 10e5eba7c5..b070011bd2 100644
--- a/progs/tests/bug_texstore_i8.c
+++ b/progs/tests/bug_texstore_i8.c
@@ -73,7 +73,7 @@ static void Init(void)
0,
sourceFormat,
GL_UNSIGNED_BYTE,
- //GL_UNSIGNED_INT,
+ /* GL_UNSIGNED_INT, */
tex2d);
glEnable(Target);
diff --git a/progs/tests/condrender.c b/progs/tests/condrender.c
new file mode 100644
index 0000000000..1db8a7c15a
--- /dev/null
+++ b/progs/tests/condrender.c
@@ -0,0 +1,242 @@
+/*
+ * Test GL_NV_conditional_render
+ *
+ * Brian Paul
+ * 30 Dec 2009
+ *
+ * Copyright (C) 2009 VMware, Inc. 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
+ * 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 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 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.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+#define TEST_DISPLAY_LISTS 0
+
+static GLboolean Anim = GL_TRUE;
+static GLfloat Xpos = 0;
+static GLuint OccQuery;
+static GLint Win = 0;
+
+
+static void Idle(void)
+{
+ static int lastTime = 0;
+ static int sign = +1;
+ int time = glutGet(GLUT_ELAPSED_TIME);
+ float step;
+
+ if (lastTime == 0)
+ lastTime = time;
+ else if (time - lastTime < 20) /* 50Hz update */
+ return;
+
+ step = (time - lastTime) / 1000.0 * sign;
+ lastTime = time;
+
+ Xpos += step;
+
+ if (Xpos > 2.5) {
+ Xpos = 2.5;
+ sign = -1;
+ }
+ else if (Xpos < -2.5) {
+ Xpos = -2.5;
+ sign = +1;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Display( void )
+{
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glEnable(GL_DEPTH_TEST);
+
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -15.0 );
+
+ /* draw the occluding polygons */
+ glColor3f(0, 0.6, 0.8);
+ glBegin(GL_QUADS);
+ glVertex2f(-1.6, -1.5);
+ glVertex2f(-0.4, -1.5);
+ glVertex2f(-0.4, 1.5);
+ glVertex2f(-1.6, 1.5);
+
+ glVertex2f( 0.4, -1.5);
+ glVertex2f( 1.6, -1.5);
+ glVertex2f( 1.6, 1.5);
+ glVertex2f( 0.4, 1.5);
+ glEnd();
+
+ /* draw the test polygon with occlusion testing */
+ glPushMatrix();
+ glTranslatef(Xpos, 0, -0.5);
+ glScalef(0.3, 0.3, 1.0);
+ glRotatef(-90.0 * Xpos, 0, 0, 1);
+
+#if TEST_DISPLAY_LISTS
+ glNewList(10, GL_COMPILE);
+ glBeginQueryARB(GL_SAMPLES_PASSED_ARB, OccQuery);
+ glEndList();
+ glCallList(10);
+#else
+ glBeginQueryARB(GL_SAMPLES_PASSED_ARB, OccQuery);
+#endif
+
+ glColorMask(0, 0, 0, 0);
+ glDepthMask(GL_FALSE);
+
+ glBegin(GL_POLYGON);
+ glVertex3f(-1, -1, 0);
+ glVertex3f( 1, -1, 0);
+ glVertex3f( 1, 1, 0);
+ glVertex3f(-1, 1, 0);
+ glEnd();
+
+#if TEST_DISPLAY_LISTS
+ glNewList(11, GL_COMPILE);
+ glEndQueryARB(GL_SAMPLES_PASSED_ARB);
+ glEndList();
+ glCallList(11);
+#else
+ glEndQueryARB(GL_SAMPLES_PASSED_ARB);
+#endif
+
+ glColorMask(1, 1, 1, 1);
+ glDepthMask(GL_TRUE);
+
+ /* Note: disable depth test here so that we'll always see the orange
+ * box, except when it's totally culled.
+ */
+ glDisable(GL_DEPTH_TEST);
+
+ glBeginConditionalRenderNV(OccQuery, GL_QUERY_WAIT_NV);
+ /* draw the orange rect, so we can see what's going on */
+ glColor3f(0.8, 0.5, 0);
+ glBegin(GL_POLYGON);
+ glVertex3f(-1, -1, 0);
+ glVertex3f( 1, -1, 0);
+ glVertex3f( 1, 1, 0);
+ glVertex3f(-1, 1, 0);
+ glEnd();
+ glEndConditionalRenderNV();
+
+ /* always draw white outline around orange box */
+ glColor3f(1.0, 1.0, 1.0);
+ glBegin(GL_LINE_LOOP);
+ glVertex3f(-1, -1, 0);
+ glVertex3f( 1, -1, 0);
+ glVertex3f( 1, 1, 0);
+ glVertex3f(-1, 1, 0);
+ glEnd();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ glDeleteQueriesARB(1, &OccQuery);
+ glutDestroyWindow(Win);
+ exit(0);
+ break;
+ case ' ':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+ const GLfloat step = 0.1;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_LEFT:
+ Xpos -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Xpos += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+ if (!glutExtensionSupported("GL_ARB_occlusion_query") ||
+ !glutExtensionSupported("GL_NV_conditional_render")) {
+ printf("Sorry, this demo requires the extensions:\n");
+ printf(" GL_ARB_occlusion_query\n");
+ printf(" GL_NV_conditional_render\n");
+ exit(-1);
+ }
+
+ glGenQueriesARB(1, &OccQuery);
+ assert(OccQuery > 0);
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInitWindowSize( 400, 400 );
+ glutInit( &argc, argv );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
+ Win = glutCreateWindow(argv[0]);
+ glewInit();
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutSpecialFunc( SpecialKey );
+ glutIdleFunc( Idle );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/crossbar.c b/progs/tests/crossbar.c
index 3dd21372f9..2988e20920 100644
--- a/progs/tests/crossbar.c
+++ b/progs/tests/crossbar.c
@@ -145,7 +145,7 @@ static void Init( void )
{
const char * const ver_string = (const char * const)
glGetString( GL_VERSION );
- float ver = strtof( ver_string, NULL );
+ float ver = strtod( ver_string, NULL );
GLint tex_units;
GLint temp[ 256 ];
@@ -174,7 +174,7 @@ static void Init( void )
exit(1);
}
- printf("\nAll %u squares should be the same color.\n", NUM_TESTS + 1);
+ printf("\nAll %lu squares should be the same color.\n", (unsigned long) NUM_TESTS + 1);
(void) memset( temp, 0x00, sizeof( temp ) );
glBindTexture( GL_TEXTURE_2D, 1 );
diff --git a/progs/tests/cva.c b/progs/tests/cva.c
index 80483900cb..02d1dcba2e 100644
--- a/progs/tests/cva.c
+++ b/progs/tests/cva.c
@@ -39,7 +39,7 @@ GLboolean compiled = GL_TRUE;
GLboolean doubleBuffer = GL_TRUE;
-void init( void )
+static void init( void )
{
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glShadeModel( GL_SMOOTH );
@@ -69,7 +69,7 @@ void init( void )
#endif
}
-void display( void )
+static void display( void )
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
@@ -81,7 +81,7 @@ void display( void )
}
}
-void keyboard( unsigned char key, int x, int y )
+static void keyboard( unsigned char key, int x, int y )
{
switch ( key ) {
case 27:
@@ -92,7 +92,7 @@ void keyboard( unsigned char key, int x, int y )
glutPostRedisplay();
}
-GLboolean args( int argc, char **argv )
+static GLboolean args( int argc, char **argv )
{
GLint i;
diff --git a/progs/tests/drawbuffers.c b/progs/tests/drawbuffers.c
index d75a870c26..7a19933e62 100644
--- a/progs/tests/drawbuffers.c
+++ b/progs/tests/drawbuffers.c
@@ -43,6 +43,8 @@ Display(void)
glUseProgram_func(Program);
+ glEnable(GL_DEPTH_TEST);
+
/* draw to user framebuffer */
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject);
@@ -68,18 +70,23 @@ Display(void)
glPopMatrix();
/* read from user framebuffer */
- /* bottom half = colorbuffer 0 */
+ /* left half = colorbuffer 0 */
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
- glReadPixels(0, 0, Width, Height / 2, GL_RGBA, GL_UNSIGNED_BYTE,
+ glPixelStorei(GL_PACK_ROW_LENGTH, Width);
+ glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
+ glReadPixels(0, 0, Width / 2, Height, GL_RGBA, GL_UNSIGNED_BYTE,
buffer);
- /* top half = colorbuffer 1 */
+
+ /* right half = colorbuffer 1 */
glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
- glReadPixels(0, Height/2, Width, Height - Height / 2,
+ glPixelStorei(GL_PACK_SKIP_PIXELS, Width / 2);
+ glReadPixels(Width / 2, 0, Width - Width / 2, Height,
GL_RGBA, GL_UNSIGNED_BYTE,
- buffer + Width * (Height / 2) * 4);
+ buffer);
/* draw to window */
glUseProgram_func(0);
+ glDisable(GL_DEPTH_TEST);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glWindowPos2iARB(0, 0);
glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
diff --git a/progs/tests/drawbuffers2.c b/progs/tests/drawbuffers2.c
new file mode 100644
index 0000000000..7b8cc5ca6a
--- /dev/null
+++ b/progs/tests/drawbuffers2.c
@@ -0,0 +1,364 @@
+/*
+ * Test GL_ARB_draw_buffers2, GL_ARB_draw_buffers, GL_EXT_framebuffer_object
+ * and GLSL's gl_FragData[].
+ *
+ * We draw to two color buffers and show the left half of the first
+ * color buffer on the left side of the window, and show the right
+ * half of the second color buffer on the right side of the window.
+ *
+ * Different color masks are used for the two color buffers.
+ * Blending is enabled for the second buffer only.
+ *
+ * Brian Paul
+ * 31 Dec 2009
+ */
+
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+#include "extfuncs.h"
+
+static int Win;
+static int Width = 400, Height = 400;
+static GLuint FBobject, RBobjects[3];
+static GLfloat Xrot = 0.0, Yrot = 0.0;
+static GLuint Program;
+static GLboolean Anim = GL_TRUE;
+
+
+static void
+CheckError(int line)
+{
+ GLenum err = glGetError();
+ if (err) {
+ printf("GL Error 0x%x at line %d\n", (int) err, line);
+ }
+}
+
+
+static void
+Display(void)
+{
+ GLubyte *buffer = malloc(Width * Height * 4);
+ static const GLenum buffers[2] = {
+ GL_COLOR_ATTACHMENT0_EXT,
+ GL_COLOR_ATTACHMENT1_EXT
+ };
+
+ glUseProgram_func(Program);
+
+ glEnable(GL_DEPTH_TEST);
+
+ /* draw to user framebuffer */
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject);
+
+ /* Clear color buffer 0 (blue) */
+ glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ /* Clear color buffer 1 (1 - blue) */
+ glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glClear(GL_DEPTH_BUFFER_BIT);
+
+ /* draw to two buffers w/ fragment shader */
+ glDrawBuffersARB(2, buffers);
+
+ /* different color masks for each buffer */
+ if (1) {
+ glColorMaskIndexedEXT(0, GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
+ glColorMaskIndexedEXT(1, GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE);
+ }
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glPushMatrix();
+ glTranslatef(1, 0, 0);
+ glutSolidTorus(1.0, 2.0, 10, 20);
+ glPopMatrix();
+ glPushMatrix();
+ glTranslatef(-1, 0, 0);
+ glRotatef(90, 1, 0, 0);
+ glutSolidTorus(1.0, 2.0, 10, 20);
+ glPopMatrix();
+ glPopMatrix();
+
+ /* restore default color masks */
+ glColorMaskIndexedEXT(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glColorMaskIndexedEXT(1, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+
+ /* read from user framebuffer */
+ /* left half = colorbuffer 0 */
+ glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
+ glPixelStorei(GL_PACK_ROW_LENGTH, Width);
+ glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
+ glReadPixels(0, 0, Width / 2, Height, GL_RGBA, GL_UNSIGNED_BYTE,
+ buffer);
+
+ /* right half = colorbuffer 1 */
+ glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
+ glPixelStorei(GL_PACK_SKIP_PIXELS, Width / 2);
+ glReadPixels(Width / 2, 0, Width - Width / 2, Height,
+ GL_RGBA, GL_UNSIGNED_BYTE,
+ buffer);
+
+ /* draw to window */
+ glUseProgram_func(0);
+ glDisable(GL_DEPTH_TEST);
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glWindowPos2iARB(0, 0);
+ glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
+
+ free(buffer);
+ glutSwapBuffers();
+ CheckError(__LINE__);
+}
+
+
+static void
+Idle(void)
+{
+ Xrot = glutGet(GLUT_ELAPSED_TIME) * 0.05;
+ glutPostRedisplay();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ float ar = (float) width / (float) height;
+
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-ar, ar, -1.0, 1.0, 5.0, 35.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -20.0);
+
+ Width = width;
+ Height = height;
+
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[0]);
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[1]);
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[2]);
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
+ Width, Height);
+}
+
+
+static void
+CleanUp(void)
+{
+ glDeleteFramebuffersEXT(1, &FBobject);
+ glDeleteRenderbuffersEXT(3, RBobjects);
+ glutDestroyWindow(Win);
+ exit(0);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case ' ':
+ Anim = !Anim;
+ glutIdleFunc(Anim ? Idle : NULL);
+ break;
+ case 'x':
+ Xrot += 5.0;
+ break;
+ case 'X':
+ Xrot -= 5.0;
+ break;
+ case 'y':
+ Yrot += 5.0;
+ break;
+ case 'Y':
+ Yrot -= 5.0;
+ break;
+ case 27:
+ CleanUp();
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+CheckExtensions(void)
+{
+ const char *req[] = {
+ "GL_EXT_framebuffer_object",
+ "GL_ARB_draw_buffers",
+ "GL_EXT_draw_buffers2"
+ };
+
+ const char *version = (const char *) glGetString(GL_VERSION);
+ GLint numBuf;
+ GLint i;
+
+ for (i = 0; i < 3; i++) {
+ if (!glutExtensionSupported(req[i])) {
+ printf("Sorry, %s extension is required!\n", req[i]);
+ exit(1);
+ }
+ }
+ if (version[0] != '2') {
+ printf("Sorry, OpenGL 2.0 is required!\n");
+ exit(1);
+ }
+
+ glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &numBuf);
+ printf("GL_MAX_DRAW_BUFFERS_ARB = %d\n", numBuf);
+ if (numBuf < 2) {
+ printf("Sorry, GL_MAX_DRAW_BUFFERS_ARB needs to be >= 2\n");
+ exit(1);
+ }
+
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+}
+
+
+static void
+SetupRenderbuffers(void)
+{
+ glGenFramebuffersEXT(1, &FBobject);
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject);
+
+ glGenRenderbuffersEXT(3, RBobjects);
+
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[0]);
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[1]);
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
+
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[2]);
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
+ Width, Height);
+
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ GL_RENDERBUFFER_EXT, RBobjects[0]);
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
+ GL_RENDERBUFFER_EXT, RBobjects[1]);
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, RBobjects[2]);
+
+ CheckError(__LINE__);
+}
+
+
+static GLuint
+LoadAndCompileShader(GLenum target, const char *text)
+{
+ GLint stat;
+ GLuint shader = glCreateShader_func(target);
+ glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
+ glCompileShader_func(shader);
+ glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
+ if (!stat) {
+ GLchar log[1000];
+ GLsizei len;
+ glGetShaderInfoLog_func(shader, 1000, &len, log);
+ fprintf(stderr, "drawbuffers: problem compiling shader:\n%s\n", log);
+ exit(1);
+ }
+ return shader;
+}
+
+
+static void
+CheckLink(GLuint prog)
+{
+ GLint stat;
+ glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
+ if (!stat) {
+ GLchar log[1000];
+ GLsizei len;
+ glGetProgramInfoLog_func(prog, 1000, &len, log);
+ fprintf(stderr, "drawbuffers: shader link error:\n%s\n", log);
+ }
+}
+
+
+static void
+SetupShaders(void)
+{
+ /* emit same color to both draw buffers */
+ static const char *fragShaderText =
+ "void main() {\n"
+ " gl_FragData[0] = gl_Color; \n"
+ " gl_FragData[1] = gl_Color; \n"
+ "}\n";
+
+ GLuint fragShader;
+
+ fragShader = LoadAndCompileShader(GL_FRAGMENT_SHADER, fragShaderText);
+ Program = glCreateProgram_func();
+
+ glAttachShader_func(Program, fragShader);
+ glLinkProgram_func(Program);
+ CheckLink(Program);
+ glUseProgram_func(Program);
+}
+
+
+static void
+SetupLighting(void)
+{
+ static const GLfloat ambient[4] = { 0.0, 0.0, 0.0, 0.0 };
+ static const GLfloat diffuse[4] = { 1.0, 1.0, 1.0, 0.75 };
+
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
+
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_LIGHTING);
+}
+
+
+static void
+Init(void)
+{
+ CheckExtensions();
+ GetExtensionFuncs();
+ SetupRenderbuffers();
+ SetupShaders();
+ SetupLighting();
+ glEnable(GL_DEPTH_TEST);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnableIndexedEXT(GL_BLEND, 1);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(Width, Height);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+ Win = glutCreateWindow(argv[0]);
+ glewInit();
+ glutIdleFunc(Anim ? Idle : NULL);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Display);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/fptest1.c b/progs/tests/fptest1.c
index 2b8f8d0f5e..1f30d5733e 100644
--- a/progs/tests/fptest1.c
+++ b/progs/tests/fptest1.c
@@ -57,6 +57,7 @@ static void Key( unsigned char key, int x, int y )
static void Init( void )
{
+#if 0
static const char *prog0 =
"!!FP1.0\n"
"MUL o[COLR], R0, f[WPOS]; \n"
@@ -73,6 +74,7 @@ static void Init( void )
"MOV HC, H2; \n"
"END \n"
;
+#endif
/* masked updates, defines, declarations */
static const char *prog1 =
diff --git a/progs/tests/getprocaddress.c b/progs/tests/getprocaddress.c
index a09ea58e1d..e699baf44b 100644
--- a/progs/tests/getprocaddress.c
+++ b/progs/tests/getprocaddress.c
@@ -1188,7 +1188,7 @@ exercise_buffer_objects(enum Map_Buffer_Usage usage)
GLuint bufferID;
GLint bufferMapped;
static GLubyte data[BUFFER_DATA_SIZE] = {0};
- float *dataPtr;
+ float *dataPtr = NULL;
/* Get the function pointers we need. These are from
* GL_ARB_vertex_buffer_object and are required in all
@@ -3516,7 +3516,7 @@ check_functions( const char *extensions )
struct name_test_pair *entry;
int failures = 0, passes = 0, untested = 0;
int totalFail = 0, totalPass = 0, totalUntested = 0, totalUnsupported = 0;
- int doTests;
+ int doTests = 0;
const char *version = (const char *) glGetString(GL_VERSION);
/* The functions list will have "real" entries (consisting of
diff --git a/progs/tests/getteximage.c b/progs/tests/getteximage.c
index 71f29b4ac8..e4053b8de1 100644
--- a/progs/tests/getteximage.c
+++ b/progs/tests/getteximage.c
@@ -58,6 +58,26 @@ TestGetTexImage(GLboolean npot)
abort();
}
}
+
+ /* get as BGRA */
+ glGetTexImage(GL_TEXTURE_2D, level, GL_BGRA, GL_UNSIGNED_BYTE, data2);
+
+ /* compare */
+ {
+ const GLubyte *rgba = (GLubyte *) data;
+ const GLubyte *bgra = (GLubyte *) data2;
+ for (i = 0; i < w * h; i += 4) {
+ if (rgba[i+0] != bgra[i+2] ||
+ rgba[i+1] != bgra[i+1] ||
+ rgba[i+2] != bgra[i+0] ||
+ rgba[i+3] != bgra[i+3]) {
+ printf("glTexImage + glGetTexImage(GL_BGRA) failure!\n");
+ printf("Expected value %d, found %d\n", data[i], data2[i]);
+ abort();
+ }
+ }
+ }
+
}
printf("Passed\n");
diff --git a/progs/tests/invert.c b/progs/tests/invert.c
index 63099fbd22..45001b44d0 100644
--- a/progs/tests/invert.c
+++ b/progs/tests/invert.c
@@ -128,7 +128,7 @@ static void Init( void )
{
const char * const ver_string = (const char * const)
glGetString( GL_VERSION );
- const float ver = strtof( ver_string, NULL );
+ const float ver = strtod( ver_string, NULL );
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
@@ -165,7 +165,7 @@ static void Init( void )
"square should look upside-down.\n");
- image = LoadRGBImage( IMAGE_FILE, & img_width, & img_height,
+ image = LoadRGBImage( IMAGE_FILE, (GLint *) & img_width, (GLint *) & img_height,
& img_format );
if ( image == NULL ) {
printf( "Could not open image file \"%s\".\n", IMAGE_FILE );
diff --git a/progs/tests/minmag.c b/progs/tests/minmag.c
index 03019f94fa..179be51120 100644
--- a/progs/tests/minmag.c
+++ b/progs/tests/minmag.c
@@ -16,7 +16,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#include <GL/glew.h>
#include <GL/glut.h>
diff --git a/progs/tests/mipmap_comp.c b/progs/tests/mipmap_comp.c
index 5842e2b880..dd2232113b 100644
--- a/progs/tests/mipmap_comp.c
+++ b/progs/tests/mipmap_comp.c
@@ -285,6 +285,12 @@ main(int argc, char** argv)
glutInitWindowSize (600, 600);
glutCreateWindow (argv[0]);
glewInit();
+
+ if (!glutExtensionSupported("GL_EXT_texture_compression_s3tc")) {
+ fprintf(stderr, "This test requires GL_EXT_texture_compression_s3tc.\n");
+ exit(1);
+ }
+
myInit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
diff --git a/progs/tests/packedpixels.c b/progs/tests/packedpixels.c
index 1703b271cb..34df95549a 100644
--- a/progs/tests/packedpixels.c
+++ b/progs/tests/packedpixels.c
@@ -17,53 +17,53 @@ struct pixel_format {
GLenum format;
GLenum type;
GLint bytes;
- GLuint redTexel, greenTexel;
+ GLuint redTexel, greenTexel; /* with approx 51% alpha, when applicable */
};
static const struct pixel_format Formats[] = {
{ "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8",
- GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, 0xff000000, 0x00ff0000 },
+ GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, 0xff000080, 0x00ff0080 },
{ "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8_REV",
- GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x000000ff, 0x0000ff00 },
+ GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x800000ff, 0x8000ff00 },
{ "GL_RGBA/GL_UNSIGNED_INT_10_10_10_2",
- GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 4, 0xffc00000, 0x3ff000 },
+ GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 4, 0xffc00002, 0x3ff002 },
{ "GL_RGBA/GL_UNSIGNED_INT_2_10_10_10_REV",
- GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4, 0x3ff, 0xffc00 },
+ GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4, 0xc00003ff, 0xc00ffc00 },
{ "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4",
- GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0xf000, 0x0f00 },
+ GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0xf008, 0x0f08 },
{ "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4_REV",
- GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x000f, 0x00f0 },
+ GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x800f, 0x80f0 },
{ "GL_RGBA/GL_UNSIGNED_SHORT_5_5_5_1",
- GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf800, 0x7c0 },
+ GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf801, 0x7c1 },
{ "GL_RGBA/GL_UNSIGNED_SHORT_1_5_5_5_REV",
- GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x1f, 0x3e0 },
+ GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x801f, 0x83e0 },
{ "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8",
- GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, 0x0000ff00, 0x00ff0000 },
+ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, 0x0000ff80, 0x00ff0080 },
{ "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8_REV",
- GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x00ff0000, 0x0000ff00 },
+ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x80ff0000, 0x8000ff00 },
{ "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4",
- GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x00f0, 0x0f00 },
+ GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x00f8, 0x0f08 },
{ "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4_REV",
- GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x0f00, 0x00f0 },
+ GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x8f00, 0x80f0 },
{ "GL_BGRA/GL_UNSIGNED_SHORT_5_5_5_1",
- GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x3e, 0x7c0 },
+ GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x3f, 0x7c1 },
{ "GL_BGRA/GL_UNSIGNED_SHORT_1_5_5_5_REV",
- GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x7c00, 0x3e0 },
+ GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0xfc00, 0x83e0 },
{ "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8",
- GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, 4, 0x000000ff, 0x0000ff00 },
+ GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, 4, 0x800000ff, 0x8000ff00 },
{ "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8_REV",
- GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0xff000000, 0x00ff0000 },
+ GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0xff000080, 0x00ff0080 },
{ "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4",
- GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x000f, 0x00f0 },
+ GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x800f, 0x80f0 },
{ "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4_REV",
- GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0xf000, 0x0f00 },
+ GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0xf008, 0x0f08 },
{ "GL_ABGR_EXT/GL_UNSIGNED_SHORT_5_5_5_1",
- GL_ABGR_EXT, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x1, 0x3e },
+ GL_ABGR_EXT, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf801, 0xf83e },
{ "GL_ABGR_EXT/GL_UNSIGNED_SHORT_1_5_5_5_REV",
- GL_ABGR_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x8000, 0x7c00 },
+ GL_ABGR_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x800f, 0x7c0f },
{ "GL_RGB/GL_UNSIGNED_SHORT_5_6_5",
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 2, 0xf800, 0x7e0 },
@@ -108,7 +108,7 @@ static const struct name_format IntFormats[] = {
static GLuint CurFormat = 0;
static GLboolean Test3D = GL_FALSE;
-
+static GLboolean Blend = GL_FALSE;
static void
@@ -191,6 +191,19 @@ MakeTexture(const struct pixel_format *format, GLenum intFormat, GLboolean swap)
format->format, format->type, texBuffer);
}
+ if (0) {
+ GLint r, g, b, a, l, i;
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &r);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &g);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &b);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &a);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &l);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &i);
+ printf("IntFormat: 0x%x R %d G %d B %d A %d L %d I %d\n",
+ intFormat, r, g, b, a, l, i);
+ glGetError();
+ }
+
if (glGetError()) {
printf("GL Error for %s\n", format->name);
memset(texBuffer, 255, 1000);
@@ -221,6 +234,10 @@ Draw(void)
glEnable(GL_TEXTURE_3D);
else
glEnable(GL_TEXTURE_2D);
+
+ if (Blend)
+ glEnable(GL_BLEND);
+
glBegin(GL_POLYGON);
glTexCoord3f(0, 0, 0.5); glVertex2f(0, 0);
glTexCoord3f(1, 0, 0.5); glVertex2f(w, 0);
@@ -232,6 +249,9 @@ Draw(void)
glDisable(GL_TEXTURE_3D);
else
glDisable(GL_TEXTURE_2D);
+
+ glDisable(GL_BLEND);
+
glColor3f(0, 0, 0);
glRasterPos2i(8, 6);
PrintString(Formats[i].name);
@@ -252,8 +272,8 @@ Draw(void)
glPushMatrix();
glTranslatef(2, (i + 1) * (h + 2), 0);
glRasterPos2i(8, 6);
- sprintf(s, "Internal Texture Format [f/F]: %s (%d of %d)",
- IntFormats[CurFormat].name, CurFormat + 1, NUM_INT_FORMATS);
+ sprintf(s, "Internal Texture Format [f/F]: %s (%d of %lu)",
+ IntFormats[CurFormat].name, CurFormat + 1, (unsigned long) NUM_INT_FORMATS);
PrintString(s);
glPopMatrix();
@@ -266,6 +286,15 @@ Draw(void)
PrintString("Target [2/3]: GL_TEXTURE_2D");
glPopMatrix();
+ glPushMatrix();
+ glTranslatef(2, (i + 3) * (h + 2), 0);
+ glRasterPos2i(8, 6);
+ if (Blend)
+ PrintString("Blend: Yes");
+ else
+ PrintString("Blend: No");
+ glPopMatrix();
+
glutSwapBuffers();
}
@@ -288,6 +317,9 @@ Key(unsigned char key, int x, int y)
(void) x;
(void) y;
switch (key) {
+ case 'b':
+ Blend = !Blend;
+ break;
case 'F':
if (CurFormat == 0)
CurFormat = NUM_INT_FORMATS - 1;
@@ -323,6 +355,7 @@ Init(void)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
diff --git a/progs/tests/prog_parameter.c b/progs/tests/prog_parameter.c
index 6dd956c402..2de7e2994a 100644
--- a/progs/tests/prog_parameter.c
+++ b/progs/tests/prog_parameter.c
@@ -116,7 +116,7 @@ static int set_parameter_batch( GLsizei count, GLfloat * param,
for ( i = 0 ; i < (4 * count) ; i++ ) {
- param[i] = (GLfloat) random() / (GLfloat) random();
+ param[i] = (GLfloat) rand() / (GLfloat) rand();
}
/* Try using the "classic" interface.
@@ -153,7 +153,7 @@ static int set_parameter_batch( GLsizei count, GLfloat * param,
for ( i = 0 ; i < (4 * count) ; i++ ) {
- param[i] = (GLfloat) random() / (GLfloat) random();
+ param[i] = (GLfloat) rand() / (GLfloat) rand();
}
printf("Testing glProgram%sParameters4fvEXT (count = %u)...\n", name, count);
@@ -192,6 +192,7 @@ static void Init( void )
GLfloat * params;
GLint max_program_env_parameters;
GLint max_program_local_parameters;
+ int i;
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
@@ -203,20 +204,20 @@ static void Init( void )
}
- program_local_parameter4fv = glutGetProcAddress( "glProgramLocalParameter4fvARB" );
- program_env_parameter4fv = glutGetProcAddress( "glProgramEnvParameter4fvARB" );
+ program_local_parameter4fv = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) glutGetProcAddress( "glProgramLocalParameter4fvARB" );
+ program_env_parameter4fv = (PFNGLPROGRAMENVPARAMETER4FVARBPROC) glutGetProcAddress( "glProgramEnvParameter4fvARB" );
- get_program_local_parameterfv = glutGetProcAddress( "glGetProgramLocalParameterfvARB" );
- get_program_env_parameterfv = glutGetProcAddress( "glGetProgramEnvParameterfvARB" );
+ get_program_local_parameterfv = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) glutGetProcAddress( "glGetProgramLocalParameterfvARB" );
+ get_program_env_parameterfv = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC) glutGetProcAddress( "glGetProgramEnvParameterfvARB" );
- bind_program = glutGetProcAddress( "glBindProgramARB" );
- get_program = glutGetProcAddress( "glGetProgramivARB" );
+ bind_program = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress( "glBindProgramARB" );
+ get_program = (PFNGLGETPROGRAMIVARBPROC) glutGetProcAddress( "glGetProgramivARB" );
if ( glutExtensionSupported("GL_EXT_gpu_program_parameters") ) {
printf("GL_EXT_gpu_program_parameters available, testing that path.\n");
- program_local_parameters4fv = glutGetProcAddress( "glProgramLocalParameters4fvEXT" );
- program_env_parameters4fv = glutGetProcAddress( "glProgramEnvParameters4fvEXT" );
+ program_local_parameters4fv = (PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) glutGetProcAddress( "glProgramLocalParameters4fvEXT" );
+ program_env_parameters4fv = (PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) glutGetProcAddress( "glProgramEnvParameters4fvEXT" );
}
else {
printf("GL_EXT_gpu_program_parameters not available.\n");
@@ -238,6 +239,10 @@ static void Init( void )
params = malloc(max_program_env_parameters * 4 * sizeof(GLfloat));
+ for (i = 0; i < max_program_env_parameters * 4; i++) {
+ params[i] = 0.0F;
+ }
+
pass &= set_parameter_batch(max_program_env_parameters, params, "Env",
program_env_parameter4fv,
program_env_parameters4fv,
diff --git a/progs/tests/quads.c b/progs/tests/quads.c
index 2098b51ccd..e5b9920b66 100644
--- a/progs/tests/quads.c
+++ b/progs/tests/quads.c
@@ -17,7 +17,10 @@ static GLfloat Xrot = 40, Yrot = 0, Zrot = 0;
static GLboolean Anim = GL_TRUE;
static GLuint Vbuffer = 0;
+#if 1
+#else
static GLfloat buf[NUM_QUADS * 6 * 4];
+#endif
static GLboolean doSwapBuffers = GL_TRUE;
diff --git a/progs/tests/scissor-viewport.c b/progs/tests/scissor-viewport.c
index 582e65fb72..4ef307b424 100644
--- a/progs/tests/scissor-viewport.c
+++ b/progs/tests/scissor-viewport.c
@@ -104,7 +104,7 @@ static void draw(void)
glDisable(GL_SCISSOR_TEST);
- //glutSwapBuffers();
+ /* glutSwapBuffers(); */
glFlush();
}
@@ -120,7 +120,7 @@ int main(int argc, char **argv)
glutInitWindowPosition(100, 0);
glutInitWindowSize(prog.width, prog.height);
- //type = GLUT_RGB | GLUT_DOUBLE;
+ /* type = GLUT_RGB | GLUT_DOUBLE; */
type = GLUT_RGB | GLUT_SINGLE;
glutInitDisplayMode(type);
diff --git a/progs/tests/scissor.c b/progs/tests/scissor.c
index 2dfd2174e8..e5a68ffabd 100644
--- a/progs/tests/scissor.c
+++ b/progs/tests/scissor.c
@@ -134,7 +134,7 @@ static void draw(void)
glDisable(GL_SCISSOR_TEST);
- //glutSwapBuffers();
+ /* glutSwapBuffers(); */
glFlush();
}
@@ -150,7 +150,7 @@ int main(int argc, char **argv)
glutInitWindowPosition(100, 0);
glutInitWindowSize(prog.width, prog.height);
- //type = GLUT_RGB | GLUT_DOUBLE;
+ /* type = GLUT_RGB | GLUT_DOUBLE; */
type = GLUT_RGB | GLUT_SINGLE;
glutInitDisplayMode(type);
diff --git a/progs/tests/shader_api.c b/progs/tests/shader_api.c
index 6453856345..fa0a992540 100644
--- a/progs/tests/shader_api.c
+++ b/progs/tests/shader_api.c
@@ -8,6 +8,10 @@
#include <GL/glew.h>
#include <GL/glut.h>
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+
static void assert_test(const char *file, int line, int cond, const char *msg)
{
if (!cond)
@@ -42,7 +46,7 @@ static void assert_error_test(const char *file, int line, GLenum expect)
#define assert_error(err) assert_error_test(__FILE__, __LINE__, (err))
-static void check_status(GLuint id, GLenum pname, void (*query)(GLuint, GLenum, GLint *))
+static void check_status(GLuint id, GLenum pname, void (APIENTRY *query)(GLuint, GLenum, GLint *))
{
GLint status;
diff --git a/progs/tests/sharedtex.c b/progs/tests/sharedtex.c
index c07ebd719c..2337b88d3f 100644
--- a/progs/tests/sharedtex.c
+++ b/progs/tests/sharedtex.c
@@ -424,13 +424,13 @@ main(int argc, char *argv[])
{
const char *dpyName = XDisplayName(NULL);
- struct window *h0, *h1, *h2, *h3;
+ struct window *h0;
/* four windows and contexts sharing display lists and texture objects */
h0 = AddWindow(dpyName, 10, 10, NULL);
- h1 = AddWindow(dpyName, 330, 10, h0);
- h2 = AddWindow(dpyName, 10, 350, h0);
- h3 = AddWindow(dpyName, 330, 350, h0);
+ (void) AddWindow(dpyName, 330, 10, h0);
+ (void) AddWindow(dpyName, 10, 350, h0);
+ (void) AddWindow(dpyName, 330, 350, h0);
InitGLstuff(h0);
diff --git a/progs/tests/stencil_twoside.c b/progs/tests/stencil_twoside.c
index 1e18ca6b5e..7d871e5877 100644
--- a/progs/tests/stencil_twoside.c
+++ b/progs/tests/stencil_twoside.c
@@ -274,9 +274,9 @@ static void Init( void )
if (atof( ver_string ) < 2.0) {
use20syntax = 0;
}
- stencil_func_separate = glutGetProcAddress( "glStencilFuncSeparate" );
- stencil_func_separate_ati = glutGetProcAddress( "glStencilFuncSeparateATI" );
- stencil_op_separate = glutGetProcAddress( "glStencilOpSeparate" );
+ stencil_func_separate = (PFNGLSTENCILFUNCSEPARATEPROC) glutGetProcAddress( "glStencilFuncSeparate" );
+ stencil_func_separate_ati = (PFNGLSTENCILFUNCSEPARATEATIPROC) glutGetProcAddress( "glStencilFuncSeparateATI" );
+ stencil_op_separate = (PFNGLSTENCILOPSEPARATEPROC) glutGetProcAddress( "glStencilOpSeparate" );
printf("\nAll 5 squares should be the same color.\n");
}
diff --git a/progs/tests/stencilwrap.c b/progs/tests/stencilwrap.c
index 2e219fd8b5..d396fc2a53 100644
--- a/progs/tests/stencilwrap.c
+++ b/progs/tests/stencilwrap.c
@@ -257,7 +257,7 @@ static void Init( void )
* part of GL 1.4.
*/
- ver_str = glGetString( GL_VERSION );
+ ver_str = (char *) glGetString( GL_VERSION );
version = (ver_str == NULL) ? 1.0 : atof( ver_str );
wrapping = (glutExtensionSupported("GL_EXT_stencil_wrap") || (version >= 1.4));
diff --git a/progs/tests/tex1d.c b/progs/tests/tex1d.c
index 4abe1068c7..7d67451c0d 100644
--- a/progs/tests/tex1d.c
+++ b/progs/tests/tex1d.c
@@ -39,11 +39,13 @@ static void draw( void )
+/*
static void idle( void )
{
Angle += 2.0;
glutPostRedisplay();
}
+*/
diff --git a/progs/tests/texcmp.c b/progs/tests/texcmp.c
index d1e829d1b7..c5d352fdae 100644
--- a/progs/tests/texcmp.c
+++ b/progs/tests/texcmp.c
@@ -106,6 +106,8 @@ static void Display( void )
glRotatef(Rot, 0, 0, 1);
glEnable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+
glBegin(GL_POLYGON);
glTexCoord2f(0, 1); glVertex2f(-1, -0.5);
glTexCoord2f(1, 1); glVertex2f( 1, -0.5);
@@ -115,7 +117,10 @@ static void Display( void )
glPopMatrix();
+ glDisable(GL_TEXTURE_2D);
+
/* info */
+ glDisable(GL_BLEND);
glColor4f(1, 1, 1, 1);
glRasterPos3f(-1.2, -0.7, 0);
@@ -149,7 +154,7 @@ static void Reshape( int width, int height )
static void ReInit( GLenum TC, TEXTURE *Tx )
{
- GLint rv;
+ GLint rv, v;
if ((Tx->TC == TC) && (Tx->cData != NULL)) {
glCompressedTexImage2DARB(GL_TEXTURE_2D, /* target */
@@ -170,6 +175,24 @@ static void ReInit( GLenum TC, TEXTURE *Tx )
GL_UNSIGNED_BYTE, /* texture type */
Tx->data); /* the texture */
+
+ v = 0;
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
+ GL_TEXTURE_INTERNAL_FORMAT, &v);
+ printf("Requested internal format = 0x%x, actual = 0x%x\n", TC, v);
+
+ if (0) {
+ GLint r, g, b, a, l, i;
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &r);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &g);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &b);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &a);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &l);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &i);
+ printf("Compressed Bits per R: %d G: %d B: %d A: %d L: %d I: %d\n",
+ r, g, b, a, l, i);
+ }
+
/* okay, now cache the compressed texture */
Tx->TC = TC;
if (Tx->cData != NULL) {
diff --git a/progs/tests/texcomp_image.h b/progs/tests/texcomp_image.h
index e63a56774f..a3884d4d0d 100644
--- a/progs/tests/texcomp_image.h
+++ b/progs/tests/texcomp_image.h
@@ -1,4 +1,4 @@
-static int ImgSize = 131072;
+#define ImgSize 131072
static unsigned char ImgData[131072] =
{
0x4d, 0xbc, 0x0b, 0xb4, 0xda, 0x0a, 0x78, 0xa8, 0x8d, 0xbc, 0x0c, 0xac, 0x8b, 0x7f, 0xeb, 0xf7, 0x8d, 0xbc, 0xeb, 0xab, 0xba, 0xb7, 0x82, 0xa2, 0x8d, 0xbc, 0x2b, 0xb4, 0xa2, 0xfd, 0xee, 0x2f,
diff --git a/progs/tests/texcompsub.c b/progs/tests/texcompsub.c
index 50106bf1e2..215f5711d9 100644
--- a/progs/tests/texcompsub.c
+++ b/progs/tests/texcompsub.c
@@ -35,6 +35,8 @@ LoadCompressedImage(void)
unsigned char ImgDataTemp[ImgSize / 4];
unsigned i;
const GLenum filter = GL_LINEAR;
+ const int half = ImgSize / 2;
+
glTexImage2D(Target, 0, CompFormat, ImgWidth, ImgHeight, 0,
GL_RGB, GL_UNSIGNED_BYTE, NULL);
@@ -42,11 +44,11 @@ LoadCompressedImage(void)
glCompressedTexSubImage2DARB(Target, 0,
0, 0, /* pos */
ImgWidth, ImgHeight / 2,
- CompFormat, ImgSize / 2, ImgData + ImgSize / 2);
+ CompFormat, ImgSize / 2, ImgData /*+ ImgSize / 2*/);
/* top left */
for (i = 0; i < ImgHeight / 8; i++) {
- memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[i * 2 * ImgWidth], ImgWidth);
+ memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[half + i * 2 * ImgWidth], ImgWidth);
}
glCompressedTexSubImage2DARB(Target, 0,
0, ImgHeight / 2, /* pos */
@@ -55,7 +57,7 @@ LoadCompressedImage(void)
/* top right */
for (i = 0; i < ImgHeight / 8; i++) {
- memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[i * 2 * ImgWidth + ImgWidth], ImgWidth);
+ memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[half + i * 2 * ImgWidth + ImgWidth], ImgWidth);
}
glCompressedTexSubImage2DARB(Target, 0,
ImgWidth / 2, ImgHeight / 2, /* pos */
diff --git a/progs/tests/texdown.c b/progs/tests/texdown.c
index 7e46045832..92df01b83d 100644
--- a/progs/tests/texdown.c
+++ b/progs/tests/texdown.c
@@ -162,7 +162,7 @@ MeasureDownloadRate(void)
const int image_bytes = align(w * h * BytesPerTexel(Format), ALIGN);
const int bytes = image_bytes * NR_TEXOBJ;
GLubyte *orig_texImage, *orig_getImage;
- GLubyte *texImage, *getImage;
+ GLubyte *texImage;
GLdouble t0, t1, time;
int count;
int i;
@@ -176,13 +176,14 @@ MeasureDownloadRate(void)
orig_getImage = (GLubyte *) malloc(image_bytes + ALIGN);
if (!orig_texImage || !orig_getImage) {
DownloadRate = 0.0;
+ free(orig_texImage);
+ free(orig_getImage);
return;
}
printf("alloc %p %p\n", orig_texImage, orig_getImage);
texImage = (GLubyte *)align((unsigned long)orig_texImage, ALIGN);
- getImage = (GLubyte *)align((unsigned long)orig_getImage, ALIGN);
for (i = 1; !(((unsigned long)texImage) & i); i<<=1)
;
diff --git a/progs/tests/texleak.c b/progs/tests/texleak.c
new file mode 100644
index 0000000000..5cf4ff3239
--- /dev/null
+++ b/progs/tests/texleak.c
@@ -0,0 +1,140 @@
+/*
+ * 'Texture leak' test
+ *
+ * Allocates and uses an additional texture of the maximum supported size for
+ * each frame. This tests the system's ability to cope with using increasing
+ * amounts of texture memory.
+ *
+ * Michel Dänzer July 2009 This program is in the public domain.
+ */
+
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+
+GLint size;
+GLvoid *image;
+static GLuint numTexObj;
+static GLuint *texObj;
+
+
+static void Idle( void )
+{
+ glutPostRedisplay();
+}
+
+
+static void DrawObject(void)
+{
+ static const GLfloat tex_coords[] = { 0.0, 0.0, 1.0, 1.0, 0.0 };
+ static const GLfloat vtx_coords[] = { -1.0, -1.0, 1.0, 1.0, -1.0 };
+ GLint i, j;
+
+ glEnable(GL_TEXTURE_2D);
+
+ for (i = 0; i < numTexObj; i++) {
+ glBindTexture(GL_TEXTURE_2D, texObj[i]);
+ glBegin(GL_QUADS);
+ for (j = 0; j < 4; j++ ) {
+ glTexCoord2f(tex_coords[j], tex_coords[j+1]);
+ glVertex2f( vtx_coords[j], vtx_coords[j+1] );
+ }
+ glEnd();
+ }
+}
+
+
+static void Display( void )
+{
+ struct timeval start, end;
+
+ texObj = realloc(texObj, ++numTexObj * sizeof(*texObj));
+
+ /* allocate a texture object */
+ glGenTextures(1, texObj + (numTexObj - 1));
+
+ glBindTexture(GL_TEXTURE_2D, texObj[numTexObj - 1]);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ memset(image, (16 * numTexObj) & 0xff, 4 * size * size);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, image);
+
+ gettimeofday(&start, NULL);
+
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ glPushMatrix();
+ glScalef(5.0, 5.0, 5.0);
+ DrawObject();
+ glPopMatrix();
+
+ glutSwapBuffers();
+
+ glFinish();
+ gettimeofday(&end, NULL);
+ printf("Rendering frame took %lu ms using %u MB of textures\n",
+ end.tv_sec * 1000 + end.tv_usec / 1000 - start.tv_sec * 1000 -
+ start.tv_usec / 1000, numTexObj * 4 * size / 1024 * size / 1024);
+
+ sleep(1);
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho( -6.0, 6.0, -6.0, 6.0, 10.0, 100.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ glTranslatef( 0.0, 0.0, -70.0 );
+}
+
+
+static void Init( int argc, char *argv[] )
+{
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size);
+ printf("%d x %d max texture size\n", size, size);
+
+ image = malloc(4 * size * size);
+ if (!image) {
+ fprintf(stderr, "Failed to allocate %u bytes of memory\n", 4 * size * size);
+ exit(1);
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ glShadeModel(GL_FLAT);
+ glClearColor(0.3, 0.3, 0.4, 1.0);
+
+ Idle();
+}
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowSize( 300, 300 );
+ glutInitWindowPosition( 0, 0 );
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
+ glutCreateWindow(argv[0] );
+ glewInit();
+
+ Init( argc, argv );
+
+ glutReshapeFunc( Reshape );
+ glutDisplayFunc( Display );
+ glutIdleFunc(Idle);
+
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/tests/unfilledclip.c b/progs/tests/unfilledclip.c
index db6fffa3e8..331cbf2f6b 100644
--- a/progs/tests/unfilledclip.c
+++ b/progs/tests/unfilledclip.c
@@ -31,6 +31,7 @@
static int win_width, win_height;
+#if 0
static void
line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
{
@@ -39,6 +40,7 @@ line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
glVertex2f(x2, y2);
glEnd();
}
+#endif
static void
line3(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2, GLfloat y2, GLfloat z2)
diff --git a/progs/tests/vao-01.c b/progs/tests/vao-01.c
index 117fae8bd9..e4a89cb19d 100644
--- a/progs/tests/vao-01.c
+++ b/progs/tests/vao-01.c
@@ -124,10 +124,10 @@ static void Init( void )
exit(2);
}
- bind_vertex_array = glutGetProcAddress( "glBindVertexArrayAPPLE" );
- gen_vertex_arrays = glutGetProcAddress( "glGenVertexArraysAPPLE" );
- delete_vertex_arrays = glutGetProcAddress( "glDeleteVertexArraysAPPLE" );
- is_vertex_array = glutGetProcAddress( "glIsVertexArrayAPPLE" );
+ bind_vertex_array = (PFNGLBINDVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glBindVertexArrayAPPLE" );
+ gen_vertex_arrays = (PFNGLGENVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glGenVertexArraysAPPLE" );
+ delete_vertex_arrays = (PFNGLDELETEVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glDeleteVertexArraysAPPLE" );
+ is_vertex_array = (PFNGLISVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glIsVertexArrayAPPLE" );
(*gen_vertex_arrays)( 1, & obj );
diff --git a/progs/tests/vao-02.c b/progs/tests/vao-02.c
index 7764ed5106..9f7f5c2779 100644
--- a/progs/tests/vao-02.c
+++ b/progs/tests/vao-02.c
@@ -125,10 +125,10 @@ static void Init( void )
exit(2);
}
- bind_vertex_array = glutGetProcAddress( "glBindVertexArrayAPPLE" );
- gen_vertex_arrays = glutGetProcAddress( "glGenVertexArraysAPPLE" );
- delete_vertex_arrays = glutGetProcAddress( "glDeleteVertexArraysAPPLE" );
- is_vertex_array = glutGetProcAddress( "glIsVertexArrayAPPLE" );
+ bind_vertex_array = (PFNGLBINDVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glBindVertexArrayAPPLE" );
+ gen_vertex_arrays = (PFNGLGENVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glGenVertexArraysAPPLE" );
+ delete_vertex_arrays = (PFNGLDELETEVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glDeleteVertexArraysAPPLE" );
+ is_vertex_array = (PFNGLISVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glIsVertexArrayAPPLE" );
(*gen_vertex_arrays)( 1, & obj );
diff --git a/progs/tests/vparray.c b/progs/tests/vparray.c
index af9b62d33e..fe168c6cd5 100644
--- a/progs/tests/vparray.c
+++ b/progs/tests/vparray.c
@@ -37,13 +37,16 @@ static void read_surface( char *filename )
}
numverts = 0;
- while (!feof(f) && numverts < MAXVERTS) {
- fscanf( f, "%f %f %f %f %f %f",
- &data[numverts][0], &data[numverts][1], &data[numverts][2],
- &data[numverts][3], &data[numverts][4], &data[numverts][5] );
+ while (numverts < MAXVERTS) {
+ int result;
+ result = fscanf( f, "%f %f %f %f %f %f",
+ &data[numverts][0], &data[numverts][1], &data[numverts][2],
+ &data[numverts][3], &data[numverts][4], &data[numverts][5] );
+ if (result == EOF) {
+ break;
+ }
numverts++;
}
- numverts--;
printf("%d vertices, %d triangles\n", numverts, numverts-2);
printf("data = %p\n", (void *) data);
diff --git a/progs/tests/vpeval.c b/progs/tests/vpeval.c
index f07737f973..3e8a732df5 100644
--- a/progs/tests/vpeval.c
+++ b/progs/tests/vpeval.c
@@ -94,16 +94,16 @@ GLfloat colorPoints[4][4][4] =
};
-void
+static void
initlights(void)
{
+#if 0 /* no lighting for now */
GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0};
GLfloat position[] = {0.0, 0.0, 2.0, 1.0};
GLfloat mat_diffuse[] = {0.6, 0.6, 0.6, 1.0};
GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
GLfloat mat_shininess[] = {50.0};
-#if 0 /* no lighting for now */
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
@@ -116,7 +116,7 @@ initlights(void)
#endif
}
-void
+static void
display(void)
{
glClearColor(.3, .3, .3, 0);
@@ -130,7 +130,7 @@ display(void)
glFlush();
}
-void
+static void
myinit(int argc, char *argv[])
{
glClearColor(0.0, 0.0, 0.0, 1.0);
@@ -186,7 +186,7 @@ myinit(int argc, char *argv[])
}
}
-void
+static void
myReshape(int w, int h)
{
glViewport(0, 0, w, h);
diff --git a/progs/tests/zreaddraw.c b/progs/tests/zreaddraw.c
index 7dfed20cfb..7740695bb6 100644
--- a/progs/tests/zreaddraw.c
+++ b/progs/tests/zreaddraw.c
@@ -58,6 +58,10 @@ static void Display(void)
printf("Depth value range: [%f, %f]\n", min, max);
}
+ /* Draw the Z image as luminance above original rendering */
+ glWindowPos2i(0, 100);
+ glDrawPixels(100, 100, GL_LUMINANCE, depthType, depth);
+
if (TestPacking) {
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
@@ -100,6 +104,7 @@ static void Display(void)
glReadPixels(100, 0, 400, 400, GL_DEPTH_COMPONENT, GL_FLOAT, depth2);
/* draw as luminance */
glPixelZoom(1.0, 1.0);
+ glWindowPos2i(100, 0);
glDrawPixels(400, 400, GL_LUMINANCE, GL_FLOAT, depth2);
glutSwapBuffers();