diff options
Diffstat (limited to 'progs/trivial')
115 files changed, 1570 insertions, 163 deletions
diff --git a/progs/trivial/.gitignore b/progs/trivial/.gitignore index d77f120b96..aec4c94527 100644 --- a/progs/trivial/.gitignore +++ b/progs/trivial/.gitignore @@ -9,6 +9,7 @@ dlist-dangling dlist-degenerate dlist-edgeflag dlist-edgeflag-dangling +draw2arrays drawarrays drawelements drawrange @@ -58,11 +59,13 @@ quad-tex-2d quad-tex-3d quad-tex-alpha quad-tex-pbo +quad-tex-sub quad-unfilled quad-unfilled-clip quad-unfilled-stipple quads quadstrip +quadstrip-clip quadstrip-cont quadstrip-flat readtex.c @@ -83,12 +86,15 @@ tri-dlist tri-edgeflag tri-fbo tri-fbo-tex +tri-fbo-tex-mip tri-flat tri-flat-clip tri-fog tri-fp tri-fp-const-imm tri-lit +tri-logicop-none +tri-logicop-xor tri-mask-tri tri-orig tri-query @@ -102,12 +108,14 @@ tri-tri tri-unfilled tri-unfilled-clip tri-unfilled-edgeflag +tri-unfilled-fog tri-unfilled-smooth tri-unfilled-tri tri-unfilled-tri-lit tri-unfilled-userclip tri-unfilled-userclip-stip tri-userclip +tri-viewport tri-z tri-z-eq trifan diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index dce96f6bc8..082387d86e 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -23,6 +23,7 @@ SOURCES = \ dlist-edgeflag.c \ dlist-degenerate.c \ drawarrays.c \ + draw2arrays.c \ drawelements.c \ drawrange.c \ flat-clip.c \ @@ -69,11 +70,13 @@ SOURCES = \ quad-tex-3d.c \ quad-tex-alpha.c \ quad-tex-pbo.c \ + quad-tex-sub.c \ quad-unfilled-clip.c \ quad-unfilled-stipple.c \ quad-unfilled.c \ quad.c \ quads.c \ + quadstrip-clip.c \ quadstrip-cont.c \ quadstrip-flat.c \ quadstrip.c \ @@ -88,8 +91,11 @@ SOURCES = \ tri-clip.c \ tri-cull-both.c \ tri-cull.c \ + tri-logicop-none.c \ + tri-logicop-xor.c \ tri-dlist.c \ tri-edgeflag.c \ + tri-fbo-tex-mip.c \ tri-fbo-tex.c \ tri-fbo.c \ tri-flat-clip.c \ @@ -108,6 +114,7 @@ SOURCES = \ tri-tex.c \ tri-tex-3d.c \ tri-tri.c \ + tri-unfilled-fog.c \ tri-unfilled-edgeflag.c \ tri-unfilled-clip.c \ tri-unfilled-smooth.c \ @@ -117,6 +124,7 @@ SOURCES = \ tri-unfilled-userclip.c \ tri-unfilled.c \ tri-userclip.c \ + tri-viewport.c \ tri-z-eq.c \ tri-z.c \ tri.c \ diff --git a/progs/trivial/SConscript b/progs/trivial/SConscript index 76826d9be0..6a9ffafe50 100644 --- a/progs/trivial/SConscript +++ b/progs/trivial/SConscript @@ -19,6 +19,7 @@ progs = [ 'dlist-edgeflag', 'dlist-degenerate', 'drawarrays', + 'draw2arrays', 'drawelements', 'drawrange', 'flat-clip', @@ -65,11 +66,13 @@ progs = [ 'quad-tex-3d', 'quad-tex-alpha', 'quad-tex-pbo', + 'quad-tex-sub', 'quad-unfilled-clip', 'quad-unfilled-stipple', 'quad-unfilled', 'quad', 'quads', + 'quadstrip-clip', 'quadstrip-cont', 'quadstrip-flat', 'quadstrip', @@ -86,6 +89,7 @@ progs = [ 'tri-cull', 'tri-dlist', 'tri-edgeflag', + 'tri-fbo-tex-mip', 'tri-fbo-tex', 'tri-fbo', 'tri-flat-clip', @@ -94,15 +98,19 @@ progs = [ 'tri-fp', 'tri-fp-const-imm', 'tri-lit', + 'tri-logicop-none', + 'tri-logicop-xor', 'tri-mask-tri', 'tri-orig', 'tri-query', 'tri-repeat', 'tri-scissor-tri', 'tri-stencil', + 'tri-stipple', 'tri-tex', 'tri-tex-3d', 'tri-tri', + 'tri-unfilled-fog', 'tri-unfilled-edgeflag', 'tri-unfilled-clip', 'tri-unfilled-smooth', @@ -112,6 +120,7 @@ progs = [ 'tri-unfilled-userclip', 'tri-unfilled', 'tri-userclip', + 'tri-viewport', 'tri-z-eq', 'tri-z', 'tri', diff --git a/progs/trivial/clear-random.c b/progs/trivial/clear-random.c index 16bd83339b..f3a67dbe8a 100644 --- a/progs/trivial/clear-random.c +++ b/progs/trivial/clear-random.c @@ -118,7 +118,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/clear-repeat.c b/progs/trivial/clear-repeat.c index 9f9490c6c8..9c618d492f 100644 --- a/progs/trivial/clear-repeat.c +++ b/progs/trivial/clear-repeat.c @@ -72,6 +72,24 @@ static void Draw(void) glClearColor((sin(f)+1)/2.0,(cos(f)+1)/2.0,0.5,1); glClear(GL_COLOR_BUFFER_BIT); glutSwapBuffers(); + + { + static GLint T0 = 0; + static GLint Frames = 0; + GLint t = glutGet(GLUT_ELAPSED_TIME); + + Frames++; + + if (t - T0 >= 5000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps); + fflush(stdout); + T0 = t; + Frames = 0; + } + } + } glutPostRedisplay(); } @@ -91,13 +109,13 @@ int main(int argc, char **argv) exit(1); } - glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); type = GLUT_RGB | GLUT_ALPHA; type |= GLUT_DOUBLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/clear.c b/progs/trivial/clear.c index da4fff0459..37cfd54fbe 100644 --- a/progs/trivial/clear.c +++ b/progs/trivial/clear.c @@ -113,7 +113,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/createwin.c b/progs/trivial/createwin.c index 901048555a..44d5b1b2c5 100644 --- a/progs/trivial/createwin.c +++ b/progs/trivial/createwin.c @@ -106,7 +106,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/dlist-dangling.c b/progs/trivial/dlist-dangling.c index 00a7507844..64054ec96c 100644 --- a/progs/trivial/dlist-dangling.c +++ b/progs/trivial/dlist-dangling.c @@ -135,7 +135,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/dlist-edgeflag-dangling.c b/progs/trivial/dlist-edgeflag-dangling.c index 08fae549c3..1b66244cab 100644 --- a/progs/trivial/dlist-edgeflag-dangling.c +++ b/progs/trivial/dlist-edgeflag-dangling.c @@ -140,7 +140,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/dlist-edgeflag.c b/progs/trivial/dlist-edgeflag.c index ae799dc355..350100681e 100644 --- a/progs/trivial/dlist-edgeflag.c +++ b/progs/trivial/dlist-edgeflag.c @@ -144,7 +144,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/draw2arrays.c b/progs/trivial/draw2arrays.c new file mode 100644 index 0000000000..95a89981d3 --- /dev/null +++ b/progs/trivial/draw2arrays.c @@ -0,0 +1,117 @@ +/* Basic VBO */ + +#include <assert.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <GL/glew.h> +#include <GL/glut.h> + +GLfloat pos[][3] = + { { 0.9, -0.9, 0.0 }, + { 0.9, 0.9, 0.0 }, + { -0.9, 0.9, 0.0 }, + { -0.9, -0.9, 0.0 } }; + +GLubyte color[][4] = +{ { 0x00, 0x00, 0xff, 0x00 }, + { 0x00, 0xff, 0x00, 0x00 }, + { 0xff, 0x00, 0x00, 0x00 }, + { 0xff, 0xff, 0xff, 0x00 } }; + +static void Init( void ) +{ + GLint errno; + GLuint prognum; + + static const char *prog1 = + "!!ARBvp1.0\n" + "MOV result.color, vertex.color;\n" + "MOV result.position, vertex.position;\n" + "END\n"; + + glGenProgramsARB(1, &prognum); + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); + glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog1), (const GLubyte *) prog1); + + assert(glIsProgramARB(prognum)); + errno = glGetError(); + printf("glGetError = %d\n", errno); + if (errno != GL_NO_ERROR) + { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + + + glEnableClientState( GL_VERTEX_ARRAY ); + glEnableClientState( GL_COLOR_ARRAY ); + + glVertexPointer( 3, GL_FLOAT, sizeof(pos[0]), pos ); + glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof(color[0]), color ); + +} + + + +static void Display( void ) +{ + glClearColor(0.3, 0.3, 0.3, 1); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glEnable(GL_VERTEX_PROGRAM_ARB); + +// glDrawArrays( GL_TRIANGLES, 0, 3 ); + glDrawArrays( GL_TRIANGLES, 1, 3 ); + + glFlush(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + /*glTranslatef( 0.0, 0.0, -15.0 );*/ +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/line-clip.c b/progs/trivial/line-clip.c index fd79d049c4..bcee32e25f 100644 --- a/progs/trivial/line-clip.c +++ b/progs/trivial/line-clip.c @@ -126,7 +126,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/line-cull.c b/progs/trivial/line-cull.c index 038004b4c4..9821873130 100644 --- a/progs/trivial/line-cull.c +++ b/progs/trivial/line-cull.c @@ -122,7 +122,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/line-stipple-wide.c b/progs/trivial/line-stipple-wide.c index 09e5e1fe08..28d96c797b 100644 --- a/progs/trivial/line-stipple-wide.c +++ b/progs/trivial/line-stipple-wide.c @@ -134,7 +134,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/line-userclip-clip.c b/progs/trivial/line-userclip-clip.c index 5c9c1b3b29..1b9f059729 100644 --- a/progs/trivial/line-userclip-clip.c +++ b/progs/trivial/line-userclip-clip.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/line-userclip-nop-clip.c b/progs/trivial/line-userclip-nop-clip.c index a6ee44fbd0..9f144a6e9a 100644 --- a/progs/trivial/line-userclip-nop-clip.c +++ b/progs/trivial/line-userclip-nop-clip.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/line-userclip-nop.c b/progs/trivial/line-userclip-nop.c index cebea5f481..7588faeb98 100644 --- a/progs/trivial/line-userclip-nop.c +++ b/progs/trivial/line-userclip-nop.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/line-userclip.c b/progs/trivial/line-userclip.c index ecfd28cac7..77d8228188 100644 --- a/progs/trivial/line-userclip.c +++ b/progs/trivial/line-userclip.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/line-wide.c b/progs/trivial/line-wide.c index 543b1f67f3..f20505378c 100644 --- a/progs/trivial/line-wide.c +++ b/progs/trivial/line-wide.c @@ -133,7 +133,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/line.c b/progs/trivial/line.c index de5f9274e4..7ccbce3750 100644 --- a/progs/trivial/line.c +++ b/progs/trivial/line.c @@ -131,7 +131,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/lineloop-clip.c b/progs/trivial/lineloop-clip.c index 211056720f..fbeca985b9 100644 --- a/progs/trivial/lineloop-clip.c +++ b/progs/trivial/lineloop-clip.c @@ -122,7 +122,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/lineloop.c b/progs/trivial/lineloop.c index fab7d1ea02..5863df654b 100644 --- a/progs/trivial/lineloop.c +++ b/progs/trivial/lineloop.c @@ -122,7 +122,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/linestrip-clip.c b/progs/trivial/linestrip-clip.c index acab0f4e1c..dae27c31d4 100644 --- a/progs/trivial/linestrip-clip.c +++ b/progs/trivial/linestrip-clip.c @@ -127,7 +127,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/linestrip-flat-stipple.c b/progs/trivial/linestrip-flat-stipple.c index b691437346..ee79f15019 100644 --- a/progs/trivial/linestrip-flat-stipple.c +++ b/progs/trivial/linestrip-flat-stipple.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/linestrip-stipple-wide.c b/progs/trivial/linestrip-stipple-wide.c index 53dfa554e9..c6307d5994 100644 --- a/progs/trivial/linestrip-stipple-wide.c +++ b/progs/trivial/linestrip-stipple-wide.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/linestrip-stipple.c b/progs/trivial/linestrip-stipple.c index 5933d1a136..2b40b5f1b8 100644 --- a/progs/trivial/linestrip-stipple.c +++ b/progs/trivial/linestrip-stipple.c @@ -127,7 +127,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/linestrip.c b/progs/trivial/linestrip.c index 06dd1c1087..865a752796 100644 --- a/progs/trivial/linestrip.c +++ b/progs/trivial/linestrip.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/long-fixed-func.c b/progs/trivial/long-fixed-func.c index 41ad25c1b3..f2a29a9d37 100644 --- a/progs/trivial/long-fixed-func.c +++ b/progs/trivial/long-fixed-func.c @@ -139,7 +139,7 @@ main(int argc, char **argv) glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); glutInitDisplayMode(type); - if (glutCreateWindow("tri-long-fixedfunc") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } glewInit(); diff --git a/progs/trivial/point-clip.c b/progs/trivial/point-clip.c index 7fec54e1db..6aaee0d1a5 100644 --- a/progs/trivial/point-clip.c +++ b/progs/trivial/point-clip.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/point-sprite.c b/progs/trivial/point-sprite.c index 583bdca1b7..2f8226ee27 100644 --- a/progs/trivial/point-sprite.c +++ b/progs/trivial/point-sprite.c @@ -160,7 +160,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/point-wide-smooth.c b/progs/trivial/point-wide-smooth.c index 55cbcaec70..63f83badf8 100644 --- a/progs/trivial/point-wide-smooth.c +++ b/progs/trivial/point-wide-smooth.c @@ -131,7 +131,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/point-wide.c b/progs/trivial/point-wide.c index 265b20097b..725edae49e 100644 --- a/progs/trivial/point-wide.c +++ b/progs/trivial/point-wide.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/point.c b/progs/trivial/point.c index 8dabfb6ca6..3c472c1b91 100644 --- a/progs/trivial/point.c +++ b/progs/trivial/point.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/poly-flat-clip.c b/progs/trivial/poly-flat-clip.c index 72c2a29a0d..d58a3a358f 100644 --- a/progs/trivial/poly-flat-clip.c +++ b/progs/trivial/poly-flat-clip.c @@ -126,7 +126,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/poly-flat-unfilled-clip.c b/progs/trivial/poly-flat-unfilled-clip.c index d3a14a516a..74249eb499 100644 --- a/progs/trivial/poly-flat-unfilled-clip.c +++ b/progs/trivial/poly-flat-unfilled-clip.c @@ -130,7 +130,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/poly-flat.c b/progs/trivial/poly-flat.c index a847d6828a..82098bc1bb 100644 --- a/progs/trivial/poly-flat.c +++ b/progs/trivial/poly-flat.c @@ -126,7 +126,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/poly-unfilled.c b/progs/trivial/poly-unfilled.c index ae092a830a..5cc8523f81 100644 --- a/progs/trivial/poly-unfilled.c +++ b/progs/trivial/poly-unfilled.c @@ -125,7 +125,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/poly.c b/progs/trivial/poly.c index 2f254de481..8944f148d0 100644 --- a/progs/trivial/poly.c +++ b/progs/trivial/poly.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-clip-all-vertices.c b/progs/trivial/quad-clip-all-vertices.c index 3e0f3d9494..6559adf4af 100644 --- a/progs/trivial/quad-clip-all-vertices.c +++ b/progs/trivial/quad-clip-all-vertices.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-clip-nearplane.c b/progs/trivial/quad-clip-nearplane.c index 1e8056c474..0e4f4c947c 100644 --- a/progs/trivial/quad-clip-nearplane.c +++ b/progs/trivial/quad-clip-nearplane.c @@ -137,7 +137,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-clip.c b/progs/trivial/quad-clip.c index 504fef3dc5..fd3522a89a 100644 --- a/progs/trivial/quad-clip.c +++ b/progs/trivial/quad-clip.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-degenerate.c b/progs/trivial/quad-degenerate.c index 8304740857..29fb2774de 100644 --- a/progs/trivial/quad-degenerate.c +++ b/progs/trivial/quad-degenerate.c @@ -129,7 +129,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-flat.c b/progs/trivial/quad-flat.c index bd8be7c43e..570eb6bc71 100644 --- a/progs/trivial/quad-flat.c +++ b/progs/trivial/quad-flat.c @@ -134,7 +134,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-offset-factor.c b/progs/trivial/quad-offset-factor.c index 90943d908f..2c4946a13a 100644 --- a/progs/trivial/quad-offset-factor.c +++ b/progs/trivial/quad-offset-factor.c @@ -142,7 +142,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-offset-unfilled.c b/progs/trivial/quad-offset-unfilled.c index 1ad44cdcae..40762825bd 100644 --- a/progs/trivial/quad-offset-unfilled.c +++ b/progs/trivial/quad-offset-unfilled.c @@ -155,7 +155,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-offset-units.c b/progs/trivial/quad-offset-units.c index d5db21469e..b4b138b4b4 100644 --- a/progs/trivial/quad-offset-units.c +++ b/progs/trivial/quad-offset-units.c @@ -143,7 +143,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-tex-2d.c b/progs/trivial/quad-tex-2d.c index 97c9fc54d8..ed6f4a0733 100644 --- a/progs/trivial/quad-tex-2d.c +++ b/progs/trivial/quad-tex-2d.c @@ -173,7 +173,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - win = glutCreateWindow("First Tri"); + win = glutCreateWindow(*argv); if (!win) { exit(1); } diff --git a/progs/trivial/quad-tex-3d.c b/progs/trivial/quad-tex-3d.c index ca7ea91d2f..84acb35fd8 100644 --- a/progs/trivial/quad-tex-3d.c +++ b/progs/trivial/quad-tex-3d.c @@ -164,7 +164,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-tex-alpha.c b/progs/trivial/quad-tex-alpha.c index cd73f013eb..be24255a3e 100644 --- a/progs/trivial/quad-tex-alpha.c +++ b/progs/trivial/quad-tex-alpha.c @@ -156,7 +156,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-tex-pbo.c b/progs/trivial/quad-tex-pbo.c index c6f60f51fa..dcb4ae0e7f 100644 --- a/progs/trivial/quad-tex-pbo.c +++ b/progs/trivial/quad-tex-pbo.c @@ -167,7 +167,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-tex-sub.c b/progs/trivial/quad-tex-sub.c new file mode 100644 index 0000000000..aabbb9edce --- /dev/null +++ b/progs/trivial/quad-tex-sub.c @@ -0,0 +1,203 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <GL/glew.h> +#include <GL/glut.h> + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + +#define SIZE 16 +GLenum doubleBuffer; +GLint line = 0; + +static void MakeImage() +{ + GLubyte tex2d[SIZE][SIZE][3]; + GLint s, t; + + for (s = 0; s < SIZE; s++) { + for (t = 0; t < SIZE; t++) { + tex2d[t][s][0] = s*255/(SIZE-1); + tex2d[t][s][1] = t*255/(SIZE-1); + tex2d[t][s][2] = 0*255/(SIZE-1); + } + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, + SIZE, SIZE, + 0, + GL_RGB, GL_UNSIGNED_BYTE, tex2d); + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glEnable(GL_TEXTURE_2D); +} + +static void UpdateLine() +{ + GLubyte tex[SIZE][3]; + GLubyte b = 0; + GLint s, t; + + t = line % SIZE; + if (line % (SIZE * 2) < SIZE) + b = 255; + else + b = 0; + + for (s = 0; s < SIZE; s++) { + tex[s][0] = s*255/(SIZE-1); + tex[s][1] = t*255/(SIZE-1); + tex[s][2] = b; + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexSubImage2D(GL_TEXTURE_2D, 0, + 0, t, + SIZE, 1, + GL_RGB, GL_UNSIGNED_BYTE, tex); + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); +} + +static void Init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + glClearColor(0.0, 0.0, 1.0, 0.0); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + MakeImage(); + UpdateLine(); + line++; +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + UpdateLine(); + line++; + break; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_QUADS); + glTexCoord2f(1,0); + glVertex3f( 0.9, -0.9, -30.0); + glTexCoord2f(1,1); + glVertex3f( 0.9, 0.9, -30.0); + glTexCoord2f(0,1); + glVertex3f(-0.9, 0.9, -30.0); + glTexCoord2f(0,0); + glVertex3f(-0.9, -0.9, -30.0); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); + glutInitWindowSize(250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow(*argv) == GL_FALSE) { + exit(1); + } + + glewInit(); + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/quad-unfilled-clip.c b/progs/trivial/quad-unfilled-clip.c index e298bd455b..e25a34bda8 100644 --- a/progs/trivial/quad-unfilled-clip.c +++ b/progs/trivial/quad-unfilled-clip.c @@ -125,7 +125,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-unfilled-stipple.c b/progs/trivial/quad-unfilled-stipple.c index 2036aacbaa..d33e5918bc 100644 --- a/progs/trivial/quad-unfilled-stipple.c +++ b/progs/trivial/quad-unfilled-stipple.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad-unfilled.c b/progs/trivial/quad-unfilled.c index 9d0087ce08..b60af3e7f5 100644 --- a/progs/trivial/quad-unfilled.c +++ b/progs/trivial/quad-unfilled.c @@ -125,7 +125,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quad.c b/progs/trivial/quad.c index 85424b7b38..c4773ec7da 100644 --- a/progs/trivial/quad.c +++ b/progs/trivial/quad.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quads.c b/progs/trivial/quads.c index 307a9e0720..5bc622144e 100644 --- a/progs/trivial/quads.c +++ b/progs/trivial/quads.c @@ -142,7 +142,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quadstrip-clip.c b/progs/trivial/quadstrip-clip.c new file mode 100644 index 0000000000..82a6d4e076 --- /dev/null +++ b/progs/trivial/quadstrip-clip.c @@ -0,0 +1,137 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <GL/glut.h> + +GLenum doubleBuffer; + +static void Init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + glClearColor(0.0, 0.0, 1.0, 0.0); +} + +static void Reshape(int width, int height) +{ + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_QUAD_STRIP); + glColor3f(1,1,1); + glVertex3f( 1.9, -0.9, -30.0); + glVertex3f( 0.9, 0.9, -30.0); + + glColor3f(1,0,0); + glVertex3f( 0.1, -0.8, -30.0); + glVertex3f( 0.1, 0.8, -30.0); + + glColor3f(0,1,0); + glVertex3f(-0.1, -0.9, -30.0); + glVertex3f(-0.1, 0.9, -30.0); + + glColor3f(0,0,0); + glVertex3f(-0.9, -0.8, -30.0); + glVertex3f(-0.9, 0.8, -30.0); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow(*argv) == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/quadstrip-cont.c b/progs/trivial/quadstrip-cont.c index c6c8f69f8c..62208dfae7 100644 --- a/progs/trivial/quadstrip-cont.c +++ b/progs/trivial/quadstrip-cont.c @@ -147,7 +147,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quadstrip-flat.c b/progs/trivial/quadstrip-flat.c index d02135f702..9011ee0873 100644 --- a/progs/trivial/quadstrip-flat.c +++ b/progs/trivial/quadstrip-flat.c @@ -136,7 +136,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/quadstrip.c b/progs/trivial/quadstrip.c index ff8644be09..6923afc04b 100644 --- a/progs/trivial/quadstrip.c +++ b/progs/trivial/quadstrip.c @@ -130,7 +130,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-alpha-tex.c b/progs/trivial/tri-alpha-tex.c index 776f39dcc3..382d7b2102 100644 --- a/progs/trivial/tri-alpha-tex.c +++ b/progs/trivial/tri-alpha-tex.c @@ -165,7 +165,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-alpha.c b/progs/trivial/tri-alpha.c index 90cfdbe199..1a653713bb 100644 --- a/progs/trivial/tri-alpha.c +++ b/progs/trivial/tri-alpha.c @@ -127,7 +127,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-blend-color.c b/progs/trivial/tri-blend-color.c index d2d72d0b62..db831e3d6e 100644 --- a/progs/trivial/tri-blend-color.c +++ b/progs/trivial/tri-blend-color.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-clear.c b/progs/trivial/tri-clear.c index 25ea77cfa7..a3908e38e9 100644 --- a/progs/trivial/tri-clear.c +++ b/progs/trivial/tri-clear.c @@ -129,7 +129,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-clip.c b/progs/trivial/tri-clip.c index f30445cdba..0d31086c85 100644 --- a/progs/trivial/tri-clip.c +++ b/progs/trivial/tri-clip.c @@ -143,7 +143,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-cull-both.c b/progs/trivial/tri-cull-both.c index 51b5865ae5..73c5583cfd 100644 --- a/progs/trivial/tri-cull-both.c +++ b/progs/trivial/tri-cull-both.c @@ -127,7 +127,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-cull.c b/progs/trivial/tri-cull.c index 2eead84115..c6bcf444e4 100644 --- a/progs/trivial/tri-cull.c +++ b/progs/trivial/tri-cull.c @@ -158,7 +158,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-dlist.c b/progs/trivial/tri-dlist.c index c21c4714ad..1c0e320f61 100644 --- a/progs/trivial/tri-dlist.c +++ b/progs/trivial/tri-dlist.c @@ -136,7 +136,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-edgeflag.c b/progs/trivial/tri-edgeflag.c index 41899c2eb4..e1278dd649 100644 --- a/progs/trivial/tri-edgeflag.c +++ b/progs/trivial/tri-edgeflag.c @@ -123,7 +123,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-fbo-tex-mip.c b/progs/trivial/tri-fbo-tex-mip.c new file mode 100644 index 0000000000..0744369501 --- /dev/null +++ b/progs/trivial/tri-fbo-tex-mip.c @@ -0,0 +1,261 @@ +/* Framebuffer object test */ + + +#include <GL/glew.h> +#include <GL/glut.h> +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + +/* For debug */ + + +static int Win = 0; +static int Width = 512, Height = 512; + +static GLenum TexTarget = GL_TEXTURE_2D; +static int TexWidth = 512, TexHeight = 512; + +static GLuint MyFB; +static GLuint TexObj; +static GLboolean Anim = GL_FALSE; +static GLfloat Rot = 0.0; +static GLuint TextureLevel = 4; /* which texture level to render to */ +static GLenum TexIntFormat = GL_RGB; /* either GL_RGB or GL_RGBA */ + + +static void +CheckError(int line) +{ + GLenum err = glGetError(); + if (err) { + printf("GL Error 0x%x at line %d\n", (int) err, line); + } +} + + +static void +Idle(void) +{ + Rot = glutGet(GLUT_ELAPSED_TIME) * 0.1; + glutPostRedisplay(); +} + + +static void +RenderTexture(void) +{ + GLenum status; + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); + + if (1) { + /* draw to texture image */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + + status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { + printf("Framebuffer incomplete!!!\n"); + } + + glViewport(0, 0, + TexWidth / (1 << TextureLevel), + TexHeight / (1 << TextureLevel)); + glClearColor(0.5, 0.5, 1.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + CheckError(__LINE__); + + glBegin(GL_POLYGON); + glColor3f(1, 0, 0); + glVertex2f(-1, -1); + glColor3f(0, 1, 0); + glVertex2f(1, -1); + glColor3f(0, 0, 1); + glVertex2f(0, 1); + glEnd(); + + /* Bind normal framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + } + else { + } + + CheckError(__LINE__); +} + + + +static void +Display(void) +{ + float ar = (float) Width / (float) Height; + + RenderTexture(); + + /* draw textured quad in the window */ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-ar, ar, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -7.0); + + glViewport(0, 0, Width, Height); + + glClearColor(0.25, 0.25, 0.25, 0); + glClear(GL_COLOR_BUFFER_BIT); + + glPushMatrix(); + glRotatef(Rot, 0, 1, 0); + glEnable(TexTarget); + glBindTexture(TexTarget, TexObj); + + { + glBegin(GL_POLYGON); + glColor3f(0.25, 0.25, 0.25); + glTexCoord2f(0, 0); + glVertex2f(-1, -1); + glTexCoord2f(1, 0); + glVertex2f(1, -1); + glColor3f(1.0, 1.0, 1.0); + glTexCoord2f(1, 1); + glVertex2f(1, 1); + glTexCoord2f(0, 1); + glVertex2f(-1, 1); + glEnd(); + } + + glPopMatrix(); + glDisable(TexTarget); + + glutSwapBuffers(); + CheckError(__LINE__); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + Width = width; + Height = height; +} + + +static void +CleanUp(void) +{ + glDeleteFramebuffersEXT(1, &MyFB); + + glDeleteTextures(1, &TexObj); + + glutDestroyWindow(Win); + + exit(0); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 's': + Rot += 2.0; + break; + case 27: + CleanUp(); + break; + } + glutPostRedisplay(); +} + + +static void +Init(int argc, char *argv[]) +{ + if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { + printf("GL_EXT_framebuffer_object not found!\n"); + exit(0); + } + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + + /* Make texture object/image */ + glGenTextures(1, &TexObj); + glBindTexture(TexTarget, TexObj); + 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); + + glTexImage2D(TexTarget, 0, TexIntFormat, TexWidth, TexHeight, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(TexTarget, TextureLevel, TexIntFormat, + TexWidth / (1 << TextureLevel), TexHeight / (1 << TextureLevel), 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + + + + /* gen framebuffer id, delete it, do some assertions, just for testing */ + glGenFramebuffersEXT(1, &MyFB); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + assert(glIsFramebufferEXT(MyFB)); + + + CheckError(__LINE__); + + /* Render color to texture */ + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + TexTarget, TexObj, TextureLevel); + + + + CheckError(__LINE__); + + /* bind regular framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + + +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(Width, Height); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); + Win = glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Display); + if (Anim) + glutIdleFunc(Idle); + Init(argc, argv); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-fbo-tex.c b/progs/trivial/tri-fbo-tex.c index 253f9310db..72b4cf3683 100644 --- a/progs/trivial/tri-fbo-tex.c +++ b/progs/trivial/tri-fbo-tex.c @@ -1,12 +1,4 @@ -/* - * Test GL_EXT_framebuffer_object render-to-texture - * - * Draw a teapot into a texture image with stenciling. - * Then draw a textured quad using that texture. - * - * Brian Paul - * 18 Apr 2005 - */ +/* Framebuffer object test */ #include <GL/glew.h> diff --git a/progs/trivial/tri-flat-clip.c b/progs/trivial/tri-flat-clip.c index 155b0c4f8d..3235100385 100644 --- a/progs/trivial/tri-flat-clip.c +++ b/progs/trivial/tri-flat-clip.c @@ -123,7 +123,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-flat.c b/progs/trivial/tri-flat.c index 0583a2a99a..a7fdaa1f46 100644 --- a/progs/trivial/tri-flat.c +++ b/progs/trivial/tri-flat.c @@ -123,7 +123,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-fog.c b/progs/trivial/tri-fog.c index 75f3262ecf..0099a90ad6 100644 --- a/progs/trivial/tri-fog.c +++ b/progs/trivial/tri-fog.c @@ -42,6 +42,15 @@ static void Init(void) fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); glClearColor(0.0, 0.0, 1.0, 0.0); + + glEnable(GL_FOG); + glFogi(GL_FOG_MODE, GL_LINEAR); + glFogf(GL_FOG_START, 25); + glFogf(GL_FOG_END, 35); +#if 0 + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable (GL_BLEND); +#endif } static void Reshape(int width, int height) @@ -70,26 +79,26 @@ static void Key(unsigned char key, int x, int y) static void Draw(void) { - glClear(GL_COLOR_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_FOG); glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); + glColor3f(1,1,1); glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); + glColor3f(1,1,1); glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); + glColor3f(1,1,1); + glVertex3f(-0.9, 0.0, -40.0); glEnd(); #if 0 glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); + glColor3f(0,0,.7); glVertex3f(-0.9, -0.9, -30.0); - glColor3f(.8,0,0); + glColor3f(.8,0,0); glVertex3f(-0.9, 0.9, -30.0); - glColor3f(0,.9,0); + glColor3f(0,.9,0); glVertex3f( 0.9, 0.0, -30.0); glEnd(); #endif @@ -138,7 +147,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-fp-const-imm.c b/progs/trivial/tri-fp-const-imm.c index 9e2c63a22a..2b1499903c 100644 --- a/progs/trivial/tri-fp-const-imm.c +++ b/progs/trivial/tri-fp-const-imm.c @@ -155,7 +155,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-fp.c b/progs/trivial/tri-fp.c index fcf57f5a85..b30f9b73e0 100644 --- a/progs/trivial/tri-fp.c +++ b/progs/trivial/tri-fp.c @@ -153,7 +153,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-lit.c b/progs/trivial/tri-lit.c index 22f199c982..91fac1a598 100644 --- a/progs/trivial/tri-lit.c +++ b/progs/trivial/tri-lit.c @@ -125,7 +125,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-logicop-none.c b/progs/trivial/tri-logicop-none.c new file mode 100644 index 0000000000..aba3614bf6 --- /dev/null +++ b/progs/trivial/tri-logicop-none.c @@ -0,0 +1,178 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <GL/glut.h> + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer = 1; +int win; + +static void Init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + glClearColor(0.3, 0.1, 0.3, 0.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + default: + glutPostRedisplay(); + return; + } +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(.8,0,0); + glVertex3f(-0.9, -0.9, -30.0); + glColor3f(0,.9,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(0,0,.7); + glVertex3f( 0.0, 0.9, -30.0); + glEnd(); + + + glLineWidth(4.0); + + glBegin(GL_LINES); + glColor3f(.1,.7,.1); + glVertex3f( 0.5, -0.5, -30.0); + glVertex3f( 0.5, 0.5, -30.0); + + glColor3f(.1,.1,.8); + glVertex3f( 0.5, 0.5, -30.0); + glVertex3f(-0.5, 0.5, -30.0); + + glColor3f(.5,.1,.1); + glVertex3f(-0.5, 0.5, -30.0); + glVertex3f(-0.5, -0.5, -30.0); + + glColor3f(.8,.8,.8); + glVertex3f(-0.5, -0.5, -30.0); + glVertex3f( 0.5, -0.5, -30.0); + glEnd(); + +// glLineWidth(12.0); + + /* Redraw parts of the lines: + */ + glBegin(GL_LINES); + glColor3f(.1,.7,.1); + glVertex3f( 0.5, -0.2, -30.0); + glVertex3f( 0.5, 0.2, -30.0); + + glColor3f(.1,.1,.8); + glVertex3f( 0.2, 0.5, -30.0); + glVertex3f(-0.2, 0.5, -30.0); + + glColor3f(.5,.1,.1); + glVertex3f(-0.5, 0.2, -30.0); + glVertex3f(-0.5, -0.2, -30.0); + + glColor3f(.8,.8,.8); + glVertex3f(-0.2, -0.5, -30.0); + glVertex3f( 0.2, -0.5, -30.0); + glEnd(); + + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + win = glutCreateWindow(*argv); + if (!win) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-logicop-xor.c b/progs/trivial/tri-logicop-xor.c new file mode 100644 index 0000000000..e2c94f9bee --- /dev/null +++ b/progs/trivial/tri-logicop-xor.c @@ -0,0 +1,186 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <GL/glut.h> + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer = 1; +int win; + +static void Init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + glClearColor(0.3, 0.1, 0.3, 0.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + default: + glutPostRedisplay(); + return; + } +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(.8,0,0); + glVertex3f(-0.9, -0.9, -30.0); + glColor3f(0,.9,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(0,0,.7); + glVertex3f( 0.0, 0.9, -30.0); + glEnd(); + + + glLineWidth(4.0); + + glEnable(GL_BLEND); + glEnable(GL_COLOR_LOGIC_OP); + glLogicOp(GL_XOR); + + glBegin(GL_LINES); + glColor3f(.1,.7,.1); + glVertex3f( 0.5, -0.5, -30.0); + glVertex3f( 0.5, 0.5, -30.0); + + glColor3f(.1,.1,.8); + glVertex3f( 0.5, 0.5, -30.0); + glVertex3f(-0.5, 0.5, -30.0); + + glColor3f(.5,.1,.1); + glVertex3f(-0.5, 0.5, -30.0); + glVertex3f(-0.5, -0.5, -30.0); + + glColor3f(.8,.8,.8); + glVertex3f(-0.5, -0.5, -30.0); + glVertex3f( 0.5, -0.5, -30.0); + glEnd(); + +// glLineWidth(12.0); + + /* Redraw parts of the lines to remove them: + */ + glBegin(GL_LINES); + glColor3f(.1,.7,.1); + glVertex3f( 0.5, -0.2, -30.0); + glVertex3f( 0.5, 0.2, -30.0); + + glColor3f(.1,.1,.8); + glVertex3f( 0.2, 0.5, -30.0); + glVertex3f(-0.2, 0.5, -30.0); + + glColor3f(.5,.1,.1); + glVertex3f(-0.5, 0.2, -30.0); + glVertex3f(-0.5, -0.2, -30.0); + + glColor3f(.8,.8,.8); + glVertex3f(-0.2, -0.5, -30.0); + glVertex3f( 0.2, -0.5, -30.0); + glEnd(); + + + + glDisable(GL_COLOR_LOGIC_OP); + glDisable(GL_BLEND); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + win = glutCreateWindow(*argv); + if (!win) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-mask-tri.c b/progs/trivial/tri-mask-tri.c index 8333f7ed8a..449125a4db 100644 --- a/progs/trivial/tri-mask-tri.c +++ b/progs/trivial/tri-mask-tri.c @@ -143,7 +143,7 @@ int main(int argc, char **argv) glutInitWindowPosition(100, 0); glutInitWindowSize(Width, Height); glutInitDisplayMode(type); - Win = glutCreateWindow("First Tri"); + Win = glutCreateWindow(*argv); Init(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); diff --git a/progs/trivial/tri-orig.c b/progs/trivial/tri-orig.c index d5e6742ce1..6861ff6e49 100644 --- a/progs/trivial/tri-orig.c +++ b/progs/trivial/tri-orig.c @@ -122,7 +122,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-query.c b/progs/trivial/tri-query.c index 25cfcb8e14..9b319ba2a7 100644 --- a/progs/trivial/tri-query.c +++ b/progs/trivial/tri-query.c @@ -144,7 +144,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-repeat.c b/progs/trivial/tri-repeat.c index e894269e84..a271fab54c 100644 --- a/progs/trivial/tri-repeat.c +++ b/progs/trivial/tri-repeat.c @@ -104,7 +104,7 @@ int main(int argc, char **argv) type |= GLUT_DOUBLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-scissor-tri.c b/progs/trivial/tri-scissor-tri.c index dcc6d282dc..2b5536ecd6 100644 --- a/progs/trivial/tri-scissor-tri.c +++ b/progs/trivial/tri-scissor-tri.c @@ -137,7 +137,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-square.c b/progs/trivial/tri-square.c index ef9ea63048..9102888abd 100644 --- a/progs/trivial/tri-square.c +++ b/progs/trivial/tri-square.c @@ -122,7 +122,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-stencil.c b/progs/trivial/tri-stencil.c index 7686e16aef..9f68bca914 100644 --- a/progs/trivial/tri-stencil.c +++ b/progs/trivial/tri-stencil.c @@ -144,7 +144,7 @@ int main(int argc, char **argv) type = GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH | GLUT_STENCIL; glutInitDisplayMode(type); - if (glutCreateWindow("Stencil Test") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-stipple.c b/progs/trivial/tri-stipple.c index 887de550e2..33e6dd16a7 100644 --- a/progs/trivial/tri-stipple.c +++ b/progs/trivial/tri-stipple.c @@ -137,7 +137,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-tex-3d.c b/progs/trivial/tri-tex-3d.c index 50f6a75418..4f276af653 100644 --- a/progs/trivial/tri-tex-3d.c +++ b/progs/trivial/tri-tex-3d.c @@ -157,7 +157,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-tex.c b/progs/trivial/tri-tex.c index a0d75b4a33..1dbbe6aa58 100644 --- a/progs/trivial/tri-tex.c +++ b/progs/trivial/tri-tex.c @@ -154,7 +154,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-tri.c b/progs/trivial/tri-tri.c index 06a0528eb8..8b0c2dafef 100644 --- a/progs/trivial/tri-tri.c +++ b/progs/trivial/tri-tri.c @@ -131,7 +131,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-unfilled-clip.c b/progs/trivial/tri-unfilled-clip.c index df161df3fb..438899dc1a 100644 --- a/progs/trivial/tri-unfilled-clip.c +++ b/progs/trivial/tri-unfilled-clip.c @@ -123,7 +123,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-unfilled-edgeflag.c b/progs/trivial/tri-unfilled-edgeflag.c index 31f41f6220..78c5ae8e9c 100644 --- a/progs/trivial/tri-unfilled-edgeflag.c +++ b/progs/trivial/tri-unfilled-edgeflag.c @@ -127,7 +127,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-unfilled-fog.c b/progs/trivial/tri-unfilled-fog.c new file mode 100644 index 0000000000..113b8d051d --- /dev/null +++ b/progs/trivial/tri-unfilled-fog.c @@ -0,0 +1,152 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <GL/glut.h> + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + +GLint Width = 250, Height = 250; + +GLenum doubleBuffer; + +static void Init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + glClearColor(0.0, 0.0, 1.0, 0.0); +} + +static void Reshape(int width, int height) +{ + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(1); + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_FOG); + + glPolygonMode(GL_FRONT, GL_FILL); + glPolygonMode(GL_BACK, GL_FILL); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.7, -0.7, -30.0); + glColor3f(.8,0,0); + glVertex3f( 0.7, 0.7, -30.0); + glColor3f(0,.9,0); + glVertex3f(-0.7, 0.0, -30.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_LINE); + glPolygonMode(GL_BACK, GL_LINE); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glDisable(GL_FOG); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(100, 0); glutInitWindowSize(Width, Height); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow(*argv) == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-unfilled-point.c b/progs/trivial/tri-unfilled-point.c index 71ac453d60..b050280155 100644 --- a/progs/trivial/tri-unfilled-point.c +++ b/progs/trivial/tri-unfilled-point.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-unfilled-smooth.c b/progs/trivial/tri-unfilled-smooth.c index f70c1cd9d4..9306af849a 100644 --- a/progs/trivial/tri-unfilled-smooth.c +++ b/progs/trivial/tri-unfilled-smooth.c @@ -136,7 +136,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-unfilled-tri-lit.c b/progs/trivial/tri-unfilled-tri-lit.c index f9e1d00988..775c3530b7 100644 --- a/progs/trivial/tri-unfilled-tri-lit.c +++ b/progs/trivial/tri-unfilled-tri-lit.c @@ -164,7 +164,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-unfilled-tri.c b/progs/trivial/tri-unfilled-tri.c index d9a9faeb9f..ce789255fd 100644 --- a/progs/trivial/tri-unfilled-tri.c +++ b/progs/trivial/tri-unfilled-tri.c @@ -161,7 +161,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-unfilled-userclip-stip.c b/progs/trivial/tri-unfilled-userclip-stip.c index 4aefa85032..6835b53c0f 100644 --- a/progs/trivial/tri-unfilled-userclip-stip.c +++ b/progs/trivial/tri-unfilled-userclip-stip.c @@ -133,7 +133,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-unfilled-userclip.c b/progs/trivial/tri-unfilled-userclip.c index 9201f9d433..aab5abc230 100644 --- a/progs/trivial/tri-unfilled-userclip.c +++ b/progs/trivial/tri-unfilled-userclip.c @@ -127,7 +127,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-unfilled.c b/progs/trivial/tri-unfilled.c index 1e44823db5..4f50d083c2 100644 --- a/progs/trivial/tri-unfilled.c +++ b/progs/trivial/tri-unfilled.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-userclip.c b/progs/trivial/tri-userclip.c index ccf631dff8..43d19cebab 100644 --- a/progs/trivial/tri-userclip.c +++ b/progs/trivial/tri-userclip.c @@ -126,7 +126,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-viewport.c b/progs/trivial/tri-viewport.c new file mode 100644 index 0000000000..3205b9ee9c --- /dev/null +++ b/progs/trivial/tri-viewport.c @@ -0,0 +1,129 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "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 BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <GL/glut.h> + +GLenum doubleBuffer = 1; +int win; + +static void Init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + glClearColor(0.3, 0.1, 0.3, 0.0); +} + +static void Reshape(int width, int height) +{ + glViewport(width / -2.0, height / -2.0, width, height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +static void Key(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + default: + glutPostRedisplay(); + return; + } +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(.8,0,0); + glVertex3f(-0.9, 0.9, -30.0); + glColor3f(0,.9,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,0,.7); + glVertex3f( 0.0, -0.9, -30.0); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + win = glutCreateWindow(*argv); + if (!win) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-z-9.c b/progs/trivial/tri-z-9.c index 4bd9986166..e7d4184bdb 100644 --- a/progs/trivial/tri-z-9.c +++ b/progs/trivial/tri-z-9.c @@ -125,7 +125,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri-z-eq.c b/progs/trivial/tri-z-eq.c index ad5f31a558..4ec55ac080 100644 --- a/progs/trivial/tri-z-eq.c +++ b/progs/trivial/tri-z-eq.c @@ -125,7 +125,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tri.c b/progs/trivial/tri.c index d3c6b59ea5..d99d5872a9 100644 --- a/progs/trivial/tri.c +++ b/progs/trivial/tri.c @@ -41,28 +41,28 @@ static void Init(void) fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); - glClearColor(0.3, 0.1, 0.3, 0.0); + glClearColor(0.3, 0.1, 0.3, 0.0); } static void Reshape(int width, int height) { - glViewport(0, 0, (GLint)width, (GLint)height); + glViewport(0, 0, (GLint)width, (GLint)height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); - glMatrixMode(GL_MODELVIEW); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); } static void Key(unsigned char key, int x, int y) { switch (key) { - case 27: - exit(0); - default: - glutPostRedisplay(); - return; + case 27: + exit(0); + default: + glutPostRedisplay(); + return; } } @@ -88,47 +88,47 @@ static void Draw(void) static GLenum Args(int argc, char **argv) { - GLint i; - - for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "-sb") == 0) { - doubleBuffer = GL_FALSE; - } else if (strcmp(argv[i], "-db") == 0) { - doubleBuffer = GL_TRUE; - } else { - fprintf(stderr, "%s (Bad option).\n", argv[i]); - return GL_FALSE; - } - } - return GL_TRUE; + GLint i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; } int main(int argc, char **argv) { - GLenum type; + GLenum type; - glutInit(&argc, argv); + glutInit(&argc, argv); - if (Args(argc, argv) == GL_FALSE) { - exit(1); - } + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } - glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); - type = GLUT_RGB | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); - win = glutCreateWindow("First Tri"); - if (!win) { - exit(1); - } + win = glutCreateWindow(*argv); + if (!win) { + exit(1); + } - Init(); + Init(); - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; } diff --git a/progs/trivial/trifan-flat-clip.c b/progs/trivial/trifan-flat-clip.c index 04042fac70..ec7a50a75e 100644 --- a/progs/trivial/trifan-flat-clip.c +++ b/progs/trivial/trifan-flat-clip.c @@ -126,7 +126,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/trifan-flat-unfilled-clip.c b/progs/trivial/trifan-flat-unfilled-clip.c index 25224412cc..4887b5a30c 100644 --- a/progs/trivial/trifan-flat-unfilled-clip.c +++ b/progs/trivial/trifan-flat-unfilled-clip.c @@ -130,7 +130,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/trifan-flat.c b/progs/trivial/trifan-flat.c index 737eccdcae..cf75d4cf08 100644 --- a/progs/trivial/trifan-flat.c +++ b/progs/trivial/trifan-flat.c @@ -126,7 +126,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/trifan-unfilled.c b/progs/trivial/trifan-unfilled.c index 8e7454108c..491fe5b3df 100644 --- a/progs/trivial/trifan-unfilled.c +++ b/progs/trivial/trifan-unfilled.c @@ -125,7 +125,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/trifan.c b/progs/trivial/trifan.c index ecb0424393..ee9854dc94 100644 --- a/progs/trivial/trifan.c +++ b/progs/trivial/trifan.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tristrip-clip.c b/progs/trivial/tristrip-clip.c index f95c66a62a..eeab676ea9 100644 --- a/progs/trivial/tristrip-clip.c +++ b/progs/trivial/tristrip-clip.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tristrip-flat.c b/progs/trivial/tristrip-flat.c index e048233e67..49bb432b9d 100644 --- a/progs/trivial/tristrip-flat.c +++ b/progs/trivial/tristrip-flat.c @@ -134,7 +134,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/tristrip.c b/progs/trivial/tristrip.c index 51ea4f2325..023e6475c0 100644 --- a/progs/trivial/tristrip.c +++ b/progs/trivial/tristrip.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/vp-tri-cb-pos.c b/progs/trivial/vp-tri-cb-pos.c index 430a4d3964..42bf9806b1 100644 --- a/progs/trivial/vp-tri-cb-pos.c +++ b/progs/trivial/vp-tri-cb-pos.c @@ -142,7 +142,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } diff --git a/progs/trivial/vp-tri-cb-tex.c b/progs/trivial/vp-tri-cb-tex.c index 57fd2cdbbd..8290226675 100644 --- a/progs/trivial/vp-tri-cb-tex.c +++ b/progs/trivial/vp-tri-cb-tex.c @@ -175,7 +175,7 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + if (glutCreateWindow(*argv) == GL_FALSE) { exit(1); } |