summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--progs/trivial/Makefile72
-rw-r--r--progs/trivial/clear-fbo-tex.c220
-rw-r--r--progs/trivial/clear-fbo.c205
-rw-r--r--progs/trivial/createwin.c120
-rw-r--r--progs/trivial/line-stipple-wide.c148
-rw-r--r--progs/trivial/line-wide.c147
-rw-r--r--progs/trivial/line.c13
-rw-r--r--progs/trivial/lineloop-elts.c120
-rw-r--r--progs/trivial/linestrip-clip.c141
-rw-r--r--progs/trivial/linestrip-flat-stipple.c142
-rw-r--r--progs/trivial/linestrip-stipple-wide.c142
-rw-r--r--progs/trivial/linestrip-stipple.c141
-rw-r--r--progs/trivial/linestrip.c138
-rw-r--r--progs/trivial/point-param.c6
-rw-r--r--progs/trivial/point-sprite.c174
-rw-r--r--progs/trivial/poly-flat-clip.c140
-rw-r--r--progs/trivial/psb_context.c0
-rw-r--r--progs/trivial/quad-offset-unfilled.c4
-rw-r--r--progs/trivial/quad-tex-alpha.c170
-rw-r--r--progs/trivial/quad-unfilled-clip.c139
-rw-r--r--progs/trivial/quad-unfilled-stipple.c142
-rw-r--r--progs/trivial/quadstrip-cont.c162
-rw-r--r--progs/trivial/tri-alpha-tex.c179
-rw-r--r--progs/trivial/tri-alpha.c141
-rw-r--r--progs/trivial/tri-blend-color.c141
-rw-r--r--progs/trivial/tri-blend-max.c145
-rw-r--r--progs/trivial/tri-blend-min.c145
-rw-r--r--progs/trivial/tri-blend-revsub.c145
-rw-r--r--progs/trivial/tri-blend-sub.c145
-rw-r--r--progs/trivial/tri-clear.c143
-rw-r--r--progs/trivial/tri-cull-both.c141
-rw-r--r--progs/trivial/tri-fbo-tex.c267
-rw-r--r--progs/trivial/tri-fbo.c200
-rw-r--r--progs/trivial/tri-fog.c152
-rw-r--r--progs/trivial/tri-mask-tri.c146
-rw-r--r--progs/trivial/tri-query.c158
-rw-r--r--progs/trivial/tri-scissor-tri.c151
-rw-r--r--progs/trivial/tri-square.c136
-rw-r--r--progs/trivial/tri-stencil.c149
-rw-r--r--progs/trivial/tri-tri.c145
-rw-r--r--progs/trivial/tri-unfilled-point.c138
-rw-r--r--progs/trivial/tri-unfilled-userclip-stip.c147
-rw-r--r--progs/trivial/tri-z-9.c139
-rw-r--r--progs/trivial/tri-z-eq.c139
-rw-r--r--progs/trivial/tristrip-flat.c148
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c38
-rw-r--r--src/mesa/drivers/x11/xm_winsys.c7
-rw-r--r--src/mesa/pipe/Makefile3
-rw-r--r--src/mesa/pipe/draw/draw_clip.c8
-rw-r--r--src/mesa/pipe/draw/draw_context.c13
-rw-r--r--src/mesa/pipe/draw/draw_cull.c9
-rw-r--r--src/mesa/pipe/draw/draw_feedback.c7
-rw-r--r--src/mesa/pipe/draw/draw_flatshade.c8
-rw-r--r--src/mesa/pipe/draw/draw_linestipple.c9
-rw-r--r--src/mesa/pipe/draw/draw_offset.c8
-rw-r--r--src/mesa/pipe/draw/draw_private.h2
-rw-r--r--src/mesa/pipe/draw/draw_twoside.c8
-rw-r--r--src/mesa/pipe/draw/draw_unfilled.c8
-rw-r--r--src/mesa/pipe/draw/draw_validate.c5
-rw-r--r--src/mesa/pipe/draw/draw_vbuf.c11
-rw-r--r--src/mesa/pipe/draw/draw_vertex_fetch.c1
-rw-r--r--src/mesa/pipe/draw/draw_wide_prims.c10
-rw-r--r--src/mesa/pipe/i915simple/i915_prim_emit.c6
-rw-r--r--src/mesa/pipe/i915simple/i915_prim_vbuf.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_texture.c3
-rw-r--r--src/mesa/pipe/p_defines.h8
-rw-r--r--src/mesa/pipe/p_util.h9
-rw-r--r--src/mesa/pipe/p_winsys.h90
-rw-r--r--src/mesa/pipe/pipebuffer/Makefile27
-rw-r--r--src/mesa/pipe/pipebuffer/linked_list.h91
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer.c52
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer.h175
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_client.c123
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_fenced.c316
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_fenced.h117
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_handle.c182
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_handle.h120
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_malloc.c132
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_null.c98
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr.h114
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c128
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c265
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c279
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c2
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_setup.c7
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_vbuf.c11
-rw-r--r--src/mesa/pipe/softpipe/sp_texture.c4
-rw-r--r--src/mesa/pipe/tgsi/exec/tgsi_exec.c12
-rw-r--r--src/mesa/pipe/tgsi/util/tgsi_dump.c308
-rw-r--r--src/mesa/pipe/tgsi/util/tgsi_dump.h8
-rw-r--r--src/mesa/pipe/xlib/xm_winsys.c14
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c2
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.c2
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c2
-rw-r--r--src/mesa/state_tracker/st_draw.c156
95 files changed, 9024 insertions, 222 deletions
diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile
index d9b200aef2..3a1caf15e7 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 0000000000..68f1ab3d77
--- /dev/null
+++ b/progs/trivial/clear-fbo-tex.c
@@ -0,0 +1,220 @@
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 0000000000..82218ed498
--- /dev/null
+++ b/progs/trivial/clear-fbo.c
@@ -0,0 +1,205 @@
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 0000000000..901048555a
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..09e5e1fe08
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..543b1f67f3
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 b435a2689a..de5f9274e4 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 0000000000..96da8e4ad6
--- /dev/null
+++ b/progs/trivial/lineloop-elts.c
@@ -0,0 +1,120 @@
+/* Test rebasing */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+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 0000000000..acab0f4e1c
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..b691437346
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..53dfa554e9
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..5933d1a136
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..06dd1c1087
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 c50b7cb103..be4328d999 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 0000000000..583bdca1b7
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..bd8d347c99
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..e69de29bb2
--- /dev/null
+++ b/progs/trivial/psb_context.c
diff --git a/progs/trivial/quad-offset-unfilled.c b/progs/trivial/quad-offset-unfilled.c
index 32b2129727..1ad44cdcae 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 0000000000..cd73f013eb
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..e298bd455b
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..2036aacbaa
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..c6c8f69f8c
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ 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 0000000000..776f39dcc3
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..90cfdbe199
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..b9a539410b
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..ebc241c1c1
--- /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 <GL/glut.h>
+#include <stdlib.h>
+
+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 0000000000..00b2dec705
--- /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 <GL/glut.h>
+#include <stdlib.h>
+
+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 0000000000..be187fd4ce
--- /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 <GL/glut.h>
+#include <stdlib.h>
+
+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 0000000000..d207791108
--- /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 <GL/glut.h>
+#include <stdlib.h>
+
+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 0000000000..25ea77cfa7
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+GLint Width = 250, Height = 250;
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ 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 0000000000..51b5865ae5
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..d413d4081f
--- /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 <GL/glut.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+/* For debug */
+
+
+static int Win = 0;
+static int Width = 512, Height = 512;
+
+static GLenum TexTarget = GL_TEXTURE_2D;
+static int TexWidth = 512, TexHeight = 512;
+
+static GLuint MyFB;
+static GLuint TexObj;
+static GLboolean Anim = GL_FALSE;
+static GLfloat Rot = 0.0;
+static GLuint TextureLevel = 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 0000000000..82d70c40b7
--- /dev/null
+++ b/progs/trivial/tri-fbo.c
@@ -0,0 +1,200 @@
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+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 0000000000..75f3262ecf
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+GLint Width = 250, Height = 250;
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ 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 0000000000..96a1ea7168
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+GLint Width = 250, Height = 250;
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ 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 0000000000..c9161c4f0a
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+#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 0000000000..dcc6d282dc
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+GLint Width = 250, Height = 250;
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ 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 0000000000..ef9ea63048
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..5edbef26ce
--- /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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+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 0000000000..06a0528eb8
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..71ac453d60
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..4aefa85032
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..4bd9986166
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..ad5f31a558
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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 0000000000..e048233e67
--- /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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+#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/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
index 1799e9b901..86ea86a58f 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
+++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
@@ -105,42 +105,48 @@ intel_buffer_reference(struct pipe_winsys *winsys,
/* Grabs the hardware lock!
*/
-static void intel_buffer_data(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
- unsigned size, const void *data,
- unsigned usage )
+static int intel_buffer_data(struct pipe_winsys *winsys,
+ struct pipe_buffer_handle *buf,
+ unsigned size, const void *data,
+ unsigned usage )
{
driBOData( dri_bo(buf), size, data, 0 );
+ return 0;
}
-static void intel_buffer_subdata(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data)
+static int intel_buffer_subdata(struct pipe_winsys *winsys,
+ struct pipe_buffer_handle *buf,
+ unsigned long offset,
+ unsigned long size,
+ const void *data)
{
driBOSubData( dri_bo(buf), offset, size, data );
+ return 0;
}
-static void intel_buffer_get_subdata(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data)
+static int intel_buffer_get_subdata(struct pipe_winsys *winsys,
+ struct pipe_buffer_handle *buf,
+ unsigned long offset,
+ unsigned long size,
+ void *data)
{
driBOGetSubData( dri_bo(buf), offset, size, data );
+ return 0;
}
/* Pipe has no concept of pools. We choose the tex/region pool
* for all buffers.
*/
static struct pipe_buffer_handle *
-intel_buffer_create(struct pipe_winsys *winsys, unsigned flags)
+intel_buffer_create(struct pipe_winsys *winsys,
+ unsigned alignment,
+ unsigned flags,
+ unsigned hint )
{
struct _DriBufferObject *buffer;
struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
driGenBuffers( iws->regionPool,
- "pipe buffer", 1, &buffer, 64, 0, 0 );
+ "pipe buffer", 1, &buffer, alignment, flags, hint );
return pipe_bo(buffer);
}
diff --git a/src/mesa/drivers/x11/xm_winsys.c b/src/mesa/drivers/x11/xm_winsys.c
index f863cdbc15..dafbe96a1e 100644
--- a/src/mesa/drivers/x11/xm_winsys.c
+++ b/src/mesa/drivers/x11/xm_winsys.c
@@ -210,7 +210,10 @@ xm_get_name(struct pipe_winsys *pws)
static struct pipe_buffer_handle *
-xm_buffer_create(struct pipe_winsys *pws, unsigned alignment)
+xm_buffer_create(struct pipe_winsys *pws,
+ unsigned alignment,
+ unsigned flags,
+ unsigned hint)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
buffer->refcount = 1;
@@ -258,7 +261,7 @@ xm_region_alloc(struct pipe_winsys *winsys,
assert(region->pitch > 0);
- region->buffer = winsys->buffer_create( winsys, alignment )
+ region->buffer = winsys->buffer_create( winsys, alignment, 0, 0 )
;
/* NULL data --> just allocate the space */
diff --git a/src/mesa/pipe/Makefile b/src/mesa/pipe/Makefile
index 5099b65885..e4b72e4940 100644
--- a/src/mesa/pipe/Makefile
+++ b/src/mesa/pipe/Makefile
@@ -1,4 +1,3 @@
-
TOP = ../../..
include $(TOP)/configs/current
@@ -7,7 +6,7 @@ ifeq ($(CONFIG_NAME), linux-cell)
CELL_DIR = cell
endif
-SUBDIRS = softpipe i915simple nv40 nv50 failover $(CELL_DIR)
+SUBDIRS = softpipe i915simple nv40 nv50 failover pipebuffer $(CELL_DIR)
default: subdirs
diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c
index e4c257a0ee..c50376f11f 100644
--- a/src/mesa/pipe/draw/draw_clip.c
+++ b/src/mesa/pipe/draw/draw_clip.c
@@ -415,6 +415,13 @@ static void clip_reset_stipple_counter( struct draw_stage *stage )
}
+static void clip_destroy( struct draw_stage *stage )
+{
+ draw_free_tmps( stage );
+ FREE( stage );
+}
+
+
/**
* Allocate a new clipper stage.
* \return pointer to new stage object
@@ -432,6 +439,7 @@ struct draw_stage *draw_clip_stage( struct draw_context *draw )
clipper->stage.tri = clip_tri;
clipper->stage.end = clip_end;
clipper->stage.reset_stipple_counter = clip_reset_stipple_counter;
+ clipper->stage.destroy = clip_destroy;
clipper->plane = draw->plane;
diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c
index e7997180b5..6792a06a4e 100644
--- a/src/mesa/pipe/draw/draw_context.c
+++ b/src/mesa/pipe/draw/draw_context.c
@@ -42,7 +42,7 @@ struct draw_context *draw_create( void )
struct draw_context *draw = CALLOC_STRUCT( draw_context );
#if defined(__i386__) || defined(__386__)
- draw->use_sse = GETENV( "GALLIUM_SSE" ) != NULL;
+ draw->use_sse = GETENV( "GALLIUM_NOSSE" ) == NULL;
#else
draw->use_sse = FALSE;
#endif
@@ -85,6 +85,7 @@ struct draw_context *draw_create( void )
draw->prim = ~0; /* != any of PIPE_PRIM_x */
draw_vertex_cache_invalidate( draw );
+ draw_set_mapped_element_buffer( draw, 0, NULL );
return draw;
}
@@ -92,6 +93,16 @@ struct draw_context *draw_create( void )
void draw_destroy( struct draw_context *draw )
{
+ draw->pipeline.wide->destroy( draw->pipeline.wide );
+ draw->pipeline.unfilled->destroy( draw->pipeline.unfilled );
+ draw->pipeline.twoside->destroy( draw->pipeline.twoside );
+ draw->pipeline.offset->destroy( draw->pipeline.offset );
+ draw->pipeline.clip->destroy( draw->pipeline.clip );
+ draw->pipeline.flatshade->destroy( draw->pipeline.flatshade );
+ draw->pipeline.cull->destroy( draw->pipeline.cull );
+ draw->pipeline.feedback->destroy( draw->pipeline.feedback );
+ draw->pipeline.validate->destroy( draw->pipeline.validate );
+ draw->pipeline.rasterize->destroy( draw->pipeline.rasterize );
FREE( draw->vcache.vertex[0] ); /* Frees all the vertices. */
FREE( draw );
}
diff --git a/src/mesa/pipe/draw/draw_cull.c b/src/mesa/pipe/draw/draw_cull.c
index f898834ba5..9bd53f45f2 100644
--- a/src/mesa/pipe/draw/draw_cull.c
+++ b/src/mesa/pipe/draw/draw_cull.c
@@ -116,6 +116,14 @@ static void cull_reset_stipple_counter( struct draw_stage *stage )
stage->next->reset_stipple_counter( stage->next );
}
+
+static void cull_destroy( struct draw_stage *stage )
+{
+ draw_free_tmps( stage );
+ FREE( stage );
+}
+
+
/**
* Create a new polygon culling stage.
*/
@@ -133,6 +141,7 @@ struct draw_stage *draw_cull_stage( struct draw_context *draw )
cull->stage.tri = cull_tri;
cull->stage.end = cull_end;
cull->stage.reset_stipple_counter = cull_reset_stipple_counter;
+ cull->stage.destroy = cull_destroy;
return &cull->stage;
}
diff --git a/src/mesa/pipe/draw/draw_feedback.c b/src/mesa/pipe/draw/draw_feedback.c
index b9906e5b4b..aea6a8184c 100644
--- a/src/mesa/pipe/draw/draw_feedback.c
+++ b/src/mesa/pipe/draw/draw_feedback.c
@@ -224,6 +224,12 @@ static void feedback_reset_stipple_counter( struct draw_stage *stage )
}
+static void feedback_destroy( struct draw_stage *stage )
+{
+ FREE( stage );
+}
+
+
/**
* Create feedback drawing stage.
*/
@@ -239,6 +245,7 @@ struct draw_stage *draw_feedback_stage( struct draw_context *draw )
feedback->stage.tri = feedback_tri;
feedback->stage.end = feedback_end;
feedback->stage.reset_stipple_counter = feedback_reset_stipple_counter;
+ feedback->stage.destroy = feedback_destroy;
return &feedback->stage;
}
diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c
index d46e53f2be..d7551e7948 100644
--- a/src/mesa/pipe/draw/draw_flatshade.c
+++ b/src/mesa/pipe/draw/draw_flatshade.c
@@ -127,6 +127,13 @@ static void flatshade_reset_stipple_counter( struct draw_stage *stage )
}
+static void flatshade_destroy( struct draw_stage *stage )
+{
+ draw_free_tmps( stage );
+ FREE( stage );
+}
+
+
/**
* Create flatshading drawing stage.
*/
@@ -144,6 +151,7 @@ struct draw_stage *draw_flatshade_stage( struct draw_context *draw )
flatshade->tri = flatshade_tri;
flatshade->end = flatshade_end;
flatshade->reset_stipple_counter = flatshade_reset_stipple_counter;
+ flatshade->destroy = flatshade_destroy;
return flatshade;
}
diff --git a/src/mesa/pipe/draw/draw_linestipple.c b/src/mesa/pipe/draw/draw_linestipple.c
index 1fac1ebe66..5f0db99b23 100644
--- a/src/mesa/pipe/draw/draw_linestipple.c
+++ b/src/mesa/pipe/draw/draw_linestipple.c
@@ -241,12 +241,18 @@ static void stipple_begin( struct clip_pipe_stage *stage )
}
-
static void stipple_end( struct clip_pipe_stage *stage )
{
stage->next->end( stage->next );
}
+
+static void stipple_destroy( struct clip_pipe_stage *stage )
+{
+ FREE( stage );
+}
+
+
struct clip_pipe_stage *clip_pipe_stipple( struct clip_pipeline *pipe )
{
struct stipple_stage *stipple = CALLOC_STRUCT(stipple_stage);
@@ -261,6 +267,7 @@ struct clip_pipe_stage *clip_pipe_stipple( struct clip_pipeline *pipe )
stipple->stage.tri = clip_passthrough_tri;
stipple->stage.reset_tmps = clip_pipe_reset_tmps;
stipple->stage.end = stipple_end;
+ stipple->stage.destroy = stipple_destroy;
return &stipple->stage;
}
diff --git a/src/mesa/pipe/draw/draw_offset.c b/src/mesa/pipe/draw/draw_offset.c
index 6acc7cbcd2..f8a01db3dd 100644
--- a/src/mesa/pipe/draw/draw_offset.c
+++ b/src/mesa/pipe/draw/draw_offset.c
@@ -151,6 +151,13 @@ static void offset_reset_stipple_counter( struct draw_stage *stage )
}
+static void offset_destroy( struct draw_stage *stage )
+{
+ draw_free_tmps( stage );
+ FREE( stage );
+}
+
+
/**
* Create polygon offset drawing stage.
*/
@@ -168,6 +175,7 @@ struct draw_stage *draw_offset_stage( struct draw_context *draw )
offset->stage.tri = offset_tri;
offset->stage.end = offset_end;
offset->stage.reset_stipple_counter = offset_reset_stipple_counter;
+ offset->stage.destroy = offset_destroy;
return &offset->stage;
}
diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h
index 53d7451113..ca5ca7b3c9 100644
--- a/src/mesa/pipe/draw/draw_private.h
+++ b/src/mesa/pipe/draw/draw_private.h
@@ -124,6 +124,8 @@ struct draw_stage
void (*reset_tmps)( struct draw_stage * );
void (*reset_stipple_counter)( struct draw_stage * );
+
+ void (*destroy)( struct draw_stage * );
};
diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c
index d987b00598..00b4ee45cd 100644
--- a/src/mesa/pipe/draw/draw_twoside.c
+++ b/src/mesa/pipe/draw/draw_twoside.c
@@ -146,6 +146,13 @@ static void twoside_reset_stipple_counter( struct draw_stage *stage )
}
+static void twoside_destroy( struct draw_stage *stage )
+{
+ draw_free_tmps( stage );
+ FREE( stage );
+}
+
+
/**
* Create twoside pipeline stage.
*/
@@ -163,6 +170,7 @@ struct draw_stage *draw_twoside_stage( struct draw_context *draw )
twoside->stage.tri = twoside_tri;
twoside->stage.end = twoside_end;
twoside->stage.reset_stipple_counter = twoside_reset_stipple_counter;
+ twoside->stage.destroy = twoside_destroy;
return &twoside->stage;
}
diff --git a/src/mesa/pipe/draw/draw_unfilled.c b/src/mesa/pipe/draw/draw_unfilled.c
index 6cab086a45..786826b33c 100644
--- a/src/mesa/pipe/draw/draw_unfilled.c
+++ b/src/mesa/pipe/draw/draw_unfilled.c
@@ -168,6 +168,13 @@ static void unfilled_reset_stipple_counter( struct draw_stage *stage )
}
+static void unfilled_destroy( struct draw_stage *stage )
+{
+ draw_free_tmps( stage );
+ FREE( stage );
+}
+
+
/**
* Create unfilled triangle stage.
*/
@@ -186,6 +193,7 @@ struct draw_stage *draw_unfilled_stage( struct draw_context *draw )
unfilled->stage.tri = unfilled_tri;
unfilled->stage.end = unfilled_end;
unfilled->stage.reset_stipple_counter = unfilled_reset_stipple_counter;
+ unfilled->stage.destroy = unfilled_destroy;
return &unfilled->stage;
}
diff --git a/src/mesa/pipe/draw/draw_validate.c b/src/mesa/pipe/draw/draw_validate.c
index 4e8f986b27..8ce4a926e2 100644
--- a/src/mesa/pipe/draw/draw_validate.c
+++ b/src/mesa/pipe/draw/draw_validate.c
@@ -110,6 +110,10 @@ static void validate_begin( struct draw_stage *stage )
}
+static void validate_destroy( struct draw_stage *stage )
+{
+ FREE( stage );
+}
/**
@@ -127,6 +131,7 @@ struct draw_stage *draw_validate_stage( struct draw_context *draw )
stage->tri = NULL;
stage->end = NULL;
stage->reset_stipple_counter = NULL;
+ stage->destroy = validate_destroy;
return stage;
}
diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c
index d00cdec56c..d010aaba07 100644
--- a/src/mesa/pipe/draw/draw_vbuf.c
+++ b/src/mesa/pipe/draw/draw_vbuf.c
@@ -369,6 +369,15 @@ vbuf_reset_stipple_counter( struct draw_stage *stage )
}
+static void vbuf_destroy( struct draw_stage *stage )
+{
+ struct vbuf_stage *vbuf = vbuf_stage( stage );
+
+ FREE( vbuf->indices );
+ FREE( stage );
+}
+
+
/**
* Create a new primitive vbuf/render stage.
*/
@@ -384,12 +393,12 @@ struct draw_stage *draw_vbuf_stage( struct draw_context *draw,
vbuf->stage.tri = vbuf_first_tri;
vbuf->stage.end = vbuf_end;
vbuf->stage.reset_stipple_counter = vbuf_reset_stipple_counter;
+ vbuf->stage.destroy = vbuf_destroy;
vbuf->render = render;
assert(render->max_indices < UNDEFINED_VERTEX_ID);
vbuf->max_indices = render->max_indices;
- /* FIXME: free this memory on takedown */
vbuf->indices = MALLOC( vbuf->max_indices );
vbuf->vertices = NULL;
diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c
index e0759c2e9a..7d983ebd29 100644
--- a/src/mesa/pipe/draw/draw_vertex_fetch.c
+++ b/src/mesa/pipe/draw/draw_vertex_fetch.c
@@ -80,6 +80,7 @@ fetch_attrib4(const void *ptr, enum pipe_format format, float attrib[4])
break;
case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_R8G8B8A8_UNORM:
attrib[0] = (float) ((unsigned char *) ptr)[2] / 255.0f;
attrib[1] = (float) ((unsigned char *) ptr)[1] / 255.0f;
attrib[2] = (float) ((unsigned char *) ptr)[0] / 255.0f;
diff --git a/src/mesa/pipe/draw/draw_wide_prims.c b/src/mesa/pipe/draw/draw_wide_prims.c
index 494a2bc619..a56c9b8893 100644
--- a/src/mesa/pipe/draw/draw_wide_prims.c
+++ b/src/mesa/pipe/draw/draw_wide_prims.c
@@ -315,7 +315,6 @@ static void wide_begin( struct draw_stage *stage )
}
-
static void wide_end( struct draw_stage *stage )
{
stage->next->end( stage->next );
@@ -327,6 +326,14 @@ static void draw_reset_stipple_counter( struct draw_stage *stage )
stage->next->reset_stipple_counter( stage->next );
}
+
+static void wide_destroy( struct draw_stage *stage )
+{
+ draw_free_tmps( stage );
+ FREE( stage );
+}
+
+
struct draw_stage *draw_wide_stage( struct draw_context *draw )
{
struct wide_stage *wide = CALLOC_STRUCT(wide_stage);
@@ -341,6 +348,7 @@ struct draw_stage *draw_wide_stage( struct draw_context *draw )
wide->stage.tri = passthrough_tri;
wide->stage.end = wide_end;
wide->stage.reset_stipple_counter = draw_reset_stipple_counter;
+ wide->stage.destroy = wide_destroy;
return &wide->stage;
}
diff --git a/src/mesa/pipe/i915simple/i915_prim_emit.c b/src/mesa/pipe/i915simple/i915_prim_emit.c
index 0a8be79ae4..c50a591589 100644
--- a/src/mesa/pipe/i915simple/i915_prim_emit.c
+++ b/src/mesa/pipe/i915simple/i915_prim_emit.c
@@ -194,6 +194,11 @@ static void reset_stipple_counter( struct draw_stage *stage )
{
}
+static void render_destroy( struct draw_stage *stage )
+{
+ FREE( stage );
+}
+
/**
* Create a new primitive setup/render stage. This gets plugged into
@@ -211,6 +216,7 @@ struct draw_stage *i915_draw_render_stage( struct i915_context *i915 )
setup->stage.tri = setup_tri;
setup->stage.end = setup_end;
setup->stage.reset_stipple_counter = reset_stipple_counter;
+ setup->stage.destroy = render_destroy;
return &setup->stage;
}
diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
index 08ac5b672c..571ad40595 100644
--- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c
+++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
@@ -99,7 +99,7 @@ i915_vbuf_render_allocate_vertices( struct vbuf_render *render,
/* FIXME: handle failure */
assert(!i915->vbo);
- i915->vbo = winsys->buffer_create(winsys, 64);
+ i915->vbo = winsys->buffer_create(winsys, 64, 0, 0);
winsys->buffer_data( winsys, i915->vbo,
size, NULL,
I915_BUFFER_USAGE_LIT_VERTEX );
diff --git a/src/mesa/pipe/i915simple/i915_texture.c b/src/mesa/pipe/i915simple/i915_texture.c
index 1ca2815dfb..59e8db8a95 100644
--- a/src/mesa/pipe/i915simple/i915_texture.c
+++ b/src/mesa/pipe/i915simple/i915_texture.c
@@ -496,7 +496,8 @@ i915_texture_create(struct pipe_context *pipe, struct pipe_texture **pt)
if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) :
i915_miptree_layout(pipe, tex)) {
tex->buffer = pipe->winsys->buffer_create(pipe->winsys,
- PIPE_SURFACE_FLAG_TEXTURE);
+ PIPE_SURFACE_FLAG_TEXTURE,
+ 0, 0);
if (tex->buffer)
pipe->winsys->buffer_data(pipe->winsys, tex->buffer,
diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h
index a853605486..8dce3aba90 100644
--- a/src/mesa/pipe/p_defines.h
+++ b/src/mesa/pipe/p_defines.h
@@ -170,8 +170,12 @@
/**
* Buffer access flags
*/
-#define PIPE_BUFFER_FLAG_READ 0x1
-#define PIPE_BUFFER_FLAG_WRITE 0x2
+#define PIPE_BUFFER_FLAG_READ 0x1
+#define PIPE_BUFFER_FLAG_WRITE 0x2
+#define PIPE_BUFFER_FLAG_MEM_LOCAL 0x4
+#define PIPE_BUFFER_FLAG_CACHED 0x8
+#define PIPE_BUFFER_FLAG_CUSTOM (1<<16)
+
/**
diff --git a/src/mesa/pipe/p_util.h b/src/mesa/pipe/p_util.h
index 7897bc90e4..3c5e98453c 100644
--- a/src/mesa/pipe/p_util.h
+++ b/src/mesa/pipe/p_util.h
@@ -114,6 +114,7 @@ REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
#define Elements(x) sizeof(x)/sizeof(*(x))
+#define Offset(TYPE, MEMBER) ((unsigned)&(((TYPE *)NULL)->MEMBER))
/**
* Return a pointer aligned to next multiple of 16 bytes.
@@ -204,8 +205,8 @@ static INLINE unsigned char float_to_ubyte( float f )
static INLINE unsigned pack_ui32_float4( float a,
float b,
- float d,
- float c )
+ float c,
+ float d )
{
return pack_ub4( float_to_ubyte(a),
float_to_ubyte(b),
@@ -300,4 +301,8 @@ static INLINE float LOG2(float val)
#define CEILF(x) ((float) ceil(x))
#endif
+/* Convenient...
+ */
+extern void _mesa_printf(const char *str, ...);
+
#endif
diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h
index 438e8bdb63..f2be7655f4 100644
--- a/src/mesa/pipe/p_winsys.h
+++ b/src/mesa/pipe/p_winsys.h
@@ -42,6 +42,13 @@
/** Opaque type for a buffer */
struct pipe_buffer_handle;
+/** Opaque type */
+struct pipe_fence_handle;
+
+struct pipe_region;
+struct pipe_surface;
+
+
/**
* Gallium3D drivers are (meant to be!) independent of both GL and the
* window system. The window system provides a buffer manager and a
@@ -52,14 +59,6 @@ struct pipe_buffer_handle;
* driver and the hardware driver about the format of command buffers,
* etc.
*/
-
-
-struct pipe_region;
-struct pipe_surface;
-
-/** Opaque type */
-struct pipe_buffer_handle;
-
struct pipe_winsys
{
/** Returns name of this winsys interface */
@@ -96,6 +95,7 @@ struct pipe_winsys
void (*surface_release)(struct pipe_winsys *ws, struct pipe_surface **s);
+
/**
* The buffer manager is modeled after the dri_bufmgr interface, which
* in turn is modeled after the ARB_vertex_buffer_object extension,
@@ -104,15 +104,16 @@ struct pipe_winsys
* systems must then implement that interface (rather than the
* other way around...).
*/
- struct pipe_buffer_handle *(*buffer_create)(struct pipe_winsys *sws,
- unsigned alignment );
+ struct pipe_buffer_handle *(*buffer_create)( struct pipe_winsys *sws,
+ unsigned alignment,
+ unsigned flags,
+ unsigned hint );
/** Create a buffer that wraps user-space data */
struct pipe_buffer_handle *(*user_buffer_create)(struct pipe_winsys *sws,
void *ptr,
unsigned bytes);
-
/**
* Map the entire data store of a buffer object into the client's address.
* flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE.
@@ -135,25 +136,64 @@ struct pipe_winsys
* usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
* usage argument is only an optimization hint, not a guarantee, therefore
* proper behavior must be observed in all circumstances.
+ *
+ * Returns zero on success.
*/
- void (*buffer_data)(struct pipe_winsys *sws,
+ int (*buffer_data)(struct pipe_winsys *sws,
struct pipe_buffer_handle *buf,
unsigned size, const void *data,
unsigned usage);
- /** Modify some or all of the data contained in a buffer's data store */
- void (*buffer_subdata)(struct pipe_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data);
-
- /** Query some or all of the data contained in a buffer's data store */
- void (*buffer_get_subdata)(struct pipe_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data);
+ /**
+ * Modify some or all of the data contained in a buffer's data store.
+ *
+ * Returns zero on success.
+ */
+ int (*buffer_subdata)(struct pipe_winsys *sws,
+ struct pipe_buffer_handle *buf,
+ unsigned long offset,
+ unsigned long size,
+ const void *data);
+
+ /**
+ * Query some or all of the data contained in a buffer's data store.
+ *
+ * Returns zero on success.
+ */
+ int (*buffer_get_subdata)(struct pipe_winsys *sws,
+ struct pipe_buffer_handle *buf,
+ unsigned long offset,
+ unsigned long size,
+ void *data);
+
+
+ /** Set ptr = buf, with reference counting */
+ void (*fence_reference)( struct pipe_winsys *sws,
+ struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *fence );
+
+ /**
+ * Checks whether the fence has been signalled.
+ *
+ * The meaning of flag is pipe-driver specific.
+ *
+ * Returns zero if it has.
+ */
+ int (*fence_signalled)( struct pipe_winsys *sws,
+ struct pipe_fence_handle *fence,
+ unsigned flag );
+
+ /**
+ * Wait for the fence to finish.
+ *
+ * The meaning of flag is pipe-driver specific.
+ *
+ * Returns zero on success.
+ */
+ int (*fence_finish)( struct pipe_winsys *sws,
+ struct pipe_fence_handle *fence,
+ unsigned flag );
+
};
diff --git a/src/mesa/pipe/pipebuffer/Makefile b/src/mesa/pipe/pipebuffer/Makefile
new file mode 100644
index 0000000000..061d8a060f
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/Makefile
@@ -0,0 +1,27 @@
+
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = pipebuffer
+
+
+DRIVER_SOURCES = \
+ pb_buffer.c \
+ pb_buffer_client.c \
+ pb_buffer_handle.c \
+ pb_buffer_fenced.c \
+ pb_buffer_malloc.c \
+ pb_buffer_null.c \
+ pb_bufmgr_fenced.c \
+ pb_bufmgr_mm.c \
+ pb_bufmgr_pool.c
+
+C_SOURCES = \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+include ../Makefile.template
+
+symlinks:
+
diff --git a/src/mesa/pipe/pipebuffer/linked_list.h b/src/mesa/pipe/pipebuffer/linked_list.h
new file mode 100644
index 0000000000..e99817fb13
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/linked_list.h
@@ -0,0 +1,91 @@
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * List macros heavily inspired by the Linux kernel
+ * list handling. No list looping yet.
+ *
+ * Is not threadsafe, so common operations need to
+ * be protected using an external mutex.
+ */
+
+#ifndef LINKED_LIST_H_
+#define LINKED_LIST_H_
+
+
+#include <stddef.h>
+
+
+struct list_head
+{
+ struct list_head *prev;
+ struct list_head *next;
+};
+
+
+#define LIST_INITHEAD(__item) \
+ do { \
+ (__item)->prev = (__item); \
+ (__item)->next = (__item); \
+ } while (0)
+
+#define LIST_ADD(__item, __list) \
+ do { \
+ (__item)->prev = (__list); \
+ (__item)->next = (__list)->next; \
+ (__list)->next->prev = (__item); \
+ (__list)->next = (__item); \
+ } while (0)
+
+#define LIST_ADDTAIL(__item, __list) \
+ do { \
+ (__item)->next = (__list); \
+ (__item)->prev = (__list)->prev; \
+ (__list)->prev->next = (__item); \
+ (__list)->prev = (__item); \
+ } while(0)
+
+#define LIST_DEL(__item) \
+ do { \
+ (__item)->prev->next = (__item)->next; \
+ (__item)->next->prev = (__item)->prev; \
+ } while(0)
+
+#define LIST_DELINIT(__item) \
+ do { \
+ (__item)->prev->next = (__item)->next; \
+ (__item)->next->prev = (__item)->prev; \
+ (__item)->next = (__item); \
+ (__item)->prev = (__item); \
+ } while(0)
+
+#define LIST_ENTRY(__type, __item, __field) \
+ ((__type *)(((char *)(__item)) - offsetof(__type, __field)))
+
+
+#endif /*LINKED_LIST_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer.c b/src/mesa/pipe/pipebuffer/pb_buffer.c
new file mode 100644
index 0000000000..99c960b697
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_buffer.c
@@ -0,0 +1,52 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * Buffer implementation.
+ *
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ */
+
+
+#include "pb_buffer.h"
+
+
+void
+buffer_reference(struct pipe_buffer **dst,
+ struct pipe_buffer *src)
+{
+ if(*dst != src) {
+ if (src)
+ src->vtbl->reference(src);
+
+ if (*dst)
+ (*dst)->vtbl->release(*dst);
+
+ *dst = src;
+ }
+}
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer.h b/src/mesa/pipe/pipebuffer/pb_buffer.h
new file mode 100644
index 0000000000..0523531395
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_buffer.h
@@ -0,0 +1,175 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * Generic code for buffers.
+ *
+ * Behind a pipe buffle handle there can be DMA buffers, client (or user)
+ * buffers, regular malloced buffers, etc. This file provides an abstract base
+ * buffer handle that allows the driver to cope with all those kinds of buffers
+ * in a more flexible way.
+ *
+ * There is no obligation of a winsys driver to use this library. And a pipe
+ * driver should be completly agnostic about it.
+ *
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ */
+
+#ifndef PB_BUFFER_H_
+#define PB_BUFFER_H_
+
+
+#include <assert.h>
+#include <stdlib.h>
+
+
+struct pipe_buffer_vtbl;
+
+
+/**
+ * Base class for all pipe buffers.
+ */
+struct pipe_buffer
+{
+ /**
+ * Pointer to the virtual function table.
+ *
+ * Avoid accessing this table directly. Use the inline functions below
+ * instead to avoid mistakes.
+ */
+ const struct pipe_buffer_vtbl *vtbl;
+};
+
+
+/**
+ * Virtual function table for the buffer storage operations.
+ *
+ * Note that creation is not done through this table.
+ */
+struct pipe_buffer_vtbl
+{
+ /**
+ * Add a reference to the buffer.
+ *
+ * This method can be a no-op for buffers that don't need reference
+ * counting.
+ */
+ void (*reference)( struct pipe_buffer *buf );
+
+ /**
+ * Release a reference to this buffer and destroy it.
+ */
+ void (*release)( struct pipe_buffer *buf );
+
+ /**
+ * Map the entire data store of a buffer object into the client's address.
+ * flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE.
+ */
+ void *(*map)( struct pipe_buffer *buf,
+ unsigned flags );
+
+ void (*unmap)( struct pipe_buffer *buf );
+
+ /**
+ * Get the base buffer and the offset.
+ *
+ * A buffer can be subdivided in smaller buffers. This method should return
+ * the underlaying buffer, and the relative offset.
+ *
+ * Buffers without an underlaying base buffer should return themselves, with
+ * a zero offset.
+ *
+ * Note that this will increase the reference count of the base buffer.
+ */
+ void (*get_base_buffer)( struct pipe_buffer *buf,
+ struct pipe_buffer **base_buf,
+ unsigned *offset );
+};
+
+
+/** *dst = src with reference counting */
+void
+buffer_reference(struct pipe_buffer **dst,
+ struct pipe_buffer *src);
+
+
+static inline void
+buffer_release(struct pipe_buffer *buf)
+{
+ assert(buf);
+ buf->vtbl->release(buf);
+}
+
+
+static inline void *
+buffer_map(struct pipe_buffer *buf,
+ unsigned flags)
+{
+ assert(buf);
+ return buf->vtbl->map(buf, flags);
+}
+
+
+static inline void
+buffer_unmap(struct pipe_buffer *buf)
+{
+ assert(buf);
+ buf->vtbl->unmap(buf);
+}
+
+
+static inline void
+buffer_get_base_buffer( struct pipe_buffer *buf,
+ struct pipe_buffer **base_buf,
+ unsigned *offset )
+{
+ buf->vtbl->get_base_buffer(buf, base_buf, offset);
+}
+
+
+/** Placeholder for empty buffers. */
+extern struct pipe_buffer null_buffer;
+
+
+/**
+ * Client buffers (also designated as user buffers) are just for convenience
+ * of the state tracker, so that it can masquerade its own data as a buffer.
+ */
+struct pipe_buffer *
+client_buffer_create(void *data);
+
+
+/**
+ * Malloc-based buffer to store data that can't be used by the graphics
+ * hardware.
+ */
+struct pipe_buffer *
+malloc_buffer_create(unsigned size);
+
+
+#endif /*PB_BUFFER_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_client.c b/src/mesa/pipe/pipebuffer/pb_buffer_client.c
new file mode 100644
index 0000000000..bb7f5a9a94
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_client.c
@@ -0,0 +1,123 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * Implementation of client buffer (also designated as "user buffers"), which
+ * are just state-tracker owned data masqueraded as buffers.
+ *
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ */
+
+
+#include "pb_buffer.h"
+
+
+struct client_buffer
+{
+ struct pipe_buffer base;
+ void *data;
+};
+
+
+extern const struct pipe_buffer_vtbl client_buffer_vtbl;
+
+
+static inline struct client_buffer *
+client_buffer(struct pipe_buffer *buf)
+{
+ assert(buf);
+ assert(buf->vtbl == &client_buffer_vtbl);
+ return (struct client_buffer *)buf;
+}
+
+
+static void
+client_buffer_reference(struct pipe_buffer *buf)
+{
+ /* No-op */
+}
+
+
+static void
+client_buffer_release(struct pipe_buffer *buf)
+{
+ assert(buf);
+ free(buf);
+}
+
+
+static void *
+client_buffer_map(struct pipe_buffer *buf,
+ unsigned flags)
+{
+ return client_buffer(buf)->data;
+}
+
+
+static void
+client_buffer_unmap(struct pipe_buffer *buf)
+{
+ /* No-op */
+}
+
+
+static void
+client_buffer_get_base_buffer(struct pipe_buffer *buf,
+ struct pipe_buffer **base_buf,
+ unsigned *offset)
+{
+ *base_buf = buf;
+ *offset = 0;
+}
+
+
+const struct pipe_buffer_vtbl
+client_buffer_vtbl = {
+ client_buffer_reference,
+ client_buffer_release,
+ client_buffer_map,
+ client_buffer_unmap,
+ client_buffer_get_base_buffer
+};
+
+
+struct pipe_buffer *
+client_buffer_create(void *data)
+{
+ struct client_buffer *buf;
+
+ buf = (struct client_buffer *)malloc(sizeof(struct client_buffer));
+ if(!buf)
+ return NULL;
+
+ buf->base.vtbl = &client_buffer_vtbl;
+
+ buf->data = data;
+
+ return &buf->base;
+}
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
new file mode 100644
index 0000000000..e69f88a323
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
@@ -0,0 +1,316 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * Implementation of fenced buffers.
+ *
+ * \author José Fonseca <jrfonseca-at-tungstengraphics-dot-com>
+ * \author Thomas Hellström <thomas-at-tungstengraphics-dot-com>
+ */
+
+
+#include <assert.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "main/imports.h"
+#include "glapi/glthread.h"
+#include "linked_list.h"
+
+#include "p_winsys.h"
+
+#include "pb_buffer.h"
+#include "pb_buffer_fenced.h"
+
+
+/**
+ * Convenience macro (type safe).
+ */
+#define SUPER(__derived) (&(__derived)->base)
+
+
+struct fenced_buffer_list
+{
+ _glthread_Mutex mutex;
+
+ struct pipe_winsys *winsys;
+
+ size_t numDelayed;
+ size_t checkDelayed;
+
+ struct list_head delayed;
+};
+
+
+/**
+ * Wrapper around a pipe buffer which adds fencing and reference counting.
+ */
+struct fenced_buffer
+{
+ struct pipe_buffer base;
+
+ struct pipe_buffer *buffer;
+
+ unsigned refcount;
+ struct pipe_fence_handle *fence;
+
+ struct list_head head;
+ struct fenced_buffer_list *list;
+};
+
+
+static inline struct fenced_buffer *
+fenced_buffer(struct pipe_buffer *buf)
+{
+ assert(buf);
+ assert(buf->vtbl == &fenced_buffer_vtbl);
+ return (struct fenced_buffer *)buf;
+}
+
+
+static void
+_fenced_buffer_destroy(struct fenced_buffer *fenced_buf)
+{
+ buffer_release(fenced_buf->buffer);
+ free(fenced_buf);
+}
+
+
+static void
+_fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
+ int wait)
+{
+ struct pipe_winsys *winsys = fenced_list->winsys;
+ struct fenced_buffer *fenced_buf;
+ struct list_head *list, *prev;
+ int signaled = -1;
+ int i;
+
+ list = fenced_list->delayed.next;
+
+ if (fenced_list->numDelayed > 3) {
+ for (i = 0; i < fenced_list->numDelayed; i += 3) {
+ list = list->next;
+ }
+ }
+
+ prev = list->prev;
+ for (; list != &fenced_list->delayed; list = prev, prev = list->prev) {
+
+ fenced_buf = LIST_ENTRY(struct fenced_buffer, list, head);
+
+ if (signaled != 0) {
+ if (wait) {
+ signaled = winsys->fence_finish(winsys, fenced_buf->fence, 0);
+ }
+ else {
+ signaled = winsys->fence_signalled(winsys, fenced_buf->fence, 0);
+ }
+ }
+
+ if (signaled != 0)
+ /* XXX: we are assuming that buffers are freed in the same order they
+ * are fenced which may not always be true...
+ */
+ break;
+
+ winsys->fence_reference(winsys, &fenced_buf->fence, NULL);
+
+ LIST_DEL(list);
+ fenced_list->numDelayed--;
+
+ _fenced_buffer_destroy(fenced_buf);
+ }
+}
+
+
+static void
+fenced_buffer_reference(struct pipe_buffer *buf)
+{
+ struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+ struct fenced_buffer_list *fenced_list = fenced_buf->list;
+
+ _glthread_LOCK_MUTEX(fenced_list->mutex);
+ fenced_buf->refcount++;
+ _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+}
+
+
+static void
+fenced_buffer_release(struct pipe_buffer *buf)
+{
+ struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+ struct fenced_buffer_list *fenced_list = fenced_buf->list;
+
+ _glthread_LOCK_MUTEX(fenced_list->mutex);
+
+ fenced_buf->refcount--;
+ if(!fenced_buf->refcount) {
+ if (fenced_buf->fence) {
+ LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed);
+ fenced_list->numDelayed++;
+ }
+ else {
+ _fenced_buffer_destroy(fenced_buf);
+ }
+
+ if ((fenced_list->numDelayed % fenced_list->checkDelayed) == 0)
+ _fenced_buffer_list_check_free(fenced_list, 0);
+ }
+
+ _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+}
+
+
+static void *
+fenced_buffer_map(struct pipe_buffer *buf,
+ unsigned flags)
+{
+ struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+ return buffer_map(fenced_buf->buffer, flags);
+}
+
+
+static void
+fenced_buffer_unmap(struct pipe_buffer *buf)
+{
+ struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+ buffer_unmap(fenced_buf->buffer);
+}
+
+
+static void
+fenced_buffer_get_base_buffer(struct pipe_buffer *buf,
+ struct pipe_buffer **base_buf,
+ unsigned *offset)
+{
+ struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+ buffer_get_base_buffer(fenced_buf->buffer, base_buf, offset);
+}
+
+
+const struct pipe_buffer_vtbl
+fenced_buffer_vtbl = {
+ fenced_buffer_reference,
+ fenced_buffer_release,
+ fenced_buffer_map,
+ fenced_buffer_unmap,
+ fenced_buffer_get_base_buffer
+};
+
+
+struct pipe_buffer *
+fenced_buffer_create(struct fenced_buffer_list *fenced_list,
+ struct pipe_buffer *buffer)
+{
+ struct fenced_buffer *buf;
+
+ buf = (struct fenced_buffer *)calloc(1, sizeof(struct fenced_buffer));
+ if(!buf)
+ return NULL;
+
+ buf->base.vtbl = &fenced_buffer_vtbl;
+ buf->buffer = buffer;
+ buf->refcount = 1;
+ buf->list = fenced_list;
+
+ return &buf->base;
+}
+
+
+void
+buffer_fence(struct pipe_buffer *buf,
+ struct pipe_fence_handle *fence)
+{
+ if(buf->vtbl == &fenced_buffer_vtbl) {
+ struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+ struct fenced_buffer_list *fenced_list = fenced_buf->list;
+ struct pipe_winsys *winsys = fenced_list->winsys;
+
+ _glthread_LOCK_MUTEX(fenced_list->mutex);
+ winsys->fence_reference(winsys, &fenced_buf->fence, fence);
+ _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ }
+ else
+ assert(0);
+}
+
+
+struct fenced_buffer_list *
+fenced_buffer_list_create(struct pipe_winsys *winsys)
+{
+ struct fenced_buffer_list *fenced_list;
+
+ fenced_list = (struct fenced_buffer_list *)calloc(1, sizeof(*fenced_list));
+ if (!fenced_list)
+ return NULL;
+
+ fenced_list->winsys = winsys;
+
+ LIST_INITHEAD(&fenced_list->delayed);
+
+ fenced_list->numDelayed = 0;
+
+ /* TODO: don't hard code this */
+ fenced_list->checkDelayed = 5;
+
+ _glthread_INIT_MUTEX(fenced_list->mutex);
+
+ return fenced_list;
+}
+
+
+void
+fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
+ int wait)
+{
+ _glthread_LOCK_MUTEX(fenced_list->mutex);
+ _fenced_buffer_list_check_free(fenced_list, wait);
+ _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+}
+
+
+void
+fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
+{
+ _glthread_LOCK_MUTEX(fenced_list->mutex);
+
+ /* Wait on outstanding fences */
+ while (fenced_list->numDelayed) {
+ _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ sched_yield();
+ _fenced_buffer_list_check_free(fenced_list, GL_TRUE);
+ _glthread_LOCK_MUTEX(fenced_list->mutex);
+ }
+
+ _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+
+ free(fenced_list);
+}
+
+
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h
new file mode 100644
index 0000000000..07e42a67f8
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h
@@ -0,0 +1,117 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * Buffer fencing.
+ *
+ * "Fenced buffers" is actually a misnomer. They should be referred as
+ * "fenceable buffers", i.e, buffers that can be fenced, but I couldn't find
+ * the word "fenceable" in the dictionary.
+ *
+ * A "fenced buffer" is a decorator around a normal buffer, which adds two
+ * special properties:
+ * - the ability for the destruction to be delayed by a fence;
+ * - reference counting.
+ *
+ * Usually DMA buffers have a life-time that will extend the life-time of its
+ * handle. The end-of-life is dictated by the fence signalling.
+ *
+ * Between the handle's destruction, and the fence signalling, the buffer is
+ * stored in a fenced buffer list.
+ *
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ */
+
+#ifndef PB_BUFFER_FENCED_H_
+#define PB_BUFFER_FENCED_H_
+
+
+#include <assert.h>
+
+
+struct pipe_winsys;
+struct pipe_buffer;
+struct pipe_fence_handle;
+
+
+/**
+ * List of buffers which are awaiting fence signalling.
+ */
+struct fenced_buffer_list;
+
+
+/**
+ * The fenced buffer's virtual function table.
+ *
+ * NOTE: Made public for debugging purposes.
+ */
+extern const struct pipe_buffer_vtbl fenced_buffer_vtbl;
+
+
+/**
+ * Create a fenced buffer list.
+ *
+ * See also fenced_bufmgr_create for a more convenient way to use this.
+ */
+struct fenced_buffer_list *
+fenced_buffer_list_create(struct pipe_winsys *winsys);
+
+
+/**
+ * Walk the fenced buffer list to check and free signalled buffers.
+ */
+void
+fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
+ int wait);
+
+void
+fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list);
+
+
+/**
+ * Wrap a buffer in a fenced buffer.
+ *
+ * NOTE: this will not increase the buffer reference count.
+ */
+struct pipe_buffer *
+fenced_buffer_create(struct fenced_buffer_list *fenced,
+ struct pipe_buffer *buffer);
+
+
+/**
+ * Set a buffer's fence.
+ *
+ * NOTE: Although it takes a generic pipe buffer argument, it will fail
+ * on everything but buffers returned by fenced_buffer_create.
+ */
+void
+buffer_fence(struct pipe_buffer *buf,
+ struct pipe_fence_handle *fence);
+
+
+#endif /*PB_BUFFER_FENCED_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_handle.c b/src/mesa/pipe/pipebuffer/pb_buffer_handle.c
new file mode 100644
index 0000000000..5a5eaee7ac
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_handle.c
@@ -0,0 +1,182 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * Drop-in implementation of the winsys driver functions for buffer handles.
+ *
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ */
+
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "pipe/p_winsys.h"
+#include "pipe/p_defines.h"
+
+#include "pb_buffer.h"
+#include "pb_buffer_handle.h"
+
+
+static struct pipe_buffer_handle *
+buffer_handle_create(struct pipe_winsys *winsys,
+ unsigned alignment,
+ unsigned flags,
+ unsigned hint)
+{
+ struct pipe_buffer_handle *handle;
+
+ handle = (struct pipe_buffer_handle *)malloc(sizeof(struct pipe_buffer_handle));
+ if(!handle)
+ return NULL;
+
+ handle->refcount = 1;
+ handle->alignment = alignment;
+ handle->flags = flags;
+ handle->hint = hint;
+
+ handle->buf = &null_buffer;
+
+ return handle;
+}
+
+
+static struct pipe_buffer_handle *
+buffer_handle_create_user(struct pipe_winsys *winsys,
+ void *data, unsigned size)
+{
+ struct pipe_buffer_handle *handle;
+ struct pipe_buffer *buf;
+
+ handle = buffer_handle_create(winsys, 1, 0, 0);
+ if(!handle)
+ return NULL;
+
+ buf = client_buffer_create(data);
+ if(!buf) {
+ free(handle);
+ return NULL;
+ }
+
+ buffer_handle_data(handle, buf);
+
+ return handle;
+}
+
+
+static void *
+buffer_handle_map(struct pipe_winsys *winsys,
+ struct pipe_buffer_handle *handle,
+ unsigned flags)
+{
+ return buffer_map(handle->buf, flags);
+}
+
+
+static void
+buffer_handle_unmap(struct pipe_winsys *winsys,
+ struct pipe_buffer_handle *handle)
+{
+ buffer_unmap(handle->buf);
+}
+
+
+static void
+buffer_handle_reference(struct pipe_winsys *winsys,
+ struct pipe_buffer_handle **dst,
+ struct pipe_buffer_handle *src)
+{
+ /* XXX: should this be thread safe? */
+
+ if (src) {
+ src->refcount++;
+ }
+
+ if (*dst) {
+ (*dst)->refcount--;
+ if ((*dst)->refcount == 0) {
+ buffer_release((*dst)->buf);
+ free(*dst);
+ }
+ }
+
+ *dst = src;
+}
+
+
+static int
+buffer_handle_subdata(struct pipe_winsys *winsys,
+ struct pipe_buffer_handle *handle,
+ unsigned long offset,
+ unsigned long size,
+ const void *data)
+{
+ void *map;
+ assert(handle);
+ assert(data);
+ map = buffer_handle_map(winsys, handle, PIPE_BUFFER_FLAG_WRITE);
+ if(map) {
+ memcpy((char *)map + offset, data, size);
+ buffer_handle_unmap(winsys, handle);
+ return 0;
+ }
+ return -1;
+}
+
+
+static int
+buffer_handle_get_subdata(struct pipe_winsys *winsys,
+ struct pipe_buffer_handle *handle,
+ unsigned long offset,
+ unsigned long size,
+ void *data)
+{
+ void *map;
+ assert(handle);
+ assert(data);
+ map = buffer_handle_map(winsys, handle, PIPE_BUFFER_FLAG_READ);
+ if(map) {
+ memcpy(data, (char *)map + offset, size);
+ buffer_handle_unmap(winsys, handle);
+ return 0;
+ }
+ return -1;
+}
+
+
+void
+buffer_handle_init_winsys(struct pipe_winsys *winsys)
+{
+ winsys->buffer_create = buffer_handle_create;
+ winsys->user_buffer_create = buffer_handle_create_user;
+ winsys->buffer_map = buffer_handle_map;
+ winsys->buffer_unmap = buffer_handle_unmap;
+ winsys->buffer_reference = buffer_handle_reference;
+ winsys->buffer_subdata = buffer_handle_subdata;
+ winsys->buffer_get_subdata = buffer_handle_get_subdata;
+}
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_handle.h b/src/mesa/pipe/pipebuffer/pb_buffer_handle.h
new file mode 100644
index 0000000000..076eec2fdc
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_handle.h
@@ -0,0 +1,120 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * Buffer handle interface.
+ *
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ */
+
+#ifndef PB_BUFFER_HANDLE_H_
+#define PB_BUFFER_HANDLE_H_
+
+
+#include <assert.h>
+
+#include "pb_buffer.h"
+
+
+/**
+ * Buffer handle.
+ *
+ * The buffer handle and the buffer data storage are separate entities. This
+ * is modelled after ARB_vertex_buffer_object, which is the interface that
+ * Gallium requires. See p_winsys.h for more information.
+ */
+struct pipe_buffer_handle
+{
+ /** Reference count */
+ unsigned refcount;
+
+ /** Allocation characteristics */
+ unsigned alignment;
+ unsigned flags;
+ unsigned hint;
+
+ /**
+ * The actual buffer.
+ *
+ * It should never be NULL. Use null_buffer instead.
+ */
+ struct pipe_buffer *buf;
+};
+
+
+/**
+ * Set buffer storage.
+ *
+ * NOTE: this will not increase the buffer reference count.
+ */
+static inline void
+buffer_handle_data(struct pipe_buffer_handle *handle,
+ struct pipe_buffer *buf)
+{
+ assert(handle);
+ assert(handle->buf);
+ buffer_release(handle->buf);
+ assert(buf);
+ handle->buf = buf;
+}
+
+
+static inline void
+buffer_handle_clear(struct pipe_buffer_handle *handle)
+{
+ buffer_handle_data(handle, &null_buffer);
+}
+
+
+static inline int
+buffer_handle_has_data(struct pipe_buffer_handle *handle) {
+ assert(handle);
+ assert(handle->buf);
+ return handle->buf != &null_buffer;
+}
+
+
+/**
+ * Fill in the pipe_winsys' buffer-related callbacks.
+ *
+ * Specifically, the fullfilled functions are:
+ * - buffer_create
+ * - user_buffer_create
+ * - buffer_map
+ * - buffer_unmap
+ * - buffer_reference
+ * - buffer_subdata
+ * - buffer_get_subdata
+ *
+ * NOTE: buffer_data is left untouched.
+ */
+void
+buffer_handle_init_winsys(struct pipe_winsys *winsys);
+
+
+#endif /*PB_BUFFER_HANDLE_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c b/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
new file mode 100644
index 0000000000..65ad51e1e7
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
@@ -0,0 +1,132 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * Implementation of malloc-based buffers to store data that can't be processed
+ * by the hardware.
+ *
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ */
+
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "pb_buffer.h"
+
+
+struct malloc_buffer
+{
+ struct pipe_buffer base;
+ void *data;
+};
+
+
+extern const struct pipe_buffer_vtbl malloc_buffer_vtbl;
+
+static inline struct malloc_buffer *
+malloc_buffer(struct pipe_buffer *buf)
+{
+ assert(buf);
+ assert(buf->vtbl == &malloc_buffer_vtbl);
+ return (struct malloc_buffer *)buf;
+}
+
+
+static void
+malloc_buffer_reference(struct pipe_buffer *buf)
+{
+ /* no-op */
+}
+
+
+static void
+malloc_buffer_release(struct pipe_buffer *buf)
+{
+ free(malloc_buffer(buf)->data);
+ free(buf);
+}
+
+
+static void *
+malloc_buffer_map(struct pipe_buffer *buf,
+ unsigned flags)
+{
+ return malloc_buffer(buf)->data;
+}
+
+
+static void
+malloc_buffer_unmap(struct pipe_buffer *buf)
+{
+ /* No-op */
+}
+
+
+static void
+malloc_buffer_get_base_buffer(struct pipe_buffer *buf,
+ struct pipe_buffer **base_buf,
+ unsigned *offset)
+{
+ *base_buf = buf;
+ *offset = 0;
+}
+
+
+const struct pipe_buffer_vtbl
+malloc_buffer_vtbl = {
+ malloc_buffer_reference,
+ malloc_buffer_release,
+ malloc_buffer_map,
+ malloc_buffer_unmap,
+ malloc_buffer_get_base_buffer
+};
+
+
+struct pipe_buffer *
+malloc_buffer_create(unsigned size)
+{
+ struct malloc_buffer *buf;
+
+ /* TODO: accept an alignment parameter */
+ /* TODO: do a single allocation */
+
+ buf = (struct malloc_buffer *)malloc(sizeof(struct malloc_buffer));
+ if(!buf)
+ return NULL;
+
+ buf->base.vtbl = &malloc_buffer_vtbl;
+
+ buf->data = malloc(size);
+ if(!buf->data) {
+ free(buf);
+ return NULL;
+ }
+
+ return &buf->base;
+}
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_null.c b/src/mesa/pipe/pipebuffer/pb_buffer_null.c
new file mode 100644
index 0000000000..a356c6b2d5
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_null.c
@@ -0,0 +1,98 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * Null buffer implementation.
+ *
+ * We have a special null buffer object so that we can safely call buffer
+ * operations without having to check whether the buffer pointer is null or not.
+ *
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ */
+
+
+#include "pipe/p_winsys.h"
+#include "pipe/p_defines.h"
+
+#include "pb_buffer.h"
+
+
+static void
+null_buffer_reference(struct pipe_buffer *buf)
+{
+ /* No-op */
+}
+
+
+static void
+null_buffer_release(struct pipe_buffer *buf)
+{
+ /* No-op */
+}
+
+
+static void *
+null_buffer_map(struct pipe_buffer *buf,
+ unsigned flags)
+{
+ assert(0);
+ return NULL;
+}
+
+
+static void
+null_buffer_unmap(struct pipe_buffer *buf)
+{
+ assert(0);
+}
+
+
+static void
+null_buffer_get_base_buffer(struct pipe_buffer *buf,
+ struct pipe_buffer **base_buf,
+ unsigned *offset)
+{
+ *base_buf = buf;
+ *offset = 0;
+}
+
+
+const struct pipe_buffer_vtbl
+pipe_buffer_vtbl = {
+ null_buffer_reference,
+ null_buffer_release,
+ null_buffer_map,
+ null_buffer_unmap,
+ null_buffer_get_base_buffer
+};
+
+
+struct pipe_buffer
+null_buffer = {
+ &pipe_buffer_vtbl
+};
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr.h b/src/mesa/pipe/pipebuffer/pb_bufmgr.h
new file mode 100644
index 0000000000..0e6c3a8d37
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr.h
@@ -0,0 +1,114 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * Buffer management.
+ *
+ * A buffer manager does only one basic thing: it creates buffers. Actually,
+ * "buffer factory" would probably a more accurate description.
+ *
+ * You can chain buffer managers so that you can have a finer grained memory
+ * management and pooling.
+ *
+ * For example, for a simple batch buffer manager you would chain:
+ * - the native buffer manager, which provides DMA memory from the graphics
+ * memory space;
+ * - the pool buffer manager, which keep around a pool of equally sized buffers
+ * to avoid latency associated with the native buffer manager;
+ * - the fenced buffer manager, which will delay buffer destruction until the
+ * the moment the card finishing processing it.
+ *
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ */
+
+#ifndef PB_BUFMGR_H_
+#define PB_BUFMGR_H_
+
+
+#include <stddef.h>
+
+
+struct pipe_buffer;
+struct pipe_winsys;
+
+
+/**
+ * Abstract base class for all buffer managers.
+ */
+struct buffer_manager
+{
+ /* XXX: we will likely need more allocation flags */
+ struct pipe_buffer *
+ (*create_buffer)( struct buffer_manager *mgr,
+ size_t size);
+
+ void
+ (*destroy)( struct buffer_manager *mgr );
+};
+
+
+/**
+ * Static buffer pool manager.
+ *
+ * Manages the allocation of equally sized buffers. It does so by allocating
+ * a single big buffer and divide it equally sized buffers.
+ *
+ * It is meant to manage the allocation of batch buffer pools.
+ */
+struct buffer_manager *
+pool_bufmgr_create(struct buffer_manager *provider,
+ size_t n, size_t size);
+
+
+/**
+ * Wraper around the old memory manager.
+ *
+ * It managers buffers of different sizes. It does so by allocating a buffer
+ * with the size of the heap, and then using the old mm memory manager to manage
+ * that heap.
+ */
+struct buffer_manager *
+mm_bufmgr_create(struct buffer_manager *provider,
+ size_t size, size_t align2);
+
+
+/**
+ * Fenced buffer manager.
+ *
+ * This manager is just meant for convenience. It wraps the buffers returned
+ * by another manager in fenced buffers, so that
+ *
+ * NOTE: the buffer manager that provides the buffers will be destroyed
+ * at the same time.
+ */
+struct buffer_manager *
+fenced_bufmgr_create(struct buffer_manager *provider,
+ struct pipe_winsys *winsys);
+
+
+#endif /*PB_BUFMGR_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
new file mode 100644
index 0000000000..defd8e4df7
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
@@ -0,0 +1,128 @@
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * A buffer manager that wraps buffers in fenced buffers.
+ *
+ * \author José Fonseca <jrfonseca@tungstengraphics.dot.com>
+ */
+
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "pb_buffer.h"
+#include "pb_buffer_fenced.h"
+#include "pb_bufmgr.h"
+
+
+struct fenced_buffer_manager
+{
+ struct buffer_manager base;
+
+ struct buffer_manager *provider;
+
+ struct fenced_buffer_list *fenced_list;
+};
+
+
+static inline struct fenced_buffer_manager *
+fenced_buffer_manager(struct buffer_manager *mgr)
+{
+ assert(mgr);
+ return (struct fenced_buffer_manager *)mgr;
+}
+
+
+static struct pipe_buffer *
+fenced_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size)
+{
+ struct fenced_buffer_manager *fenced_mgr = fenced_buffer_manager(mgr);
+ struct pipe_buffer *buf;
+ struct pipe_buffer *fenced_buf;
+
+ /* check for free buffers before allocating new ones */
+ fenced_buffer_list_check_free(fenced_mgr->fenced_list, 0);
+
+ buf = fenced_mgr->provider->create_buffer(fenced_mgr->provider, size);
+ if(!buf) {
+ /* try harder to get a buffer */
+ fenced_buffer_list_check_free(fenced_mgr->fenced_list, 1);
+
+ buf = fenced_mgr->provider->create_buffer(fenced_mgr->provider, size);
+ if(!buf) {
+ /* give up */
+ return NULL;
+ }
+ }
+
+ fenced_buf = fenced_buffer_create(fenced_mgr->fenced_list, buf);
+ if(!fenced_buf) {
+ buffer_release(buf);
+ }
+
+ return fenced_buf;
+}
+
+
+static void
+fenced_bufmgr_destroy(struct buffer_manager *mgr)
+{
+ struct fenced_buffer_manager *fenced_mgr = fenced_buffer_manager(mgr);
+
+ fenced_buffer_list_destroy(fenced_mgr->fenced_list);
+
+ fenced_mgr->provider->destroy(fenced_mgr->provider);
+
+ free(fenced_mgr);
+}
+
+
+struct buffer_manager *
+fenced_bufmgr_create(struct buffer_manager *provider,
+ struct pipe_winsys *winsys)
+{
+ struct fenced_buffer_manager *fenced_mgr;
+
+ fenced_mgr = (struct fenced_buffer_manager *)calloc(1, sizeof(*fenced_mgr));
+ if (!fenced_mgr)
+ return NULL;
+
+ fenced_mgr->base.destroy = fenced_bufmgr_destroy;
+ fenced_mgr->base.create_buffer = fenced_bufmgr_create_buffer;
+
+ fenced_mgr->provider = provider;
+ fenced_mgr->fenced_list = fenced_buffer_list_create(winsys);
+ if(!fenced_mgr->fenced_list) {
+ free(fenced_mgr);
+ return NULL;
+ }
+
+ return &fenced_mgr->base;
+}
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
new file mode 100644
index 0000000000..8e6dcf1116
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
@@ -0,0 +1,265 @@
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * Buffer manager using the old texture memory manager.
+ *
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ */
+
+
+#include <assert.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "main/imports.h"
+#include "glapi/glthread.h"
+#include "main/mm.h"
+#include "linked_list.h"
+
+#include "p_defines.h"
+#include "pb_buffer.h"
+#include "pb_bufmgr.h"
+
+
+/**
+ * Convenience macro (type safe).
+ */
+#define SUPER(__derived) (&(__derived)->base)
+
+
+struct mm_buffer_manager
+{
+ struct buffer_manager base;
+
+ _glthread_Mutex mutex;
+
+ size_t size;
+ struct mem_block *heap;
+
+ size_t align2;
+
+ struct pipe_buffer *buffer;
+ void *map;
+};
+
+
+static inline struct mm_buffer_manager *
+mm_buffer_manager(struct buffer_manager *mgr)
+{
+ assert(mgr);
+ return (struct mm_buffer_manager *)mgr;
+}
+
+
+struct mm_buffer
+{
+ struct pipe_buffer base;
+
+ struct mm_buffer_manager *mgr;
+
+ struct mem_block *block;
+};
+
+
+static inline struct mm_buffer *
+mm_buffer(struct pipe_buffer *buf)
+{
+ assert(buf);
+ return (struct mm_buffer *)buf;
+}
+
+
+static void
+mm_buffer_reference(struct pipe_buffer *buf)
+{
+ /* No-op */
+}
+
+
+static void
+mm_buffer_release(struct pipe_buffer *buf)
+{
+ struct mm_buffer *mm_buf = mm_buffer(buf);
+ struct mm_buffer_manager *mm = mm_buf->mgr;
+
+ _glthread_LOCK_MUTEX(mm->mutex);
+ mmFreeMem(mm_buf->block);
+ free(buf);
+ _glthread_UNLOCK_MUTEX(mm->mutex);
+}
+
+
+static void *
+mm_buffer_map(struct pipe_buffer *buf,
+ unsigned flags)
+{
+ struct mm_buffer *mm_buf = mm_buffer(buf);
+ struct mm_buffer_manager *mm = mm_buf->mgr;
+
+ return (unsigned char *) mm->map + mm_buf->block->ofs;
+}
+
+
+static void
+mm_buffer_unmap(struct pipe_buffer *buf)
+{
+ /* No-op */
+}
+
+
+static void
+mm_buffer_get_base_buffer(struct pipe_buffer *buf,
+ struct pipe_buffer **base_buf,
+ unsigned *offset)
+{
+ struct mm_buffer *mm_buf = mm_buffer(buf);
+ struct mm_buffer_manager *mm = mm_buf->mgr;
+ buffer_get_base_buffer(mm->buffer, base_buf, offset);
+ *offset += mm_buf->block->ofs;
+}
+
+
+static const struct pipe_buffer_vtbl
+mm_buffer_vtbl = {
+ mm_buffer_reference,
+ mm_buffer_release,
+ mm_buffer_map,
+ mm_buffer_unmap,
+ mm_buffer_get_base_buffer
+};
+
+
+static struct pipe_buffer *
+mm_bufmgr_create_buffer(struct buffer_manager *mgr,
+ size_t size)
+{
+ struct mm_buffer_manager *mm = mm_buffer_manager(mgr);
+ struct mm_buffer *mm_buf;
+
+ _glthread_LOCK_MUTEX(mm->mutex);
+
+ mm_buf = (struct mm_buffer *)malloc(sizeof(*mm_buf));
+ if (!mm_buf) {
+ _glthread_UNLOCK_MUTEX(mm->mutex);
+ return NULL;
+ }
+
+ mm_buf->base.vtbl = &mm_buffer_vtbl;
+
+ mm_buf->mgr = mm;
+
+ mm_buf->block = mmAllocMem(mm->heap, size, mm->align2, 0);
+ if(!mm_buf->block) {
+ fprintf(stderr, "warning: heap full\n");
+#if 0
+ mmDumpMemInfo(mm->heap);
+#endif
+
+ mm_buf->block = mmAllocMem(mm->heap, size, mm->align2, 0);
+ if(!mm_buf->block) {
+ assert(0);
+ free(mm_buf);
+ _glthread_UNLOCK_MUTEX(mm->mutex);
+ return NULL;
+ }
+ }
+
+ /* Some sanity checks */
+ assert(0 <= mm_buf->block->ofs && mm_buf->block->ofs < mm->size);
+ assert(size <= mm_buf->block->size && mm_buf->block->ofs + mm_buf->block->size <= mm->size);
+
+ _glthread_UNLOCK_MUTEX(mm->mutex);
+ return SUPER(mm_buf);
+}
+
+
+static void
+mm_bufmgr_destroy(struct buffer_manager *mgr)
+{
+ struct mm_buffer_manager *mm = mm_buffer_manager(mgr);
+
+ _glthread_LOCK_MUTEX(mm->mutex);
+
+ mmDestroy(mm->heap);
+
+ buffer_unmap(mm->buffer);
+ buffer_release(mm->buffer);
+
+ _glthread_UNLOCK_MUTEX(mm->mutex);
+
+ free(mgr);
+}
+
+
+struct buffer_manager *
+mm_bufmgr_create(struct buffer_manager *provider,
+ size_t size, size_t align2)
+{
+ struct mm_buffer_manager *mm;
+
+ mm = (struct mm_buffer_manager *)calloc(1, sizeof(*mm));
+ if (!mm)
+ return NULL;
+
+ assert(provider);
+ assert(provider->create_buffer);
+ mm->base.create_buffer = mm_bufmgr_create_buffer;
+ mm->base.destroy = mm_bufmgr_destroy;
+
+ mm->size = size;
+ mm->align2 = align2; /* 64-byte alignment */
+
+ _glthread_INIT_MUTEX(mm->mutex);
+
+ mm->buffer = provider->create_buffer(provider, size);
+ if (!mm->buffer)
+ goto failure;
+
+ mm->map = buffer_map(mm->buffer,
+ PIPE_BUFFER_FLAG_READ | PIPE_BUFFER_FLAG_WRITE );
+ if(!mm->map)
+ goto failure;
+
+ mm->heap = mmInit(0, size);
+ if (!mm->heap)
+ goto failure;
+
+ return SUPER(mm);
+
+failure:
+if(mm->heap)
+ mmDestroy(mm->heap);
+ if(mm->map)
+ buffer_unmap(mm->buffer);
+ if(mm->buffer)
+ buffer_release(mm->buffer);
+ if(mm)
+ free(mm);
+ return NULL;
+}
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
new file mode 100644
index 0000000000..ee6fa62500
--- /dev/null
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
@@ -0,0 +1,279 @@
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ *
+ **************************************************************************/
+
+/**
+ * \file
+ * Batch buffer pool management.
+ *
+ * \author José Fonseca <jrfonseca-at-tungstengraphics-dot-com>
+ * \author Thomas Hellström <thomas-at-tungstengraphics-dot-com>
+ */
+
+
+#include <assert.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "main/imports.h"
+#include "glapi/glthread.h"
+#include "linked_list.h"
+
+#include "p_defines.h"
+
+#include "pb_buffer.h"
+#include "pb_bufmgr.h"
+
+
+/**
+ * Convenience macro (type safe).
+ */
+#define SUPER(__derived) (&(__derived)->base)
+
+
+struct pool_buffer_manager
+{
+ struct buffer_manager base;
+
+ _glthread_Mutex mutex;
+
+ size_t bufSize;
+
+ size_t numFree;
+ size_t numTot;
+
+ struct list_head free;
+
+ struct pipe_buffer *buffer;
+ void *map;
+
+ struct pool_buffer *bufs;
+};
+
+
+static inline struct pool_buffer_manager *
+pool_buffer_manager(struct buffer_manager *mgr)
+{
+ assert(mgr);
+ return (struct pool_buffer_manager *)mgr;
+}
+
+
+struct pool_buffer
+{
+ struct pipe_buffer base;
+
+ struct pool_buffer_manager *mgr;
+
+ struct list_head head;
+
+ size_t start;
+};
+
+
+static inline struct pool_buffer *
+pool_buffer(struct pipe_buffer *buf)
+{
+ assert(buf);
+ return (struct pool_buffer *)buf;
+}
+
+
+static void
+pool_buffer_reference(struct pipe_buffer *buf)
+{
+ /* No-op */
+}
+
+
+static void
+pool_buffer_release(struct pipe_buffer *buf)
+{
+ struct pool_buffer *pool_buf = pool_buffer(buf);
+ struct pool_buffer_manager *pool = pool_buf->mgr;
+
+ _glthread_LOCK_MUTEX(pool->mutex);
+ LIST_ADD(&pool_buf->head, &pool->free);
+ pool->numFree++;
+ _glthread_UNLOCK_MUTEX(pool->mutex);
+}
+
+
+static void *
+pool_buffer_map(struct pipe_buffer *buf, unsigned flags)
+{
+ struct pool_buffer *pool_buf = pool_buffer(buf);
+ struct pool_buffer_manager *pool = pool_buf->mgr;
+ void *map;
+
+ _glthread_LOCK_MUTEX(pool->mutex);
+ map = (unsigned char *) pool->map + pool_buf->start;
+ _glthread_UNLOCK_MUTEX(pool->mutex);
+ return map;
+}
+
+
+static void
+pool_buffer_unmap(struct pipe_buffer *buf)
+{
+ /* No-op */
+}
+
+
+static void
+pool_buffer_get_base_buffer(struct pipe_buffer *buf,
+ struct pipe_buffer **base_buf,
+ unsigned *offset)
+{
+ struct pool_buffer *pool_buf = pool_buffer(buf);
+ struct pool_buffer_manager *pool = pool_buf->mgr;
+ buffer_get_base_buffer(pool->buffer, base_buf, offset);
+ *offset += pool_buf->start;
+}
+
+
+static const struct pipe_buffer_vtbl
+pool_buffer_vtbl = {
+ pool_buffer_reference,
+ pool_buffer_release,
+ pool_buffer_map,
+ pool_buffer_unmap,
+ pool_buffer_get_base_buffer
+};
+
+
+static struct pipe_buffer *
+pool_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size)
+{
+ struct pool_buffer_manager *pool = pool_buffer_manager(mgr);
+ struct pool_buffer *pool_buf;
+ struct list_head *item;
+
+ assert(size == pool->bufSize);
+
+ _glthread_LOCK_MUTEX(pool->mutex);
+
+ if (pool->numFree == 0) {
+ _glthread_UNLOCK_MUTEX(pool->mutex);
+ fprintf(stderr, "warning: out of fixed size buffer objects\n");
+ return NULL;
+ }
+
+ item = pool->free.next;
+
+ if (item == &pool->free) {
+ _glthread_UNLOCK_MUTEX(pool->mutex);
+ fprintf(stderr, "error: fixed size buffer pool corruption\n");
+ return NULL;
+ }
+
+ LIST_DEL(item);
+ --pool->numFree;
+
+ _glthread_UNLOCK_MUTEX(pool->mutex);
+ pool_buf = LIST_ENTRY(struct pool_buffer, item, head);
+ return SUPER(pool_buf);
+}
+
+
+static void
+pool_bufmgr_destroy(struct buffer_manager *mgr)
+{
+ struct pool_buffer_manager *pool = pool_buffer_manager(mgr);
+ _glthread_LOCK_MUTEX(pool->mutex);
+
+ free(pool->bufs);
+
+ buffer_unmap(pool->buffer);
+ buffer_release(pool->buffer);
+
+ _glthread_UNLOCK_MUTEX(pool->mutex);
+
+ free(mgr);
+}
+
+
+struct buffer_manager *
+pool_bufmgr_create(struct buffer_manager *provider,
+ size_t numBufs,
+ size_t bufSize)
+{
+ struct pool_buffer_manager *pool;
+ struct pool_buffer *pool_buf;
+ int i;
+
+ pool = (struct pool_buffer_manager *)calloc(1, sizeof(*pool));
+ if (!pool)
+ return NULL;
+
+ pool->base.destroy = pool_bufmgr_destroy;
+ pool->base.create_buffer = pool_bufmgr_create_buffer;
+
+ LIST_INITHEAD(&pool->free);
+
+ pool->numTot = numBufs;
+ pool->numFree = numBufs;
+ pool->bufSize = bufSize;
+
+ _glthread_INIT_MUTEX(pool->mutex);
+
+ pool->buffer = provider->create_buffer(provider, numBufs*bufSize);
+ if (!pool->buffer)
+ goto failure;
+
+ pool->map = buffer_map(pool->buffer,
+ PIPE_BUFFER_FLAG_READ |
+ PIPE_BUFFER_FLAG_WRITE );
+ if(!pool->map)
+ goto failure;
+
+ pool->bufs = (struct pool_buffer *) malloc(numBufs * sizeof(*pool->bufs));
+ if (!pool->bufs)
+ goto failure;
+
+ pool_buf = pool->bufs;
+ for (i = 0; i < numBufs; ++i) {
+ pool_buf->base.vtbl = &pool_buffer_vtbl;
+ pool_buf->mgr = pool;
+ pool_buf->start = i * bufSize;
+ LIST_ADDTAIL(&pool_buf->head, &pool->free);
+ pool_buf++;
+ }
+
+ return SUPER(pool);
+
+failure:
+ if(pool->bufs)
+ free(pool->bufs);
+ if(pool->map)
+ buffer_unmap(pool->buffer);
+ if(pool->buffer)
+ buffer_release(pool->buffer);
+ if(pool)
+ free(pool);
+ return NULL;
+}
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index df4e0cbd5a..809b165f45 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -244,7 +244,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
uint i;
#if defined(__i386__) || defined(__386__)
- softpipe->use_sse = GETENV( "GALLIUM_SSE" ) != NULL;
+ softpipe->use_sse = GETENV( "GALLIUM_NOSSE" ) == NULL;
#else
softpipe->use_sse = FALSE;
#endif
diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c
index 9f5a43a827..6980564bdc 100644
--- a/src/mesa/pipe/softpipe/sp_prim_setup.c
+++ b/src/mesa/pipe/softpipe/sp_prim_setup.c
@@ -1124,6 +1124,12 @@ static void reset_stipple_counter( struct draw_stage *stage )
}
+static void render_destroy( struct draw_stage *stage )
+{
+ FREE( stage );
+}
+
+
/**
* Create a new primitive setup/render stage.
*/
@@ -1139,6 +1145,7 @@ struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe )
setup->stage.tri = setup_tri;
setup->stage.end = setup_end;
setup->stage.reset_stipple_counter = reset_stipple_counter;
+ setup->stage.destroy = render_destroy;
setup->quad.coef = setup->coef;
diff --git a/src/mesa/pipe/softpipe/sp_prim_vbuf.c b/src/mesa/pipe/softpipe/sp_prim_vbuf.c
index 59cf1c4eb7..2cfdeb5809 100644
--- a/src/mesa/pipe/softpipe/sp_prim_vbuf.c
+++ b/src/mesa/pipe/softpipe/sp_prim_vbuf.c
@@ -275,6 +275,16 @@ static void reset_stipple_counter( struct draw_stage *stage )
}
+static void vbuf_destroy( struct draw_stage *stage )
+{
+ struct vbuf_stage *vbuf = vbuf_stage( stage );
+
+ FREE( vbuf->element_map );
+ FREE( vbuf->vertex_map );
+ FREE( stage );
+}
+
+
/**
* Create a new primitive vbuf/render stage.
*/
@@ -290,6 +300,7 @@ struct draw_stage *sp_draw_vbuf_stage( struct draw_context *draw_context,
vbuf->stage.tri = vbuf_first_tri;
vbuf->stage.end = vbuf_end;
vbuf->stage.reset_stipple_counter = reset_stipple_counter;
+ vbuf->stage.destroy = vbuf_destroy;
vbuf->pipe = pipe;
vbuf->draw = draw;
diff --git a/src/mesa/pipe/softpipe/sp_texture.c b/src/mesa/pipe/softpipe/sp_texture.c
index 2288c343bf..cfe9628184 100644
--- a/src/mesa/pipe/softpipe/sp_texture.c
+++ b/src/mesa/pipe/softpipe/sp_texture.c
@@ -382,7 +382,9 @@ softpipe_texture_create(struct pipe_context *pipe, struct pipe_texture **pt)
if (softpipe_mipmap_tree_layout(pipe, spt)) {
spt->buffer = pipe->winsys->buffer_create(pipe->winsys,
- PIPE_SURFACE_FLAG_TEXTURE);
+ 32,
+ PIPE_SURFACE_FLAG_TEXTURE,
+ 0);
if (spt->buffer) {
pipe->winsys->buffer_data(pipe->winsys, spt->buffer,
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.c b/src/mesa/pipe/tgsi/exec/tgsi_exec.c
index dd11dd58b7..ab83f27c1b 100644
--- a/src/mesa/pipe/tgsi/exec/tgsi_exec.c
+++ b/src/mesa/pipe/tgsi/exec/tgsi_exec.c
@@ -1066,6 +1066,10 @@ fetch_source(
case TGSI_UTIL_SIGN_KEEP:
break;
}
+
+ if (reg->SrcRegisterExtMod.Complement) {
+ micro_sub( chan, &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], chan );
+ }
}
static void
@@ -1808,7 +1812,7 @@ exec_instruction(
micro_sub( &r[2], &r[2], &r[5] );
if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &r[2], 0, CHAN_X );
+ STORE( &r[2], 0, CHAN_X );
}
FETCH(&r[2], 1, CHAN_X);
@@ -1821,7 +1825,7 @@ exec_instruction(
micro_sub( &r[3], &r[3], &r[1] );
if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
- STORE( &r[3], 0, CHAN_Y );
+ STORE( &r[3], 0, CHAN_Y );
}
micro_mul( &r[5], &r[5], &r[4] );
@@ -1829,11 +1833,11 @@ exec_instruction(
micro_sub( &r[5], &r[5], &r[0] );
if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- STORE( &r[5], 0, CHAN_Z );
+ STORE( &r[5], 0, CHAN_Z );
}
if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
+ STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
}
break;
diff --git a/src/mesa/pipe/tgsi/util/tgsi_dump.c b/src/mesa/pipe/tgsi/util/tgsi_dump.c
index 982d5ce796..3f4d930dec 100644
--- a/src/mesa/pipe/tgsi/util/tgsi_dump.c
+++ b/src/mesa/pipe/tgsi/util/tgsi_dump.c
@@ -31,129 +31,196 @@
#include "tgsi_parse.h"
#include "tgsi_build.h"
-struct text_dump
+struct gen_dump
{
- FILE *file;
unsigned tabs;
+ void (* write)(
+ struct gen_dump *dump,
+ const void *data,
+ unsigned size );
+};
+
+struct text_dump
+{
+ struct gen_dump base;
+ char *text;
+ unsigned length;
+ unsigned capacity;
};
static void
-text_dump_str(
- struct text_dump *dump,
- const char *str )
+_text_dump_write(
+ struct gen_dump *dump,
+ const void *data,
+ unsigned size )
{
- unsigned i;
- size_t len = strlen( str );
+ struct text_dump *td = (struct text_dump *) dump;
+ unsigned new_length = td->length + size;
+
+ if( new_length >= td->capacity ) {
+ unsigned new_capacity = td->capacity;
+
+ do {
+ if( new_capacity == 0 ) {
+ new_capacity = 256;
+ }
+ else {
+ new_capacity *= 2;
+ }
+ } while( new_length >= new_capacity );
+ td->text = (char *) REALLOC(
+ td->text,
+ td->capacity,
+ new_capacity );
+ td->capacity = new_capacity;
+ }
+ memcpy(
+ &td->text[td->length],
+ data,
+ size );
+ td->length = new_length;
+ td->text[td->length] = '\0';
+}
+
+struct file_dump
+{
+ struct gen_dump base;
+ FILE *file;
+};
+
+static void
+_file_dump_write(
+ struct gen_dump *dump,
+ const void *data,
+ unsigned size )
+{
+ struct file_dump *fd = (struct file_dump *) dump;
+
+#if 0
+ fwrite( data, 1, size, fd->file );
+#else
+ {
+ unsigned i;
- for( i = 0; i < len; i++ ) {
- fprintf( dump->file, "%c", str[i] );
+ for (i = 0; i < size; i++ ) {
+ fprintf( fd->file, "%c", ((const char *) data)[i] );
+ }
+ }
+#endif
+}
- if( str[i] == '\n' ) {
+static void
+gen_dump_str(
+ struct gen_dump *dump,
+ const char *str )
+{
+ unsigned i;
+ size_t len = strlen( str );
+
+ for (i = 0; i < len; i++) {
+ dump->write( dump, &str[i], 1 );
+ if (str[i] == '\n') {
unsigned i;
- for( i = 0; i < dump->tabs; i++ ) {
- fprintf( dump->file, " " );
+ for (i = 0; i < dump->tabs; i++) {
+ dump->write( dump, " ", 4 );
}
}
}
}
static void
-text_dump_chr(
- struct text_dump *dump,
- const char chr )
+gen_dump_chr(
+ struct gen_dump *dump,
+ const char chr )
{
- char str[2];
-
- str[0] = chr;
- str[1] = '\0';
- text_dump_str( dump, str );
+ dump->write( dump, &chr, 1 );
}
static void
-text_dump_uix(
- struct text_dump *dump,
- const unsigned ui )
+gen_dump_uix(
+ struct gen_dump *dump,
+ const unsigned ui )
{
- char str[36];
+ char str[36];
sprintf( str, "0x%x", ui );
- text_dump_str( dump, str );
+ gen_dump_str( dump, str );
}
static void
-text_dump_uid(
- struct text_dump *dump,
- const unsigned ui )
+gen_dump_uid(
+ struct gen_dump *dump,
+ const unsigned ui )
{
- char str[16];
+ char str[16];
sprintf( str, "%u", ui );
- text_dump_str( dump, str );
+ gen_dump_str( dump, str );
}
static void
-text_dump_sid(
- struct text_dump *dump,
- const int si )
+gen_dump_sid(
+ struct gen_dump *dump,
+ const int si )
{
- char str[16];
+ char str[16];
sprintf( str, "%d", si );
- text_dump_str( dump, str );
+ gen_dump_str( dump, str );
}
static void
-text_dump_flt(
- struct text_dump *dump,
- const float f )
+gen_dump_flt(
+ struct gen_dump *dump,
+ const float flt )
{
- char str[48];
+ char str[48];
- sprintf( str, "%10.4f", f );
- text_dump_str( dump, str );
+ sprintf( str, "%10.4f", flt );
+ gen_dump_str( dump, str );
}
static void
-text_dump_enum(
- struct text_dump *dump,
- const unsigned e,
- const char **enums,
- const unsigned enums_count )
+gen_dump_enum(
+ struct gen_dump *dump,
+ const unsigned e,
+ const char **enums,
+ const unsigned enums_count )
{
- if( e >= enums_count ) {
- text_dump_uid( dump, e );
+ if (e >= enums_count) {
+ gen_dump_uid( dump, e );
}
else {
- text_dump_str( dump, enums[e] );
+ gen_dump_str( dump, enums[e] );
}
}
static void
-text_dump_tab(
- struct text_dump *dump )
+gen_dump_tab(
+ struct gen_dump *dump )
{
- dump->tabs++;
+ ++dump->tabs;
}
static void
-text_dump_untab(
- struct text_dump *dump )
+gen_dump_untab(
+ struct gen_dump *dump )
{
assert( dump->tabs > 0 );
--dump->tabs;
}
-#define TXT(S) text_dump_str( dump, S )
-#define CHR(C) text_dump_chr( dump, C )
-#define UIX(I) text_dump_uix( dump, I )
-#define UID(I) text_dump_uid( dump, I )
-#define SID(I) text_dump_sid( dump, I )
-#define FLT(F) text_dump_flt( dump, F )
-#define TAB() text_dump_tab( dump )
-#define UNT() text_dump_untab( dump )
-#define ENM(E,ENUMS) text_dump_enum( dump, E, ENUMS, sizeof( ENUMS ) / sizeof( *ENUMS ) )
+#define TXT(S) gen_dump_str( dump, S )
+#define CHR(C) gen_dump_chr( dump, C )
+#define UIX(I) gen_dump_uix( dump, I )
+#define UID(I) gen_dump_uid( dump, I )
+#define SID(I) gen_dump_sid( dump, I )
+#define FLT(F) gen_dump_flt( dump, F )
+#define TAB() gen_dump_tab( dump )
+#define UNT() gen_dump_untab( dump )
+#define ENM(E,ENUMS) gen_dump_enum( dump, E, ENUMS, sizeof( ENUMS ) / sizeof( *ENUMS ) )
static const char *TGSI_PROCESSOR_TYPES[] =
{
@@ -659,8 +726,8 @@ static const char *TGSI_MODULATES[] =
static void
dump_declaration_short(
- struct text_dump *dump,
- struct tgsi_full_declaration *decl )
+ struct gen_dump *dump,
+ struct tgsi_full_declaration *decl )
{
TXT( "\nDCL " );
ENM( decl->Declaration.File, TGSI_FILES_SHORT );
@@ -711,11 +778,11 @@ dump_declaration_short(
static void
dump_declaration_verbose(
- struct text_dump *dump,
- struct tgsi_full_declaration *decl,
- unsigned ignored,
- unsigned deflt,
- struct tgsi_full_declaration *fd )
+ struct gen_dump *dump,
+ struct tgsi_full_declaration *decl,
+ unsigned ignored,
+ unsigned deflt,
+ struct tgsi_full_declaration *fd )
{
TXT( "\nFile : " );
ENM( decl->Declaration.File, TGSI_FILES );
@@ -792,7 +859,7 @@ dump_declaration_verbose(
static void
dump_immediate_short(
- struct text_dump *dump,
+ struct gen_dump *dump,
struct tgsi_full_immediate *imm )
{
unsigned i;
@@ -820,9 +887,9 @@ dump_immediate_short(
static void
dump_immediate_verbose(
- struct text_dump *dump,
+ struct gen_dump *dump,
struct tgsi_full_immediate *imm,
- unsigned ignored )
+ unsigned ignored )
{
unsigned i;
@@ -849,12 +916,12 @@ dump_immediate_verbose(
static void
dump_instruction_short(
- struct text_dump *dump,
- struct tgsi_full_instruction *inst,
- unsigned instno )
+ struct gen_dump *dump,
+ struct tgsi_full_instruction *inst,
+ unsigned instno )
{
unsigned i;
- boolean first_reg = TRUE;
+ boolean first_reg = TRUE;
CHR( '\n' );
UID( instno );
@@ -915,6 +982,9 @@ dump_instruction_short(
}
CHR( ' ' );
+ if( src->SrcRegisterExtMod.Complement ) {
+ TXT( "(1 - " );
+ }
if( src->SrcRegisterExtMod.Negate ) {
CHR( '-' );
}
@@ -957,6 +1027,9 @@ dump_instruction_short(
if( src->SrcRegisterExtMod.Absolute ) {
CHR( '|' );
}
+ if( src->SrcRegisterExtMod.Complement ) {
+ CHR( ')' );
+ }
first_reg = FALSE;
}
@@ -975,11 +1048,11 @@ dump_instruction_short(
static void
dump_instruction_verbose(
- struct text_dump *dump,
- struct tgsi_full_instruction *inst,
- unsigned ignored,
- unsigned deflt,
- struct tgsi_full_instruction *fi )
+ struct gen_dump *dump,
+ struct tgsi_full_instruction *inst,
+ unsigned ignored,
+ unsigned deflt,
+ struct tgsi_full_instruction *fi )
{
unsigned i;
@@ -1317,13 +1390,12 @@ dump_instruction_verbose(
}
}
-void
-tgsi_dump(
+static void
+dump_gen(
+ struct gen_dump *dump,
const struct tgsi_token *tokens,
- unsigned flags )
+ unsigned flags )
{
- struct text_dump _dump;
- struct text_dump *dump = &_dump;
struct tgsi_parse_context parse;
struct tgsi_full_instruction fi;
struct tgsi_full_declaration fd;
@@ -1332,18 +1404,7 @@ tgsi_dump(
unsigned deflt = !(flags & TGSI_DUMP_NO_DEFAULT);
unsigned instno = 0;
- {
-#if 0
- static unsigned counter = 0;
- char buffer[64];
-
- sprintf( buffer, "tgsi-dump-%.4u.txt", counter++ );
- dump->file = fopen( buffer, "wt" );
-#else
- dump->file = stderr;
-#endif
- dump->tabs = 0;
- }
+ dump->tabs = 0;
/* sanity check */
assert(strcmp(TGSI_OPCODES[TGSI_OPCODE_CONT], "OPCODE_CONT") == 0);
@@ -1457,3 +1518,52 @@ tgsi_dump(
tgsi_parse_free( &parse );
}
+void
+tgsi_dump(
+ const struct tgsi_token *tokens,
+ unsigned flags )
+{
+ struct file_dump dump;
+
+ dump.base.write = _file_dump_write;
+#if 0
+ {
+ static unsigned counter = 0;
+ char buffer[64];
+ sprintf( buffer, "tgsi-dump-%.4u.txt", counter++ );
+ dump.file = fopen( buffer, "wt" );
+ }
+#else
+ dump.file = stderr;
+#endif
+
+ dump_gen(
+ &dump.base,
+ tokens,
+ flags );
+
+#if 0
+ fclose( dump.file );
+#endif
+}
+
+void
+tgsi_dump_str(
+ char **str,
+ const struct tgsi_token *tokens,
+ unsigned flags )
+{
+ struct text_dump dump;
+
+ dump.base.write = _text_dump_write;
+ dump.text = NULL;
+ dump.length = 0;
+ dump.capacity = 0;
+
+ dump_gen(
+ &dump.base,
+ tokens,
+ flags );
+
+ *str = dump.text;
+}
diff --git a/src/mesa/pipe/tgsi/util/tgsi_dump.h b/src/mesa/pipe/tgsi/util/tgsi_dump.h
index 70860c0885..1adc9db251 100644
--- a/src/mesa/pipe/tgsi/util/tgsi_dump.h
+++ b/src/mesa/pipe/tgsi/util/tgsi_dump.h
@@ -12,7 +12,13 @@ extern "C" {
void
tgsi_dump(
const struct tgsi_token *tokens,
- unsigned flags );
+ unsigned flags );
+
+void
+tgsi_dump_str(
+ char **str,
+ const struct tgsi_token *tokens,
+ unsigned flags );
#if defined __cplusplus
} // extern "C"
diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c
index 976884ad52..c347d1c2a3 100644
--- a/src/mesa/pipe/xlib/xm_winsys.c
+++ b/src/mesa/pipe/xlib/xm_winsys.c
@@ -155,7 +155,7 @@ xm_buffer_reference(struct pipe_winsys *pws,
}
}
-static void
+static int
xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
unsigned size, const void *data, unsigned usage )
{
@@ -169,9 +169,10 @@ xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
}
if (data)
memcpy(xm_buf->data, data, size);
+ return 0;
}
-static void
+static int
xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
unsigned long offset, unsigned long size, const void *data)
{
@@ -180,9 +181,10 @@ xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
assert(!xm_buf->userBuffer);
assert(b);
memcpy(b + offset, data, size);
+ return 0;
}
-static void
+static int
xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
unsigned long offset, unsigned long size, void *data)
{
@@ -191,6 +193,7 @@ xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
assert(!xm_buf->userBuffer);
assert(b);
memcpy(data, b + offset, size);
+ return 0;
}
@@ -255,7 +258,10 @@ xm_get_name(struct pipe_winsys *pws)
static struct pipe_buffer_handle *
-xm_buffer_create(struct pipe_winsys *pws, unsigned flags)
+xm_buffer_create(struct pipe_winsys *pws,
+ unsigned alignment,
+ unsigned flags,
+ unsigned hints)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
buffer->refcount = 1;
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index 446250c226..57f5ec68d2 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -70,7 +70,7 @@ void st_upload_constants( struct st_context *st,
_mesa_load_state_parameters(st->ctx, params);
if (!cbuf->buffer)
- cbuf->buffer = ws->buffer_create(ws, 1);
+ cbuf->buffer = ws->buffer_create(ws, 1, 0, 0);
if (0)
{
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 99e1eb3c7a..872248cdb5 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -63,7 +63,7 @@ st_bufferobj_alloc(GLcontext *ctx, GLuint name, GLenum target)
_mesa_initialize_buffer_object(&st_obj->Base, name, target);
- st_obj->buffer = st->pipe->winsys->buffer_create( st->pipe->winsys, 32 );
+ st_obj->buffer = st->pipe->winsys->buffer_create( st->pipe->winsys, 32, 0, 0 );
return &st_obj->Base;
}
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index cbda56b5c3..10396c3feb 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -118,7 +118,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
pipe->winsys->buffer_reference(pipe->winsys, &strb->surface->buffer,
NULL);
- strb->surface->buffer = pipe->winsys->buffer_create(pipe->winsys, flags);
+ strb->surface->buffer = pipe->winsys->buffer_create(pipe->winsys, 32, flags, 0);
if (!strb->surface->buffer)
return GL_FALSE; /* out of memory, try s/w buffer? */
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 32dcd73c46..c6fea1f7bc 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -50,37 +50,141 @@
#include "pipe/draw/draw_context.h"
+static GLuint double_types[4] = {
+ PIPE_FORMAT_R64_FLOAT,
+ PIPE_FORMAT_R64G64_FLOAT,
+ PIPE_FORMAT_R64G64B64_FLOAT,
+ PIPE_FORMAT_R64G64B64A64_FLOAT
+};
+
+static GLuint float_types[4] = {
+ PIPE_FORMAT_R32_FLOAT,
+ PIPE_FORMAT_R32G32_FLOAT,
+ PIPE_FORMAT_R32G32B32_FLOAT,
+ PIPE_FORMAT_R32G32B32A32_FLOAT
+};
+
+static GLuint uint_types_norm[4] = {
+ PIPE_FORMAT_R32_UNORM,
+ PIPE_FORMAT_R32G32_UNORM,
+ PIPE_FORMAT_R32G32B32_UNORM,
+ PIPE_FORMAT_R32G32B32A32_UNORM
+};
+
+static GLuint uint_types_scale[4] = {
+ PIPE_FORMAT_R32_USCALED,
+ PIPE_FORMAT_R32G32_USCALED,
+ PIPE_FORMAT_R32G32B32_USCALED,
+ PIPE_FORMAT_R32G32B32A32_USCALED
+};
+
+static GLuint int_types_norm[4] = {
+ PIPE_FORMAT_R32_SNORM,
+ PIPE_FORMAT_R32G32_SNORM,
+ PIPE_FORMAT_R32G32B32_SNORM,
+ PIPE_FORMAT_R32G32B32A32_SNORM
+};
+
+static GLuint int_types_scale[4] = {
+ PIPE_FORMAT_R32_SSCALED,
+ PIPE_FORMAT_R32G32_SSCALED,
+ PIPE_FORMAT_R32G32B32_SSCALED,
+ PIPE_FORMAT_R32G32B32A32_SSCALED
+};
+
+static GLuint ushort_types_norm[4] = {
+ PIPE_FORMAT_R16_UNORM,
+ PIPE_FORMAT_R16G16_UNORM,
+ PIPE_FORMAT_R16G16B16_UNORM,
+ PIPE_FORMAT_R16G16B16A16_UNORM
+};
+
+static GLuint ushort_types_scale[4] = {
+ PIPE_FORMAT_R16_USCALED,
+ PIPE_FORMAT_R16G16_USCALED,
+ PIPE_FORMAT_R16G16B16_USCALED,
+ PIPE_FORMAT_R16G16B16A16_USCALED
+};
+
+static GLuint short_types_norm[4] = {
+ PIPE_FORMAT_R16_SNORM,
+ PIPE_FORMAT_R16G16_SNORM,
+ PIPE_FORMAT_R16G16B16_SNORM,
+ PIPE_FORMAT_R16G16B16A16_SNORM
+};
+
+static GLuint short_types_scale[4] = {
+ PIPE_FORMAT_R16_SSCALED,
+ PIPE_FORMAT_R16G16_SSCALED,
+ PIPE_FORMAT_R16G16B16_SSCALED,
+ PIPE_FORMAT_R16G16B16A16_SSCALED
+};
+
+static GLuint ubyte_types_norm[4] = {
+ PIPE_FORMAT_R8_UNORM,
+ PIPE_FORMAT_R8G8_UNORM,
+ PIPE_FORMAT_R8G8B8_UNORM,
+ PIPE_FORMAT_R8G8B8A8_UNORM
+};
+
+static GLuint ubyte_types_scale[4] = {
+ PIPE_FORMAT_R8_USCALED,
+ PIPE_FORMAT_R8G8_USCALED,
+ PIPE_FORMAT_R8G8B8_USCALED,
+ PIPE_FORMAT_R8G8B8A8_USCALED
+};
+
+static GLuint byte_types_norm[4] = {
+ PIPE_FORMAT_R8_SNORM,
+ PIPE_FORMAT_R8G8_SNORM,
+ PIPE_FORMAT_R8G8B8_SNORM,
+ PIPE_FORMAT_R8G8B8A8_SNORM
+};
+
+static GLuint byte_types_scale[4] = {
+ PIPE_FORMAT_R8_SSCALED,
+ PIPE_FORMAT_R8G8_SSCALED,
+ PIPE_FORMAT_R8G8B8_SSCALED,
+ PIPE_FORMAT_R8G8B8A8_SSCALED
+};
+
+
/**
* Return a PIPE_FORMAT_x for the given GL datatype and size.
*/
static GLuint
-pipe_vertex_format(GLenum type, GLuint size)
+pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized)
{
- static const GLuint float_fmts[4] = {
- PIPE_FORMAT_R32_FLOAT,
- PIPE_FORMAT_R32G32_FLOAT,
- PIPE_FORMAT_R32G32B32_FLOAT,
- PIPE_FORMAT_R32G32B32A32_FLOAT,
- };
- static const GLuint int_fmts[4] = {
- PIPE_FORMAT_R32_SSCALED,
- PIPE_FORMAT_R32G32_SSCALED,
- PIPE_FORMAT_R32G32B32_SSCALED,
- PIPE_FORMAT_R32G32B32A32_SSCALED,
- };
-
assert(type >= GL_BYTE);
assert(type <= GL_DOUBLE);
assert(size >= 1);
assert(size <= 4);
- switch (type) {
- case GL_FLOAT:
- return float_fmts[size - 1];
- case GL_INT:
- return int_fmts[size - 1];
- default:
- assert(0);
+ if (normalized) {
+ switch (type) {
+ case GL_DOUBLE: return double_types[size-1];
+ case GL_FLOAT: return float_types[size-1];
+ case GL_INT: return int_types_norm[size-1];
+ case GL_SHORT: return short_types_norm[size-1];
+ case GL_BYTE: return byte_types_norm[size-1];
+ case GL_UNSIGNED_INT: return uint_types_norm[size-1];
+ case GL_UNSIGNED_SHORT: return ushort_types_norm[size-1];
+ case GL_UNSIGNED_BYTE: return ubyte_types_norm[size-1];
+ default: assert(0); return 0;
+ }
+ }
+ else {
+ switch (type) {
+ case GL_DOUBLE: return double_types[size-1];
+ case GL_FLOAT: return float_types[size-1];
+ case GL_INT: return int_types_scale[size-1];
+ case GL_SHORT: return short_types_scale[size-1];
+ case GL_BYTE: return byte_types_scale[size-1];
+ case GL_UNSIGNED_INT: return uint_types_scale[size-1];
+ case GL_UNSIGNED_SHORT: return ushort_types_scale[size-1];
+ case GL_UNSIGNED_BYTE: return ubyte_types_scale[size-1];
+ default: assert(0); return 0;
+ }
}
return 0; /* silence compiler warning */
}
@@ -95,7 +199,7 @@ static void
create_default_attribs_buffer(struct st_context *st)
{
struct pipe_context *pipe = st->pipe;
- st->default_attrib_buffer = pipe->winsys->buffer_create( pipe->winsys, 32 );
+ st->default_attrib_buffer = pipe->winsys->buffer_create( pipe->winsys, 32, 0, 0 );
}
@@ -181,7 +285,8 @@ st_draw_vbo(GLcontext *ctx,
velement.vertex_buffer_index = attr;
velement.dst_offset = 0; /* need this? */
velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type,
- arrays[mesaAttr]->Size);
+ arrays[mesaAttr]->Size,
+ arrays[mesaAttr]->Normalized);
assert(velement.src_format);
/* tell pipe about this attribute */
@@ -288,7 +393,7 @@ st_draw_vertices(GLcontext *ctx, unsigned prim,
}
/* XXX create one-time */
- vbuf = pipe->winsys->buffer_create(pipe->winsys, 32);
+ vbuf = pipe->winsys->buffer_create(pipe->winsys, 32, 0, 0);
pipe->winsys->buffer_data(pipe->winsys, vbuf,
vertex_bytes, verts,
PIPE_BUFFER_USAGE_VERTEX);
@@ -438,7 +543,8 @@ st_feedback_draw_vbo(GLcontext *ctx,
velement.vertex_buffer_index = attr;
velement.dst_offset = 0; /* need this? */
velement.src_format = pipe_vertex_format(arrays[mesaAttr]->Type,
- arrays[mesaAttr]->Size);
+ arrays[mesaAttr]->Size,
+ arrays[mesaAttr]->Normalized);
assert(velement.src_format);
/* tell draw about this attribute */