From 3c0790ca9254e20e273f4f3023750b456260a499 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 20 Jun 2007 17:19:13 -0600 Subject: triangles w/ depth test --- progs/trivial/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 341c115c07d..e1ce6b5a1ed 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -63,6 +63,7 @@ SOURCES = \ tri-unfilled.c \ tri-userclip.c \ tri-dlist.c \ + tri-z.c \ tri.c \ tristrip-clip.c \ tristrip.c \ -- cgit v1.2.3 From 9110dbd9b2b598183815ed113dd690051d42e5f0 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 24 Jul 2007 10:00:29 -0600 Subject: simple fragment shader test --- progs/trivial/Makefile | 6 ++ progs/trivial/fs-tri.c | 207 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 213 insertions(+) create mode 100644 progs/trivial/fs-tri.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index e1ce6b5a1ed..2edf0ae0084 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -12,6 +12,7 @@ LIBS = $(APP_LIB_DEPS) SOURCES = \ clear.c \ + fs-tri.c \ line-clip.c \ line-cull.c \ line-userclip-clip.c \ @@ -138,6 +139,11 @@ readtex.c: $(TOP)/progs/util/readtex.c ln -s $(TOP)/progs/util/readtex.c . +fs-tri: fs-tri.c extfuncs.h + + +extfuncs.h: $(TOP)/progs/util/extfuncs.h + cp $< . # Emacs tags diff --git a/progs/trivial/fs-tri.c b/progs/trivial/fs-tri.c new file mode 100644 index 00000000000..ecb13fd56d5 --- /dev/null +++ b/progs/trivial/fs-tri.c @@ -0,0 +1,207 @@ +/* Test fragment shader */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "extfuncs.h" + + +static GLuint fragShader; +static GLuint vertShader; +static GLuint program; +static GLint win = 0; +static GLfloat xpos = 0, ypos = 0; + + +static void +Redisplay(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glTranslatef(xpos, ypos, 0); + + glBegin(GL_TRIANGLES); + glVertex2f(-0.9, -0.9); + glVertex2f( 0.9, -0.9); + glVertex2f( 0, 0.9); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1, 1, -1, 1, -1, 1); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + +static void +CleanUp(void) +{ + glDeleteShader_func(fragShader); + glDeleteShader_func(vertShader); + glDeleteProgram_func(program); + glutDestroyWindow(win); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + + switch(key) { + case 27: + CleanUp(); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +SpecialKey(int key, int x, int y) +{ + const GLfloat step = 0.1; + + (void) x; + (void) y; + + switch(key) { + case GLUT_KEY_UP: + ypos += step; + break; + case GLUT_KEY_DOWN: + ypos -= step; + break; + case GLUT_KEY_LEFT: + xpos -= step; + break; + case GLUT_KEY_RIGHT: + xpos += step; + break; + } + glutPostRedisplay(); +} + + +static void +LoadAndCompileShader(GLuint shader, const char *text) +{ + GLint stat; + + glShaderSource_func(shader, 1, (const GLchar **) &text, NULL); + + glCompileShader_func(shader); + + glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat); + if (!stat) { + GLchar log[1000]; + GLsizei len; + glGetShaderInfoLog_func(shader, 1000, &len, log); + fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log); + exit(1); + } +} + + +static void +CheckLink(GLuint prog) +{ + GLint stat; + glGetProgramiv_func(prog, GL_LINK_STATUS, &stat); + if (!stat) { + GLchar log[1000]; + GLsizei len; + glGetProgramInfoLog_func(prog, 1000, &len, log); + fprintf(stderr, "Linker error:\n%s\n", log); + } +} + + +static void +Init(void) +{ + /* fragment color is a function of fragment position: */ + static const char *fragShaderText = + "void main() {\n" + " gl_FragColor = gl_FragCoord * vec4(0.005); \n" + "}\n"; +#if 0 + static const char *vertShaderText = + "varying vec3 normal;\n" + "void main() {\n" + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + " normal = gl_NormalMatrix * gl_Normal;\n" + "}\n"; +#endif + const char *version; + + version = (const char *) glGetString(GL_VERSION); + if (version[0] != '2' || version[1] != '.') { + printf("This program requires OpenGL 2.x, found %s\n", version); + exit(1); + } + + GetExtensionFuncs(); + + fragShader = glCreateShader_func(GL_FRAGMENT_SHADER); + LoadAndCompileShader(fragShader, fragShaderText); + +#if 0 + vertShader = glCreateShader_func(GL_VERTEX_SHADER); + LoadAndCompileShader(vertShader, vertShaderText); +#endif + + program = glCreateProgram_func(); + glAttachShader_func(program, fragShader); +#if 0 + glAttachShader_func(program, vertShader); +#endif + glLinkProgram_func(program); + CheckLink(program); + glUseProgram_func(program); + + assert(glGetError() == 0); + + glClearColor(0.3f, 0.3f, 0.3f, 0.0f); + + printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition( 0, 0); + glutInitWindowSize(200, 200); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + win = glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(Redisplay); + Init(); + glutMainLoop(); + return 0; +} + + -- cgit v1.2.3 From bf64be22686a8e5168bf80d1a57e367da3fffd57 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 2 Aug 2007 12:14:16 -0600 Subject: added clear-scissor.c --- progs/trivial/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 2edf0ae0084..80f2b752cd8 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -12,6 +12,7 @@ LIBS = $(APP_LIB_DEPS) SOURCES = \ clear.c \ + clear-scissor.c \ fs-tri.c \ line-clip.c \ line-cull.c \ -- cgit v1.2.3 From 34d535ad2c9ea06c61c6c0e3755ad8177aa30147 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 10 Aug 2007 13:06:07 -0600 Subject: glRead/DrawPixels test --- progs/trivial/Makefile | 1 + progs/trivial/readpixels.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 progs/trivial/readpixels.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 80f2b752cd8..82769e817a7 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -46,6 +46,7 @@ SOURCES = \ quads.c \ quadstrip.c \ quadstrip-flat.c \ + readpixels.c \ dlist-edgeflag.c \ dlist-dangling.c \ dlist-edgeflag-dangling.c \ diff --git a/progs/trivial/readpixels.c b/progs/trivial/readpixels.c new file mode 100644 index 00000000000..b1f04f81d97 --- /dev/null +++ b/progs/trivial/readpixels.c @@ -0,0 +1,88 @@ +/* + * glRead/DrawPixels test + */ + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include + +static int Width = 250, Height = 250; + +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) +{ + Width = width / 2; + Height = height; + /* draw on left half (we'll read that area) */ + 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); +} + +static void Key(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + default: + return; + } + glutPostRedisplay(); +} + +static void Draw(void) +{ + GLfloat *image = (GLfloat *) malloc(Width * Height * 4 * sizeof(GLfloat)); + + 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(); + + glReadPixels(0, 0, Width, Height, GL_RGBA, GL_FLOAT, image); + printf("Pixel(0,0) = %f, %f, %f, %f\n", + image[0], image[1], image[2], image[3]); + /* draw to right half of window */ + glWindowPos2iARB(Width, 0); + glDrawPixels(Width, Height, GL_RGBA, GL_FLOAT, image); + free(image); + + glutSwapBuffers(); +} + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(Width*2, Height); + glutInitDisplayMode(GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE); + if (glutCreateWindow(argv[0]) == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From f726ffd060a80519cfef63ee2ec3381480802bcc Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 30 Aug 2007 14:43:59 -0600 Subject: test flat shading w/ clipping --- progs/trivial/Makefile | 1 + progs/trivial/flat-clip.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 progs/trivial/flat-clip.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 82769e817a7..d9b200aef2f 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -13,6 +13,7 @@ LIBS = $(APP_LIB_DEPS) SOURCES = \ clear.c \ clear-scissor.c \ + flat-clip.c \ fs-tri.c \ line-clip.c \ line-cull.c \ diff --git a/progs/trivial/flat-clip.c b/progs/trivial/flat-clip.c new file mode 100644 index 00000000000..3e073aca54d --- /dev/null +++ b/progs/trivial/flat-clip.c @@ -0,0 +1,149 @@ +/** + * Test flat shading and clipping. + * + * Brian Paul + * 30 August 2007 + */ + + +#include +#include +#include +#include + +static int Win; +static GLfloat Scale = 2.0, Zrot = 50; +static GLenum Mode = GL_LINE_LOOP; +static GLboolean Smooth = 0; +static GLenum PolygonMode = GL_FILL; + + +static void +Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + if (Smooth) + glShadeModel(GL_SMOOTH); + else + glShadeModel(GL_FLAT); + + glPushMatrix(); + glScalef(Scale, Scale, 1); + glRotatef(Zrot, 0, 0, 1); + + glPolygonMode(GL_FRONT_AND_BACK, PolygonMode); + + glBegin(Mode); + glColor3f(1, 0, 0); + glVertex2f(-1, -1); + glColor3f(0, 1, 0); + glVertex2f( 2, -1); + glColor3f(0, 0, 1); + glVertex2f( 0, 1); + glEnd(); + + glPushMatrix(); + glScalef(0.9, 0.9, 1); + glBegin(Mode); + glColor3f(1, 0, 0); + glVertex2f( 0, 1); + + glColor3f(0, 0, 1); + glVertex2f( 2, -1); + + glColor3f(0, 1, 0); + glVertex2f(-1, -1); + + glEnd(); + glPopMatrix(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 'p': + if (Mode == GL_TRIANGLES) + Mode = GL_LINE_LOOP; + else + Mode = GL_TRIANGLES; + break; + case 'f': + if (PolygonMode == GL_POINT) + PolygonMode = GL_LINE; + else if (PolygonMode == GL_LINE) + PolygonMode = GL_FILL; + else + PolygonMode = GL_POINT; + printf("PolygonMode = 0x%x\n", PolygonMode); + break; + case 'r': + Zrot -= 5.0; + break; + case 'R': + Zrot += 5.0; + break; + case 'z': + Scale *= 1.1; + break; + case 'Z': + Scale /= 1.1; + break; + case 's': + Smooth = !Smooth; + break; + case 27: + glutDestroyWindow(Win); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +Init(void) +{ + printf("Usage:\n"); + printf(" z/Z: change triangle size\n"); + printf(" r/R: rotate\n"); + printf(" p: toggle line/fill mode\n"); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(400, 400); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + Win = glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From b1399a5dd20fad801ee10383143439f8cf4615db Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sun, 25 Nov 2007 15:06:54 +0000 Subject: gallium: more trivial tests --- progs/trivial/Makefile | 72 +++++--- progs/trivial/clear-fbo-tex.c | 220 ++++++++++++++++++++++++ progs/trivial/clear-fbo.c | 205 ++++++++++++++++++++++ progs/trivial/createwin.c | 120 +++++++++++++ progs/trivial/line-stipple-wide.c | 148 ++++++++++++++++ progs/trivial/line-wide.c | 147 ++++++++++++++++ progs/trivial/line.c | 13 +- progs/trivial/lineloop-elts.c | 120 +++++++++++++ progs/trivial/linestrip-clip.c | 141 +++++++++++++++ progs/trivial/linestrip-flat-stipple.c | 142 +++++++++++++++ progs/trivial/linestrip-stipple-wide.c | 142 +++++++++++++++ progs/trivial/linestrip-stipple.c | 141 +++++++++++++++ progs/trivial/linestrip.c | 138 +++++++++++++++ progs/trivial/point-param.c | 6 +- progs/trivial/point-sprite.c | 174 +++++++++++++++++++ progs/trivial/poly-flat-clip.c | 140 +++++++++++++++ progs/trivial/psb_context.c | 0 progs/trivial/quad-offset-unfilled.c | 4 +- progs/trivial/quad-tex-alpha.c | 170 ++++++++++++++++++ progs/trivial/quad-unfilled-clip.c | 139 +++++++++++++++ progs/trivial/quad-unfilled-stipple.c | 142 +++++++++++++++ progs/trivial/quadstrip-cont.c | 162 +++++++++++++++++ progs/trivial/tri-alpha-tex.c | 179 +++++++++++++++++++ progs/trivial/tri-alpha.c | 141 +++++++++++++++ progs/trivial/tri-blend-color.c | 141 +++++++++++++++ progs/trivial/tri-blend-max.c | 145 ++++++++++++++++ progs/trivial/tri-blend-min.c | 145 ++++++++++++++++ progs/trivial/tri-blend-revsub.c | 145 ++++++++++++++++ progs/trivial/tri-blend-sub.c | 145 ++++++++++++++++ progs/trivial/tri-clear.c | 143 +++++++++++++++ progs/trivial/tri-cull-both.c | 141 +++++++++++++++ progs/trivial/tri-fbo-tex.c | 267 +++++++++++++++++++++++++++++ progs/trivial/tri-fbo.c | 200 +++++++++++++++++++++ progs/trivial/tri-fog.c | 152 ++++++++++++++++ progs/trivial/tri-mask-tri.c | 146 ++++++++++++++++ progs/trivial/tri-query.c | 158 +++++++++++++++++ progs/trivial/tri-scissor-tri.c | 151 ++++++++++++++++ progs/trivial/tri-square.c | 136 +++++++++++++++ progs/trivial/tri-stencil.c | 149 ++++++++++++++++ progs/trivial/tri-tri.c | 145 ++++++++++++++++ progs/trivial/tri-unfilled-point.c | 138 +++++++++++++++ progs/trivial/tri-unfilled-userclip-stip.c | 147 ++++++++++++++++ progs/trivial/tri-z-9.c | 139 +++++++++++++++ progs/trivial/tri-z-eq.c | 139 +++++++++++++++ progs/trivial/tristrip-flat.c | 148 ++++++++++++++++ progs/trivial/vbo-drawarrays.c | 4 +- progs/trivial/vbo-drawelements.c | 4 +- 47 files changed, 6201 insertions(+), 33 deletions(-) create mode 100644 progs/trivial/clear-fbo-tex.c create mode 100644 progs/trivial/clear-fbo.c create mode 100644 progs/trivial/createwin.c create mode 100644 progs/trivial/line-stipple-wide.c create mode 100644 progs/trivial/line-wide.c create mode 100644 progs/trivial/lineloop-elts.c create mode 100644 progs/trivial/linestrip-clip.c create mode 100644 progs/trivial/linestrip-flat-stipple.c create mode 100644 progs/trivial/linestrip-stipple-wide.c create mode 100644 progs/trivial/linestrip-stipple.c create mode 100644 progs/trivial/linestrip.c create mode 100644 progs/trivial/point-sprite.c create mode 100644 progs/trivial/poly-flat-clip.c create mode 100644 progs/trivial/psb_context.c create mode 100644 progs/trivial/quad-tex-alpha.c create mode 100644 progs/trivial/quad-unfilled-clip.c create mode 100644 progs/trivial/quad-unfilled-stipple.c create mode 100644 progs/trivial/quadstrip-cont.c create mode 100644 progs/trivial/tri-alpha-tex.c create mode 100644 progs/trivial/tri-alpha.c create mode 100644 progs/trivial/tri-blend-color.c create mode 100644 progs/trivial/tri-blend-max.c create mode 100644 progs/trivial/tri-blend-min.c create mode 100644 progs/trivial/tri-blend-revsub.c create mode 100644 progs/trivial/tri-blend-sub.c create mode 100644 progs/trivial/tri-clear.c create mode 100644 progs/trivial/tri-cull-both.c create mode 100644 progs/trivial/tri-fbo-tex.c create mode 100644 progs/trivial/tri-fbo.c create mode 100644 progs/trivial/tri-fog.c create mode 100644 progs/trivial/tri-mask-tri.c create mode 100644 progs/trivial/tri-query.c create mode 100644 progs/trivial/tri-scissor-tri.c create mode 100644 progs/trivial/tri-square.c create mode 100644 progs/trivial/tri-stencil.c create mode 100644 progs/trivial/tri-tri.c create mode 100644 progs/trivial/tri-unfilled-point.c create mode 100644 progs/trivial/tri-unfilled-userclip-stip.c create mode 100644 progs/trivial/tri-z-9.c create mode 100644 progs/trivial/tri-z-eq.c create mode 100644 progs/trivial/tristrip-flat.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index d9b200aef2f..3a1caf15e71 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -11,74 +11,104 @@ include $(TOP)/configs/current LIBS = $(APP_LIB_DEPS) SOURCES = \ - clear.c \ + clear-fbo-tex.c \ + clear-fbo.c \ clear-scissor.c \ + clear.c \ + dlist-dangling.c \ + dlist-edgeflag-dangling.c \ + dlist-edgeflag.c \ + drawarrays.c \ + drawelements.c \ + drawrange.c \ flat-clip.c \ fs-tri.c \ line-clip.c \ line-cull.c \ + line-stipple-wide.c \ line-userclip-clip.c \ line-userclip-nop-clip.c \ line-userclip-nop.c \ line-userclip.c \ + line-wide.c \ line.c \ lineloop-clip.c \ + lineloop-elts.c \ lineloop.c \ - point.c \ + linestrip-flat-stipple.c \ + linestrip-stipple-wide.c \ + linestrip-stipple.c \ + linestrip.c \ point-clip.c \ point-param.c \ + point-sprite.c \ point-wide.c \ + point.c \ poly-flat.c \ poly-unfilled.c \ poly.c \ - quad-clip.c \ quad-clip-all-vertices.c \ quad-clip-nearplane.c \ + quad-clip.c \ quad-degenerate.c \ quad-flat.c \ quad-offset-factor.c \ - quad-offset-units.c \ quad-offset-unfilled.c \ - quad-unfilled.c \ + quad-offset-units.c \ quad-tex-2d.c \ - quad-tex-pbo.c \ quad-tex-3d.c \ + quad-tex-alpha.c \ + quad-tex-pbo.c \ + quad-unfilled-clip.c \ + quad-unfilled-stipple.c \ + quad-unfilled.c \ quad.c \ quads.c \ - quadstrip.c \ + quadstrip-cont.c \ quadstrip-flat.c \ - readpixels.c \ - dlist-edgeflag.c \ - dlist-dangling.c \ - dlist-edgeflag-dangling.c \ - drawrange.c \ - drawelements.c \ - drawarrays.c \ + quadstrip.c \ + tri-alpha.c \ + tri-blend-color.c \ + tri-blend-max.c \ + tri-blend-min.c \ + tri-blend-revsub.c \ + tri-blend-sub.c \ tri-blend.c \ - tri-tex-3d.c \ tri-clip.c \ + tri-cull-both.c \ tri-cull.c \ + tri-dlist.c \ tri-edgeflag.c \ + tri-fbo-tex.c \ + tri-fbo.c \ tri-flat-clip.c \ tri-flat.c \ + tri-fog.c \ + tri-mask-tri.c \ + tri-query.c \ + tri-scissor-tri.c \ + tri-stencil.c \ + tri-tex-3d.c \ + tri-tri.c \ tri-unfilled-clip.c \ tri-unfilled-smooth.c \ + tri-unfilled-userclip-stip.c \ tri-unfilled-userclip.c \ tri-unfilled.c \ tri-userclip.c \ - tri-dlist.c \ + tri-z-eq.c \ tri-z.c \ tri.c \ tristrip-clip.c \ tristrip.c \ - vbo-drawrange.c \ - vbo-drawelements.c \ vbo-drawarrays.c \ + vbo-drawelements.c \ + vbo-drawrange.c \ + vp-array.c \ vp-clip.c \ - vp-tri.c \ vp-line-clip.c \ - vp-unfilled.c \ - vp-array.c + vp-tri.c \ + vp-unfilled.c PROGS = $(SOURCES:%.c=%) diff --git a/progs/trivial/clear-fbo-tex.c b/progs/trivial/clear-fbo-tex.c new file mode 100644 index 00000000000..68f1ab3d77e --- /dev/null +++ b/progs/trivial/clear-fbo-tex.c @@ -0,0 +1,220 @@ + +#include +#include +#include +#include +#include + +#define GL_GLEXT_PROTOTYPES +#include + + + +static GLenum TexTarget = GL_TEXTURE_2D; +static int TexWidth = 512, TexHeight = 512; +static GLenum TexIntFormat = GL_RGBA; /* either GL_RGB or GL_RGBA */ + +static int Width = 512, Height = 512; +static GLuint MyFB, TexObj; + + +#define CheckError() assert(glGetError() == 0) + +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)); + + + if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { + printf("GL_EXT_framebuffer_object not found!\n"); + exit(0); + } + + + glGenFramebuffersEXT(1, &MyFB); + glGenTextures(1, &TexObj); + + /* Make texture object/image */ + 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, 0); + glTexParameteri(TexTarget, GL_TEXTURE_MAX_LEVEL, 0); + + glTexImage2D(TexTarget, 0, TexIntFormat, TexWidth, TexHeight, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + + + { + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + TexTarget, TexObj, 0); + + + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + } + +} + + + +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 ); + + Width = width; + Height = height; +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + + + +static void Draw( void ) +{ + + + /* draw to texture image */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); +// glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); +// glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); + + + glViewport(0, 0, TexWidth, TexHeight); + CheckError(); + + glClearColor(0.5, 0.5, 1.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + CheckError(); + + if (0) { + 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(); + } + + { + GLubyte *buffer = malloc(Width * Height * 4); + + /* read from user framebuffer */ + glReadPixels(0, 0, Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + CheckError(); + + /* draw to window */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glViewport(0, 0, Width, Height); + + /* Try to clear the window, but will overwrite: + */ + glClearColor(0.8, 0.8, 0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glWindowPos2iARB(30, 30); + glDrawPixels(Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + free(buffer); + } + + /* Bind normal framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glViewport(0, 0, Width, Height); + + if (0) { + glBegin(GL_TRIANGLES); + glColor3f(0,.7,0); + glVertex3f( 0.5, -0.5, -30.0); + glColor3f(0,0,.8); + glVertex3f( 0.5, 0.5, -30.0); + glColor3f(.9,0,0); + glVertex3f(-0.5, 0.0, -30.0); + glEnd(); + } + + if (doubleBuffer) { + glutSwapBuffers(); + } + + CheckError(); +} + + +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[0]) == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/clear-fbo.c b/progs/trivial/clear-fbo.c new file mode 100644 index 00000000000..82218ed4985 --- /dev/null +++ b/progs/trivial/clear-fbo.c @@ -0,0 +1,205 @@ + +#include +#include +#include +#include +#include + +#define GL_GLEXT_PROTOTYPES +#include + + + +static int Width = 512, Height = 512; +static GLuint MyFB, MyRB; + + +#define CheckError() assert(glGetError() == 0) + +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)); + + + if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { + printf("GL_EXT_framebuffer_object not found!\n"); + exit(0); + } + + + glGenFramebuffersEXT(1, &MyFB); + glGenRenderbuffersEXT(1, &MyRB); + + { + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, MyRB); + + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, + GL_RENDERBUFFER_EXT, MyRB); + + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); + + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + } + +} + + + +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 ); + + Width = width; + Height = height; + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + + + +static void Draw( void ) +{ + + /* draw to user framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); + glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); + + + glViewport(0, 0, Width, Height); + CheckError(); + + glClearColor(0.5, 0.5, 1.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + CheckError(); + + if (0) { + 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(); + } + + { + GLubyte *buffer = malloc(Width * Height * 4); + + /* read from user framebuffer */ + glReadPixels(0, 0, Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + CheckError(); + + /* draw to window */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glViewport(0, 0, Width, Height); + + /* Try to clear the window, but will overwrite: + */ + glClearColor(0.8, 0.8, 0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glWindowPos2iARB(30, 30); + glDrawPixels(Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + free(buffer); + } + + /* Bind normal framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glViewport(0, 0, Width, Height); + + if (0) { + glBegin(GL_TRIANGLES); + glColor3f(0,.7,0); + glVertex3f( 0.5, -0.5, -30.0); + glColor3f(0,0,.8); + glVertex3f( 0.5, 0.5, -30.0); + glColor3f(.9,0,0); + glVertex3f(-0.5, 0.0, -30.0); + glEnd(); + } + + if (doubleBuffer) + glutSwapBuffers(); + else + glFinish(); + + CheckError(); +} + + +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[0]) == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/createwin.c b/progs/trivial/createwin.c new file mode 100644 index 00000000000..901048555a9 --- /dev/null +++ b/progs/trivial/createwin.c @@ -0,0 +1,120 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ +} + +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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); +// glutMainLoop(); + return 0; +} diff --git a/progs/trivial/line-stipple-wide.c b/progs/trivial/line-stipple-wide.c new file mode 100644 index 00000000000..09e5e1fe089 --- /dev/null +++ b/progs/trivial/line-stipple-wide.c @@ -0,0 +1,148 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_LINE_STIPPLE); + glLineStipple( 5, 0xfffe ); + glLineWidth( 4 ); + + glBegin(GL_LINES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(.8,0,0); + 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); + + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -30.0); + glColor3f(0,0,.7); + 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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/line-wide.c b/progs/trivial/line-wide.c new file mode 100644 index 00000000000..543b1f67f34 --- /dev/null +++ b/progs/trivial/line-wide.c @@ -0,0 +1,147 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glLineWidth(4.0); + + glBegin(GL_LINES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(.8,0,0); + 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); + + + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -30.0); + glColor3f(0,0,.7); + 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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/line.c b/progs/trivial/line.c index b435a2689a0..de5f9274e41 100644 --- a/progs/trivial/line.c +++ b/progs/trivial/line.c @@ -40,7 +40,7 @@ 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.3, 0.3, 0.0); + glClearColor(0.0, 0.0, 1.0, 0.0); } static void Reshape(int width, int height) @@ -71,15 +71,20 @@ static void Draw(void) { glClear(GL_COLOR_BUFFER_BIT); - glBegin(GL_LINE_STRIP); + glBegin(GL_LINES); glColor3f(0,0,.7); glVertex3f( 0.9, -0.9, -30.0); glColor3f(.8,0,0); 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); + + glColor3f(0,.9,0); glVertex3f(-0.9, 0.0, -30.0); - /* Repeat the first vertex - don't have lineloop support in GS yet - */ glColor3f(0,0,.7); glVertex3f( 0.9, -0.9, -30.0); glEnd(); diff --git a/progs/trivial/lineloop-elts.c b/progs/trivial/lineloop-elts.c new file mode 100644 index 00000000000..96da8e4ad6b --- /dev/null +++ b/progs/trivial/lineloop-elts.c @@ -0,0 +1,120 @@ +/* Test rebasing */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +GLfloat verts[][4] = { + { 0.9, -0.9, 0.0, 1.0 }, + { 0.9, 0.9, 0.0, 1.0 }, + { -0.9, 0.9, 0.0, 1.0 }, + { -0.9, -0.9, 0.0, 1.0 }, +}; + +GLubyte color[][4] = { + { 0x00, 0x00, 0xff, 0x00 }, + { 0x00, 0xff, 0x00, 0x00 }, + { 0xff, 0x00, 0x00, 0x00 }, + { 0xff, 0xff, 0xff, 0x00 }, +}; + +GLuint indices[] = { 1, 2, 3 }; + +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(verts[0]), verts ); + glColorPointer( 4, GL_UNSIGNED_BYTE, 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_NV); + + /* Should have min_index == 1, maybe force a rebase: + */ + glDrawElements( GL_LINE_LOOP, 3, GL_UNSIGNED_INT, indices ); + + 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]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/linestrip-clip.c b/progs/trivial/linestrip-clip.c new file mode 100644 index 00000000000..acab0f4e1cf --- /dev/null +++ b/progs/trivial/linestrip-clip.c @@ -0,0 +1,141 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_LINE_STRIP); + 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(-1.9, 0.0, -30.0); + + glColor3f(0,0,.7); + glVertex3f( 0.8, -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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/linestrip-flat-stipple.c b/progs/trivial/linestrip-flat-stipple.c new file mode 100644 index 00000000000..b691437346a --- /dev/null +++ b/progs/trivial/linestrip-flat-stipple.c @@ -0,0 +1,142 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glShadeModel(GL_FLAT); + glEnable(GL_LINE_STIPPLE); + glLineStipple( 5, 0xfffe ); + + glBegin(GL_LINE_STRIP); + 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); + glColor3f(0,0,.7); + 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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/linestrip-stipple-wide.c b/progs/trivial/linestrip-stipple-wide.c new file mode 100644 index 00000000000..53dfa554e98 --- /dev/null +++ b/progs/trivial/linestrip-stipple-wide.c @@ -0,0 +1,142 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_LINE_STIPPLE); + glLineStipple( 5, 0xfffe ); + glLineWidth( 4 ); + + glBegin(GL_LINE_STRIP); + 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); + glColor3f(0,0,.7); + 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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/linestrip-stipple.c b/progs/trivial/linestrip-stipple.c new file mode 100644 index 00000000000..5933d1a136f --- /dev/null +++ b/progs/trivial/linestrip-stipple.c @@ -0,0 +1,141 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_LINE_STIPPLE); + glLineStipple( 5, 0xfffe ); + + glBegin(GL_LINE_STRIP); + 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); + glColor3f(0,0,.7); + 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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/linestrip.c b/progs/trivial/linestrip.c new file mode 100644 index 00000000000..06dd1c10872 --- /dev/null +++ b/progs/trivial/linestrip.c @@ -0,0 +1,138 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_LINE_STRIP); + 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); + glColor3f(0,0,.7); + 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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/point-param.c b/progs/trivial/point-param.c index c50b7cb1034..be4328d9995 100644 --- a/progs/trivial/point-param.c +++ b/progs/trivial/point-param.c @@ -80,13 +80,13 @@ static void Draw(void) glBegin(GL_POINTS); glColor3f(1,0,0); - glVertex3f( 0.9, -0.9, -30.0); + glVertex3f( 0.9, -0.9, -10.0); glColor3f(1,1,0); - glVertex3f( 0.9, 0.9, -30.0); + glVertex3f( 0.9, 0.9, -5.0); glColor3f(1,0,1); glVertex3f(-0.9, 0.9, -30.0); glColor3f(0,1,1); - glVertex3f(-0.9, -0.9, -30.0); + glVertex3f(-0.9, -0.9, -20.0); glEnd(); glFlush(); diff --git a/progs/trivial/point-sprite.c b/progs/trivial/point-sprite.c new file mode 100644 index 00000000000..583bdca1b71 --- /dev/null +++ b/progs/trivial/point-sprite.c @@ -0,0 +1,174 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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)); + + +#define SIZE 16 + { + GLubyte tex2d[SIZE][SIZE][3]; + GLint s, t; + + for (s = 0; s < SIZE; s++) { + for (t = 0; t < SIZE; t++) { +#if 1 + tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255; + tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255; + tex2d[t][s][2] = 0; +#else + tex2d[t][s][0] = s*255/(SIZE-1); + tex2d[t][s][1] = t*255/(SIZE-1); + tex2d[t][s][2] = 0; +#endif + } + } + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0, + GL_RGB, GL_UNSIGNED_BYTE, tex2d); + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glEnable(GL_TEXTURE_2D); + } + + glEnable(GL_POINT_SPRITE); + + 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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glPointSize(16.0); + + glBegin(GL_POINTS); + glColor3f(1,0,0); + glVertex3f( 0.6, -0.6, -30.0); + glColor3f(1,1,0); + glVertex3f( 0.6, 0.6, -30.0); + glColor3f(1,0,1); + glVertex3f(-0.6, 0.6, -30.0); + glColor3f(0,1,1); + glVertex3f(-0.6, -0.6, -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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/poly-flat-clip.c b/progs/trivial/poly-flat-clip.c new file mode 100644 index 00000000000..bd8d347c999 --- /dev/null +++ b/progs/trivial/poly-flat-clip.c @@ -0,0 +1,140 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glShadeModel(GL_FLAT); + + + glBegin(GL_POLYGON); + glColor3f(1,0,0); + glVertex3f( 1.1, -1.1, -30.0); + glColor3f(1,1,0); + glVertex3f( 1.1, 1.1, -30.0); + glColor3f(1,0,1); + glVertex3f(-1.1, 1.1, -30.0); + glColor3f(0,1,1); + glVertex3f(-1.1, -1.1, -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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/psb_context.c b/progs/trivial/psb_context.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/progs/trivial/quad-offset-unfilled.c b/progs/trivial/quad-offset-unfilled.c index 32b2129727b..1ad44cdcaec 100644 --- a/progs/trivial/quad-offset-unfilled.c +++ b/progs/trivial/quad-offset-unfilled.c @@ -72,6 +72,8 @@ static void Draw(void) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glEnable(GL_POLYGON_OFFSET_FILL); @@ -95,7 +97,7 @@ static void Draw(void) glVertex3f(-0.6, -0.6, -35.0); glEnd(); - glEnable(GL_POLYGON_OFFSET_FILL); + glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(-1, 0); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); diff --git a/progs/trivial/quad-tex-alpha.c b/progs/trivial/quad-tex-alpha.c new file mode 100644 index 00000000000..cd73f013eb0 --- /dev/null +++ b/progs/trivial/quad-tex-alpha.c @@ -0,0 +1,170 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + +#define SIZE 16 + { + GLubyte tex2d[SIZE][SIZE][4]; + GLint s, t; + + for (s = 0; s < SIZE; s++) { + for (t = 0; t < SIZE; t++) { + tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255; + tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255; + tex2d[t][s][2] = 0; + tex2d[t][s][3] = ((t^s) & 3) * 63; + } + } + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, 4, SIZE, SIZE, 0, + GL_RGBA, GL_UNSIGNED_BYTE, tex2d); + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glEnable(GL_TEXTURE_2D); + } +} + +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: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glDisable(GL_DEPTH_TEST); + glDisable(GL_STENCIL_TEST); + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GEQUAL, 0.5); + + 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(100, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + 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 new file mode 100644 index 00000000000..e298bd455bf --- /dev/null +++ b/progs/trivial/quad-unfilled-clip.c @@ -0,0 +1,139 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + + glBegin(GL_QUADS); + glColor3f(1,0,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,1,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(1,0,1); + glVertex3f(-1.9, 0.9, -30.0); + glColor3f(0,1,1); + 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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/quad-unfilled-stipple.c b/progs/trivial/quad-unfilled-stipple.c new file mode 100644 index 00000000000..2036aacbaab --- /dev/null +++ b/progs/trivial/quad-unfilled-stipple.c @@ -0,0 +1,142 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + + glEnable(GL_LINE_STIPPLE); + glLineStipple( 5, 0xfffe ); + + glBegin(GL_QUADS); + glColor3f(1,0,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,1,1); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.9, -30.0); + glColor3f(0,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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == 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 new file mode 100644 index 00000000000..c6c8f69f8ca --- /dev/null +++ b/progs/trivial/quadstrip-cont.c @@ -0,0 +1,162 @@ +/* + * 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 +#include +#include +#include + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_QUAD_STRIP); + glColor3f(1,0,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,1,0); + glVertex3f( 0.9, 0.9, -30.0); + + glColor3f(1,0,0); + glVertex3f( 0.1, -0.8, -30.0); + glColor3f(1,1,0); + glVertex3f( 0.1, 0.8, -30.0); + + glColor3f(0,1,1); + glVertex3f(-0.1, -0.9, -30.0); + glColor3f(1,0,1); + glVertex3f(-0.1, 0.9, -30.0); + + glColor3f(0,1,1); + glVertex3f(-0.9, -0.8, -30.0); + glColor3f(1,0,1); + glVertex3f(-0.9, 0.8, -30.0); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static void +idle(void) +{ + glutPostRedisplay(); +} + + +static void +visible(int vis) +{ + if (vis == GLUT_VISIBLE) + glutIdleFunc(idle); + else + glutIdleFunc(NULL); +} + + +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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutVisibilityFunc(visible); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-alpha-tex.c b/progs/trivial/tri-alpha-tex.c new file mode 100644 index 00000000000..776f39dcc35 --- /dev/null +++ b/progs/trivial/tri-alpha-tex.c @@ -0,0 +1,179 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + +#define SIZE 16 + { + GLubyte tex2d[SIZE][SIZE][4]; + GLint s, t; + + for (s = 0; s < SIZE; s++) { + for (t = 0; t < SIZE; t++) { + tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255; + tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255; + tex2d[t][s][2] = 0; + tex2d[t][s][3] = ((t^s) & 3) * 63; + } + } + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, 4, SIZE, SIZE, 0, + GL_RGBA, GL_UNSIGNED_BYTE, tex2d); + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glEnable(GL_TEXTURE_2D); + } +} + +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: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glDisable(GL_DEPTH_TEST); + glDisable(GL_STENCIL_TEST); + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GEQUAL, 0.5); + + 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(); +#if 0 + glBegin(GL_TRIANGLES); + glColor4f(0,0,.7,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor4f(.8,0,0,.5); + glVertex3f( 0.9, 0.9, -30.0); + glColor4f(0,.9,0,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); +#endif + + 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( 250, 250); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-alpha.c b/progs/trivial/tri-alpha.c new file mode 100644 index 00000000000..90cfdbe199d --- /dev/null +++ b/progs/trivial/tri-alpha.c @@ -0,0 +1,141 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glDisable(GL_DEPTH_TEST); + glDisable(GL_STENCIL_TEST); + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GEQUAL, 0.5); + + glBegin(GL_TRIANGLES); + glColor4f(0,0,.7,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor4f(.8,0,0,.5); + glVertex3f( 0.9, 0.9, -30.0); + glColor4f(0,.9,0,0); + glVertex3f(-0.9, 0.0, -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(100, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-blend-color.c b/progs/trivial/tri-blend-color.c new file mode 100644 index 00000000000..b9a539410bc --- /dev/null +++ b/progs/trivial/tri-blend-color.c @@ -0,0 +1,141 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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)); + +} + +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: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClearColor(0.0, 0.0, 1.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendColor(1.0, 0, 0, 0); + glBlendFunc(GL_CONSTANT_COLOR, GL_SRC_COLOR); + + 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(); + + 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( 250, 250); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-blend-max.c b/progs/trivial/tri-blend-max.c new file mode 100644 index 00000000000..ebc241c1c16 --- /dev/null +++ b/progs/trivial/tri-blend-max.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * alpha.c + * This program draws several overlapping filled polygons + * to demonstrate the effect order has on alpha blending results. + * Use the 't' key to toggle the order of drawing polygons. + */ +#include +#include + +static int leftFirst = GL_TRUE; + +/* Initialize alpha blending function. + */ +static void init(void) +{ + glBlendEquation (GL_MAX); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glShadeModel (GL_FLAT); + glClearColor (1.0, 0.0, 0.0, 0.0); +} + +static void drawLeftTriangle(void) +{ + /* draw yellow triangle on LHS of screen */ + + glBegin (GL_TRIANGLES); + glColor4f(1.0, 1.0, 0.0, 0.75); + glVertex3f(0.1, 0.9, 0.0); + glVertex3f(0.1, 0.1, 0.0); + glVertex3f(0.7, 0.5, 0.0); + glEnd(); +} + +static void drawRightTriangle(void) +{ + /* draw cyan triangle on RHS of screen */ + + glEnable (GL_BLEND); + glBegin (GL_TRIANGLES); + glColor4f(0.0, 1.0, 1.0, 0.75); + glVertex3f(0.9, 0.9, 0.0); + glVertex3f(0.3, 0.5, 0.0); + glVertex3f(0.9, 0.1, 0.0); + glEnd(); + glDisable (GL_BLEND); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + if (leftFirst) { + drawLeftTriangle(); + drawRightTriangle(); + } + else { + drawRightTriangle(); + drawLeftTriangle(); + } + + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + gluOrtho2D (0.0, 1.0, 0.0, 1.0*(GLfloat)h/(GLfloat)w); + else + gluOrtho2D (0.0, 1.0*(GLfloat)w/(GLfloat)h, 0.0, 1.0); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 't': + case 'T': + leftFirst = !leftFirst; + glutPostRedisplay(); + break; + case 27: /* Escape key */ + exit(0); + break; + default: + break; + } +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (200, 200); + glutCreateWindow (argv[0]); + init(); + glutReshapeFunc (reshape); + glutKeyboardFunc (keyboard); + glutDisplayFunc (display); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-blend-min.c b/progs/trivial/tri-blend-min.c new file mode 100644 index 00000000000..00b2dec7056 --- /dev/null +++ b/progs/trivial/tri-blend-min.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * alpha.c + * This program draws several overlapping filled polygons + * to demonstrate the effect order has on alpha blending results. + * Use the 't' key to toggle the order of drawing polygons. + */ +#include +#include + +static int leftFirst = GL_TRUE; + +/* Initialize alpha blending function. + */ +static void init(void) +{ + glBlendEquation (GL_MIN); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glShadeModel (GL_FLAT); + glClearColor (1.0, 0.0, 0.0, 0.0); +} + +static void drawLeftTriangle(void) +{ + /* draw yellow triangle on LHS of screen */ + + glBegin (GL_TRIANGLES); + glColor4f(1.0, 1.0, 0.0, 0.75); + glVertex3f(0.1, 0.9, 0.0); + glVertex3f(0.1, 0.1, 0.0); + glVertex3f(0.7, 0.5, 0.0); + glEnd(); +} + +static void drawRightTriangle(void) +{ + /* draw cyan triangle on RHS of screen */ + + glEnable (GL_BLEND); + glBegin (GL_TRIANGLES); + glColor4f(0.0, 1.0, 1.0, 0.75); + glVertex3f(0.9, 0.9, 0.0); + glVertex3f(0.3, 0.5, 0.0); + glVertex3f(0.9, 0.1, 0.0); + glEnd(); + glDisable (GL_BLEND); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + if (leftFirst) { + drawLeftTriangle(); + drawRightTriangle(); + } + else { + drawRightTriangle(); + drawLeftTriangle(); + } + + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + gluOrtho2D (0.0, 1.0, 0.0, 1.0*(GLfloat)h/(GLfloat)w); + else + gluOrtho2D (0.0, 1.0*(GLfloat)w/(GLfloat)h, 0.0, 1.0); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 't': + case 'T': + leftFirst = !leftFirst; + glutPostRedisplay(); + break; + case 27: /* Escape key */ + exit(0); + break; + default: + break; + } +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (200, 200); + glutCreateWindow (argv[0]); + init(); + glutReshapeFunc (reshape); + glutKeyboardFunc (keyboard); + glutDisplayFunc (display); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-blend-revsub.c b/progs/trivial/tri-blend-revsub.c new file mode 100644 index 00000000000..be187fd4cee --- /dev/null +++ b/progs/trivial/tri-blend-revsub.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * alpha.c + * This program draws several overlapping filled polygons + * to demonstrate the effect order has on alpha blending results. + * Use the 't' key to toggle the order of drawing polygons. + */ +#include +#include + +static int leftFirst = GL_TRUE; + +/* Initialize alpha blending function. + */ +static void init(void) +{ + glBlendEquation (GL_FUNC_REVERSE_SUBTRACT); + glBlendFunc (GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); + glShadeModel (GL_FLAT); + glClearColor (1.0, 0.0, 0.0, 0.0); +} + +static void drawLeftTriangle(void) +{ + /* draw yellow triangle on LHS of screen */ + + glBegin (GL_TRIANGLES); + glColor4f(1.0, 1.0, 0.0, 0.75); + glVertex3f(0.1, 0.9, 0.0); + glVertex3f(0.1, 0.1, 0.0); + glVertex3f(0.7, 0.5, 0.0); + glEnd(); +} + +static void drawRightTriangle(void) +{ + /* draw cyan triangle on RHS of screen */ + + glEnable (GL_BLEND); + glBegin (GL_TRIANGLES); + glColor4f(0.0, 1.0, 1.0, 0.75); + glVertex3f(0.9, 0.9, 0.0); + glVertex3f(0.3, 0.5, 0.0); + glVertex3f(0.9, 0.1, 0.0); + glEnd(); + glDisable (GL_BLEND); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + if (leftFirst) { + drawLeftTriangle(); + drawRightTriangle(); + } + else { + drawRightTriangle(); + drawLeftTriangle(); + } + + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + gluOrtho2D (0.0, 1.0, 0.0, 1.0*(GLfloat)h/(GLfloat)w); + else + gluOrtho2D (0.0, 1.0*(GLfloat)w/(GLfloat)h, 0.0, 1.0); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 't': + case 'T': + leftFirst = !leftFirst; + glutPostRedisplay(); + break; + case 27: /* Escape key */ + exit(0); + break; + default: + break; + } +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (200, 200); + glutCreateWindow (argv[0]); + init(); + glutReshapeFunc (reshape); + glutKeyboardFunc (keyboard); + glutDisplayFunc (display); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-blend-sub.c b/progs/trivial/tri-blend-sub.c new file mode 100644 index 00000000000..d207791108c --- /dev/null +++ b/progs/trivial/tri-blend-sub.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 1993-1997, 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(R) is a registered trademark of Silicon Graphics, Inc. + */ + +/* + * alpha.c + * This program draws several overlapping filled polygons + * to demonstrate the effect order has on alpha blending results. + * Use the 't' key to toggle the order of drawing polygons. + */ +#include +#include + +static int leftFirst = GL_TRUE; + +/* Initialize alpha blending function. + */ +static void init(void) +{ + glBlendEquation (GL_FUNC_SUBTRACT); + glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glShadeModel (GL_FLAT); + glClearColor (1.0, 0.0, 0.0, 0.0); +} + +static void drawLeftTriangle(void) +{ + /* draw yellow triangle on LHS of screen */ + + glBegin (GL_TRIANGLES); + glColor4f(1.0, 1.0, 0.0, 0.75); + glVertex3f(0.1, 0.9, 0.0); + glVertex3f(0.1, 0.1, 0.0); + glVertex3f(0.7, 0.5, 0.0); + glEnd(); +} + +static void drawRightTriangle(void) +{ + /* draw cyan triangle on RHS of screen */ + + glEnable (GL_BLEND); + glBegin (GL_TRIANGLES); + glColor4f(0.0, 1.0, 1.0, 0.75); + glVertex3f(0.9, 0.9, 0.0); + glVertex3f(0.3, 0.5, 0.0); + glVertex3f(0.9, 0.1, 0.0); + glEnd(); + glDisable (GL_BLEND); +} + +void display(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + if (leftFirst) { + drawLeftTriangle(); + drawRightTriangle(); + } + else { + drawRightTriangle(); + drawLeftTriangle(); + } + + glFlush(); +} + +void reshape(int w, int h) +{ + glViewport(0, 0, (GLsizei) w, (GLsizei) h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if (w <= h) + gluOrtho2D (0.0, 1.0, 0.0, 1.0*(GLfloat)h/(GLfloat)w); + else + gluOrtho2D (0.0, 1.0*(GLfloat)w/(GLfloat)h, 0.0, 1.0); +} + +/* ARGSUSED1 */ +void keyboard(unsigned char key, int x, int y) +{ + switch (key) { + case 't': + case 'T': + leftFirst = !leftFirst; + glutPostRedisplay(); + break; + case 27: /* Escape key */ + exit(0); + break; + default: + break; + } +} + +/* Main Loop + * Open window with initial window size, title bar, + * RGBA display mode, and handle input events. + */ +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize (200, 200); + glutCreateWindow (argv[0]); + init(); + glutReshapeFunc (reshape); + glutKeyboardFunc (keyboard); + glutDisplayFunc (display); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-clear.c b/progs/trivial/tri-clear.c new file mode 100644 index 00000000000..25ea77cfa75 --- /dev/null +++ b/progs/trivial/tri-clear.c @@ -0,0 +1,143 @@ +/* + * 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 +#include +#include +#include + + +#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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + 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(); + + glEnable(GL_SCISSOR_TEST); + glClearColor(1, 0, 1, 0); + glScissor(Width / 2, Height / 2, Width - Width / 2, Height - Height / 2); + glClear(GL_COLOR_BUFFER_BIT); + glDisable(GL_SCISSOR_TEST); + + 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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-cull-both.c b/progs/trivial/tri-cull-both.c new file mode 100644 index 00000000000..51b5865ae5c --- /dev/null +++ b/progs/trivial/tri-cull-both.c @@ -0,0 +1,141 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + glCullFace(GL_FRONT_AND_BACK); + glEnable(GL_CULL_FACE); + +} + +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: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + + + glBegin(GL_TRIANGLES); + glColor3f(.8,0,0); + glVertex3f( 0.93, 0.9, -30.0); + glColor3f(0,.9,0); + glVertex3f(-0.93, 0.0, -30.0); + glColor3f(0,0,.7); + glVertex3f( 0.93, -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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-fbo-tex.c b/progs/trivial/tri-fbo-tex.c new file mode 100644 index 00000000000..d413d4081f1 --- /dev/null +++ b/progs/trivial/tri-fbo-tex.c @@ -0,0 +1,267 @@ +/* + * 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 + */ + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include +#include +#include + +/* 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 = 0; /* 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, TexHeight); + + 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[]) +{ + static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 }; + GLint i; + + 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); + + + 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]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Display); + if (Anim) + glutIdleFunc(Idle); + Init(argc, argv); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-fbo.c b/progs/trivial/tri-fbo.c new file mode 100644 index 00000000000..82d70c40b7e --- /dev/null +++ b/progs/trivial/tri-fbo.c @@ -0,0 +1,200 @@ + +#include +#include +#include +#include +#include + +#define GL_GLEXT_PROTOTYPES +#include + + + +static int Width = 400, Height = 400; +static GLuint MyFB, MyRB; + + +#define CheckError() assert(glGetError() == 0) + +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)); + + + if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { + printf("GL_EXT_framebuffer_object not found!\n"); + exit(0); + } + + + glGenFramebuffersEXT(1, &MyFB); + glGenRenderbuffersEXT(1, &MyRB); + + { + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, MyRB); + + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, + GL_RENDERBUFFER_EXT, MyRB); + + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); + + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + } + + glClearColor(0.0, 0.0, 1.0, 0.0); +} + + + +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 ); + + Width = width; + Height = height; + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); +} + + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + + + +static void Draw( void ) +{ + + /* draw to user framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); + glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); + glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); + + glClearColor(0.5, 0.5, 1.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + CheckError(); + + 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(); + + + { + GLubyte *buffer = malloc(Width * Height * 4); + + /* read from user framebuffer */ + glReadPixels(0, 0, Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + CheckError(); + + /* draw to window */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + /* Try to clear the window, but will overwrite: + */ + glClearColor(0.8, 0.8, 0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glWindowPos2iARB(30, 30); + glDrawPixels(Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + + free(buffer); + } + + /* Bind normal framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + + if (1) { + glBegin(GL_TRIANGLES); + glColor3f(0,.7,0); + glVertex3f( 0.5, -0.5, -30.0); + glColor3f(0,0,.8); + glVertex3f( 0.5, 0.5, -30.0); + glColor3f(.9,0,0); + glVertex3f(-0.5, 0.0, -30.0); + glEnd(); + } + + if (doubleBuffer) + glutSwapBuffers(); + else + glFinish(); + + CheckError(); +} + + +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[0]) == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-fog.c b/progs/trivial/tri-fog.c new file mode 100644 index 00000000000..75f3262ecf4 --- /dev/null +++ b/progs/trivial/tri-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 +#include +#include +#include + + +#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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_FOG); + + 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(); + +#if 0 + 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(); +#endif + + 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("First Tri") == GL_FALSE) { + 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 new file mode 100644 index 00000000000..96a1ea7168a --- /dev/null +++ b/progs/trivial/tri-mask-tri.c @@ -0,0 +1,146 @@ +/* + * 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 +#include +#include +#include + + +#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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,1,0); + glVertex3f( 0.9, -0.9, -30.0); + glVertex3f( 0.9, 0.9, -30.0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glColorMask(1,0,1,0); + + glBegin(GL_TRIANGLES); + glColor3f(1,1,1); + glVertex3f(-0.9, -0.9, -30.0); + glVertex3f(-0.9, 0.9, -30.0); + glVertex3f( 0.9, 0.0, -30.0); + glEnd(); + + glDisable(GL_SCISSOR_TEST); + + 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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-query.c b/progs/trivial/tri-query.c new file mode 100644 index 00000000000..c9161c4f0ad --- /dev/null +++ b/progs/trivial/tri-query.c @@ -0,0 +1,158 @@ +/* + * 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 +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + +static GLuint OccQuery; + +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); + + glGenQueriesARB(1, &OccQuery); +} + +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: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + GLuint passed; + GLint ready; + + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + + glEnable(GL_DEPTH_TEST); + + glBeginQueryARB(GL_SAMPLES_PASSED_ARB, OccQuery); + + 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(); + + glEndQueryARB(GL_SAMPLES_PASSED_ARB); + + do { + /* do useful work here, if any */ + glGetQueryObjectivARB(OccQuery, GL_QUERY_RESULT_AVAILABLE_ARB, &ready); + } while (!ready); + glGetQueryObjectuivARB(OccQuery, GL_QUERY_RESULT_ARB, &passed); + + fprintf(stderr, " %d Fragments Visible\n", passed); + + 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( 250, 250); + + type = GLUT_RGB | GLUT_DEPTH; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-scissor-tri.c b/progs/trivial/tri-scissor-tri.c new file mode 100644 index 00000000000..dcc6d282dc2 --- /dev/null +++ b/progs/trivial/tri-scissor-tri.c @@ -0,0 +1,151 @@ +/* + * 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 +#include +#include +#include + + +#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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + 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(); + + glScissor(Width / 4, Height / 4, Width / 2, Height / 2); + glEnable(GL_SCISSOR_TEST); + + 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_SCISSOR_TEST); + + 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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-square.c b/progs/trivial/tri-square.c new file mode 100644 index 00000000000..ef9ea63048f --- /dev/null +++ b/progs/trivial/tri-square.c @@ -0,0 +1,136 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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(); + gluOrtho2D(0, (GLdouble)width, 0, (GLdouble)height); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glColor3f(1,1,1); + + glBegin(GL_TRIANGLES); + glVertex3f( 10, 10, -30.0); + glVertex3f( 200, 150, -30.0); + glVertex3f( 10, 200, -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(100, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-stencil.c b/progs/trivial/tri-stencil.c new file mode 100644 index 00000000000..5edbef26ced --- /dev/null +++ b/progs/trivial/tri-stencil.c @@ -0,0 +1,149 @@ +/* + * 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 +#include +#include +#include +#include + + +static void Init(void) +{ +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + } +} + +static void Draw(void) +{ + glShadeModel(GL_FLAT); + + { + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearStencil(0); + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); + } + + + glStencilMask(1); + glEnable(GL_STENCIL_TEST); + glStencilFunc(GL_ALWAYS, 1, 1); + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + + glColor3ub(200, 0, 0); + glBegin(GL_POLYGON); + glVertex3i(-4, -4, 0); + glVertex3i( 4, -4, 0); + glVertex3i( 0, 4, 0); + glEnd(); + +#if 1 + glStencilFunc(GL_EQUAL, 1, 1); + glStencilOp(GL_INCR, GL_KEEP, GL_DECR); + + glColor3ub(0, 200, 0); + glBegin(GL_POLYGON); + glVertex3i(3, 3, 0); + glVertex3i(-3, 3, 0); + glVertex3i(-3, -3, 0); + glVertex3i(3, -3, 0); + glEnd(); +#endif + +#if 0 + glStencilFunc(GL_EQUAL, 1, 1); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + + glColor3ub(0, 0, 200); + glBegin(GL_POLYGON); + glVertex3f(2.5, 2.5, 0); + glVertex3f(-2.5, 2.5, 0); + glVertex3f(-2.5, -2.5, 0); + glVertex3f(2.5, -2.5, 0); + glEnd(); +#endif + + glFlush(); +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-dr") == 0) { + } else { + printf("%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( 300, 300); + + type = GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH | GLUT_STENCIL; + glutInitDisplayMode(type); + + if (glutCreateWindow("Stencil Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-tri.c b/progs/trivial/tri-tri.c new file mode 100644 index 00000000000..06a0528eb87 --- /dev/null +++ b/progs/trivial/tri-tri.c @@ -0,0 +1,145 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + 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(); + + 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(); + + 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( 250, 250); + + type = GLUT_RGB; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == 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 new file mode 100644 index 00000000000..71ac453d603 --- /dev/null +++ b/progs/trivial/tri-unfilled-point.c @@ -0,0 +1,138 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glPolygonMode(GL_FRONT, GL_POINT); + glPolygonMode(GL_BACK, GL_POINT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-unfilled-userclip-stip.c b/progs/trivial/tri-unfilled-userclip-stip.c new file mode 100644 index 00000000000..4aefa85032f --- /dev/null +++ b/progs/trivial/tri-unfilled-userclip-stip.c @@ -0,0 +1,147 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer; + +static void Init(void) +{ + static GLdouble plane[4] = { -.5, 0, 1, 0 }; + + 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); + glClipPlane(GL_CLIP_PLANE0, plane); + glEnable(GL_CLIP_PLANE0); + glLineWidth( 4 ); +} + +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: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + + glEnable(GL_LINE_STIPPLE); + glLineStipple( 5, 0xfffe ); + + + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, 0.0); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, 0.0); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, 0.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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + 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 new file mode 100644 index 00000000000..4bd99861660 --- /dev/null +++ b/progs/trivial/tri-z-9.c @@ -0,0 +1,139 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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)); + +} + +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, 1, -1); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClearColor(0.0, 0.0, 1.0, 0.0); + glClearDepth(1.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glDepthFunc(GL_EQUAL); + glEnable(GL_DEPTH_TEST); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, .5); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, .5); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, .5); + 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(100, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_DEPTH; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-z-eq.c b/progs/trivial/tri-z-eq.c new file mode 100644 index 00000000000..ad5f31a5588 --- /dev/null +++ b/progs/trivial/tri-z-eq.c @@ -0,0 +1,139 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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)); + +} + +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, 1, -1); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClearColor(0.0, 0.0, 1.0, 0.0); + glClearDepth(1.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glDepthFunc(GL_EQUAL); + glEnable(GL_DEPTH_TEST); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, 1.0); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, 1.0); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, 1.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(100, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_DEPTH; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tristrip-flat.c b/progs/trivial/tristrip-flat.c new file mode 100644 index 00000000000..e048233e67c --- /dev/null +++ b/progs/trivial/tristrip-flat.c @@ -0,0 +1,148 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glShadeModel(GL_FLAT); + + if (0) { + glBegin(GL_LINES); + glColor3f(1,0,0); + glVertex3f( 0.95, -0.9, -30.0); + glColor3f(1,1,0); + glVertex3f( 0.95, 0.9, -30.0); + glEnd(); + } + + glBegin(GL_TRIANGLE_STRIP); + glColor3f(1,0,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(0,1,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,0,.5); + glVertex3f(-0.9, -0.9, -30.0); + glColor3f(1,1,1); + 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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/vbo-drawarrays.c b/progs/trivial/vbo-drawarrays.c index 3eec9c47237..fb590098a32 100644 --- a/progs/trivial/vbo-drawarrays.c +++ b/progs/trivial/vbo-drawarrays.c @@ -79,7 +79,7 @@ static void Init( void ) static void Display( void ) { glClearColor(0.3, 0.3, 0.3, 1); - glClear( GL_COLOR_BUFFER_BIT); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glEnable(GL_VERTEX_PROGRAM_ARB); @@ -122,7 +122,7 @@ int main( int argc, char *argv[] ) glutInit( &argc, argv ); glutInitWindowPosition( 0, 0 ); glutInitWindowSize( 250, 250 ); - glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE); + glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); diff --git a/progs/trivial/vbo-drawelements.c b/progs/trivial/vbo-drawelements.c index 28943431183..dddb45695cb 100644 --- a/progs/trivial/vbo-drawelements.c +++ b/progs/trivial/vbo-drawelements.c @@ -85,7 +85,7 @@ static void Init( void ) static void Display( void ) { glClearColor(0.3, 0.3, 0.3, 1); - glClear( GL_COLOR_BUFFER_BIT); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glEnable(GL_VERTEX_PROGRAM_ARB); glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, NULL ); @@ -126,7 +126,7 @@ int main( int argc, char *argv[] ) glutInit( &argc, argv ); glutInitWindowPosition( 0, 0 ); glutInitWindowSize( 250, 250 ); - glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE); + glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); -- cgit v1.2.3 From ca2f2c76641a299e31bf3d0e26049ccc3a375caf Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 14 Feb 2008 14:54:37 -0700 Subject: gallium: new pgon-mode.c test A two-triangle strip is drawn such that the first tri is front-facing and the second tri is back-facing. Use different front/back polygon modes. --- progs/trivial/Makefile | 1 + progs/trivial/pgon-mode.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 progs/trivial/pgon-mode.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 3a1caf15e71..d19abe7e865 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -39,6 +39,7 @@ SOURCES = \ linestrip-stipple-wide.c \ linestrip-stipple.c \ linestrip.c \ + pgon-mode.c \ point-clip.c \ point-param.c \ point-sprite.c \ diff --git a/progs/trivial/pgon-mode.c b/progs/trivial/pgon-mode.c new file mode 100644 index 00000000000..db586386196 --- /dev/null +++ b/progs/trivial/pgon-mode.c @@ -0,0 +1,136 @@ +/** + * Test glPolygonMode. + * A tri-strip w/ two tris is drawn so that the first tri is front-facing + * but the second tri is back-facing. + * Set glPolygonMode differently for the front/back faces + * + */ + + +#include +#include +#include +#include + +static int Win; +static GLfloat Zrot = 0; +static GLboolean FrontFillBackUnfilled = GL_TRUE; +static GLboolean Lines = GL_TRUE; + + +static void +Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + if (FrontFillBackUnfilled) { + if (Lines) { + printf("FrontMode = FILL, BackMode = LINE\n"); + glPolygonMode(GL_BACK, GL_LINE); + } + else { + printf("FrontMode = FILL, BackMode = POINT\n"); + glPolygonMode(GL_BACK, GL_POINT); + } + glPolygonMode(GL_FRONT, GL_FILL); + } + else { + if (Lines) { + printf("FrontMode = LINE, BackMode = FILL\n"); + glPolygonMode(GL_FRONT, GL_LINE); + } + else { + printf("FrontMode = POINT, BackMode = FILL\n"); + glPolygonMode(GL_FRONT, GL_POINT); + } + glPolygonMode(GL_BACK, GL_FILL); + } + + glPushMatrix(); + glRotatef(Zrot, 0, 0, 1); + + glBegin(GL_TRIANGLE_STRIP); + glVertex2f(-1, 0); + glVertex2f( 1, 0); + glVertex2f(0, 1); + glVertex2f(0, -1); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); +} + + +static void +Key(unsigned char key, int x, int y) +{ + const GLfloat step = 3.0; + (void) x; + (void) y; + switch (key) { + case 'p': + FrontFillBackUnfilled = !FrontFillBackUnfilled; + break; + case 'l': + Lines = !Lines; + break; + case 'z': + Zrot -= step; + break; + case 'Z': + Zrot += step; + break; + case 27: + glutDestroyWindow(Win); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +Init(void) +{ + printf("GL_RENDERER = %s\n", (char*) glGetString(GL_RENDERER)); + + glLineWidth(3.0); + glPointSize(3.0); + + glColor4f(1, 1, 1, 0.8); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + printf("Press 'p' to toggle polygon mode\n"); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(400, 400); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + Win = glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From bc3f2c908e085538ed0956159503e97825161bb9 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 25 Feb 2008 16:26:37 -0700 Subject: Added line smooth test --- progs/trivial/Makefile | 1 + progs/trivial/line-smooth.c | 172 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 progs/trivial/line-smooth.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index d19abe7e865..8bc6ad4e387 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -25,6 +25,7 @@ SOURCES = \ fs-tri.c \ line-clip.c \ line-cull.c \ + line-smooth.c \ line-stipple-wide.c \ line-userclip-clip.c \ line-userclip-nop-clip.c \ diff --git a/progs/trivial/line-smooth.c b/progs/trivial/line-smooth.c new file mode 100644 index 00000000000..f030de9b9fe --- /dev/null +++ b/progs/trivial/line-smooth.c @@ -0,0 +1,172 @@ +/* + * 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 +#include +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer; +GLboolean smooth = GL_TRUE; +GLfloat width = 1.0; + + +static void Init(void) +{ + float range[2], aarange[2]; + 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)); + glGetFloatv(GL_LINE_WIDTH_RANGE, aarange); + glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, range); + printf("Non-AA line width range: %f .. %f\n", range[0], range[1]); + printf("AA line width range: %f .. %f\n", aarange[0], aarange[1]); +} + + +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); + glLoadIdentity(); + glTranslatef(0, 0, -30); +} + +static void Key(unsigned char key, int x, int y) +{ + switch (key) { + case 'w': + width -= 0.5; + if (width < 0.5) + width = 0.5; + break; + case 'W': + width += 0.5; + break; + case 's': + smooth = !smooth; + break; + case 27: + exit(1); + default: + return; + } + printf("LineWidth: %g\n", width); + glutPostRedisplay(); +} + + +static void Draw(void) +{ + float a; + + glClear(GL_COLOR_BUFFER_BIT); + + glLineWidth(width); + + if (smooth) { + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_LINE_SMOOTH); + } + + glColor3f(1, 1, 1); + + glBegin(GL_LINES); + for (a = 0; a < 3.14159; a += 0.2) { + float x = .9 * cos(a); + float y = .9 * sin(a); + + glVertex2f(-x, -y); + glVertex2f( x, y); + } + glEnd(); + + glDisable(GL_LINE_SMOOTH); + glDisable(GL_BLEND); + + 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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow(argv[0]) == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 1e3087cd0315e130248da211811a010bffcaa982 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 23 Apr 2008 13:10:13 +0100 Subject: mesa: add dedicated point-wide-smooth test, restore original tri.c as tri-orig.c --- progs/trivial/Makefile | 2 + progs/trivial/point-wide-smooth.c | 145 ++++++++++++++++++++++++++++++++++++++ progs/trivial/point-wide.c | 15 +--- progs/trivial/tri-orig.c | 136 +++++++++++++++++++++++++++++++++++ 4 files changed, 284 insertions(+), 14 deletions(-) create mode 100644 progs/trivial/point-wide-smooth.c create mode 100644 progs/trivial/tri-orig.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 8bc6ad4e387..48c6caf6382 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -45,6 +45,7 @@ SOURCES = \ point-param.c \ point-sprite.c \ point-wide.c \ + point-wide-smooth.c \ point.c \ poly-flat.c \ poly-unfilled.c \ @@ -69,6 +70,7 @@ SOURCES = \ quadstrip-cont.c \ quadstrip-flat.c \ quadstrip.c \ + tri-orig.c \ tri-alpha.c \ tri-blend-color.c \ tri-blend-max.c \ diff --git a/progs/trivial/point-wide-smooth.c b/progs/trivial/point-wide-smooth.c new file mode 100644 index 00000000000..55cbcaec70b --- /dev/null +++ b/progs/trivial/point-wide-smooth.c @@ -0,0 +1,145 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glPointSize(8.0); + + glEnable(GL_POINT_SMOOTH); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glBegin(GL_POINTS); + glColor3f(1,0,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,1,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(1,0,1); + glVertex3f(-0.9, 0.9, -30.0); + glColor3f(0,1,1); + 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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/point-wide.c b/progs/trivial/point-wide.c index d1038ecfa15..265b20097b1 100644 --- a/progs/trivial/point-wide.c +++ b/progs/trivial/point-wide.c @@ -33,7 +33,6 @@ GLenum doubleBuffer; -static GLboolean smooth = GL_FALSE; static void Init(void) @@ -60,9 +59,6 @@ static void Key(unsigned char key, int x, int y) { switch (key) { - case 's': - smooth = !smooth; - break; case 27: exit(1); default: @@ -75,19 +71,10 @@ static void Key(unsigned char key, int x, int y) static void Draw(void) { glClear(GL_COLOR_BUFFER_BIT); + glDisable(GL_DEPTH_TEST); glPointSize(8.0); - if (smooth) { - glEnable(GL_POINT_SMOOTH); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - else { - glDisable(GL_POINT_SMOOTH); - glDisable(GL_BLEND); - } - glBegin(GL_POINTS); glColor3f(1,0,0); glVertex3f( 0.9, -0.9, -30.0); diff --git a/progs/trivial/tri-orig.c b/progs/trivial/tri-orig.c new file mode 100644 index 00000000000..d5e6742ce1a --- /dev/null +++ b/progs/trivial/tri-orig.c @@ -0,0 +1,136 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 63e6e33db64fc39db16790d0988d370252a96e29 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 24 Apr 2008 12:38:58 +0100 Subject: trivial: simple edgeflag test --- progs/trivial/Makefile | 1 + progs/trivial/tri-unfilled-edgeflag.c | 141 ++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 progs/trivial/tri-unfilled-edgeflag.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 48c6caf6382..1dbc4721e87 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -94,6 +94,7 @@ SOURCES = \ tri-stencil.c \ tri-tex-3d.c \ tri-tri.c \ + tri-unfilled-edgeflag.c \ tri-unfilled-clip.c \ tri-unfilled-smooth.c \ tri-unfilled-userclip-stip.c \ diff --git a/progs/trivial/tri-unfilled-edgeflag.c b/progs/trivial/tri-unfilled-edgeflag.c new file mode 100644 index 00000000000..31f41f6220b --- /dev/null +++ b/progs/trivial/tri-unfilled-edgeflag.c @@ -0,0 +1,141 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glPolygonMode(GL_FRONT, GL_LINE); + glPolygonMode(GL_BACK, GL_LINE); + + glBegin(GL_TRIANGLES); + glEdgeFlag(1); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glEdgeFlag(0); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glEdgeFlag(1); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From d915f40195fc20669c4720b597a3f7299508c507 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 10 Jun 2008 12:58:13 +0100 Subject: trivial: add tristrip-flat to makefile --- progs/trivial/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 1dbc4721e87..594a9bddb2c 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -105,6 +105,7 @@ SOURCES = \ tri-z.c \ tri.c \ tristrip-clip.c \ + tristrip-flat.c \ tristrip.c \ vbo-drawarrays.c \ vbo-drawelements.c \ -- cgit v1.2.3 From f5801fba247d8b0b5afe01196e9c7da7437d18ff Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 10 Jun 2008 14:09:45 +0100 Subject: trivial: add poly-flat-clip tests --- progs/trivial/Makefile | 2 + progs/trivial/poly-flat-clip.c | 8 +- progs/trivial/poly-flat-unfilled-clip.c | 144 ++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 progs/trivial/poly-flat-unfilled-clip.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 594a9bddb2c..cbfcdfcf5bf 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -48,6 +48,8 @@ SOURCES = \ point-wide-smooth.c \ point.c \ poly-flat.c \ + poly-flat-clip.c \ + poly-flat-unfilled-clip.c \ poly-unfilled.c \ poly.c \ quad-clip-all-vertices.c \ diff --git a/progs/trivial/poly-flat-clip.c b/progs/trivial/poly-flat-clip.c index bd8d347c999..72c2a29a0d2 100644 --- a/progs/trivial/poly-flat-clip.c +++ b/progs/trivial/poly-flat-clip.c @@ -75,13 +75,13 @@ static void Draw(void) glBegin(GL_POLYGON); glColor3f(1,0,0); - glVertex3f( 1.1, -1.1, -30.0); + glVertex3f( 0, 0, -30.0); glColor3f(1,1,0); - glVertex3f( 1.1, 1.1, -30.0); + glVertex3f( 1.3, 1.1, -30.0); glColor3f(1,0,1); - glVertex3f(-1.1, 1.1, -30.0); + glVertex3f(-.9, .9, -30.0); glColor3f(0,1,1); - glVertex3f(-1.1, -1.1, -30.0); + glVertex3f(-1.1, -1.3, -30.0); glEnd(); glFlush(); diff --git a/progs/trivial/poly-flat-unfilled-clip.c b/progs/trivial/poly-flat-unfilled-clip.c new file mode 100644 index 00000000000..d3a14a516a4 --- /dev/null +++ b/progs/trivial/poly-flat-unfilled-clip.c @@ -0,0 +1,144 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glShadeModel(GL_FLAT); + + glPolygonMode(GL_FRONT, GL_LINE); + glPolygonMode(GL_BACK, GL_LINE); + glLineWidth(4.0); + + + glBegin(GL_POLYGON); + glColor3f(1,0,0); + glVertex3f( 0, 0, -30.0); + glColor3f(1,1,0); + glVertex3f( 1.3, 1.1, -30.0); + glColor3f(1,0,1); + glVertex3f(-.9, .9, -30.0); + glColor3f(0,1,1); + glVertex3f(-1.1, -1.3, -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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From ac833b9aeff1957769c271dd6d390b6b28d59e4c Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 10 Jun 2008 14:23:49 +0100 Subject: trivial: add trifan tests --- progs/trivial/Makefile | 5 ++ progs/trivial/trifan-flat-clip.c | 140 +++++++++++++++++++++++++++++ progs/trivial/trifan-flat-unfilled-clip.c | 144 ++++++++++++++++++++++++++++++ progs/trivial/trifan-flat.c | 140 +++++++++++++++++++++++++++++ progs/trivial/trifan-unfilled.c | 139 ++++++++++++++++++++++++++++ progs/trivial/trifan.c | 138 ++++++++++++++++++++++++++++ 6 files changed, 706 insertions(+) create mode 100644 progs/trivial/trifan-flat-clip.c create mode 100644 progs/trivial/trifan-flat-unfilled-clip.c create mode 100644 progs/trivial/trifan-flat.c create mode 100644 progs/trivial/trifan-unfilled.c create mode 100644 progs/trivial/trifan.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index cbfcdfcf5bf..e88c239cd5e 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -106,6 +106,11 @@ SOURCES = \ tri-z-eq.c \ tri-z.c \ tri.c \ + trifan-flat.c \ + trifan-flat-clip.c \ + trifan-flat-unfilled-clip.c \ + trifan-unfilled.c \ + trifan.c \ tristrip-clip.c \ tristrip-flat.c \ tristrip.c \ diff --git a/progs/trivial/trifan-flat-clip.c b/progs/trivial/trifan-flat-clip.c new file mode 100644 index 00000000000..04042fac704 --- /dev/null +++ b/progs/trivial/trifan-flat-clip.c @@ -0,0 +1,140 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glShadeModel(GL_FLAT); + + + glBegin(GL_TRIANGLE_FAN); + glColor3f(1,0,0); + glVertex3f( 0, 0, -30.0); + glColor3f(1,1,0); + glVertex3f( 1.3, 1.1, -30.0); + glColor3f(1,0,1); + glVertex3f(-.9, .9, -30.0); + glColor3f(0,1,1); + glVertex3f(-1.1, -1.3, -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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/trifan-flat-unfilled-clip.c b/progs/trivial/trifan-flat-unfilled-clip.c new file mode 100644 index 00000000000..25224412cc9 --- /dev/null +++ b/progs/trivial/trifan-flat-unfilled-clip.c @@ -0,0 +1,144 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glShadeModel(GL_FLAT); + + glPolygonMode(GL_FRONT, GL_LINE); + glPolygonMode(GL_BACK, GL_LINE); + glLineWidth(4.0); + + + glBegin(GL_TRIANGLE_FAN); + glColor3f(1,0,0); + glVertex3f( 0, 0, -30.0); + glColor3f(1,1,0); + glVertex3f( 1.3, 1.1, -30.0); + glColor3f(1,0,1); + glVertex3f(-.9, .9, -30.0); + glColor3f(0,1,1); + glVertex3f(-1.1, -1.3, -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; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/trifan-flat.c b/progs/trivial/trifan-flat.c new file mode 100644 index 00000000000..737eccdcae7 --- /dev/null +++ b/progs/trivial/trifan-flat.c @@ -0,0 +1,140 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glShadeModel(GL_FLAT); + + + glBegin(GL_TRIANGLE_FAN); + glColor3f(1,0,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,1,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(1,0,1); + glVertex3f(-0.9, 0.9, -30.0); + glColor3f(0,1,1); + 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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/trifan-unfilled.c b/progs/trivial/trifan-unfilled.c new file mode 100644 index 00000000000..8e7454108c0 --- /dev/null +++ b/progs/trivial/trifan-unfilled.c @@ -0,0 +1,139 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + + glBegin(GL_TRIANGLE_FAN); + glColor3f(1,0,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,1,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(1,0,1); + glVertex3f(-0.9, 0.9, -30.0); + glColor3f(0,1,1); + 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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/trifan.c b/progs/trivial/trifan.c new file mode 100644 index 00000000000..ecb0424393e --- /dev/null +++ b/progs/trivial/trifan.c @@ -0,0 +1,138 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLE_FAN); + glColor3f(1,0,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,1,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(1,0,1); + glVertex3f(-0.9, 0.9, -30.0); + glColor3f(0,1,1); + 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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 3bdeff5becbba27d57250f761777bedbdcb66a1e Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 11 Jun 2008 09:18:42 +0100 Subject: trivial: add test for integer vertex arrays --- progs/trivial/Makefile | 1 + progs/trivial/vp-array-int.c | 117 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 progs/trivial/vp-array-int.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index e88c239cd5e..9e32bd7c26b 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -118,6 +118,7 @@ SOURCES = \ vbo-drawelements.c \ vbo-drawrange.c \ vp-array.c \ + vp-array-int.c \ vp-clip.c \ vp-line-clip.c \ vp-tri.c \ diff --git a/progs/trivial/vp-array-int.c b/progs/trivial/vp-array-int.c new file mode 100644 index 00000000000..4d60f2bd5f5 --- /dev/null +++ b/progs/trivial/vp-array-int.c @@ -0,0 +1,117 @@ +/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +GLint verts[][4] = { + { 1, -1, 0, 1 }, + { 1, 1, 0, 1 }, + { -1, 1, 0, 1 }, + { -1, -1, 0, 1 }, +}; + +GLubyte color[][4] = { + { 0x00, 0x00, 0xff, 0x00 }, + { 0x00, 0xff, 0x00, 0x00 }, + { 0xff, 0x00, 0x00, 0x00 }, + { 0xff, 0xff, 0xff, 0x00 }, +}; + +GLuint indices[] = { 0, 1, 2, 3 }; + +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_INT, sizeof(verts[0]), verts ); + glColorPointer( 4, GL_UNSIGNED_BYTE, 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_NV); + glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, indices ); + + 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]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 39bd7eb6dcd97e61096bbae4041cd5eeff21e767 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 13 Jun 2008 17:42:44 +0200 Subject: trival: Added test for undefined context of buffer --- progs/trivial/Makefile | 1 + progs/trivial/clear-undefined.c | 130 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 progs/trivial/clear-undefined.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 9e32bd7c26b..786576cd13b 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -14,6 +14,7 @@ SOURCES = \ clear-fbo-tex.c \ clear-fbo.c \ clear-scissor.c \ + clear-undefined.c \ clear.c \ dlist-dangling.c \ dlist-edgeflag-dangling.c \ diff --git a/progs/trivial/clear-undefined.c b/progs/trivial/clear-undefined.c new file mode 100644 index 00000000000..1569860f7a2 --- /dev/null +++ b/progs/trivial/clear-undefined.c @@ -0,0 +1,130 @@ +/* + * glClear + glScissor + Undefined content of framebuffer + */ + +#include +#include +#include +#include + + +GLenum doubleBuffer; +GLint Width = 200, Height = 150; + +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)); + fprintf(stderr, "Top right corner should be red\n"); +} + +static void Reshape(int width, int height) +{ + Width = width; + Height = 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: + glutPostRedisplay(); + return; + } + +} + +static void Draw(void) +{ + glColor4f(1.0, 0.0, 0.0, 1.0); + glBegin(GL_QUADS); + glVertex2d(0.0, 0.0); + glVertex2d(0.0, 1.0); + glVertex2d(1.0, 1.0); + glVertex2d(1.0, 0.0); + glEnd(); + + glEnable(GL_SCISSOR_TEST); + glClearColor(1, 1, 0, 0); + glScissor(Width / 2, 0, Width - Width / 2, Height / 2); + glClear(GL_COLOR_BUFFER_BIT); + + glClearColor(0, 0, 1, 0); + glScissor(0, Height / 2, Width / 2, Height - Height / 2); + glClear(GL_COLOR_BUFFER_BIT); + glDisable(GL_SCISSOR_TEST); + + glColor4f(0.0, 1.0, 0.0, 1.0); + glBegin(GL_QUADS); + glVertex2d( 0.0, 0.0); + glVertex2d( 0.0, -1.0); + glVertex2d(-1.0, -1.0); + glVertex2d(-1.0, 0.0); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_TRUE; + + 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( Width, Height ); + + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow(argv[0]) == GL_FALSE) { + exit(1); + } + + Init(); + Reshape(Width, Height); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 380385ab7d0c1964464b40aeea237671189d19cb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 28 Aug 2008 15:22:44 -0600 Subject: mesa: added test for very long fixed-function vertex programs --- progs/trivial/Makefile | 1 + progs/trivial/long-fixed-func.c | 151 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 progs/trivial/long-fixed-func.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 786576cd13b..d745fefbbf4 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -41,6 +41,7 @@ SOURCES = \ linestrip-stipple-wide.c \ linestrip-stipple.c \ linestrip.c \ + long-fixed-func.c \ pgon-mode.c \ point-clip.c \ point-param.c \ diff --git a/progs/trivial/long-fixed-func.c b/progs/trivial/long-fixed-func.c new file mode 100644 index 00000000000..88f4fe01ec8 --- /dev/null +++ b/progs/trivial/long-fixed-func.c @@ -0,0 +1,151 @@ +/** + * Enable as much fixed-function vertex processing state as possible + * to test fixed-function -> program code generation. + */ + + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include + + +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 +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(); + + glutSwapBuffers(); +} + + +static void +Init(void) +{ + GLubyte tex[16][16][4]; + GLfloat pos[4] = {5, 10, 3, 1.0}; + int i, j; + + 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); + + for (i = 0; i < 16; i++) { + for (j = 0; j < 16; j++) { + if ((i+j) & 1) { + tex[i][j][0] = 100; + tex[i][j][1] = 100; + tex[i][j][2] = 100; + tex[i][j][3] = 255; + } + else { + tex[i][j][0] = 200; + tex[i][j][1] = 200; + tex[i][j][2] = 200; + tex[i][j][3] = 255; + } + } + } + + + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1); + glFogi(GL_FOG_MODE, GL_LINEAR); + glEnable(GL_FOG); + + glPointParameterfv(GL_DISTANCE_ATTENUATION_EXT, pos); + + for (i = 0; i < 8; i++) { + GLuint texObj; + + glEnable(GL_LIGHT0 + i); + glLightf(GL_LIGHT0 + i, GL_SPOT_EXPONENT, 3.5); + glLightf(GL_LIGHT0 + i, GL_SPOT_CUTOFF, 30.); + glLightf(GL_LIGHT0 + i, GL_CONSTANT_ATTENUATION, 3.); + glLightf(GL_LIGHT0 + i, GL_LINEAR_ATTENUATION, 3.); + glLightf(GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, 3.); + glLightfv(GL_LIGHT0 + i, GL_POSITION, pos); + + glActiveTexture(GL_TEXTURE0 + i); + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + glEnable(GL_TEXTURE_GEN_R); + glEnable(GL_TEXTURE_GEN_Q); + glEnable(GL_TEXTURE_2D); + + glMatrixMode(GL_TEXTURE); + glScalef(2.0, 1.0, 3.0); + + glGenTextures(1, &texObj); + glBindTexture(GL_TEXTURE_2D, texObj); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, tex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } + + glEnable(GL_LIGHTING); + glActiveTexture(GL_TEXTURE0); + glMatrixMode(GL_MODELVIEW); +} + + +static void +Key(unsigned char key, int x, int y) +{ + if (key == 27) { + exit(0); + } + glutPostRedisplay(); +} + + +int +main(int argc, char **argv) +{ + GLenum type = GLUT_RGB | GLUT_DOUBLE; + + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize( 250, 250); + glutInitDisplayMode(type); + if (glutCreateWindow("tri-long-fixedfunc") == GL_FALSE) { + exit(1); + } + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 90c93bbeeec1a8ca75b68004afc5d8cb689860bc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Sep 2008 11:00:54 -0600 Subject: define new APP_CC configuration variable for building apps/demos/tests For Cell, need to use different compilers for the libraries vs. the demos/tests to avoid strange link error regarding "_Unwind_GetIPInfo@GCC_4.2.0" --- configs/default | 4 ++++ configs/linux-cell | 4 +++- progs/demos/Makefile | 28 ++++++++++++++-------------- progs/glsl/Makefile | 12 ++++++------ progs/redbook/Makefile | 2 +- progs/samples/Makefile | 8 ++++---- progs/tests/Makefile | 40 ++++++++++++++++++++-------------------- progs/trivial/Makefile | 16 ++++++++-------- progs/xdemos/Makefile | 22 +++++++++++----------- 9 files changed, 71 insertions(+), 65 deletions(-) (limited to 'progs/trivial/Makefile') diff --git a/configs/default b/configs/default index cd2c39c3650..94582d82746 100644 --- a/configs/default +++ b/configs/default @@ -23,6 +23,10 @@ CFLAGS = -O CXXFLAGS = -O GLU_CFLAGS = +# Compiler for building demos/tests/etc +APP_CC = $(CC) +APP_CXX = $(CXX) + # Misc tools and flags MKLIB_OPTIONS = MKDEP = makedepend diff --git a/configs/linux-cell b/configs/linux-cell index cdaa17c6636..86651b83d7b 100644 --- a/configs/linux-cell +++ b/configs/linux-cell @@ -12,6 +12,8 @@ GALLIUM_DRIVER_DIRS += cell CC = ppu32-gcc CXX = ppu32-g++ HOST_CC = gcc +APP_CC = gcc +APP_CXX = g++ OPT_FLAGS = -O3 @@ -19,7 +21,7 @@ OPT_FLAGS = -O3 ## For SDK 2.1: (plus, remove -DSPU_MAIN_PARAM_LONG_LONG below) #SDK = /opt/ibm/cell-sdk/prototype/sysroot/usr ## For SDK 3.0: -SDK = /opt/cell/sdk/usr/ +SDK = /opt/cell/sdk/usr CFLAGS = $(OPT_FLAGS) -Wall -Winline -fPIC -m32 -mabi=altivec -maltivec \ diff --git a/progs/demos/Makefile b/progs/demos/Makefile index 43874ecdaa0..fe0e0fbd91b 100644 --- a/progs/demos/Makefile +++ b/progs/demos/Makefile @@ -74,7 +74,7 @@ PROGS = \ # make executable from .c file: .c: $(LIB_DEP) readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@ ##### TARGETS ##### @@ -90,7 +90,7 @@ readtex.h: $(TOP)/progs/util/readtex.h cp $< . readtex.o: readtex.c readtex.h - $(CC) -c -I$(INCDIR) $(CFLAGS) readtex.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) readtex.c showbuffer.c: $(TOP)/progs/util/showbuffer.c @@ -100,7 +100,7 @@ showbuffer.h: $(TOP)/progs/util/showbuffer.h cp $< . showbuffer.o: showbuffer.c showbuffer.h - $(CC) -c -I$(INCDIR) $(CFLAGS) showbuffer.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) showbuffer.c trackball.c: $(TOP)/progs/util/trackball.c @@ -110,7 +110,7 @@ trackball.h: $(TOP)/progs/util/trackball.h cp $< . trackball.o: trackball.c trackball.h - $(CC) -c -I$(INCDIR) $(CFLAGS) trackball.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) trackball.c extfuncs.h: $(TOP)/progs/util/extfuncs.h @@ -118,38 +118,38 @@ extfuncs.h: $(TOP)/progs/util/extfuncs.h reflect: reflect.o showbuffer.o readtex.o - $(CC) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ + $(APP_CC) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ reflect.o: reflect.c showbuffer.h - $(CC) -c -I$(INCDIR) $(CFLAGS) reflect.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) reflect.c shadowtex: shadowtex.o showbuffer.o - $(CC) shadowtex.o showbuffer.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ + $(APP_CC) shadowtex.o showbuffer.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ shadowtex.o: shadowtex.c showbuffer.h - $(CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c gloss: gloss.o trackball.o readtex.o - $(CC) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ + $(APP_CC) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ gloss.o: gloss.c trackball.h - $(CC) -c -I$(INCDIR) $(CFLAGS) gloss.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) gloss.c engine: engine.o trackball.o readtex.o - $(CC) engine.o trackball.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ + $(APP_CC) engine.o trackball.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ engine.o: engine.c trackball.h - $(CC) -c -I$(INCDIR) $(CFLAGS) engine.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) engine.c fslight: fslight.o - $(CC) fslight.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ + $(APP_CC) fslight.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@ fslight.o: fslight.c extfuncs.h - $(CC) -c -I$(INCDIR) $(CFLAGS) fslight.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) fslight.c diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index b9cae668152..9c1d3f8126b 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -26,7 +26,7 @@ PROGS = \ # make executable from .c file: .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ ##### TARGETS ##### @@ -47,7 +47,7 @@ readtex.h: $(TOP)/progs/util/readtex.h cp $< . readtex.o: readtex.c readtex.h - $(CC) -c -I$(INCDIR) $(CFLAGS) readtex.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) readtex.c brick.c: extfuncs.h @@ -58,16 +58,16 @@ mandelbrot.c: extfuncs.h toyball.c: extfuncs.h texdemo1: texdemo1.o readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) texdemo1.o readtex.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) texdemo1.o readtex.o $(APP_LIB_DEPS) -o $@ texdemo1.o: texdemo1.c readtex.h extfuncs.h - $(CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c convolutions: convolutions.o readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) convolutions.o readtex.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) convolutions.o readtex.o $(APP_LIB_DEPS) -o $@ convolutions.o: convolutions.c readtex.h - $(CC) -c -I$(INCDIR) $(CFLAGS) convolutions.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) convolutions.c clean: diff --git a/progs/redbook/Makefile b/progs/redbook/Makefile index febc74441b9..956c398873a 100644 --- a/progs/redbook/Makefile +++ b/progs/redbook/Makefile @@ -24,7 +24,7 @@ PROGS = aaindex aapoly aargb accanti accpersp alpha alpha3D anti \ .SUFFIXES: .c .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ diff --git a/progs/samples/Makefile b/progs/samples/Makefile index 063008dccff..25ce14740a8 100644 --- a/progs/samples/Makefile +++ b/progs/samples/Makefile @@ -18,7 +18,7 @@ PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \ .SUFFIXES: .c .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ ##### TARGETS ##### @@ -27,10 +27,10 @@ default: $(PROGS) sphere: sphere.o readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) sphere.o readtex.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) sphere.o readtex.o $(APP_LIB_DEPS) -o $@ sphere.o: sphere.c readtex.h - $(CC) -c -I$(INCDIR) $(CFLAGS) sphere.c + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) sphere.c readtex.c: $(TOP)/progs/util/readtex.c cp $< . @@ -39,7 +39,7 @@ readtex.h: $(TOP)/progs/util/readtex.h cp $< . readtex.o: readtex.c readtex.h - $(CC) -c -I$(INCDIR) $(CFLAGS) $< -o $@ + $(APP_CC) -c -I$(INCDIR) $(CFLAGS) $< -o $@ clean: diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 3bead54e200..9c81f870d88 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -103,13 +103,13 @@ UTIL_FILES = readtex.h readtex.c .SUFFIXES: .c .c: - $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ + $(APP_CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ .c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ .S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ ##### TARGETS ##### @@ -129,58 +129,58 @@ getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress. python getprocaddress.py > getproclist.h arraytexture: arraytexture.o readtex.o - $(CC) $(CFLAGS) arraytexture.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) arraytexture.o readtex.o $(LIBS) -o $@ arraytexture.o: arraytexture.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ afsmultiarb: afsmultiarb.o readtex.o - $(CC) $(CFLAGS) afsmultiarb.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) afsmultiarb.o readtex.o $(LIBS) -o $@ afsmultiarb.o: afsmultiarb.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ drawbuffers: drawbuffers.o - $(CC) $(CFLAGS) drawbuffers.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) drawbuffers.o $(LIBS) -o $@ drawbuffers.o: drawbuffers.c extfuncs.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ texrect: texrect.o readtex.o - $(CC) $(CFLAGS) texrect.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) texrect.o readtex.o $(LIBS) -o $@ texrect.o: texrect.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ bug_3195: bug_3195.o readtex.o - $(CC) $(CFLAGS) bug_3195.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) bug_3195.o readtex.o $(LIBS) -o $@ bug_3195.o: bug_3195.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ invert: invert.o readtex.o - $(CC) $(CFLAGS) invert.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) invert.o readtex.o $(LIBS) -o $@ invert.o: invert.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ mipmap_view: mipmap_view.o readtex.o - $(CC) $(CFLAGS) mipmap_view.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) mipmap_view.o readtex.o $(LIBS) -o $@ mipmap_view.o: mipmap_view.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ fillrate: fillrate.o readtex.o - $(CC) $(CFLAGS) fillrate.o readtex.o $(LIBS) -o $@ + $(APP_CC) $(CFLAGS) fillrate.o readtex.o $(LIBS) -o $@ fillrate.o: fillrate.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ readtex.o: readtex.c - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ readtex.h: $(TOP)/progs/util/readtex.h diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index d745fefbbf4..c868ab6e6ff 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -139,13 +139,13 @@ UTIL_FILES = readtex.h readtex.c .SUFFIXES: .c .c: - $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ + $(APP_CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ .c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ .S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ ##### TARGETS ##### @@ -166,19 +166,19 @@ getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress. texrect: texrect.o readtex.o - $(CC) texrect.o readtex.o $(LIBS) -o $@ + $(APP_CC) texrect.o readtex.o $(LIBS) -o $@ texrect.o: texrect.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ invert: invert.o readtex.o - $(CC) invert.o readtex.o $(LIBS) -o $@ + $(APP_CC) invert.o readtex.o $(LIBS) -o $@ invert.o: invert.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ readtex.o: readtex.c - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ readtex.h: $(TOP)/progs/util/readtex.h diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile index 896b1608780..38f3884d589 100644 --- a/progs/xdemos/Makefile +++ b/progs/xdemos/Makefile @@ -39,7 +39,7 @@ PROGS = glthreads \ .SUFFIXES: .c .c: $(LIB_DEP) - $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ ##### TARGETS ##### @@ -54,32 +54,32 @@ clean: # special cases pbinfo: pbinfo.o pbutil.o - $(CC) -I$(INCDIR) $(CFLAGS) pbinfo.o pbutil.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) pbinfo.o pbutil.o $(APP_LIB_DEPS) -o $@ pbdemo: pbdemo.o pbutil.o - $(CC) -I$(INCDIR) $(CFLAGS) pbdemo.o pbutil.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) pbdemo.o pbutil.o $(APP_LIB_DEPS) -o $@ pbinfo.o: pbinfo.c pbutil.h - $(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbinfo.c + $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) pbinfo.c pbdemo.o: pbdemo.c pbutil.h - $(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbdemo.c + $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) pbdemo.c pbutil.o: pbutil.c pbutil.h - $(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbutil.c + $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) pbutil.c glxgears_fbconfig: glxgears_fbconfig.o pbutil.o - $(CC) -I$(INCDIR) $(CFLAGS) glxgears_fbconfig.o pbutil.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) glxgears_fbconfig.o pbutil.o $(APP_LIB_DEPS) -o $@ glxgears_fbconfig.o: glxgears_fbconfig.c pbutil.h - $(CC) -I$(INCDIR) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c + $(APP_CC) -I$(INCDIR) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c xrotfontdemo: xrotfontdemo.o xuserotfont.o - $(CC) -I$(INCDIR) $(CFLAGS) xrotfontdemo.o xuserotfont.o $(APP_LIB_DEPS) -o $@ + $(APP_CC) -I$(INCDIR) $(CFLAGS) xrotfontdemo.o xuserotfont.o $(APP_LIB_DEPS) -o $@ xuserotfont.o: xuserotfont.c xuserotfont.h - $(CC) -c -I. -I$(INCDIR) $(CFLAGS) xuserotfont.c + $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) xuserotfont.c xrotfontdemo.o: xrotfontdemo.c xuserotfont.h - $(CC) -c -I. -I$(INCDIR) $(CFLAGS) xrotfontdemo.c + $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) xrotfontdemo.c -- cgit v1.2.3 From a381c9e8b32af6e98879940eba5f11680d4b89b6 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 7 Oct 2008 13:09:05 +0100 Subject: trivial: exercise vertprog sligtly --- progs/trivial/Makefile | 1 + progs/trivial/vp-tri-swap.c | 103 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 progs/trivial/vp-tri-swap.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index c868ab6e6ff..65937f2f3f5 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -124,6 +124,7 @@ SOURCES = \ vp-clip.c \ vp-line-clip.c \ vp-tri.c \ + vp-tri-swap.c \ vp-unfilled.c PROGS = $(SOURCES:%.c=%) diff --git a/progs/trivial/vp-tri-swap.c b/progs/trivial/vp-tri-swap.c new file mode 100644 index 00000000000..e9ca1a03789 --- /dev/null +++ b/progs/trivial/vp-tri-swap.c @@ -0,0 +1,103 @@ +/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static void Init( void ) +{ + GLint errno; + GLuint prognum; + + static const char *prog1 = + "!!ARBvp1.0\n" + "MOV result.position, vertex.color;\n" + "MOV result.color, 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)); + } +} + +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_NV); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.0); + glEnd(); + + + 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_DEPTH | GLUT_RGB | GLUT_SINGLE ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 1ec78df1e76a58f23cadce7b22d34849af83bf84 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 7 Oct 2008 19:12:26 +0100 Subject: trivial: add more vp tests --- progs/trivial/Makefile | 2 + progs/trivial/vp-tri-cb.c | 107 +++++++++++++++++++++++++++++++++++++++++++++ progs/trivial/vp-tri-imm.c | 101 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 progs/trivial/vp-tri-cb.c create mode 100644 progs/trivial/vp-tri-imm.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 65937f2f3f5..d2821718260 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -125,6 +125,8 @@ SOURCES = \ vp-line-clip.c \ vp-tri.c \ vp-tri-swap.c \ + vp-tri-imm.c \ + vp-tri-cb.c \ vp-unfilled.c PROGS = $(SOURCES:%.c=%) diff --git a/progs/trivial/vp-tri-cb.c b/progs/trivial/vp-tri-cb.c new file mode 100644 index 00000000000..f9d0d7f559d --- /dev/null +++ b/progs/trivial/vp-tri-cb.c @@ -0,0 +1,107 @@ +/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static void Init( void ) +{ + GLint errno; + GLuint prognum; + + static const char *prog1 = + "!!ARBvp1.0\n" + "PARAM Diffuse = state.material.diffuse; \n" + "MOV result.color, Diffuse;\n" + "MOV result.position, vertex.position;\n" + "END\n"; + + const float Diffuse[4] = { 0.0, 1.0, 0.0, 1.0 }; + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse); + + + 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)); + } +} + +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_NV); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.0); + glEnd(); + + + 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_DEPTH | GLUT_RGB | GLUT_SINGLE ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/vp-tri-imm.c b/progs/trivial/vp-tri-imm.c new file mode 100644 index 00000000000..c774573ba8b --- /dev/null +++ b/progs/trivial/vp-tri-imm.c @@ -0,0 +1,101 @@ +/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static void Init( void ) +{ + GLint errno; + GLuint prognum; + + static const char *prog1 = + "!!ARBvp1.0\n" + "ADD result.color, vertex.color, {.5}.x;\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)); + } +} + +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_NV); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,0); + glVertex3f( 0.9, -0.9, -0.0); + glVertex3f( 0.9, 0.9, -0.0); + glVertex3f(-0.9, 0.0, -0.0); + glEnd(); + + + 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_DEPTH | GLUT_RGB | GLUT_SINGLE ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 055d986efefa310d6ffd1106e565ca2f5964159a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 14 Oct 2008 13:56:12 +0100 Subject: trivial: more vp tests --- progs/trivial/Makefile | 4 + progs/trivial/tri-tex.c | 168 +++++++++++++++++++++++++++++++++++++ progs/trivial/vp-tri-cb-pos.c | 156 ++++++++++++++++++++++++++++++++++ progs/trivial/vp-tri-cb-tex.c | 189 ++++++++++++++++++++++++++++++++++++++++++ progs/trivial/vp-tri-tex.c | 137 ++++++++++++++++++++++++++++++ 5 files changed, 654 insertions(+) create mode 100644 progs/trivial/tri-tex.c create mode 100644 progs/trivial/vp-tri-cb-pos.c create mode 100644 progs/trivial/vp-tri-cb-tex.c create mode 100644 progs/trivial/vp-tri-tex.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index d2821718260..6c8c9fad909 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -96,6 +96,7 @@ SOURCES = \ tri-query.c \ tri-scissor-tri.c \ tri-stencil.c \ + tri-tex.c \ tri-tex-3d.c \ tri-tri.c \ tri-unfilled-edgeflag.c \ @@ -125,8 +126,11 @@ SOURCES = \ vp-line-clip.c \ vp-tri.c \ vp-tri-swap.c \ + vp-tri-tex.c \ vp-tri-imm.c \ vp-tri-cb.c \ + vp-tri-cb-pos.c \ + vp-tri-cb-tex.c \ vp-unfilled.c PROGS = $(SOURCES:%.c=%) diff --git a/progs/trivial/tri-tex.c b/progs/trivial/tri-tex.c new file mode 100644 index 00000000000..a0d75b4a331 --- /dev/null +++ b/progs/trivial/tri-tex.c @@ -0,0 +1,168 @@ +/* + * 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 +#include +#include +#include + + + +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); + + +#define SIZE 32 + { + GLubyte tex2d[SIZE][SIZE][3]; + GLint s, t; + + for (s = 0; s < SIZE; s++) { + for (t = 0; t < SIZE; t++) { +#if 0 + tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255; + tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255; + tex2d[t][s][2] = 0; +#else + tex2d[t][s][0] = s*255/(SIZE-1); + tex2d[t][s][1] = t*255/(SIZE-1); + tex2d[t][s][2] = 0; +#endif + } + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0, + GL_RGB, GL_UNSIGNED_BYTE, tex2d); + + glEnable(GL_TEXTURE_2D); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + } + +} + +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: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glTexCoord2f(1,-1); + glVertex3f( 0.9, -0.9, -0.0); + glTexCoord2f(1,1); + glVertex3f( 0.9, 0.9, -0.0); + glTexCoord2f(-1,0); + glVertex3f(-0.9, 0.0, -0.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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/vp-tri-cb-pos.c b/progs/trivial/vp-tri-cb-pos.c new file mode 100644 index 00000000000..eb3aa0a8dc6 --- /dev/null +++ b/progs/trivial/vp-tri-cb-pos.c @@ -0,0 +1,156 @@ +/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +GLenum doubleBuffer; + +static void Init(void) +{ + GLint errno; + GLuint prognum; + + static const char *prog1 = + "!!ARBvp1.0\n" + "PARAM Emission = state.material.emission; \n" + "PARAM Ambient = state.material.ambient; \n" + "PARAM Diffuse = state.material.diffuse; \n" + "PARAM Specular = state.material.specular; \n" + "DP4 result.position.x, Ambient, vertex.position;\n" + "DP4 result.position.y, Diffuse, vertex.position;\n" + "DP4 result.position.z, Specular, vertex.position;\n" + "DP4 result.position.w, Emission, vertex.position;\n" + "MOV result.color, vertex.color;\n" + "END\n"; + + const float Ambient[4] = { 0.0, 1.0, 0.0, 0.0 }; + const float Diffuse[4] = { 1.0, 0.0, 0.0, 0.0 }; + const float Specular[4] = { 0.0, 0.0, 1.0, 0.0 }; + const float Emission[4] = { 0.0, 0.0, 0.0, 1.0 }; + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Ambient); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular); + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Emission); + + + 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)); + } + + glEnable(GL_VERTEX_PROGRAM_NV); + +} + + +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: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/vp-tri-cb-tex.c b/progs/trivial/vp-tri-cb-tex.c new file mode 100644 index 00000000000..1e99d5b6abc --- /dev/null +++ b/progs/trivial/vp-tri-cb-tex.c @@ -0,0 +1,189 @@ +/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + + +GLenum doubleBuffer; + +static void Init(void) +{ + GLint errno; + GLuint prognum; + + static const char *prog1 = + "!!ARBvp1.0\n" + "PARAM Emission = state.material.emission; \n" + "PARAM Ambient = state.material.ambient; \n" + "PARAM Diffuse = state.material.diffuse; \n" + "PARAM Specular = state.material.specular; \n" + "DP4 result.position.x, Ambient, vertex.position;\n" + "DP4 result.position.y, Diffuse, vertex.position;\n" + "DP4 result.position.z, Specular, vertex.position;\n" + "DP4 result.position.w, Emission, vertex.position;\n" + "MOV result.texcoord[0], vertex.texcoord[0];\n" + "END\n"; + + const float Ambient[4] = { 0.0, 1.0, 0.0, 0.0 }; + const float Diffuse[4] = { 1.0, 0.0, 0.0, 0.0 }; + const float Specular[4] = { 0.0, 0.0, 1.0, 0.0 }; + const float Emission[4] = { 0.0, 0.0, 0.0, 1.0 }; + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Ambient); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular); + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Emission); + + + 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)); + } + + glEnable(GL_VERTEX_PROGRAM_NV); + +#define SIZE 32 + { + GLubyte tex2d[SIZE][SIZE][3]; + GLint s, t; + + for (s = 0; s < SIZE; s++) { + for (t = 0; t < SIZE; t++) { +#if 0 + tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255; + tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255; + tex2d[t][s][2] = 0; +#else + tex2d[t][s][0] = s*255/(SIZE-1); + tex2d[t][s][1] = t*255/(SIZE-1); + tex2d[t][s][2] = 0; +#endif + } + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0, + GL_RGB, GL_UNSIGNED_BYTE, tex2d); + + glEnable(GL_TEXTURE_2D); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + } + +} + + +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: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glTexCoord2f(1,-1); + glVertex3f( 0.9, -0.9, -0.0); + glTexCoord2f(1,1); + glVertex3f( 0.9, 0.9, -0.0); + glTexCoord2f(-1,0); + glVertex3f(-0.9, 0.0, -0.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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/vp-tri-tex.c b/progs/trivial/vp-tri-tex.c new file mode 100644 index 00000000000..83ec1ef2e2f --- /dev/null +++ b/progs/trivial/vp-tri-tex.c @@ -0,0 +1,137 @@ +/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +static void Init( void ) +{ + GLint errno; + GLuint prognum; + + static const char *prog1 = + "!!ARBvp1.0\n" + "MOV result.texcoord[0], vertex.texcoord[0];\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)); + } + +#define SIZE 32 + { + GLubyte tex2d[SIZE][SIZE][3]; + GLint s, t; + + for (s = 0; s < SIZE; s++) { + for (t = 0; t < SIZE; t++) { +#if 0 + tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255; + tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255; + tex2d[t][s][2] = 0; +#else + tex2d[t][s][0] = s*255/(SIZE-1); + tex2d[t][s][1] = t*255/(SIZE-1); + tex2d[t][s][2] = 0; +#endif + } + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0, + GL_RGB, GL_UNSIGNED_BYTE, tex2d); + + glEnable(GL_TEXTURE_2D); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + } + +} + +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_NV); + + glBegin(GL_TRIANGLES); + glTexCoord2f(1,-1); + glVertex3f( 0.9, -0.9, -0.0); + glTexCoord2f(1,1); + glVertex3f( 0.9, 0.9, -0.0); + glTexCoord2f(-1,0); + glVertex3f(-0.9, 0.0, -0.0); + glEnd(); + + + 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_DEPTH | GLUT_RGB | GLUT_SINGLE ); + glutCreateWindow(argv[0]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From d04caf2ce47bcf1d9da6e42b749320fce9273390 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 5 Nov 2008 11:31:57 +0000 Subject: trivial: more tests --- progs/trivial/Makefile | 7 ++ progs/trivial/clear-repeat.c | 111 ++++++++++++++++++++++ progs/trivial/tri-fp-const-imm.c | 169 +++++++++++++++++++++++++++++++++ progs/trivial/tri-fp.c | 167 ++++++++++++++++++++++++++++++++ progs/trivial/tri-lit.c | 139 +++++++++++++++++++++++++++ progs/trivial/tri-repeat.c | 118 +++++++++++++++++++++++ progs/trivial/tri-unfilled-tri-lit.c | 178 +++++++++++++++++++++++++++++++++++ progs/trivial/tri-unfilled-tri.c | 175 ++++++++++++++++++++++++++++++++++ 8 files changed, 1064 insertions(+) create mode 100644 progs/trivial/clear-repeat.c create mode 100644 progs/trivial/tri-fp-const-imm.c create mode 100644 progs/trivial/tri-fp.c create mode 100644 progs/trivial/tri-lit.c create mode 100644 progs/trivial/tri-repeat.c create mode 100644 progs/trivial/tri-unfilled-tri-lit.c create mode 100644 progs/trivial/tri-unfilled-tri.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 6c8c9fad909..1b9a50b437b 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -15,6 +15,7 @@ SOURCES = \ clear-fbo.c \ clear-scissor.c \ clear-undefined.c \ + clear-repeat.c \ clear.c \ dlist-dangling.c \ dlist-edgeflag-dangling.c \ @@ -92,8 +93,12 @@ SOURCES = \ tri-flat-clip.c \ tri-flat.c \ tri-fog.c \ + tri-fp.c \ + tri-fp-const-imm.c \ + tri-lit.c \ tri-mask-tri.c \ tri-query.c \ + tri-repeat.c \ tri-scissor-tri.c \ tri-stencil.c \ tri-tex.c \ @@ -102,6 +107,8 @@ SOURCES = \ tri-unfilled-edgeflag.c \ tri-unfilled-clip.c \ tri-unfilled-smooth.c \ + tri-unfilled-tri.c \ + tri-unfilled-tri-lit.c \ tri-unfilled-userclip-stip.c \ tri-unfilled-userclip.c \ tri-unfilled.c \ diff --git a/progs/trivial/clear-repeat.c b/progs/trivial/clear-repeat.c new file mode 100644 index 00000000000..9f9490c6c87 --- /dev/null +++ b/progs/trivial/clear-repeat.c @@ -0,0 +1,111 @@ +/* + * 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 +#include +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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) +{ + static float f = 0; + while (1) { + f += .1; + glClearColor((sin(f)+1)/2.0,(cos(f)+1)/2.0,0.5,1); + glClear(GL_COLOR_BUFFER_BIT); + glutSwapBuffers(); + } + glutPostRedisplay(); +} + +static GLenum Args(int argc, char **argv) +{ + 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 |= GLUT_DOUBLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-fp-const-imm.c b/progs/trivial/tri-fp-const-imm.c new file mode 100644 index 00000000000..71113802ed1 --- /dev/null +++ b/progs/trivial/tri-fp-const-imm.c @@ -0,0 +1,169 @@ +/* + * 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 +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer; + +static void Init(void) +{ + GLint errno; + GLuint prognum; + static const char *prog1 = + "!!ARBfp1.0\n" + "TEMP R1;\n" + "MOV R1, state.material.emission;\n" + "MUL R1, R1, {0.9}.x;\n" + "MOV result.color, R1;\n" + "END\n"; + + + 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)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &prognum); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prognum); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog1), (const GLubyte *)prog1); + + errno = glGetError(); + printf("glGetError = 0x%x\n", errno); + if (errno != GL_NO_ERROR) { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + 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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glTexCoord3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glColor3f(.8,0,0); + glTexCoord3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glColor3f(0,.9,0); + glTexCoord3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-fp.c b/progs/trivial/tri-fp.c new file mode 100644 index 00000000000..9ff355a4caf --- /dev/null +++ b/progs/trivial/tri-fp.c @@ -0,0 +1,167 @@ +/* + * 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 +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer; + +static void Init(void) +{ + GLint errno; + GLuint prognum; + static const char *prog1 = + "!!ARBfp1.0\n" + "MOV result.color, fragment.texcoord[1];\n" +// "MOV result.color, fragment.color;\n" + "END\n"; + + + 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)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &prognum); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prognum); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog1), (const GLubyte *)prog1); + + errno = glGetError(); + printf("glGetError = 0x%x\n", errno); + if (errno != GL_NO_ERROR) { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + 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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glTexCoord3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glColor3f(.8,0,0); + glTexCoord3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glColor3f(0,.9,0); + glTexCoord3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-lit.c b/progs/trivial/tri-lit.c new file mode 100644 index 00000000000..22f199c9828 --- /dev/null +++ b/progs/trivial/tri-lit.c @@ -0,0 +1,139 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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)); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + 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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glNormal3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glNormal3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glNormal3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-repeat.c b/progs/trivial/tri-repeat.c new file mode 100644 index 00000000000..e894269e84b --- /dev/null +++ b/progs/trivial/tri-repeat.c @@ -0,0 +1,118 @@ +/* + * 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 +#include +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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) +{ + static float f = 0; + f += .1; + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f((sin(f)+1)/2.0,0,0); + glVertex3f(-0.9, -0.9, -30.0); + glColor3f(0,(cos(f)+1)/2.0,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(0,0,.7); + glVertex3f( 0.0, 0.9, -30.0); + glEnd(); + + glutSwapBuffers(); + glutPostRedisplay(); +} + +static GLenum Args(int argc, char **argv) +{ + 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 |= GLUT_DOUBLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-unfilled-tri-lit.c b/progs/trivial/tri-unfilled-tri-lit.c new file mode 100644 index 00000000000..f9e1d009884 --- /dev/null +++ b/progs/trivial/tri-unfilled-tri-lit.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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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)); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + 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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glPolygonMode(GL_FRONT, GL_LINE); + glPolygonMode(GL_BACK, GL_LINE); + + glBegin(GL_TRIANGLES); + glNormal3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glNormal3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glNormal3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_FILL); + glPolygonMode(GL_BACK, GL_FILL); + + glBegin(GL_TRIANGLES); + glNormal3f(0,0,.7); + glVertex3f( 0.8, -0.8, -0.0); + glNormal3f(.8,0,0); + glVertex3f( 0.8, 0.8, -0.0); + glNormal3f(0,.9,0); + glVertex3f(-0.8, 0.0, -0.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_LINE); + glPolygonMode(GL_BACK, GL_LINE); + + glBegin(GL_TRIANGLES); + glNormal3f(.8,0,0); + glVertex3f( -0.9, 0.9, -0.0); + glNormal3f(0,0,.7); + glVertex3f( -0.9, -0.9, -0.0); + glNormal3f(0,.9,0); + glVertex3f( 0.9, 0.0, -0.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_FILL); + glPolygonMode(GL_BACK, GL_FILL); + + glBegin(GL_TRIANGLES); + glNormal3f(.8,0,0); + glVertex3f( -0.8, 0.8, -0.0); + glNormal3f(0,0,.7); + glVertex3f( -0.8, -0.8, -0.0); + glNormal3f(0,.9,0); + glVertex3f( 0.8, 0.0, -0.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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-unfilled-tri.c b/progs/trivial/tri-unfilled-tri.c new file mode 100644 index 00000000000..d9a9faeb9f5 --- /dev/null +++ b/progs/trivial/tri-unfilled-tri.c @@ -0,0 +1,175 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glPolygonMode(GL_FRONT, GL_LINE); + glPolygonMode(GL_BACK, GL_LINE); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_FILL); + glPolygonMode(GL_BACK, GL_FILL); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.8, -0.8, -0.0); + glColor3f(.8,0,0); + glVertex3f( 0.8, 0.8, -0.0); + glColor3f(0,.9,0); + glVertex3f(-0.8, 0.0, -0.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_LINE); + glPolygonMode(GL_BACK, GL_LINE); + + glBegin(GL_TRIANGLES); + glColor3f(.8,0,0); + glVertex3f( -0.9, 0.9, -0.0); + glColor3f(0,0,.7); + glVertex3f( -0.9, -0.9, -0.0); + glColor3f(0,.9,0); + glVertex3f( 0.9, 0.0, -0.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_FILL); + glPolygonMode(GL_BACK, GL_FILL); + + glBegin(GL_TRIANGLES); + glColor3f(.8,0,0); + glVertex3f( -0.8, 0.8, -0.0); + glColor3f(0,0,.7); + glVertex3f( -0.8, -0.8, -0.0); + glColor3f(0,.9,0); + glVertex3f( 0.8, 0.0, -0.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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From e1645313be9be2493311780a2f66361601903559 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 25 Nov 2008 20:02:00 +0000 Subject: mesa: more trivial tests --- progs/trivial/Makefile | 2 + progs/trivial/tri-array-interleaved.c | 119 +++++++++++++++++++++++++++ progs/trivial/tri-stipple.c | 151 ++++++++++++++++++++++++++++++++++ 3 files changed, 272 insertions(+) create mode 100644 progs/trivial/tri-array-interleaved.c create mode 100644 progs/trivial/tri-stipple.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 1b9a50b437b..cfe7fe6f31e 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -77,6 +77,7 @@ SOURCES = \ quadstrip.c \ tri-orig.c \ tri-alpha.c \ + tri-array-interleaved.c \ tri-blend-color.c \ tri-blend-max.c \ tri-blend-min.c \ @@ -101,6 +102,7 @@ SOURCES = \ tri-repeat.c \ tri-scissor-tri.c \ tri-stencil.c \ + tri-stipple.c \ tri-tex.c \ tri-tex-3d.c \ tri-tri.c \ diff --git a/progs/trivial/tri-array-interleaved.c b/progs/trivial/tri-array-interleaved.c new file mode 100644 index 00000000000..e40e69266e8 --- /dev/null +++ b/progs/trivial/tri-array-interleaved.c @@ -0,0 +1,119 @@ +/* Test rebasing */ + +#include +#include +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + +struct { + GLubyte color[4]; + GLfloat vert[3]; +} verts[] = { + + { { 0x00, 0x00, 0xff, 0x00 }, + { 0.9, -0.9, 0.0 } }, + + { { 0x00, 0xff, 0x00, 0x00 }, + { 0.9, 0.9, 0.0 } }, + + { { 0xff, 0x00, 0x00, 0x00 }, + { -0.9, 0.9, 0.0 } }, + + { { 0xff, 0xff, 0xff, 0x00 }, + { -0.9, -0.9, 0.0 } }, +}; + +GLuint indices[] = { 1, 2, 3 }; + +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)); + } + + glInterleavedArrays( GL_C4UB_V3F, sizeof(verts[0]), verts ); +} + + + +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_NV); + + /* Should have min_index == 1, maybe force a rebase: + */ + glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, indices ); + + 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]); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-stipple.c b/progs/trivial/tri-stipple.c new file mode 100644 index 00000000000..887de550e2c --- /dev/null +++ b/progs/trivial/tri-stipple.c @@ -0,0 +1,151 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + +static GLubyte fly[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x03, 0x80, 0x01, 0xC0, 0x06, 0xC0, 0x03, 0x60, 0x04, 0x60, 0x06, 0x20, +0x04, 0x30, 0x0C, 0x20, 0x04, 0x18, 0x18, 0x20, 0x04, 0x0C, 0x30, 0x20, +0x04, 0x06, 0x60, 0x20, 0x44, 0x03, 0xC0, 0x22, 0x44, 0x01, 0x80, 0x22, +0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, +0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x66, 0x01, 0x80, 0x66, +0x33, 0x01, 0x80, 0xCC, 0x19, 0x81, 0x81, 0x98, 0x0C, 0xC1, 0x83, 0x30, +0x07, 0xe1, 0x87, 0xe0, 0x03, 0x3f, 0xfc, 0xc0, 0x03, 0x31, 0x8c, 0xc0, +0x03, 0x33, 0xcc, 0xc0, 0x06, 0x64, 0x26, 0x60, 0x0c, 0xcc, 0x33, 0x30, +0x18, 0xcc, 0x33, 0x18, 0x10, 0xc4, 0x23, 0x08, 0x10, 0x63, 0xC6, 0x08, +0x10, 0x30, 0x0c, 0x08, 0x10, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x08}; + + +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)); + + glEnable (GL_POLYGON_STIPPLE); + glPolygonStipple (fly); + + 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); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.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("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 2d155f91d22d67c3aee5a11219a6e1a7c45c2d74 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 14 Jan 2009 20:33:06 +0000 Subject: trivial: clear with random color --- progs/trivial/Makefile | 1 + progs/trivial/clear-random.c | 132 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 progs/trivial/clear-random.c (limited to 'progs/trivial/Makefile') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index f7bfd1f039d..2c158c8d49a 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -16,6 +16,7 @@ SOURCES = \ clear-scissor.c \ clear-undefined.c \ clear-repeat.c \ + clear-random.c \ clear.c \ dlist-dangling.c \ dlist-edgeflag-dangling.c \ diff --git a/progs/trivial/clear-random.c b/progs/trivial/clear-random.c new file mode 100644 index 00000000000..16bd83339b8 --- /dev/null +++ b/progs/trivial/clear-random.c @@ -0,0 +1,132 @@ +/* + * 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 +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +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)); + +} + +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: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClearColor( + rand() / (float)RAND_MAX, + rand() / (float)RAND_MAX, + rand() / (float)RAND_MAX, + 0.0); + + glClear(GL_COLOR_BUFFER_BIT); + 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( 256, 256); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 479ea7d87b6d283cd74d345cb618d69a889284d9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 23 Jan 2009 14:35:36 +0000 Subject: progs/trivial: Use glew where needed. Builds on windows now. --- progs/SConstruct | 25 +++++++++++++++++++++++-- progs/trivial/Makefile | 2 +- progs/trivial/clear-fbo-tex.c | 4 +++- progs/trivial/clear-fbo.c | 4 +++- progs/trivial/drawarrays.c | 3 ++- progs/trivial/drawelements.c | 3 ++- progs/trivial/drawrange.c | 3 ++- progs/trivial/lineloop-elts.c | 3 ++- progs/trivial/long-fixed-func.c | 3 ++- progs/trivial/point-param.c | 4 +++- progs/trivial/quad-tex-3d.c | 3 +++ progs/trivial/quad-tex-pbo.c | 4 +++- progs/trivial/readpixels.c | 4 +++- progs/trivial/tri-array-interleaved.c | 3 ++- progs/trivial/tri-blend-color.c | 3 +++ progs/trivial/tri-blend-max.c | 4 +++- progs/trivial/tri-blend-min.c | 4 +++- progs/trivial/tri-blend-revsub.c | 4 +++- progs/trivial/tri-blend-sub.c | 4 +++- progs/trivial/tri-fbo-tex.c | 3 ++- progs/trivial/tri-fbo.c | 4 +++- progs/trivial/tri-fp-const-imm.c | 4 +++- progs/trivial/tri-fp.c | 4 +++- progs/trivial/tri-query.c | 4 +++- progs/trivial/tri-tex-3d.c | 3 +++ progs/trivial/vbo-drawarrays.c | 3 ++- progs/trivial/vbo-drawelements.c | 3 ++- progs/trivial/vbo-drawrange.c | 3 ++- progs/trivial/vp-array-int.c | 3 ++- progs/trivial/vp-array.c | 3 ++- progs/trivial/vp-clip.c | 3 ++- progs/trivial/vp-line-clip.c | 3 ++- progs/trivial/vp-tri-cb-pos.c | 6 ++++-- progs/trivial/vp-tri-cb-tex.c | 4 +++- progs/trivial/vp-tri-cb.c | 3 ++- progs/trivial/vp-tri-imm.c | 3 ++- progs/trivial/vp-tri-swap.c | 3 ++- progs/trivial/vp-tri-tex.c | 3 ++- progs/trivial/vp-tri.c | 3 ++- progs/trivial/vp-unfilled.c | 3 ++- 40 files changed, 119 insertions(+), 39 deletions(-) (limited to 'progs/trivial/Makefile') diff --git a/progs/SConstruct b/progs/SConstruct index ac5314fac57..bce48f72ff1 100644 --- a/progs/SConstruct +++ b/progs/SConstruct @@ -10,9 +10,23 @@ env = Environment( # Use Mesa's headers and libs -if 0: +if 1: + build_topdir = 'build' + build_subdir = env['platform'] + if env['machine'] != 'generic': + build_subdir += '-' + env['machine'] + if env['debug']: + build_subdir += "-debug" + if env['profile']: + build_subdir += "-profile" + build_dir = os.path.join(build_topdir, build_subdir) + + env.Append(CPPDEFINES = ['GLEW_STATIC']) env.Append(CPPPATH = ['#../include']) - env.Append(LIBPATH = ['#../lib']) + env.Append(LIBPATH = [ + '#../' + build_dir + '/glew/', + '#../' + build_dir + '/glut/glx', + ]) conf = Configure(env) @@ -32,6 +46,13 @@ if conf.CheckCHeader('GL/glut.h'): env['GLUT_LIB'] = 'glut' env['GLUT'] = True +# GLEW +env['GLEW'] = False +if conf.CheckCHeader('GL/glew.h'): + env['GLEW_LIB'] = 'glew' + env['GLEW'] = True + env.Prepend(LIBS = ['glew']) + conf.Finish() diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 2c158c8d49a..dce96f6bc8c 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/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 $(GLEW_LIB) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) SOURCES = \ clear-fbo-tex.c \ diff --git a/progs/trivial/clear-fbo-tex.c b/progs/trivial/clear-fbo-tex.c index 68f1ab3d77e..eccfde5ae63 100644 --- a/progs/trivial/clear-fbo-tex.c +++ b/progs/trivial/clear-fbo-tex.c @@ -5,7 +5,7 @@ #include #include -#define GL_GLEXT_PROTOTYPES +#include #include @@ -210,6 +210,8 @@ main( int argc, char *argv[] ) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/clear-fbo.c b/progs/trivial/clear-fbo.c index 82218ed4985..64b25430c66 100644 --- a/progs/trivial/clear-fbo.c +++ b/progs/trivial/clear-fbo.c @@ -5,7 +5,7 @@ #include #include -#define GL_GLEXT_PROTOTYPES +#include #include @@ -195,6 +195,8 @@ main( int argc, char *argv[] ) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/drawarrays.c b/progs/trivial/drawarrays.c index 596eee9eef1..27d86682f75 100644 --- a/progs/trivial/drawarrays.c +++ b/progs/trivial/drawarrays.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include @@ -118,6 +118,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/drawelements.c b/progs/trivial/drawelements.c index e0c8e80b68c..4c115030afc 100644 --- a/progs/trivial/drawelements.c +++ b/progs/trivial/drawelements.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include GLfloat verts[][4] = { @@ -111,6 +111,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/drawrange.c b/progs/trivial/drawrange.c index 9c787cbfcde..e9ea99b5376 100644 --- a/progs/trivial/drawrange.c +++ b/progs/trivial/drawrange.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include GLfloat verts[][4] = { @@ -109,6 +109,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/lineloop-elts.c b/progs/trivial/lineloop-elts.c index 96da8e4ad6b..ab944157c01 100644 --- a/progs/trivial/lineloop-elts.c +++ b/progs/trivial/lineloop-elts.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include GLfloat verts[][4] = { @@ -111,6 +111,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/long-fixed-func.c b/progs/trivial/long-fixed-func.c index 88f4fe01ec8..41ad25c1b3d 100644 --- a/progs/trivial/long-fixed-func.c +++ b/progs/trivial/long-fixed-func.c @@ -5,7 +5,7 @@ -#define GL_GLEXT_PROTOTYPES +#include #include #include #include @@ -142,6 +142,7 @@ main(int argc, char **argv) if (glutCreateWindow("tri-long-fixedfunc") == GL_FALSE) { exit(1); } + glewInit(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Draw); diff --git a/progs/trivial/point-param.c b/progs/trivial/point-param.c index 96544a05255..1edeec3468a 100644 --- a/progs/trivial/point-param.c +++ b/progs/trivial/point-param.c @@ -22,7 +22,7 @@ * OF THIS SOFTWARE. */ -#define GL_GLEXT_PROTOTYPES +#include #include #include #include @@ -146,6 +146,8 @@ int main(int argc, char **argv) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/quad-tex-3d.c b/progs/trivial/quad-tex-3d.c index fd02d9d6adc..ca7ea91d2f3 100644 --- a/progs/trivial/quad-tex-3d.c +++ b/progs/trivial/quad-tex-3d.c @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -167,6 +168,8 @@ int main(int argc, char **argv) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/quad-tex-pbo.c b/progs/trivial/quad-tex-pbo.c index 5b63c698a7e..c6f60f51fa6 100644 --- a/progs/trivial/quad-tex-pbo.c +++ b/progs/trivial/quad-tex-pbo.c @@ -22,7 +22,7 @@ * OF THIS SOFTWARE. */ -#define GL_GLEXT_PROTOTYPES +#include #include #include @@ -171,6 +171,8 @@ int main(int argc, char **argv) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/readpixels.c b/progs/trivial/readpixels.c index 783468ae2f6..88aac2684a8 100644 --- a/progs/trivial/readpixels.c +++ b/progs/trivial/readpixels.c @@ -3,7 +3,7 @@ */ -#define GL_GLEXT_PROTOTYPES +#include #include #include #include @@ -91,6 +91,8 @@ int main(int argc, char **argv) if (argc > 1) Zoom = atof(argv[1]); + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/tri-array-interleaved.c b/progs/trivial/tri-array-interleaved.c index e40e69266e8..95de2056cf1 100644 --- a/progs/trivial/tri-array-interleaved.c +++ b/progs/trivial/tri-array-interleaved.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include struct { @@ -110,6 +110,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/tri-blend-color.c b/progs/trivial/tri-blend-color.c index b9a539410bc..d2d72d0b62f 100644 --- a/progs/trivial/tri-blend-color.c +++ b/progs/trivial/tri-blend-color.c @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -131,6 +132,8 @@ int main(int argc, char **argv) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/tri-blend-max.c b/progs/trivial/tri-blend-max.c index ebc241c1c16..b39f8f3f12a 100644 --- a/progs/trivial/tri-blend-max.c +++ b/progs/trivial/tri-blend-max.c @@ -41,8 +41,9 @@ * to demonstrate the effect order has on alpha blending results. * Use the 't' key to toggle the order of drawing polygons. */ -#include #include +#include +#include static int leftFirst = GL_TRUE; @@ -136,6 +137,7 @@ int main(int argc, char** argv) glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (200, 200); glutCreateWindow (argv[0]); + glewInit(); init(); glutReshapeFunc (reshape); glutKeyboardFunc (keyboard); diff --git a/progs/trivial/tri-blend-min.c b/progs/trivial/tri-blend-min.c index 00b2dec7056..656297c0ce0 100644 --- a/progs/trivial/tri-blend-min.c +++ b/progs/trivial/tri-blend-min.c @@ -41,8 +41,9 @@ * to demonstrate the effect order has on alpha blending results. * Use the 't' key to toggle the order of drawing polygons. */ -#include #include +#include +#include static int leftFirst = GL_TRUE; @@ -136,6 +137,7 @@ int main(int argc, char** argv) glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (200, 200); glutCreateWindow (argv[0]); + glewInit(); init(); glutReshapeFunc (reshape); glutKeyboardFunc (keyboard); diff --git a/progs/trivial/tri-blend-revsub.c b/progs/trivial/tri-blend-revsub.c index be187fd4cee..fe225f1f4e0 100644 --- a/progs/trivial/tri-blend-revsub.c +++ b/progs/trivial/tri-blend-revsub.c @@ -41,8 +41,9 @@ * to demonstrate the effect order has on alpha blending results. * Use the 't' key to toggle the order of drawing polygons. */ -#include #include +#include +#include static int leftFirst = GL_TRUE; @@ -136,6 +137,7 @@ int main(int argc, char** argv) glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (200, 200); glutCreateWindow (argv[0]); + glewInit(); init(); glutReshapeFunc (reshape); glutKeyboardFunc (keyboard); diff --git a/progs/trivial/tri-blend-sub.c b/progs/trivial/tri-blend-sub.c index d207791108c..cc1aeaf4a48 100644 --- a/progs/trivial/tri-blend-sub.c +++ b/progs/trivial/tri-blend-sub.c @@ -41,8 +41,9 @@ * to demonstrate the effect order has on alpha blending results. * Use the 't' key to toggle the order of drawing polygons. */ -#include #include +#include +#include static int leftFirst = GL_TRUE; @@ -136,6 +137,7 @@ int main(int argc, char** argv) glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (200, 200); glutCreateWindow (argv[0]); + glewInit(); init(); glutReshapeFunc (reshape); glutKeyboardFunc (keyboard); diff --git a/progs/trivial/tri-fbo-tex.c b/progs/trivial/tri-fbo-tex.c index d413d4081f1..253f9310db4 100644 --- a/progs/trivial/tri-fbo-tex.c +++ b/progs/trivial/tri-fbo-tex.c @@ -9,7 +9,7 @@ */ -#define GL_GLEXT_PROTOTYPES +#include #include #include #include @@ -256,6 +256,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/trivial/tri-fbo.c b/progs/trivial/tri-fbo.c index 82d70c40b7e..7a38f2124cc 100644 --- a/progs/trivial/tri-fbo.c +++ b/progs/trivial/tri-fbo.c @@ -5,7 +5,7 @@ #include #include -#define GL_GLEXT_PROTOTYPES +#include #include @@ -190,6 +190,8 @@ main( int argc, char *argv[] ) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/tri-fp-const-imm.c b/progs/trivial/tri-fp-const-imm.c index 71113802ed1..9e2c63a22af 100644 --- a/progs/trivial/tri-fp-const-imm.c +++ b/progs/trivial/tri-fp-const-imm.c @@ -25,7 +25,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include @@ -159,6 +159,8 @@ int main(int argc, char **argv) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/tri-fp.c b/progs/trivial/tri-fp.c index 9ff355a4caf..fcf57f5a85f 100644 --- a/progs/trivial/tri-fp.c +++ b/progs/trivial/tri-fp.c @@ -25,7 +25,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include @@ -157,6 +157,8 @@ int main(int argc, char **argv) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/tri-query.c b/progs/trivial/tri-query.c index c9161c4f0ad..25cfcb8e148 100644 --- a/progs/trivial/tri-query.c +++ b/progs/trivial/tri-query.c @@ -25,7 +25,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include @@ -148,6 +148,8 @@ int main(int argc, char **argv) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/tri-tex-3d.c b/progs/trivial/tri-tex-3d.c index 613803fd1b1..50f6a754189 100644 --- a/progs/trivial/tri-tex-3d.c +++ b/progs/trivial/tri-tex-3d.c @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -160,6 +161,8 @@ int main(int argc, char **argv) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/vbo-drawarrays.c b/progs/trivial/vbo-drawarrays.c index fb590098a32..c29954b9033 100644 --- a/progs/trivial/vbo-drawarrays.c +++ b/progs/trivial/vbo-drawarrays.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include @@ -124,6 +124,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/vbo-drawelements.c b/progs/trivial/vbo-drawelements.c index dddb45695cb..b1b16d920b9 100644 --- a/progs/trivial/vbo-drawelements.c +++ b/progs/trivial/vbo-drawelements.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include struct { @@ -128,6 +128,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/vbo-drawrange.c b/progs/trivial/vbo-drawrange.c index 407b7541f07..fa87eaf8fe5 100644 --- a/progs/trivial/vbo-drawrange.c +++ b/progs/trivial/vbo-drawrange.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include #define ELTOBJ 0 @@ -136,6 +136,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/vp-array-int.c b/progs/trivial/vp-array-int.c index 4d60f2bd5f5..2e1ac1374d7 100644 --- a/progs/trivial/vp-array-int.c +++ b/progs/trivial/vp-array-int.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include GLint verts[][4] = { @@ -108,6 +108,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/vp-array.c b/progs/trivial/vp-array.c index abe8f62bec3..852bf7d44d7 100644 --- a/progs/trivial/vp-array.c +++ b/progs/trivial/vp-array.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include GLfloat verts[][4] = { @@ -108,6 +108,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/vp-clip.c b/progs/trivial/vp-clip.c index 206ba0b8cb8..267b927b93f 100644 --- a/progs/trivial/vp-clip.c +++ b/progs/trivial/vp-clip.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include static void Init( void ) @@ -93,6 +93,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/vp-line-clip.c b/progs/trivial/vp-line-clip.c index b2aaf17ca4f..d27e4aae079 100644 --- a/progs/trivial/vp-line-clip.c +++ b/progs/trivial/vp-line-clip.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include static void Init( void ) @@ -107,6 +107,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/vp-tri-cb-pos.c b/progs/trivial/vp-tri-cb-pos.c index eb3aa0a8dc6..430a4d3964c 100644 --- a/progs/trivial/vp-tri-cb-pos.c +++ b/progs/trivial/vp-tri-cb-pos.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include @@ -146,11 +146,13 @@ int main(int argc, char **argv) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Draw); glutMainLoop(); - return 0; + return 0; } diff --git a/progs/trivial/vp-tri-cb-tex.c b/progs/trivial/vp-tri-cb-tex.c index 1e99d5b6abc..57fd2cdbbd1 100644 --- a/progs/trivial/vp-tri-cb-tex.c +++ b/progs/trivial/vp-tri-cb-tex.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include @@ -179,6 +179,8 @@ int main(int argc, char **argv) exit(1); } + glewInit(); + Init(); glutReshapeFunc(Reshape); diff --git a/progs/trivial/vp-tri-cb.c b/progs/trivial/vp-tri-cb.c index f9d0d7f559d..1f12a2c297a 100644 --- a/progs/trivial/vp-tri-cb.c +++ b/progs/trivial/vp-tri-cb.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include static void Init( void ) @@ -98,6 +98,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/vp-tri-imm.c b/progs/trivial/vp-tri-imm.c index c774573ba8b..f2549f3697f 100644 --- a/progs/trivial/vp-tri-imm.c +++ b/progs/trivial/vp-tri-imm.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include static void Init( void ) @@ -92,6 +92,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/vp-tri-swap.c b/progs/trivial/vp-tri-swap.c index e9ca1a03789..a3ab1206fdf 100644 --- a/progs/trivial/vp-tri-swap.c +++ b/progs/trivial/vp-tri-swap.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include static void Init( void ) @@ -94,6 +94,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/vp-tri-tex.c b/progs/trivial/vp-tri-tex.c index 83ec1ef2e2f..bd2b5e59f9d 100644 --- a/progs/trivial/vp-tri-tex.c +++ b/progs/trivial/vp-tri-tex.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include static void Init( void ) @@ -128,6 +128,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/vp-tri.c b/progs/trivial/vp-tri.c index d2ef5043b22..29329773143 100644 --- a/progs/trivial/vp-tri.c +++ b/progs/trivial/vp-tri.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include static void Init( void ) @@ -95,6 +95,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); diff --git a/progs/trivial/vp-unfilled.c b/progs/trivial/vp-unfilled.c index ac23181fff7..fe2de674ea3 100644 --- a/progs/trivial/vp-unfilled.c +++ b/progs/trivial/vp-unfilled.c @@ -5,7 +5,7 @@ #include #include #include -#define GL_GLEXT_PROTOTYPES +#include #include static void Init( void ) @@ -95,6 +95,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); + glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); glutDisplayFunc( Display ); -- cgit v1.2.3