summaryrefslogtreecommitdiff
path: root/progs/tests
diff options
context:
space:
mode:
Diffstat (limited to 'progs/tests')
-rw-r--r--progs/tests/Makefile3
-rw-r--r--progs/tests/SConscript22
-rw-r--r--progs/tests/arbgpuprog.c4
-rw-r--r--progs/tests/bug_texstore_i8.c2
-rw-r--r--progs/tests/condrender.c242
-rw-r--r--progs/tests/crossbar.c2
-rw-r--r--progs/tests/cva.c8
-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/invert.c2
-rw-r--r--progs/tests/packedpixels.c68
-rw-r--r--progs/tests/prog_parameter.c5
-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/sharedtex.c8
-rw-r--r--progs/tests/stencilwrap.c2
-rw-r--r--progs/tests/tex1d.c2
-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/vparray.c13
-rw-r--r--progs/tests/vpeval.c10
24 files changed, 848 insertions, 73 deletions
diff --git a/progs/tests/Makefile b/progs/tests/Makefile
index 197e14d5b0..836396b249 100644
--- a/progs/tests/Makefile
+++ b/progs/tests/Makefile
@@ -37,10 +37,12 @@ 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 \
@@ -98,6 +100,7 @@ SOURCES = \
texdown \
texfilt.c \
texgenmix.c \
+ texleak.c \
texline.c \
texobj.c \
texobjshare.c \
diff --git a/progs/tests/SConscript b/progs/tests/SConscript
index 3a0da62717..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',
]
@@ -59,10 +41,12 @@ progs = [
'bug_3195',
'bug_texstore_i8',
'calibrate_rast',
+ 'condrender',
'copypixrate',
'crossbar',
'cva',
'drawbuffers',
+ 'drawbuffers2',
'exactrast',
'ext422square',
'fbotest1',
@@ -138,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/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 bd8e05aee1..2988e20920 100644
--- a/progs/tests/crossbar.c
+++ b/progs/tests/crossbar.c
@@ -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/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/invert.c b/progs/tests/invert.c
index 3bc97a460b..45001b44d0 100644
--- a/progs/tests/invert.c
+++ b/progs/tests/invert.c
@@ -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/packedpixels.c b/progs/tests/packedpixels.c
index d318cf516a..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
@@ -234,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);
@@ -245,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);
@@ -265,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();
@@ -279,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();
}
@@ -301,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;
@@ -336,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 0241f3a249..2de7e2994a 100644
--- a/progs/tests/prog_parameter.c
+++ b/progs/tests/prog_parameter.c
@@ -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));
@@ -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/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/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/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/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);