diff options
Diffstat (limited to 'progs/tests')
96 files changed, 1345 insertions, 170 deletions
diff --git a/progs/tests/.gitignore b/progs/tests/.gitignore index c5b9e28dab..0ed3a885c2 100644 --- a/progs/tests/.gitignore +++ b/progs/tests/.gitignore @@ -14,7 +14,9 @@ arbvpwarpmesh arraytexture blendminmax blendsquare +blendxor bufferobj +bumpmap bug_3050 bug_3101 bug_3195 @@ -59,6 +61,8 @@ readtex.h seccolor sharedtex shader_api +shaderutil.c +shaderutil.h stencil_twoside stencil_wrap stencilwrap diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 34c9ab1dce..58ea5690df 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -8,7 +8,7 @@ TOP = ../.. include $(TOP)/configs/current -LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) +LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) SOURCES = \ afsmultiarb.c \ @@ -28,6 +28,7 @@ SOURCES = \ blendsquare.c \ blendxor.c \ bufferobj.c \ + bumpmap.c \ bug_3050.c \ bug_3101.c \ bug_3195.c \ @@ -54,7 +55,10 @@ SOURCES = \ jkrahntest.c \ lineclip.c \ manytex.c \ + mapbufrange.c \ + mapvbo.c \ minmag.c \ + mipgen.c \ mipmap_limits.c \ mipmap_view.c \ multipal.c \ @@ -145,6 +149,12 @@ afsmultiarb: afsmultiarb.o readtex.o afsmultiarb.o: afsmultiarb.c readtex.h $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) afsmultiarb.c -o $@ +bumpmap: bumpmap.o readtex.o + $(CC) $(CFLAGS) $(LDFLAGS) bumpmap.o readtex.o $(LIBS) -o $@ + +bumpmap.o: bumpmap.c readtex.h + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) bumpmap.c -o $@ + drawbuffers: drawbuffers.o $(APP_CC) $(CFLAGS) $(LDFLAGS) drawbuffers.o $(LIBS) -o $@ @@ -175,6 +185,11 @@ mipmap_view: mipmap_view.o readtex.o mipmap_view.o: mipmap_view.c readtex.h $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ +mipmap_limits: mipmap_limits.o readtex.o + $(APP_CC) $(CFLAGS) mipmap_limits.o readtex.o $(LIBS) -o $@ + +mipmap_limits.o: mipmap_limits.c readtex.h + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ fillrate: fillrate.o readtex.o $(APP_CC) $(CFLAGS) fillrate.o readtex.o $(LIBS) -o $@ diff --git a/progs/tests/SConscript b/progs/tests/SConscript new file mode 100644 index 0000000000..cfeb9d1c37 --- /dev/null +++ b/progs/tests/SConscript @@ -0,0 +1,134 @@ +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', +] + +glx_progs = [ + 'auxbuffer', + 'getprocaddress', + 'jkrahntest', + 'sharedtex', + 'texcompress2', + 'texobjshare', +] + +mesa_progs = [ + 'debugger', +] + +progs = [ + 'afsmultiarb', + 'antialias', + 'arbfpspec', + 'arbfptest1', + 'arbfptexture', + 'arbfptrig', + 'arbnpot-mipmap', + 'arbnpot', + 'arbvptest1', + 'arbvptest3', + 'arbvptorus', + 'arbvpwarpmesh', + 'arraytexture', + 'blendminmax', + 'blendsquare', + 'blendxor', + 'bufferobj', + 'bug_3050', + 'bug_3101', + 'bug_3195', + 'bug_texstore_i8', + 'calibrate_rast', + 'copypixrate', + 'crossbar', + 'cva', + 'dinoshade', + 'drawbuffers', + 'exactrast', + 'ext422square', + 'fbotest1', + 'fbotest2', + 'fbotexture', + 'fillrate', + 'floattex', + 'fog', + 'fogcoord', + 'fptest1', + 'fptexture', + 'interleave', + 'invert', + 'lineclip', + 'manytex', + 'mapbufrange', + 'mapvbo', + 'minmag', + 'mipgen', + 'mipmap_limits', + 'mipmap_view', + 'multipal', + 'multitexarray', + 'multiwindow', + 'no_s3tc', + 'packedpixels', + 'pbo', + 'prog_parameter', + 'projtex', + 'quads', + 'random', + 'readrate', + 'rubberband', + 'seccolor', + 'shader_api', + 'stencil_twoside', + 'stencil_wrap', + 'stencilwrap', + 'subtex', + 'subtexrate', + 'tex1d', + 'texcmp', + 'texfilt', + 'texgenmix', + 'texline', + 'texrect', + 'texwrap', + 'unfilledclip', + 'vao-01', + 'vao-02', + 'vparray', + 'vpeval', + 'vptest1', + 'vptest2', + 'vptest3', + 'vptorus', + 'vpwarpmesh', + 'yuvrect', + 'yuvsquare', + 'zcomp', + 'zdrawpix', + 'zreaddraw', +] + +for prog in progs: + env.Program( + target = prog, + source = prog + '.c', + ) diff --git a/progs/tests/afsmultiarb.c b/progs/tests/afsmultiarb.c index c026ecd4ce..162ab19493 100644 --- a/progs/tests/afsmultiarb.c +++ b/progs/tests/afsmultiarb.c @@ -11,7 +11,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> #include "readtex.h" @@ -442,6 +442,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 300, 300 ); glutInitWindowPosition( 0, 0 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glewInit(); glutCreateWindow(argv[0] ); Init( argc, argv ); diff --git a/progs/tests/antialias.c b/progs/tests/antialias.c index f23b5aff32..656bf2471f 100644 --- a/progs/tests/antialias.c +++ b/progs/tests/antialias.c @@ -9,6 +9,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> @@ -29,7 +30,7 @@ PrintString(const char *s) static void -Polygon( GLint verts, GLfloat radius, GLfloat z ) +doPolygon( GLint verts, GLfloat radius, GLfloat z ) { int i; for (i = 0; i < verts; i++) { @@ -47,33 +48,33 @@ DrawObject( void ) glLineWidth(3.0); glColor3f(1, 1, 1); glBegin(GL_LINE_LOOP); - Polygon(12, 1.2, 0); + doPolygon(12, 1.2, 0); glEnd(); glLineWidth(1.0); glColor3f(1, 1, 1); glBegin(GL_LINE_LOOP); - Polygon(12, 1.1, 0); + doPolygon(12, 1.1, 0); glEnd(); glColor3f(1, 0, 0); glBegin(GL_POLYGON); - Polygon(12, 0.4, 0.3); + doPolygon(12, 0.4, 0.3); glEnd(); glColor3f(0, 1, 0); glBegin(GL_POLYGON); - Polygon(12, 0.6, 0.2); + doPolygon(12, 0.6, 0.2); glEnd(); glColor3f(0, 0, 1); glBegin(GL_POLYGON); - Polygon(12, 0.8, 0.1); + doPolygon(12, 0.8, 0.1); glEnd(); glColor3f(1, 1, 1); glBegin(GL_POLYGON); - Polygon(12, 1.0, 0); + doPolygon(12, 1.0, 0); glEnd(); } @@ -225,6 +226,7 @@ main( int argc, char *argv[] ) glutInitDisplayMode( GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/api_speed.c b/progs/tests/api_speed.c index aed65b35fe..28e28e61d8 100644 --- a/progs/tests/api_speed.c +++ b/progs/tests/api_speed.c @@ -37,9 +37,7 @@ #include <stdio.h> #include <stdlib.h> -#define GL_GLEXT_PROTOTYPES -#include <GL/gl.h> -#include <GL/glext.h> +#include <GL/glew.h> #include <GL/glut.h> #define inline __inline__ @@ -127,6 +125,7 @@ int main( int argc, char *argv[] ) glutInitDisplayMode( GLUT_RGB ); glutCreateWindow( argv[0] ); + glewInit(); if ( argc > 1 ) { count = strtoul( argv[1], NULL, 0 ); diff --git a/progs/tests/arbfpspec.c b/progs/tests/arbfpspec.c index eac2a9100f..550e954340 100644 --- a/progs/tests/arbfpspec.c +++ b/progs/tests/arbfpspec.c @@ -8,7 +8,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> static float Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; @@ -180,6 +180,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/arbfptest1.c b/progs/tests/arbfptest1.c index 7949f87edd..e7237b76a8 100644 --- a/progs/tests/arbfptest1.c +++ b/progs/tests/arbfptest1.c @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> @@ -201,6 +201,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/arbfptexture.c b/progs/tests/arbfptexture.c index a854908c31..f66b060cbb 100644 --- a/progs/tests/arbfptexture.c +++ b/progs/tests/arbfptexture.c @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> #include "readtex.c" @@ -143,6 +143,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/arbfptrig.c b/progs/tests/arbfptrig.c index 26b68c6b41..95f008a078 100644 --- a/progs/tests/arbfptrig.c +++ b/progs/tests/arbfptrig.c @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> #include "readtex.c" @@ -146,6 +146,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/arbnpot-mipmap.c b/progs/tests/arbnpot-mipmap.c index 4ed84e7ace..700ec0b09d 100644 --- a/progs/tests/arbnpot-mipmap.c +++ b/progs/tests/arbnpot-mipmap.c @@ -46,6 +46,7 @@ */ #include <stdlib.h> #include <stdio.h> +#include <GL/glew.h> #include <GL/glut.h> GLubyte mipmapImage32[40][46][3]; @@ -175,6 +176,7 @@ int main(int argc, char** argv) glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize (500, 500); glutCreateWindow (argv[0]); + glewInit(); myinit(); glutReshapeFunc (myReshape); glutDisplayFunc(display); diff --git a/progs/tests/arbnpot.c b/progs/tests/arbnpot.c index 05ba85dad9..c51a541641 100644 --- a/progs/tests/arbnpot.c +++ b/progs/tests/arbnpot.c @@ -8,6 +8,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include "../util/readtex.c" @@ -188,6 +189,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 400, 400 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/arbvptest1.c b/progs/tests/arbvptest1.c index 0ebd3987f5..3a6d71a42b 100644 --- a/progs/tests/arbvptest1.c +++ b/progs/tests/arbvptest1.c @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> static void Display( void ) @@ -155,6 +155,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/arbvptest3.c b/progs/tests/arbvptest3.c index 6437062900..56de7b4696 100644 --- a/progs/tests/arbvptest3.c +++ b/progs/tests/arbvptest3.c @@ -4,7 +4,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> static float Zrot = 0.0; @@ -118,6 +118,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/arbvptorus.c b/progs/tests/arbvptorus.c index 9d19ef90da..f1f84d8774 100644 --- a/progs/tests/arbvptorus.c +++ b/progs/tests/arbvptorus.c @@ -7,7 +7,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> static float Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; @@ -174,6 +174,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/arbvpwarpmesh.c b/progs/tests/arbvpwarpmesh.c index 3dfe94f759..973a157409 100644 --- a/progs/tests/arbvpwarpmesh.c +++ b/progs/tests/arbvpwarpmesh.c @@ -7,7 +7,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> static float Xrot = -60.0, Yrot = 0.0, Zrot = 0.0; @@ -234,6 +234,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/arraytexture.c b/progs/tests/arraytexture.c index 48c622be30..6c0484df0d 100644 --- a/progs/tests/arraytexture.c +++ b/progs/tests/arraytexture.c @@ -34,6 +34,7 @@ #include <stdio.h> #include <string.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include <GL/glext.h> @@ -326,6 +327,7 @@ int main(int argc, char *argv[]) glutInitWindowSize(350, 350); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutCreateWindow("Array texture test"); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/tests/blendminmax.c b/progs/tests/blendminmax.c index 2aab1a39d2..7297f41b78 100644 --- a/progs/tests/blendminmax.c +++ b/progs/tests/blendminmax.c @@ -34,6 +34,7 @@ #include <stdio.h> #include <stdlib.h> +#include <GL/glew.h> #include <GL/glut.h> static int Width = 400; @@ -200,6 +201,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow( "GL_EXT_blend_minmax test" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/blendsquare.c b/progs/tests/blendsquare.c index 1694866a55..3ee3ae2230 100644 --- a/progs/tests/blendsquare.c +++ b/progs/tests/blendsquare.c @@ -34,6 +34,7 @@ #include <stdio.h> #include <stdlib.h> +#include <GL/glew.h> #include <GL/glut.h> static int Width = 400; @@ -169,6 +170,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow( "GL_NV_blend_square test" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/blendxor.c b/progs/tests/blendxor.c index 8961a827ea..d6dcb8b848 100644 --- a/progs/tests/blendxor.c +++ b/progs/tests/blendxor.c @@ -3,10 +3,10 @@ * */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include "readtex.c" @@ -183,6 +183,7 @@ main(int argc, char *argv[]) glutInitWindowSize(Width, Height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/tests/bufferobj.c b/progs/tests/bufferobj.c index d1a85392e1..1d97b060ef 100644 --- a/progs/tests/bufferobj.c +++ b/progs/tests/bufferobj.c @@ -6,18 +6,19 @@ */ -#define GL_GLEXT_PROTOTYPES #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #define NUM_OBJECTS 10 struct object { - GLuint BufferID; + GLuint VertexBufferID; + GLuint ColorBufferID; GLuint ElementsBufferID; GLuint NumVerts; GLuint VertexOffset; @@ -47,7 +48,7 @@ static void CheckError(int line) static void DrawObject( const struct object *obj ) { - glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->VertexBufferID); glVertexPointer(3, GL_FLOAT, obj->VertexStride, (void *) obj->VertexOffset); glEnable(GL_VERTEX_ARRAY); @@ -62,6 +63,7 @@ static void DrawObject( const struct object *obj ) glPopClientAttrib(); } #endif + glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->ColorBufferID); glColorPointer(3, GL_FLOAT, obj->ColorStride, (void *) obj->ColorOffset); glEnable(GL_COLOR_ARRAY); @@ -92,7 +94,7 @@ static void Display( void ) glClear( GL_COLOR_BUFFER_BIT ); for (i = 0; i < NumObjects; i++) { - float x = 5.0 * ((float) i / (NumObjects-1) - 0.5); + float x = 7.0 * ((float) i / (NumObjects-1) - 0.5); glPushMatrix(); glTranslatef(x, 0, 0); glRotatef(Xrot, 1, 0, 0); @@ -125,8 +127,11 @@ static void Reshape( int width, int height ) static void FreeBuffers(void) { int i; - for (i = 0; i < NUM_OBJECTS; i++) - glDeleteBuffersARB(1, &Objects[i].BufferID); + for (i = 0; i < NUM_OBJECTS; i++) { + glDeleteBuffersARB(1, &Objects[i].VertexBufferID); + glDeleteBuffersARB(1, &Objects[i].ColorBufferID); + glDeleteBuffersARB(1, &Objects[i].ElementsBufferID); + } } @@ -182,7 +187,9 @@ static void SpecialKey( int key, int x, int y ) } - +/* + * Non-interleaved position/color data. + */ static void MakeObject1(struct object *obj) { GLfloat *v, *c; @@ -193,10 +200,11 @@ static void MakeObject1(struct object *obj) for (i = 0; i < 500; i++) buffer[i] = i & 0xff; - obj->BufferID = 0; - glGenBuffersARB(1, &obj->BufferID); - assert(obj->BufferID != 0); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID); + obj->VertexBufferID = 0; + glGenBuffersARB(1, &obj->VertexBufferID); + obj->ColorBufferID = obj->VertexBufferID; + assert(obj->VertexBufferID != 0); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->VertexBufferID); glBufferDataARB(GL_ARRAY_BUFFER_ARB, 500, buffer, GL_STATIC_DRAW_ARB); for (i = 0; i < 500; i++) @@ -257,13 +265,18 @@ static void MakeObject1(struct object *obj) } +/* + * Interleaved position/color data. + */ static void MakeObject2(struct object *obj) { GLfloat *v; int start = 40; /* bytes, to test non-zero array offsets */ - glGenBuffersARB(1, &obj->BufferID); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID); + glGenBuffersARB(1, &obj->VertexBufferID); + obj->ColorBufferID = obj->VertexBufferID; + + glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->VertexBufferID); glBufferDataARB(GL_ARRAY_BUFFER_ARB, 1000, NULL, GL_STATIC_DRAW_ARB); v = (GLfloat *) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); @@ -287,6 +300,9 @@ static void MakeObject2(struct object *obj) } +/* + * Use an index buffer and glDrawElements(). + */ static void MakeObject3(struct object *obj) { GLfloat vertexData[1000]; @@ -314,8 +330,10 @@ static void MakeObject3(struct object *obj) bytes = obj->NumVerts * (3 + 3) * sizeof(GLfloat); /* Don't use glMap/UnmapBuffer for this object */ - glGenBuffersARB(1, &obj->BufferID); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->BufferID); + glGenBuffersARB(1, &obj->VertexBufferID); + obj->ColorBufferID = obj->VertexBufferID; + + glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->VertexBufferID); glBufferDataARB(GL_ARRAY_BUFFER_ARB, bytes, vertexData, GL_STATIC_DRAW_ARB); /* Setup a buffer of indices to test the ELEMENTS path */ @@ -332,6 +350,46 @@ static void MakeObject3(struct object *obj) } +/* + * Vertex and color data in different buffers. + */ +static void MakeObject4(struct object *obj) +{ + static const GLfloat vertexData[] = { + 0, -1, 0, + 0.5, 0, 0, + 0, 1, 0, + -0.5, 0, 0 + }; + static const GLfloat colorData[] = { + 1, 1, 1, + 1, 1, 0, + .5, .5, 0, + 1, 1, 0 + }; + + obj->VertexOffset = 0; + obj->VertexStride = 0; + obj->ColorOffset = 0; + obj->ColorStride = 0; + obj->NumVerts = 4; + + glGenBuffersARB(1, &obj->VertexBufferID); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->VertexBufferID); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(vertexData), vertexData, + GL_STATIC_DRAW_ARB); + + glGenBuffersARB(1, &obj->ColorBufferID); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->ColorBufferID); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(colorData), colorData, + GL_STATIC_DRAW_ARB); + + /* Setup a buffer of indices to test the ELEMENTS path */ + obj->ElementsBufferID = 0; + obj->NumElements = 0; +} + + static void Init( void ) { @@ -358,7 +416,8 @@ static void Init( void ) MakeObject1(Objects + 0); MakeObject2(Objects + 1); MakeObject3(Objects + 2); - NumObjects = 3; + MakeObject4(Objects + 3); + NumObjects = 4; } @@ -369,6 +428,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 600, 300 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/bug_3050.c b/progs/tests/bug_3050.c index 4ea7b80f23..a04e40eaf6 100644 --- a/progs/tests/bug_3050.c +++ b/progs/tests/bug_3050.c @@ -39,6 +39,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <GL/glew.h> #include <GL/glut.h> static int Width = 400; @@ -154,6 +155,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow( "Bug #3050 Test" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/bug_3101.c b/progs/tests/bug_3101.c index 761dcbb951..06a9776155 100644 --- a/progs/tests/bug_3101.c +++ b/progs/tests/bug_3101.c @@ -34,6 +34,7 @@ #include <stdio.h> #include <stdlib.h> +#include <GL/glew.h> #include <GL/glut.h> static int Width = 400; @@ -119,6 +120,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow( "Bug #3101 Test" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/bug_3195.c b/progs/tests/bug_3195.c index 4aceae04ab..a075b94e37 100644 --- a/progs/tests/bug_3195.c +++ b/progs/tests/bug_3195.c @@ -36,6 +36,7 @@ #include <stdlib.h> #include <stdio.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include <GL/glext.h> @@ -264,6 +265,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 350, 350 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow( "Bug #3195 Test" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/bug_texstore_i8.c b/progs/tests/bug_texstore_i8.c index f8dac210f7..10e5eba7c5 100644 --- a/progs/tests/bug_texstore_i8.c +++ b/progs/tests/bug_texstore_i8.c @@ -29,6 +29,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <GL/glew.h> #include <GL/glut.h> static GLenum Target = GL_TEXTURE_2D; @@ -180,6 +181,7 @@ int main(int argc, char **argv) glutInitDisplayMode(type); win = glutCreateWindow("Tex test"); + glewInit(); if (!win) { exit(1); } diff --git a/progs/tests/bumpmap.c b/progs/tests/bumpmap.c new file mode 100644 index 0000000000..1b7ec2c135 --- /dev/null +++ b/progs/tests/bumpmap.c @@ -0,0 +1,208 @@ +/* + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * Simple test for testing ATI_envmap_bumpmap support. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <GL/glut.h> + +#include "readtex.h" + +static PFNGLGETTEXBUMPPARAMETERFVATIPROC glGetTexBumpParameterfvATI_func = NULL; +static PFNGLGETTEXBUMPPARAMETERIVATIPROC glGetTexBumpParameterivATI_func = NULL; +static PFNGLTEXBUMPPARAMETERFVATIPROC glTexBumpParameterfvATI_func = NULL; + +static const char *TexFile = "../images/arch.rgb"; + +static const GLfloat Near = 5.0, Far = 25.0; + +static void Display( void ) +{ + /* together with the construction of dudv map, do fixed translation + in y direction (up), some cosine deformation in x and more + deformation in y dir */ + GLfloat bumpMatrix[4] = {0.1, 0.0, 0.2, 0.1}; + + + glClearColor(0.2, 0.2, 0.8, 0); + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + + /* this is the base map */ + glActiveTexture( GL_TEXTURE0 ); + glEnable( GL_TEXTURE_2D ); + glBindTexture( GL_TEXTURE_2D, 1 ); + glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); + glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE ); + glTexEnvf( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE ); + + /* bump map */ + glActiveTexture( GL_TEXTURE1 ); + glEnable( GL_TEXTURE_2D ); + glBindTexture( GL_TEXTURE_2D, 2 ); + glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); + glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_BUMP_ENVMAP_ATI ); + glTexEnvf( GL_TEXTURE_ENV, GL_BUMP_TARGET_ATI, GL_TEXTURE0); + + glTexBumpParameterfvATI_func(GL_BUMP_ROT_MATRIX_ATI, bumpMatrix); + + glCallList(1); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + GLfloat ar = (float) width / (float) height; + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -ar, ar, -1.0, 1.0, Near, Far ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -6.0 ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + const char * const ver_string = (const char * const) + glGetString( GL_VERSION ); + GLfloat temp[16][16][2]; + GLubyte *image = NULL; + GLint imgWidth, imgHeight; + GLenum imgFormat; + GLint i,j; + GLint param, paramArray[16]; + GLfloat paramMat[4]; + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", ver_string); + + if ( !glutExtensionSupported("GL_ATI_envmap_bumpmap")) { + printf("\nSorry, this program requires GL_ATI_envmap_bumpmap\n"); + exit(1); + } + + glGetTexBumpParameterfvATI_func = glutGetProcAddress("glGetTexBumpParameterfvATI"); + glGetTexBumpParameterivATI_func = glutGetProcAddress("glGetTexBumpParameterivATI"); + glTexBumpParameterfvATI_func = glutGetProcAddress("glTexBumpParameterfvATI"); + + glGetTexBumpParameterivATI_func(GL_BUMP_ROT_MATRIX_SIZE_ATI, ¶m); + printf("BUMP_ROT_MATRIX_SIZE_ATI = %d\n", param); + glGetTexBumpParameterivATI_func(GL_BUMP_NUM_TEX_UNITS_ATI, ¶m); + printf("BUMP_NUM_TEX_UNITS_ATI = %d\n", param); + glGetTexBumpParameterfvATI_func(GL_BUMP_ROT_MATRIX_ATI, paramMat); + printf("initial rot matrix %f %f %f %f\n", paramMat[0], paramMat[1], paramMat[2], paramMat[3]); + glGetTexBumpParameterivATI_func(GL_BUMP_TEX_UNITS_ATI, paramArray); + printf("units supporting bump mapping: "); + for (i = 0; i < param; i++) + printf("%d ", paramArray[i] - GL_TEXTURE0); + printf("\n"); + + image = LoadRGBImage(TexFile, &imgWidth, &imgHeight, &imgFormat); + if (!image) { + printf("Couldn't read %s\n", TexFile); + exit(0); + } + + glBindTexture( GL_TEXTURE_2D, 1 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + glTexImage2D( GL_TEXTURE_2D, 0, imgFormat, imgWidth, imgHeight, 0, + imgFormat, GL_UNSIGNED_BYTE, image ); + + for (j = 0; j < 16; j++) { + for (i = 0; i < 16; i++) { + temp[j][i][0] = cos((float)(i) * 3.1415 / 16.0); + temp[j][i][1] = -0.5; + } + } + glBindTexture( GL_TEXTURE_2D, 2 ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + glTexImage2D( GL_TEXTURE_2D, 0, GL_DU8DV8_ATI, 16, 16, 0, + GL_DUDV_ATI, GL_FLOAT, temp ); + + + glNewList( 1, GL_COMPILE ); + glBegin(GL_QUADS); + glColor3f( 0.9, 0.0, 0.0 ); + glMultiTexCoord2f( GL_TEXTURE0, 0.0, 0.0 ); + glMultiTexCoord2f( GL_TEXTURE1, 0.0, 0.0 ); + glVertex2f(-1, -1); + glMultiTexCoord2f( GL_TEXTURE0, 1.0, 0.0 ); + glMultiTexCoord2f( GL_TEXTURE1, 1.0, 0.0 ); + glVertex2f( 1, -1); + glMultiTexCoord2f( GL_TEXTURE0, 1.0, 1.0 ); + glMultiTexCoord2f( GL_TEXTURE1, 1.0, 1.0 ); + glVertex2f( 1, 1); + glMultiTexCoord2f( GL_TEXTURE0, 0.0, 1.0 ); + glMultiTexCoord2f( GL_TEXTURE1, 0.0, 1.0 ); + glVertex2f(-1, 1); + glEnd(); + glEndList(); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 400, 400 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow( "GL_ATI_envmap_bumpmap test" ); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/calibrate_rast.c b/progs/tests/calibrate_rast.c index 37d8ac85e5..5d89ff79c5 100644 --- a/progs/tests/calibrate_rast.c +++ b/progs/tests/calibrate_rast.c @@ -19,6 +19,7 @@ #include <assert.h> #include <stdio.h> #include <stdlib.h> +#include <GL/glew.h> #include <GL/glut.h> @@ -386,6 +387,7 @@ main(int argc, char *argv[]) glutInitWindowSize(Width, Height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Draw); diff --git a/progs/tests/copypixrate.c b/progs/tests/copypixrate.c index 142315364c..aa4acfc18b 100644 --- a/progs/tests/copypixrate.c +++ b/progs/tests/copypixrate.c @@ -5,11 +5,11 @@ * 26 Jan 2006 */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> static GLint WinWidth = 1000, WinHeight = 800; @@ -260,6 +260,7 @@ main(int argc, char *argv[]) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(mode); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/tests/crossbar.c b/progs/tests/crossbar.c index 12aabb1c9a..3dd21372f9 100644 --- a/progs/tests/crossbar.c +++ b/progs/tests/crossbar.c @@ -35,6 +35,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <GL/glew.h> #include <GL/glut.h> static const GLint tests[][8] = { @@ -226,6 +227,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow( "GL_ARB_texture_env_crossbar test" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/cva.c b/progs/tests/cva.c index a9393aef0c..80483900cb 100644 --- a/progs/tests/cva.c +++ b/progs/tests/cva.c @@ -15,6 +15,7 @@ #include <windows.h> #endif #define GL_GLEXT_LEGACY +#include <GL/glew.h> #include <GL/glut.h> #include <GL/glext.h> @@ -129,6 +130,7 @@ int main( int argc, char **argv ) glutInitWindowSize( 250, 250 ); glutInitWindowPosition( 100, 100 ); glutCreateWindow( "CVA Test" ); + glewInit(); /* Make sure the server supports GL 1.2 vertex arrays. */ diff --git a/progs/tests/debugger.c b/progs/tests/debugger.c index 4c6955bcfc..1c2f9bebca 100644 --- a/progs/tests/debugger.c +++ b/progs/tests/debugger.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> @@ -81,6 +81,7 @@ find_line_column(const GLubyte *string, const GLubyte *pos, #define NV_FRAGMENT_PROGRAM 4 + struct breakpoint { enum {PIXEL, LINE} type; int x, y; @@ -101,7 +102,7 @@ static void Debugger2(GLenum target, GLvoid *data) { static GLuint skipCount = 0; const GLubyte *ln; - GLint pos, line, column; + GLint pos = 0, line, column; GLint id; int progType; GLint len; @@ -721,6 +722,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 200, 200 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/dinoshade.c b/progs/tests/dinoshade.c index 44115b9209..fb7c3f4535 100644 --- a/progs/tests/dinoshade.c +++ b/progs/tests/dinoshade.c @@ -43,6 +43,7 @@ #include <windows.h> #endif #define GL_GLEXT_LEGACY +#include <GL/glew.h> /* OpenGL Utility Toolkit header */ #include <GL/glut.h> /* OpenGL Utility Toolkit header */ /* Some <math.h> files do not define M_PI... */ @@ -823,6 +824,7 @@ main(int argc, char **argv) #endif glutCreateWindow("Shadowy Leapin' Lizards"); + glewInit(); if (glutGet(GLUT_WINDOW_STENCIL_SIZE) <= 1) { printf("dinoshade: Sorry, I need at least 2 bits of stencil.\n"); diff --git a/progs/tests/drawbuffers.c b/progs/tests/drawbuffers.c index 5e89569380..d75a870c26 100644 --- a/progs/tests/drawbuffers.c +++ b/progs/tests/drawbuffers.c @@ -7,11 +7,11 @@ */ -#define GL_GLEXT_PROTOTYPES #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include "extfuncs.h" @@ -294,6 +294,7 @@ main(int argc, char *argv[]) glutInitWindowSize(Width, Height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Display); diff --git a/progs/tests/exactrast.c b/progs/tests/exactrast.c index 56c0c79c3f..63b8336d97 100644 --- a/progs/tests/exactrast.c +++ b/progs/tests/exactrast.c @@ -26,6 +26,7 @@ #include <stdio.h> #include <stdlib.h> +#include <GL/glew.h> #include <GL/glut.h> static int Width = 400, Height = 400; @@ -34,14 +35,14 @@ static float Xtrans = 0, Ytrans = 0; static float Step = 0.125; enum { - POINTS, - HLINES, - VLINES, - QUADS, + MODE_POINTS, + MODE_HLINES, + MODE_VLINES, + MODE_QUADS, NUM_MODES }; -static int Mode = POINTS; +static int Mode = MODE_POINTS; static void @@ -58,7 +59,7 @@ Draw(void) glPushMatrix(); glTranslatef(tx + Xtrans, ty + Ytrans, 0); - if (Mode == POINTS) { + if (Mode == MODE_POINTS) { glBegin(GL_POINTS); for (j = 0; j < Height; j += 2) { for (i = 0; i < Width; i += 2) { @@ -67,7 +68,7 @@ Draw(void) } glEnd(); } - else if (Mode == HLINES) { + else if (Mode == MODE_HLINES) { glBegin(GL_LINES); for (i = 0; i < Height; i += 2) { glVertex2f(0, i); @@ -75,7 +76,7 @@ Draw(void) } glEnd(); } - else if (Mode == VLINES) { + else if (Mode == MODE_VLINES) { glBegin(GL_LINES); for (i = 0; i < Width; i += 2) { glVertex2f(i, 0 ); @@ -83,7 +84,7 @@ Draw(void) } glEnd(); } - else if (Mode == QUADS) { + else if (Mode == MODE_QUADS) { glBegin(GL_QUADS); for (j = 0; j < Height; j += 4) { for (i = 0; i < Width; i += 4) { @@ -189,6 +190,7 @@ main(int argc, char *argv[]) glutInitWindowSize(Width, Height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/tests/ext422square.c b/progs/tests/ext422square.c index 6533514d69..89e99f0292 100644 --- a/progs/tests/ext422square.c +++ b/progs/tests/ext422square.c @@ -12,7 +12,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> #include <assert.h> @@ -249,6 +249,7 @@ int main( int argc, char *argv[] ) glutInitWindowPosition( 0, 0 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow(argv[0] ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/fbotest1.c b/progs/tests/fbotest1.c index ab2757c3c3..8dac21494e 100644 --- a/progs/tests/fbotest1.c +++ b/progs/tests/fbotest1.c @@ -6,11 +6,11 @@ */ -#define GL_GLEXT_PROTOTYPES #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> static int Win; @@ -202,6 +202,7 @@ main( int argc, char *argv[] ) glutInitWindowSize(Width, Height); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/fbotest2.c b/progs/tests/fbotest2.c index 5283c7e1fd..f9c506193f 100644 --- a/progs/tests/fbotest2.c +++ b/progs/tests/fbotest2.c @@ -6,11 +6,11 @@ */ -#define GL_GLEXT_PROTOTYPES #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> static int Win = 0; @@ -191,6 +191,7 @@ main( int argc, char *argv[] ) glutInitWindowSize(Width, Height); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/fbotexture.c b/progs/tests/fbotexture.c index 1f7c45fc79..50a4b00afc 100644 --- a/progs/tests/fbotexture.c +++ b/progs/tests/fbotexture.c @@ -9,7 +9,7 @@ */ -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> #include <assert.h> #include <stdio.h> @@ -26,9 +26,16 @@ static int Win = 0; static int Width = 400, Height = 400; -static GLenum TexTarget = GL_TEXTURE_2D; /*GL_TEXTURE_RECTANGLE_ARB;*/ +#if 1 +static GLenum TexTarget = GL_TEXTURE_2D; static int TexWidth = 512, TexHeight = 512; -/*static int TexWidth = 600, TexHeight = 600;*/ +static GLenum TexIntFormat = GL_RGB; /* either GL_RGB or GL_RGBA */ +#else +static GLenum TexTarget = GL_TEXTURE_RECTANGLE_ARB; +static int TexWidth = 200, TexHeight = 200; +static GLenum TexIntFormat = GL_RGB5; /* either GL_RGB or GL_RGBA */ +#endif +static GLuint TextureLevel = 0; /* which texture level to render to */ static GLuint MyFB; static GLuint TexObj; @@ -38,8 +45,6 @@ static GLfloat Rot = 0.0; static GLboolean UsePackedDepthStencil = GL_FALSE; static GLboolean UsePackedDepthStencilBoth = GL_FALSE; static GLboolean Use_ARB_fbo = GL_FALSE; -static GLuint TextureLevel = 0; /* which texture level to render to */ -static GLenum TexIntFormat = GL_RGB; /* either GL_RGB or GL_RGBA */ static GLboolean Cull = GL_FALSE; static GLboolean Wireframe = GL_FALSE; @@ -404,8 +409,12 @@ AttachDepthAndStencilBuffers(GLuint fbo, return GL_FALSE; status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); - if (status != GL_FRAMEBUFFER_COMPLETE_EXT) + if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { + glDeleteRenderbuffersEXT(1, depthRbOut); + *depthRbOut = 0; + glDeleteRenderbuffersEXT(1, &rb); return GL_FALSE; + } *stencilRbOut = rb; } @@ -554,15 +563,17 @@ Init(void) /* make two image levels */ glTexImage2D(TexTarget, 0, TexIntFormat, TexWidth, TexHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glTexImage2D(TexTarget, 1, TexIntFormat, TexWidth/2, TexHeight/2, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - TexWidth = TexWidth >> TextureLevel; - TexHeight = TexHeight >> TextureLevel; + if (TexTarget == GL_TEXTURE_2D) { + glTexImage2D(TexTarget, 1, TexIntFormat, TexWidth/2, TexHeight/2, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + TexWidth = TexWidth >> TextureLevel; + TexHeight = TexHeight >> TextureLevel; + glTexParameteri(TexTarget, GL_TEXTURE_MAX_LEVEL, TextureLevel); + } glTexParameteri(TexTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(TexTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(TexTarget, GL_TEXTURE_BASE_LEVEL, TextureLevel); - glTexParameteri(TexTarget, GL_TEXTURE_MAX_LEVEL, TextureLevel); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } @@ -576,7 +587,7 @@ Usage(void) printf("Usage:\n"); printf(" -ds Use combined depth/stencil renderbuffer\n"); printf(" -arb Try GL_ARB_framebuffer_object's mismatched buffer sizes\n"); - printf(" -ds2 Tye GL_ARB_framebuffer_object's GL_DEPTH_STENCIL_ATTACHMENT\n"); + printf(" -ds2 Try GL_ARB_framebuffer_object's GL_DEPTH_STENCIL_ATTACHMENT\n"); printf("Keys:\n"); printf(" a Toggle animation\n"); printf(" s/s Step/rotate\n"); @@ -594,6 +605,7 @@ main(int argc, char *argv[]) glutInitWindowSize(Width, Height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Display); diff --git a/progs/tests/fillrate.c b/progs/tests/fillrate.c index 8fe636c364..1e58df281e 100644 --- a/progs/tests/fillrate.c +++ b/progs/tests/fillrate.c @@ -6,10 +6,10 @@ */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include "readtex.h" @@ -194,6 +194,7 @@ main(int argc, char *argv[]) glutInitWindowSize(Width, Height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Draw); diff --git a/progs/tests/floattex.c b/progs/tests/floattex.c index dd6d882089..dd99d836c6 100644 --- a/progs/tests/floattex.c +++ b/progs/tests/floattex.c @@ -8,6 +8,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include "extfuncs.h" #include "readtex.h" @@ -230,6 +231,7 @@ main(int argc, char *argv[]) glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Draw); diff --git a/progs/tests/fog.c b/progs/tests/fog.c index ecd9f533f9..b6cea8c080 100644 --- a/progs/tests/fog.c +++ b/progs/tests/fog.c @@ -30,10 +30,10 @@ * Test to exercise fog modes and for comparison with GL_EXT_fog_coord. */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> static int Width = 600; @@ -190,6 +190,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/fogcoord.c b/progs/tests/fogcoord.c index 89355742aa..7822d33b09 100644 --- a/progs/tests/fogcoord.c +++ b/progs/tests/fogcoord.c @@ -3,10 +3,10 @@ */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> static int Width = 600; @@ -93,6 +93,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/fptest1.c b/progs/tests/fptest1.c index 095190a8ae..2b8f8d0f5e 100644 --- a/progs/tests/fptest1.c +++ b/progs/tests/fptest1.c @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> @@ -216,6 +216,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/fptexture.c b/progs/tests/fptexture.c index f57ad62828..332e07182d 100644 --- a/progs/tests/fptexture.c +++ b/progs/tests/fptexture.c @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> #include "../util/readtex.c" @@ -141,6 +141,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/interleave.c b/progs/tests/interleave.c index e98b3ed046..47bf9dfbe5 100644 --- a/progs/tests/interleave.c +++ b/progs/tests/interleave.c @@ -36,6 +36,7 @@ #include <stdlib.h> #include <string.h> #include <time.h> +#include <GL/glew.h> #include <GL/glut.h> static int Width = 400; @@ -386,6 +387,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow( "glInterleavedArrays test" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/invert.c b/progs/tests/invert.c index 750592ed79..63099fbd22 100644 --- a/progs/tests/invert.c +++ b/progs/tests/invert.c @@ -35,6 +35,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <GL/glew.h> #include <GL/glut.h> #include "readtex.h" @@ -186,6 +187,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow( "GL_MESA_pack_invert test" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/lineclip.c b/progs/tests/lineclip.c index 098f5e92eb..bb688c04a5 100644 --- a/progs/tests/lineclip.c +++ b/progs/tests/lineclip.c @@ -26,6 +26,7 @@ */ #include <stdlib.h> +#include <GL/glew.h> #include <GL/glut.h> static int win_width, win_height; @@ -164,6 +165,7 @@ main(int argc, char *argv[]) glutInitWindowSize(win_width, win_height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(reshape); glutKeyboardFunc(key); glutDisplayFunc(display); diff --git a/progs/tests/manytex.c b/progs/tests/manytex.c index 83c8676657..52e7e1de44 100644 --- a/progs/tests/manytex.c +++ b/progs/tests/manytex.c @@ -13,6 +13,7 @@ #include <stdlib.h> #include <string.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> @@ -336,6 +337,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( WinWidth, WinHeight ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/mapbufrange.c b/progs/tests/mapbufrange.c new file mode 100644 index 0000000000..0021bb2607 --- /dev/null +++ b/progs/tests/mapbufrange.c @@ -0,0 +1,205 @@ +/* + * Test glMapBuffer() and glMapBufferRange() + * + * Fill a VBO with vertex data to draw several colored quads. + * On each redraw, update the geometry for just one rect in the VBO. + * + * Brian Paul + * 4 March 2009 + */ + + +#include <assert.h> +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <GL/glew.h> +#include <GL/glew.h> +#include <GL/glut.h> + +static GLuint Win; +static const GLuint NumRects = 10; +static GLuint BufferID; +static GLboolean Anim = GL_TRUE; +static GLboolean UseBufferRange = GL_FALSE; + + + +static const float RectData[] = { + /* vertex */ /* color */ + 0, -1, 0, 1, 0, 0, + 1, 0, 0, 1, 1, 0, + 0, 1, 0, 0, 1, 1, + -1, 0, 0, 1, 0, 1 +}; + + +/** + * The buffer contains vertex positions (float[3]) and colors (float[3]) + * for 'NumRects' quads. + * This function updates/rotates one quad in the buffer. + */ +static void +UpdateRect(int r, float angle) +{ + float *rect; + int i; + + assert(r < NumRects); + + glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferID); + if (UseBufferRange) { + GLintptr offset = r * sizeof(RectData); + GLsizeiptr length = sizeof(RectData); + GLbitfield access = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT; + float *buf = (float *) glMapBufferRange(GL_ARRAY_BUFFER_ARB, + offset, length, access); + rect = buf; + } + else { + /* map whole buffer */ + float *buf = (float *) + glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); + rect = buf + r * 24; + } + + /* set rect verts/colors */ + memcpy(rect, RectData, sizeof(RectData)); + + /* loop over four verts, updating vertices */ + for (i = 0; i < 4; i++) { + float x = 0.2 * RectData[i*6+0]; + float y = 0.2 * RectData[i*6+1]; + float xpos = -2.5 + 0.5 * r; + float ypos = 0.0; + + /* translate and rotate vert */ + rect[i * 6 + 0] = xpos + x * cos(angle) + y * sin(angle); + rect[i * 6 + 1] = ypos + x * sin(angle) - y * cos(angle); + } + + glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); +} + + +static void +LoadBuffer(void) +{ + static int frame = 0; + float angle = glutGet(GLUT_ELAPSED_TIME) * 0.001; + UpdateRect(frame % NumRects, angle); + frame++; +} + + +static void +Draw(void) +{ + glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferID); + glVertexPointer(3, GL_FLOAT, 24, 0); + glEnable(GL_VERTEX_ARRAY); + + glColorPointer(3, GL_FLOAT, 24, (void*) 12); + glEnable(GL_COLOR_ARRAY); + + glDrawArrays(GL_QUADS, 0, NumRects * 4); + + if (0) + glFinish(); +} + + +static void +Display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + Draw(); + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-3.0, 3.0, -1.0, 1.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + +static void +Idle(void) +{ + LoadBuffer(); + glutPostRedisplay(); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + if (key == 'a') { + Anim = !Anim; + glutIdleFunc(Anim ? Idle : NULL); + } + else if (key == 's') { + LoadBuffer(); + } + else if (key == 27) { + glutDestroyWindow(Win); + exit(0); + } + glutPostRedisplay(); +} + + +static void +Init(void) +{ + GLuint BufferSize = NumRects * sizeof(RectData); + float *buf; + + if (!glutExtensionSupported("GL_ARB_vertex_buffer_object")) { + printf("GL_ARB_vertex_buffer_object not found!\n"); + exit(0); + } + + UseBufferRange = glutExtensionSupported("GL_ARB_map_buffer_range"); + printf("Use GL_ARB_map_buffer_range: %c\n", "NY"[UseBufferRange]); + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* initially load buffer with zeros */ + buf = (float *) calloc(1, BufferSize); + + glGenBuffersARB(1, &BufferID); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferID); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, BufferSize, buf, GL_DYNAMIC_DRAW_ARB); + + free(buf); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowSize(800, 200); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); + Win = glutCreateWindow(argv[0]); + glewInit(); + glewInit(); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Display); + glutIdleFunc(Anim ? Idle : NULL); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/mapvbo.c b/progs/tests/mapvbo.c new file mode 100644 index 0000000000..c392e76835 --- /dev/null +++ b/progs/tests/mapvbo.c @@ -0,0 +1,139 @@ +/* + * Test glMapBuffer() call immediately after glDrawArrays(). + * See details below. + * + * NOTE: Do not use freeglut with this test! It calls the Display() + * callback twice right away instead of just once. + * + * Brian Paul + * 27 Feb 2009 + */ + + +#include <stdio.h> +#include <stdlib.h> +#include <GL/glew.h> +#include <GL/glut.h> + +static GLuint BufferID; + + +static GLuint Win; + + + + +/* + * Create VBO (position and color) and load with data. + */ +static void +SetupBuffers(void) +{ + static const GLfloat data[] = { + /* vertex */ /* color */ + 0, -1, 0, 1, 1, 0, + 1, 0, 0, 1, 1, 0, + 0, 1, 0, 1, 1, 0, + -1, 0, 0, 1, 1, 0 + }; + + glGenBuffersARB(1, &BufferID); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferID); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(data), data, + GL_STATIC_DRAW_ARB); +} + + +static void +Draw(void) +{ + static int count = 1; + + printf("Draw Frame %d\n", count); + count++; + + glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferID); + glVertexPointer(3, GL_FLOAT, 24, 0); + glEnable(GL_VERTEX_ARRAY); + + glColorPointer(3, GL_FLOAT, 24, (void*) 12); + glEnable(GL_COLOR_ARRAY); + + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + + if (0) + glFinish(); + + /* Immediately map the color buffer and change something. + * This should not effect the first glDrawArrays above, but the + * next time we draw we should see a black vertex. + */ + if (1) { + GLfloat *m = (GLfloat *) glMapBufferARB(GL_ARRAY_BUFFER_ARB, + GL_WRITE_ONLY_ARB); + m[3] = m[4] = m[5] = 0.0f; /* black vertex */ + glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); + } +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + Draw(); + glutSwapBuffers(); +} + + +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, 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; + if (key == 27) { + glutDestroyWindow(Win); + exit(0); + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + if (!glutExtensionSupported("GL_ARB_vertex_buffer_object")) { + printf("GL_ARB_vertex_buffer_object not found!\n"); + exit(0); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + SetupBuffers(); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 300, 300 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + Win = glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/minmag.c b/progs/tests/minmag.c index 78ef9db03a..03019f94fa 100644 --- a/progs/tests/minmag.c +++ b/progs/tests/minmag.c @@ -17,6 +17,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <GL/glew.h> #include <GL/glut.h> @@ -189,6 +190,7 @@ main(int argc, char *argv[]) glutInitWindowSize(Width, Height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(redraw); diff --git a/progs/tests/mipgen.c b/progs/tests/mipgen.c new file mode 100644 index 0000000000..088f643215 --- /dev/null +++ b/progs/tests/mipgen.c @@ -0,0 +1,207 @@ +/* Test GL_TEXTURE_BASE_LEVEL and GL_TEXTURE_MAX_LEVEL + * Brian Paul + * 10 May 2006 + */ + + +/* Copyright (c) Mark J. Kilgard, 1994. */ + +/* + * (c) Copyright 1993, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * Permission to use, copy, modify, and distribute this software for + * any purpose and without fee is hereby granted, provided that the above + * copyright notice appear in all copies and that both the copyright notice + * and this permission notice appear in supporting documentation, and that + * the name of Silicon Graphics, Inc. not be used in advertising + * or publicity pertaining to distribution of the software without specific, + * written prior permission. + * + * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" + * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR + * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, + * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY + * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, + * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF + * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. + * + * US Government Users Restricted Rights + * Use, duplication, or disclosure by the Government is subject to + * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph + * (c)(1)(ii) of the Rights in Technical Data and Computer Software + * clause at DFARS 252.227-7013 and/or in similar or successor + * clauses in the FAR or the DOD or NASA FAR Supplement. + * Unpublished-- rights reserved under the copyright laws of the + * United States. Contractor/manufacturer is Silicon Graphics, + * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. + * + * OpenGL(TM) is a trademark of Silicon Graphics, Inc. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <GL/glew.h> +#include <GL/glut.h> + +#include "readtex.h" + + +static GLfloat LodBias = 6.0; /* make smallest miplevel visible */ +static GLuint texImage; + +#define WIDTH 2 +#define HEIGHT 2 + +static void +InitValues(void) +{ + LodBias = 6.0; /* make smallest miplevel visible */ +} + + +static void MakeImage(void) +{ + const GLubyte color0[4] = { 0xff, 0x80, 0x20, 0xff }; + const GLubyte color1[4] = { 0x10, 0x20, 0x40, 0xff }; + + GLubyte img[WIDTH*HEIGHT*3]; + int i, j; + for (i = 0; i < HEIGHT; i++) { + for (j = 0; j < WIDTH; j++) { + int k = (i * WIDTH + j) * 3; + int p = ((i+j)%2); + if (p == 0) { + img[k + 0] = color0[0]; + img[k + 1] = color0[1]; + img[k + 2] = color0[2]; + } + else { + img[k + 0] = color1[0]; + img[k + 1] = color1[1]; + img[k + 2] = color1[2]; + } + } + } + + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, WIDTH, HEIGHT, 0, + GL_RGB, GL_UNSIGNED_BYTE, img); + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_FALSE); +} + + + +static void myinit(void) +{ + InitValues(); + + glShadeModel(GL_FLAT); + + glTranslatef(0.0, 0.0, -3.6); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glGenTextures(1, &texImage); + glBindTexture(GL_TEXTURE_2D, texImage); + MakeImage(); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glEnable(GL_TEXTURE_2D); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, -1); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 1); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_NEAREST_MIPMAP_NEAREST); +} + + + +static void display(void) +{ + GLfloat tcm = 1.0; + glBindTexture(GL_TEXTURE_2D, texImage); + + printf("Bias=%.2g\n", LodBias); + fflush(stdout); + + glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias); + + glClear(GL_COLOR_BUFFER_BIT); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); + glTexCoord2f(0.0, tcm); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(tcm * 3000.0, tcm); glVertex3f(3000.0, 1.0, -6000.0); + glTexCoord2f(tcm * 3000.0, 0.0); glVertex3f(3000.0, -1.0, -6000.0); + glEnd(); + glFlush(); +} + +static void myReshape(int w, int h) +{ + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +static void +key(unsigned char k, int x, int y) +{ + (void) x; + (void) y; + switch (k) { + case 'l': + LodBias -= 0.25; + break; + case 'L': + LodBias += 0.25; + break; + case ' ': + InitValues(); + break; + case 27: /* Escape */ + exit(0); + break; + default: + return; + } + glutPostRedisplay(); +} + + +static void usage(void) +{ + printf("usage:\n"); + printf(" l/L decrease/increase GL_TEXTURE_LOD_BIAS\n"); + printf(" SPACE reset values\n"); +} + + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB ); + glutInitWindowSize (600, 600); + glutCreateWindow (argv[0]); + glewInit(); + myinit(); + glutReshapeFunc (myReshape); + glutDisplayFunc(display); + glutKeyboardFunc(key); + usage(); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/tests/mipmap_limits.c b/progs/tests/mipmap_limits.c index 8bdad826f7..5b899cd155 100644 --- a/progs/tests/mipmap_limits.c +++ b/progs/tests/mipmap_limits.c @@ -51,19 +51,25 @@ */ #include <stdlib.h> #include <stdio.h> +#include <GL/glew.h> #include <GL/glut.h> -static GLint BaseLevel = 0, MaxLevel = 8; +#include "readtex.h" + +#define TEXTURE_FILE "../images/girl.rgb" + +static GLint BaseLevel = 0, MaxLevel = 9; static GLfloat MinLod = -1, MaxLod = 9; static GLfloat LodBias = 0.0; static GLboolean NearestFilter = GL_TRUE; +static GLuint texImage, texColor, texCurrent; static void InitValues(void) { BaseLevel = 0; - MaxLevel = 8; + MaxLevel = 9; MinLod = -1; MaxLod = 9; LodBias = 0.0; @@ -74,7 +80,7 @@ InitValues(void) static void MakeImage(int level, int width, int height, const GLubyte color[4]) { const int makeStripes = 0; - GLubyte img[256*256*3]; + GLubyte img[512*512*3]; int i, j; for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { @@ -98,87 +104,138 @@ static void MakeImage(int level, int width, int height, const GLubyte color[4]) } -static void makeImages(void) +static void makeImages(int image) { - static const GLubyte colors[8][3] = { - {128, 128, 128 }, - { 0, 255, 255 }, - { 255, 255, 0 }, - { 255, 0, 255 }, - { 255, 0, 0 }, - { 0, 255, 0 }, - { 0, 0, 255 }, - { 255, 255, 255 } - }; - int i, sz = 128; - - for (i = 0; i < 8; i++) { - MakeImage(i, sz, sz, colors[i]); - sz /= 2; +#define WIDTH 512 +#define HEIGHT 512 + if (glutExtensionSupported("GL_SGIS_generate_mipmap") && image) { + /* test auto mipmap generation */ + GLint width, height, i; + GLenum format; + GLubyte *image = LoadRGBImage(TEXTURE_FILE, &width, &height, &format); + if (!image) { + printf("Error: could not load texture image %s\n", TEXTURE_FILE); + exit(1); + } + /* resize */ + if (width != WIDTH || height != HEIGHT) { + GLubyte *newImage = malloc(WIDTH * HEIGHT * 4); + gluScaleImage(format, width, height, GL_UNSIGNED_BYTE, image, + WIDTH, HEIGHT, GL_UNSIGNED_BYTE, newImage); + free(image); + image = newImage; + } + printf("Using GL_SGIS_generate_mipmap\n"); + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); + glTexImage2D(GL_TEXTURE_2D, 0, format, WIDTH, HEIGHT, 0, + format, GL_UNSIGNED_BYTE, image); + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_FALSE); + free(image); + + /* make sure mipmap was really generated correctly */ + width = WIDTH; height = HEIGHT; + for (i = 0; i < 10; i++) { + GLint w, h; + glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_WIDTH, &w); + glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_HEIGHT, &h); + printf("Level %d size: %d x %d\n", i, w, h); + width /= 2; + height /= 2; + } + } else { + static const GLubyte colors[10][3] = { + {128, 128, 128 }, + { 0, 255, 255 }, + { 255, 255, 0 }, + { 255, 0, 255 }, + { 255, 0, 0 }, + { 0, 255, 0 }, + { 0, 0, 255 }, + { 0, 255, 255 }, + { 255, 255, 0 }, + { 255, 255, 255 } + }; + int i, sz = 512; + + for (i = 0; i < 10; i++) { + MakeImage(i, sz, sz, colors[i]); + printf("Level %d size: %d x %d\n", i, sz, sz); + sz /= 2; + } } } static void myinit(void) { - InitValues(); + InitValues(); + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + glShadeModel(GL_FLAT); - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - glShadeModel(GL_FLAT); + glTranslatef(0.0, 0.0, -3.6); - glTranslatef(0.0, 0.0, -3.6); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glGenTextures(1, &texImage); + glBindTexture(GL_TEXTURE_2D, texImage); + makeImages(1); + glGenTextures(1, &texColor); + glBindTexture(GL_TEXTURE_2D, texColor); + makeImages(0); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - makeImages(); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); - glEnable(GL_TEXTURE_2D); + texCurrent = texImage; + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glEnable(GL_TEXTURE_2D); } static void display(void) { - GLfloat tcm = 4.0; - printf("BASE_LEVEL=%d MAX_LEVEL=%d MIN_LOD=%.2g MAX_LOD=%.2g Bias=%.2g Filter=%s\n", - BaseLevel, MaxLevel, MinLod, MaxLod, LodBias, - NearestFilter ? "NEAREST" : "LINEAR"); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MaxLevel); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, MinLod); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, MaxLod); - - if (NearestFilter) { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - GL_NEAREST_MIPMAP_NEAREST); - } - else { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - GL_LINEAR_MIPMAP_LINEAR); - } - - glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); - glTexCoord2f(0.0, tcm); glVertex3f(-2.0, 1.0, 0.0); - glTexCoord2f(tcm, tcm); glVertex3f(3000.0, 1.0, -6000.0); - glTexCoord2f(tcm, 0.0); glVertex3f(3000.0, -1.0, -6000.0); - glEnd(); - glFlush(); + GLfloat tcm = 1.0; + glBindTexture(GL_TEXTURE_2D, texCurrent); + + printf("BASE_LEVEL=%d MAX_LEVEL=%d MIN_LOD=%.2g MAX_LOD=%.2g Bias=%.2g Filter=%s\n", + BaseLevel, MaxLevel, MinLod, MaxLod, LodBias, + NearestFilter ? "NEAREST" : "LINEAR"); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MaxLevel); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, MinLod); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, MaxLod); + + if (NearestFilter) { + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_NEAREST_MIPMAP_NEAREST); + } + else { + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_LINEAR_MIPMAP_LINEAR); + } + + glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); + glTexCoord2f(0.0, tcm); glVertex3f(-2.0, 1.0, 0.0); + glTexCoord2f(tcm * 3000.0, tcm); glVertex3f(3000.0, 1.0, -6000.0); + glTexCoord2f(tcm * 3000.0, 0.0); glVertex3f(3000.0, -1.0, -6000.0); + glEnd(); + glFlush(); } static void myReshape(int w, int h) { - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); } static void @@ -228,6 +285,12 @@ key(unsigned char k, int x, int y) case 'f': NearestFilter = !NearestFilter; break; + case 't': + if (texCurrent == texColor) + texCurrent = texImage; + else + texCurrent = texColor; + break; case ' ': InitValues(); break; @@ -250,6 +313,7 @@ static void usage(void) printf(" x/X decrease/increase GL_TEXTURE_MAX_LOD\n"); printf(" l/L decrease/increase GL_TEXTURE_LOD_BIAS\n"); printf(" f toggle nearest/linear filtering\n"); + printf(" t toggle texture color/image\n"); printf(" SPACE reset values\n"); } @@ -260,6 +324,7 @@ int main(int argc, char** argv) glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize (600, 600); glutCreateWindow (argv[0]); + glewInit(); myinit(); glutReshapeFunc (myReshape); glutDisplayFunc(display); diff --git a/progs/tests/mipmap_view.c b/progs/tests/mipmap_view.c index 54607b8939..16f3584f70 100644 --- a/progs/tests/mipmap_view.c +++ b/progs/tests/mipmap_view.c @@ -10,6 +10,7 @@ #include <stdlib.h> #include <stdio.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include <GL/glext.h> @@ -242,6 +243,7 @@ main(int argc, char *argv[]) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Display); diff --git a/progs/tests/multipal.c b/progs/tests/multipal.c index 7bd4473565..4a94016978 100644 --- a/progs/tests/multipal.c +++ b/progs/tests/multipal.c @@ -13,6 +13,7 @@ #include <windows.h> #endif #define GL_GLEXT_LEGACY +#include <GL/glew.h> #include <GL/glut.h> #include "../util/readtex.c" /* I know, this is a hack. */ @@ -350,6 +351,7 @@ int main( int argc, char *argv[] ) glutInitWindowPosition( 0, 0 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow(argv[0] ); + glewInit(); Init( argc, argv ); diff --git a/progs/tests/multitexarray.c b/progs/tests/multitexarray.c index b4fab004a6..518fee2992 100644 --- a/progs/tests/multitexarray.c +++ b/progs/tests/multitexarray.c @@ -16,6 +16,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include "GL/glew.h" #include "GL/glut.h" static GLuint Window = 0; @@ -221,6 +222,7 @@ int main( int argc, char *argv[] ) glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); Window = glutCreateWindow("Texture Objects"); + glewInit(); if (!Window) { exit(1); } diff --git a/progs/tests/multiwindow.c b/progs/tests/multiwindow.c index b069bea91c..6db552d195 100644 --- a/progs/tests/multiwindow.c +++ b/progs/tests/multiwindow.c @@ -25,6 +25,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> @@ -145,6 +146,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 400, 400 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); Window[0] = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display0 ); @@ -155,6 +157,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 400, 400 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); Window[1] = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display1 ); diff --git a/progs/tests/no_s3tc.c b/progs/tests/no_s3tc.c index d3383ff98a..31cfb40b9d 100644 --- a/progs/tests/no_s3tc.c +++ b/progs/tests/no_s3tc.c @@ -38,6 +38,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <GL/glew.h> #include <GL/glut.h> #include <GL/glext.h> @@ -59,6 +60,7 @@ main( int argc, char ** argv ) glutInitWindowPosition( 0, 0 ); glutInitWindowSize( 300, 300 ); glutCreateWindow( "No S3TC Test" ); + glewInit(); gl_version = strtod( (const char *) glGetString( GL_VERSION ), NULL ); if ( ! glutExtensionSupported( "GL_ARB_texture_compression" ) diff --git a/progs/tests/packedpixels.c b/progs/tests/packedpixels.c index 67ffe08825..1703b271cb 100644 --- a/progs/tests/packedpixels.c +++ b/progs/tests/packedpixels.c @@ -8,6 +8,7 @@ #include <stdlib.h> #include <math.h> #include <string.h> +#include <GL/glew.h> #include <GL/glut.h> @@ -333,6 +334,7 @@ main(int argc, char *argv[]) glutInitWindowSize(700, 800); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Draw); diff --git a/progs/tests/pbo.c b/progs/tests/pbo.c index b31b36cc12..9974486db3 100644 --- a/progs/tests/pbo.c +++ b/progs/tests/pbo.c @@ -5,12 +5,12 @@ * 11 March 2004 */ -#define GL_GLEXT_PROTOTYPES #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include "../util/readtex.c" /* a hack, I know */ @@ -287,6 +287,7 @@ main( int argc, char *argv[] ) glutInitWindowSize( 750, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow(argv[0]); + glewInit(); Init(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); diff --git a/progs/tests/prog_parameter.c b/progs/tests/prog_parameter.c index 96697e5bda..6dd956c402 100644 --- a/progs/tests/prog_parameter.c +++ b/progs/tests/prog_parameter.c @@ -35,6 +35,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #ifndef GL_EXT_gpu_program_parameters @@ -274,6 +275,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB ); glutCreateWindow( "Program Parameters Test" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/projtex.c b/progs/tests/projtex.c index e3ef948ab6..800d81ecd6 100644 --- a/progs/tests/projtex.c +++ b/progs/tests/projtex.c @@ -18,6 +18,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #if 0 #include "texture.h" @@ -1005,6 +1006,7 @@ main(int argc, char **argv) glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE); (void) glutCreateWindow("projtex"); + glewInit(); loadTexture = loadImageTextures; drawObject = drawCube; diff --git a/progs/tests/quads.c b/progs/tests/quads.c index 1bf57e6337..2098b51ccd 100644 --- a/progs/tests/quads.c +++ b/progs/tests/quads.c @@ -3,10 +3,10 @@ */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #define NUM_QUADS 20 @@ -19,7 +19,7 @@ static GLuint Vbuffer = 0; static GLfloat buf[NUM_QUADS * 6 * 4]; -static GLboolean SwapBuffers = GL_TRUE; +static GLboolean doSwapBuffers = GL_TRUE; static GLint Frames = 0, T0 = 0; @@ -48,7 +48,7 @@ Draw(void) glPopMatrix(); - if (SwapBuffers) + if (doSwapBuffers) glutSwapBuffers(); /* else @@ -91,7 +91,7 @@ Key(unsigned char key, int x, int y) (void) y; switch (key) { case 's': - SwapBuffers = !SwapBuffers; + doSwapBuffers = !doSwapBuffers; break; case 'a': Anim = !Anim; @@ -246,6 +246,7 @@ main(int argc, char *argv[]) glutInitWindowSize(600, 600); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/tests/random.c b/progs/tests/random.c index d52c338e0e..4023674c05 100644 --- a/progs/tests/random.c +++ b/progs/tests/random.c @@ -5,13 +5,13 @@ * 21 June 2007 */ -#define GL_GLEXT_PROTOTYPES #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; @@ -445,6 +445,7 @@ main(int argc, char *argv[]) glutInitWindowSize(Width, Height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); Win = glutCreateWindow(argv[0]); + glewInit(); ParseArgs(argc, argv); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); diff --git a/progs/tests/readrate.c b/progs/tests/readrate.c index 42ae62d48a..6bdda04907 100644 --- a/progs/tests/readrate.c +++ b/progs/tests/readrate.c @@ -7,11 +7,11 @@ * gcc readrate.c -L/usr/X11R6/lib -lglut -lGLU -lGL -lX11 -o readrate */ -#define GL_GLEXT_PROTOTYPES #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> /* Hack, to test drawing instead of reading */ @@ -275,6 +275,7 @@ main(int argc, char *argv[]) glutInitWindowSize(MAX_WIDTH, MAX_HEIGHT); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/tests/rubberband.c b/progs/tests/rubberband.c index a8e64bc091..866a0f519e 100644 --- a/progs/tests/rubberband.c +++ b/progs/tests/rubberband.c @@ -2,10 +2,10 @@ * Test rubber-band selection box w/ logicops and blend. */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include "readtex.c" @@ -232,6 +232,7 @@ main(int argc, char *argv[]) glutInitWindowSize(Width, Height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/tests/seccolor.c b/progs/tests/seccolor.c index 77fd40647b..f1ba314ef0 100644 --- a/progs/tests/seccolor.c +++ b/progs/tests/seccolor.c @@ -3,10 +3,10 @@ */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> static int Width = 600; @@ -136,6 +136,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/shader_api.c b/progs/tests/shader_api.c index 679f9137c8..a513ca6ba1 100644 --- a/progs/tests/shader_api.c +++ b/progs/tests/shader_api.c @@ -5,7 +5,7 @@ #include <string.h> #include <stdio.h> #include <stdlib.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> static void assert_test(const char *file, int line, int cond, const char *msg) @@ -323,6 +323,7 @@ int main(int argc, char **argv) { glutInit(&argc, argv); glutCreateWindow("Mesa bug demo"); + glewInit(); RUN_TEST(test_uniform_size_type); RUN_TEST(test_attrib_size_type); diff --git a/progs/tests/stencil_twoside.c b/progs/tests/stencil_twoside.c index 8826c46fc2..1e18ca6b5e 100644 --- a/progs/tests/stencil_twoside.c +++ b/progs/tests/stencil_twoside.c @@ -33,6 +33,7 @@ #include <stdio.h> #include <stdlib.h> +#include <GL/glew.h> #include <GL/glut.h> static int use20syntax = 1; @@ -288,6 +289,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL ); glutCreateWindow( "GL_ATI_separate_stencil test" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/stencil_wrap.c b/progs/tests/stencil_wrap.c index 88cf3809ca..28307fef4f 100644 --- a/progs/tests/stencil_wrap.c +++ b/progs/tests/stencil_wrap.c @@ -34,6 +34,7 @@ #include <stdio.h> #include <stdlib.h> +#include <GL/glew.h> #include <GL/glut.h> static int Width = 550; @@ -248,6 +249,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL ); glutCreateWindow( "GL_EXT_stencil_wrap test" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/stencilwrap.c b/progs/tests/stencilwrap.c index 753375d0f3..2e219fd8b5 100644 --- a/progs/tests/stencilwrap.c +++ b/progs/tests/stencilwrap.c @@ -8,6 +8,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> GLboolean wrapping; @@ -272,6 +273,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 400, 400 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_STENCIL ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/subtex.c b/progs/tests/subtex.c index 81ceb085aa..86b737c01f 100644 --- a/progs/tests/subtex.c +++ b/progs/tests/subtex.c @@ -9,6 +9,7 @@ #include <assert.h> #include <stdio.h> #include <stdlib.h> +#include "GL/glew.h" #include "GL/glut.h" static GLuint Window = 0; @@ -207,6 +208,7 @@ int main( int argc, char *argv[] ) glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); Window = glutCreateWindow("Texture Objects"); + glewInit(); if (!Window) { exit(1); } diff --git a/progs/tests/subtexrate.c b/progs/tests/subtexrate.c index 568b68d552..4bda970d06 100644 --- a/progs/tests/subtexrate.c +++ b/progs/tests/subtexrate.c @@ -5,11 +5,11 @@ * 26 Jan 2006 */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> static GLint WinWidth = 1024, WinHeight = 512; @@ -337,6 +337,7 @@ main(int argc, char *argv[]) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(mode); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/tests/tex1d.c b/progs/tests/tex1d.c index 1fab849dd3..4abe1068c7 100644 --- a/progs/tests/tex1d.c +++ b/progs/tests/tex1d.c @@ -7,6 +7,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include "GL/glew.h" #include "GL/glut.h" static GLuint Window = 0; @@ -124,6 +125,7 @@ int main( int argc, char *argv[] ) glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); Window = glutCreateWindow("Texture Objects"); + glewInit(); if (!Window) { exit(1); } diff --git a/progs/tests/texcmp.c b/progs/tests/texcmp.c index 6e822fb689..52c504a318 100644 --- a/progs/tests/texcmp.c +++ b/progs/tests/texcmp.c @@ -7,7 +7,7 @@ #include <stdlib.h> #include <math.h> #include <string.h> -#define GL_GLEXT_PROTOTYPES 1 +#include <GL/glew.h> #include <GL/glut.h> #include "readtex.c" /* I know, this is a hack. */ @@ -371,6 +371,7 @@ int main( int argc, char *argv[] ) glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); if (glutCreateWindow(argv[0]) <= 0) { + glewInit(); printf("Couldn't create window\n"); exit(0); } diff --git a/progs/tests/texcompress2.c b/progs/tests/texcompress2.c index e2eed756b6..3e8e9908cb 100644 --- a/progs/tests/texcompress2.c +++ b/progs/tests/texcompress2.c @@ -3,9 +3,9 @@ */ -#define GL_GLEXT_PROTOTYPES #include <assert.h> #include <stdio.h> +#include <GL/glew.h> #include <GL/glut.h> #include <GL/glx.h> #include "readtex.c" @@ -258,6 +258,7 @@ main( int argc, char *argv[] ) glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); diff --git a/progs/tests/texfilt.c b/progs/tests/texfilt.c index 6ee4bc4eae..fa919dba62 100644 --- a/progs/tests/texfilt.c +++ b/progs/tests/texfilt.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <string.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> const GLenum filter_modes[] = { @@ -219,8 +220,8 @@ static void Init( void ) static void generate_tunnel( unsigned num_segs, GLfloat ** pos_data, GLfloat ** tex_data ) { - const GLfloat far = 20.0f; - const GLfloat near = -90.0f; + const GLfloat far_distance = 20.0f; + const GLfloat near_distance = -90.0f; const GLfloat far_tex = 30.0f; const GLfloat near_tex = 0.0f; const GLfloat angle_step = (2 * M_PI) / num_segs; @@ -241,12 +242,12 @@ static void generate_tunnel( unsigned num_segs, GLfloat ** pos_data, for ( i = 0 ; i < num_segs ; i++ ) { position[0] = 2.5 * sinf( angle ); position[1] = 2.5 * cosf( angle ); - position[2] = (i & 1) ? far : near; + position[2] = (i & 1) ? far_distance : near_distance; position[3] = 1.0f; position[4] = position[0]; position[5] = position[1]; - position[6] = (i & 1) ? near : far; + position[6] = (i & 1) ? near_distance : far_distance; position[7] = 1.0f; position += 8; @@ -264,12 +265,12 @@ static void generate_tunnel( unsigned num_segs, GLfloat ** pos_data, position[0] = 2.5 * sinf( angle ); position[1] = 2.5 * cosf( angle ); - position[2] = (i & 1) ? near : far; + position[2] = (i & 1) ? near_distance : far_distance; position[3] = 1.0f; position[4] = position[0]; position[5] = position[1]; - position[6] = (i & 1) ? far : near; + position[6] = (i & 1) ? far_distance : near_distance; position[7] = 1.0f; position += 8; @@ -381,6 +382,7 @@ int main( int argc, char ** argv ) glutInitWindowSize( 800, 600 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow( "Texture Filter Test" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/texgenmix.c b/progs/tests/texgenmix.c index be8f6775c7..008da8625e 100644 --- a/progs/tests/texgenmix.c +++ b/progs/tests/texgenmix.c @@ -6,6 +6,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <GL/glew.h> #include <GL/glut.h> #undef max @@ -618,6 +619,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( winWidth, winHeight ); glutInitWindowPosition( 0, 0 ); glutCreateWindow( "Mixed texgen/non-texgen texture coordinate test" ); + glewInit(); initialize(); instructions(); diff --git a/progs/tests/texline.c b/progs/tests/texline.c index 76dfccd9b1..1803832b47 100644 --- a/progs/tests/texline.c +++ b/progs/tests/texline.c @@ -9,6 +9,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include "../util/readtex.c" /* I know, this is a hack. */ @@ -263,6 +264,7 @@ int main( int argc, char *argv[] ) glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow(argv[0] ); + glewInit(); Init(argc, argv); diff --git a/progs/tests/texrect.c b/progs/tests/texrect.c index 43edc49180..10061ee586 100644 --- a/progs/tests/texrect.c +++ b/progs/tests/texrect.c @@ -6,11 +6,11 @@ */ -#define GL_GLEXT_PROTOTYPES #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <GL/glew.h> #include <GL/glut.h> #include "readtex.h" @@ -328,6 +328,7 @@ int main( int argc, char *argv[] ) glutInitWindowPosition( 0, 0 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow(argv[0] ); + glewInit(); Init( argc, argv ); diff --git a/progs/tests/texwrap.c b/progs/tests/texwrap.c index 8143256f8a..12f045b72e 100644 --- a/progs/tests/texwrap.c +++ b/progs/tests/texwrap.c @@ -8,10 +8,10 @@ */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> @@ -294,6 +294,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 1000, 270 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/unfilledclip.c b/progs/tests/unfilledclip.c index f25e52616a..db6fffa3e8 100644 --- a/progs/tests/unfilledclip.c +++ b/progs/tests/unfilledclip.c @@ -26,6 +26,7 @@ */ #include <stdlib.h> +#include <GL/glew.h> #include <GL/glut.h> static int win_width, win_height; @@ -194,6 +195,7 @@ main(int argc, char *argv[]) glutInitWindowSize(win_width, win_height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(reshape); glutKeyboardFunc(key); glutDisplayFunc(display); diff --git a/progs/tests/vao-01.c b/progs/tests/vao-01.c index c2d70885f0..117fae8bd9 100644 --- a/progs/tests/vao-01.c +++ b/progs/tests/vao-01.c @@ -49,6 +49,7 @@ typedef void (* PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); typedef GLboolean (* PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); #else +#include <GL/glew.h> #include <GL/glut.h> #endif @@ -166,6 +167,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB ); glutCreateWindow( "GL_APPLE_vertex_array_object demo" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/vao-02.c b/progs/tests/vao-02.c index 993bc368d4..7764ed5106 100644 --- a/progs/tests/vao-02.c +++ b/progs/tests/vao-02.c @@ -49,6 +49,7 @@ typedef void (* PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); typedef GLboolean (* PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); #else +#include <GL/glew.h> #include <GL/glut.h> #endif @@ -194,6 +195,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( Width, Height ); glutInitDisplayMode( GLUT_RGB ); glutCreateWindow( "GL_APPLE_vertex_array_object demo" ); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/vparray.c b/progs/tests/vparray.c index 580a670f8e..9c2fad97d9 100644 --- a/progs/tests/vparray.c +++ b/progs/tests/vparray.c @@ -12,7 +12,7 @@ #include <stdlib.h> #include <string.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include "GL/glew.h" #include "GL/glut.h" #define MAXVERTS 10000 @@ -280,6 +280,7 @@ int main(int argc, char **argv) glutInitWindowPosition(0, 0); glutInitWindowSize(400, 400); if (glutCreateWindow("Isosurface") <= 0) { + glewInit(); exit(0); } glutReshapeFunc(Reshape); diff --git a/progs/tests/vpeval.c b/progs/tests/vpeval.c index 8b6996d3b5..f07737f973 100644 --- a/progs/tests/vpeval.c +++ b/progs/tests/vpeval.c @@ -10,7 +10,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> @@ -222,6 +222,7 @@ main(int argc, char **argv) glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowPosition(0, 0); glutCreateWindow(argv[0]); + glewInit(); myinit(argc, argv); glutReshapeFunc(myReshape); glutDisplayFunc(display); diff --git a/progs/tests/vptest1.c b/progs/tests/vptest1.c index 560df2c3fd..5162919292 100644 --- a/progs/tests/vptest1.c +++ b/progs/tests/vptest1.c @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> @@ -161,6 +161,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/vptest2.c b/progs/tests/vptest2.c index 2158e07f04..4161b03a67 100644 --- a/progs/tests/vptest2.c +++ b/progs/tests/vptest2.c @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> @@ -140,6 +140,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 50, 50 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/vptest3.c b/progs/tests/vptest3.c index 2c5c800040..4e4bfee31d 100644 --- a/progs/tests/vptest3.c +++ b/progs/tests/vptest3.c @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> static float Zrot = 0.0; @@ -111,6 +111,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/tests/vptorus.c b/progs/tests/vptorus.c index 764dea4ec2..e61ffdac21 100644 --- a/progs/tests/vptorus.c +++ b/progs/tests/vptorus.c @@ -7,7 +7,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> static float Xrot = 0.0, Yrot = 0.0, Zrot = 0.0; @@ -162,6 +162,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/vpwarpmesh.c b/progs/tests/vpwarpmesh.c index 56aa8200ec..80204ea136 100644 --- a/progs/tests/vpwarpmesh.c +++ b/progs/tests/vpwarpmesh.c @@ -7,7 +7,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> static float Xrot = -60.0, Yrot = 0.0, Zrot = 0.0; @@ -224,6 +224,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutSpecialFunc( SpecialKey ); diff --git a/progs/tests/yuvrect.c b/progs/tests/yuvrect.c index acef406097..aab2f80ed9 100644 --- a/progs/tests/yuvrect.c +++ b/progs/tests/yuvrect.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> #include "../util/readtex.c" /* I know, this is a hack. */ @@ -180,6 +180,7 @@ int main( int argc, char *argv[] ) glutInitWindowPosition( 0, 0 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow(argv[0] ); + glewInit(); Init( argc, argv ); diff --git a/progs/tests/yuvsquare.c b/progs/tests/yuvsquare.c index 3601e7a31c..658528b799 100644 --- a/progs/tests/yuvsquare.c +++ b/progs/tests/yuvsquare.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> #include "../util/readtex.c" /* I know, this is a hack. */ @@ -219,6 +219,7 @@ int main( int argc, char *argv[] ) glutInitWindowPosition( 0, 0 ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow(argv[0] ); + glewInit(); Init( argc, argv ); diff --git a/progs/tests/zcomp.c b/progs/tests/zcomp.c index b53079d07f..15e35f17b0 100644 --- a/progs/tests/zcomp.c +++ b/progs/tests/zcomp.c @@ -2,10 +2,10 @@ * Test Z compositing with glDrawPixels(GL_DEPTH_COMPONENT) and stencil test. */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include "../util/showbuffer.c" @@ -211,6 +211,7 @@ main(int argc, char *argv[]) glutInitWindowSize(Width, Height); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/tests/zdrawpix.c b/progs/tests/zdrawpix.c index dd222e7dd0..ba7da571eb 100644 --- a/progs/tests/zdrawpix.c +++ b/progs/tests/zdrawpix.c @@ -10,10 +10,10 @@ * Press 'd' to view the Z buffer as a grayscale image. */ -#define GL_GLEXT_PROTOTYPES #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <GL/glew.h> #include <GL/glut.h> #include "../util/showbuffer.c" @@ -180,6 +180,7 @@ main(int argc, char *argv[]) glutInitWindowSize(400, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); Win = glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); diff --git a/progs/tests/zreaddraw.c b/progs/tests/zreaddraw.c index e2dacbf7f2..3d8c557b37 100644 --- a/progs/tests/zreaddraw.c +++ b/progs/tests/zreaddraw.c @@ -8,7 +8,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES +#include <GL/glew.h> #include <GL/glut.h> static GLint WinWidth = 500, WinHeight = 500; @@ -107,6 +107,7 @@ int main(int argc, char *argv[]) glutInitWindowSize(WinWidth, WinHeight); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Display); |