summaryrefslogtreecommitdiffstats
path: root/progs
diff options
context:
space:
mode:
authorDavid Nusinow <[email protected]>2005-11-09 02:46:07 +0000
committerDavid Nusinow <[email protected]>2005-11-09 02:46:07 +0000
commitc37d6b4ca8a9a7ac42a2e0082cf1bb0acbbff3cc (patch)
tree85b03b216318e1c3c138fd1f4371df3d3ac2dd35 /progs
Commit Mesa 6.4 sources and packaging
Diffstat (limited to 'progs')
-rw-r--r--progs/Makefile30
-rw-r--r--progs/util/README22
-rw-r--r--progs/util/dumpstate.c1959
-rw-r--r--progs/util/errcheck.c27
-rw-r--r--progs/util/glstate.c504
-rw-r--r--progs/util/glstate.h53
-rw-r--r--progs/util/glutskel.c157
-rw-r--r--progs/util/idproj.c26
-rw-r--r--progs/util/imagesgi.h55
-rw-r--r--progs/util/matrix.c181
-rw-r--r--progs/util/mwmborder.c91
-rw-r--r--progs/util/readtex.c451
-rw-r--r--progs/util/readtex.h26
-rw-r--r--progs/util/sampleMakefile49
-rw-r--r--progs/util/showbuffer.c192
-rw-r--r--progs/util/showbuffer.h36
-rw-r--r--progs/util/winpos.c42
17 files changed, 3901 insertions, 0 deletions
diff --git a/progs/Makefile b/progs/Makefile
new file mode 100644
index 00000000000..858d628c0a5
--- /dev/null
+++ b/progs/Makefile
@@ -0,0 +1,30 @@
+# progs/Makefile
+
+TOP = ..
+
+include $(TOP)/configs/current
+
+SUBDIRS = $(PROGRAM_DIRS)
+
+
+default: message subdirs
+
+
+message:
+ @echo "Making programs for" $(CONFIG_NAME)
+
+
+subdirs:
+ @for dir in $(SUBDIRS) ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir ; $(MAKE)) || exit 1 ; \
+ fi \
+ done
+
+
+clean:
+ @for dir in $(SUBDIRS) tests ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir ; $(MAKE) clean) ; \
+ fi \
+ done
diff --git a/progs/util/README b/progs/util/README
new file mode 100644
index 00000000000..8c143142e41
--- /dev/null
+++ b/progs/util/README
@@ -0,0 +1,22 @@
+
+This directory is a collection of function which may be useful to
+OpenGL/Mesa programmers.
+
+
+errcheck.c - an OpenGL error check/report function
+glutskel.c - handy skeleton for GLUT programs
+idproj.c - setup an identity projection
+mwmborder.c - remove Motif window decoration/border
+winpos.c - set absolute window raster position
+readtex.c - load textures/mipmaps from an .rgb file
+showbuffer.[ch] - show depth, alpha, or stencil buffer contents
+glstate.[ch] - query/print GL state variables, for debugging, etc.
+sampleMakefile - example Makefile for making OpenGL/Mesa apps on Unix
+dumpsate.c - dump all OpenGL state, from Stephane Rehel
+imagesgi.cpp,.h - read SGI image files
+
+
+more to come...
+
+----------------------------------------------------------------------
+$Id: README,v 1.1.1.1 1999/08/19 00:55:42 jtg Exp $
diff --git a/progs/util/dumpstate.c b/progs/util/dumpstate.c
new file mode 100644
index 00000000000..4c039a40f97
--- /dev/null
+++ b/progs/util/dumpstate.c
@@ -0,0 +1,1959 @@
+
+/*
+ *
+ * From: Stephane Rehel <[email protected]>
+ * Date: Mon, 31 May 1999 18:40:54 -0400
+ * To: Paul Brian <[email protected]>
+ * Subject: OpenGL State Dump Function
+ *
+ * Here is a function that dumps the current OpenGL state. I wrote it
+ * some time ago.
+ *
+ * In the attachment:
+ * + the code itself
+ * + its output
+ *
+ * I think Mesa is wrong on some getBooleanv(). For example, GL_VERTEX_ARRAY
+ * is queried by IsEnabled() (cf. p. 196 of the spec). But on page 193
+ * we can read that all the boolean attribs that can be queried by IsEnabled()
+ * can also be queried by IsEnabled().
+ *
+ * I had duplicated all the enums (LOCAL_*) so that the code can run on any
+ * OpenGL version, even if an enum is not recognized.
+ *
+ * The code can be shipped in the public domain.
+ *
+ * Stephane.
+ */
+
+
+/*
+ * Stephane Rehel
+ * Creation: February 5 1999
+ */
+
+#include <stdio.h>
+#include <GL/gl.h>
+
+/***************************************************************************/
+
+enum {
+ /* Data types */
+ LOCAL_GL_BYTE = 0x1400,
+ LOCAL_GL_UNSIGNED_BYTE = 0x1401,
+ LOCAL_GL_SHORT = 0x1402,
+ LOCAL_GL_UNSIGNED_SHORT = 0x1403,
+ LOCAL_GL_INT = 0x1404,
+ LOCAL_GL_UNSIGNED_INT = 0x1405,
+ LOCAL_GL_FLOAT = 0x1406,
+ LOCAL_GL_DOUBLE = 0x140A,
+ LOCAL_GL_2_BYTES = 0x1407,
+ LOCAL_GL_3_BYTES = 0x1408,
+ LOCAL_GL_4_BYTES = 0x1409,
+
+ /* Primitives */
+ LOCAL_GL_LINES = 0x0001,
+ LOCAL_GL_POINTS = 0x0000,
+ LOCAL_GL_LINE_STRIP = 0x0003,
+ LOCAL_GL_LINE_LOOP = 0x0002,
+ LOCAL_GL_TRIANGLES = 0x0004,
+ LOCAL_GL_TRIANGLE_STRIP = 0x0005,
+ LOCAL_GL_TRIANGLE_FAN = 0x0006,
+ LOCAL_GL_QUADS = 0x0007,
+ LOCAL_GL_QUAD_STRIP = 0x0008,
+ LOCAL_GL_POLYGON = 0x0009,
+ LOCAL_GL_EDGE_FLAG = 0x0B43,
+
+ /* Vertex Arrays */
+ LOCAL_GL_VERTEX_ARRAY = 0x8074,
+ LOCAL_GL_NORMAL_ARRAY = 0x8075,
+ LOCAL_GL_COLOR_ARRAY = 0x8076,
+ LOCAL_GL_INDEX_ARRAY = 0x8077,
+ LOCAL_GL_TEXTURE_COORD_ARRAY = 0x8078,
+ LOCAL_GL_EDGE_FLAG_ARRAY = 0x8079,
+ LOCAL_GL_VERTEX_ARRAY_SIZE = 0x807A,
+ LOCAL_GL_VERTEX_ARRAY_TYPE = 0x807B,
+ LOCAL_GL_VERTEX_ARRAY_STRIDE = 0x807C,
+ LOCAL_GL_NORMAL_ARRAY_TYPE = 0x807E,
+ LOCAL_GL_NORMAL_ARRAY_STRIDE = 0x807F,
+ LOCAL_GL_COLOR_ARRAY_SIZE = 0x8081,
+ LOCAL_GL_COLOR_ARRAY_TYPE = 0x8082,
+ LOCAL_GL_COLOR_ARRAY_STRIDE = 0x8083,
+ LOCAL_GL_INDEX_ARRAY_TYPE = 0x8085,
+ LOCAL_GL_INDEX_ARRAY_STRIDE = 0x8086,
+ LOCAL_GL_TEXTURE_COORD_ARRAY_SIZE = 0x8088,
+ LOCAL_GL_TEXTURE_COORD_ARRAY_TYPE = 0x8089,
+ LOCAL_GL_TEXTURE_COORD_ARRAY_STRIDE = 0x808A,
+ LOCAL_GL_EDGE_FLAG_ARRAY_STRIDE = 0x808C,
+ LOCAL_GL_VERTEX_ARRAY_POINTER = 0x808E,
+ LOCAL_GL_NORMAL_ARRAY_POINTER = 0x808F,
+ LOCAL_GL_COLOR_ARRAY_POINTER = 0x8090,
+ LOCAL_GL_INDEX_ARRAY_POINTER = 0x8091,
+ LOCAL_GL_TEXTURE_COORD_ARRAY_POINTER = 0x8092,
+ LOCAL_GL_EDGE_FLAG_ARRAY_POINTER = 0x8093,
+ LOCAL_GL_V2F = 0x2A20,
+ LOCAL_GL_V3F = 0x2A21,
+ LOCAL_GL_C4UB_V2F = 0x2A22,
+ LOCAL_GL_C4UB_V3F = 0x2A23,
+ LOCAL_GL_C3F_V3F = 0x2A24,
+ LOCAL_GL_N3F_V3F = 0x2A25,
+ LOCAL_GL_C4F_N3F_V3F = 0x2A26,
+ LOCAL_GL_T2F_V3F = 0x2A27,
+ LOCAL_GL_T4F_V4F = 0x2A28,
+ LOCAL_GL_T2F_C4UB_V3F = 0x2A29,
+ LOCAL_GL_T2F_C3F_V3F = 0x2A2A,
+ LOCAL_GL_T2F_N3F_V3F = 0x2A2B,
+ LOCAL_GL_T2F_C4F_N3F_V3F = 0x2A2C,
+ LOCAL_GL_T4F_C4F_N3F_V4F = 0x2A2D,
+
+ /* Matrix Mode */
+ LOCAL_GL_MATRIX_MODE = 0x0BA0,
+ LOCAL_GL_MODELVIEW = 0x1700,
+ LOCAL_GL_PROJECTION = 0x1701,
+ LOCAL_GL_TEXTURE = 0x1702,
+
+ /* Points */
+ LOCAL_GL_POINT_SMOOTH = 0x0B10,
+ LOCAL_GL_POINT_SIZE = 0x0B11,
+ LOCAL_GL_POINT_SIZE_GRANULARITY = 0x0B13,
+ LOCAL_GL_POINT_SIZE_RANGE = 0x0B12,
+
+ /* Lines */
+ LOCAL_GL_LINE_SMOOTH = 0x0B20,
+ LOCAL_GL_LINE_STIPPLE = 0x0B24,
+ LOCAL_GL_LINE_STIPPLE_PATTERN = 0x0B25,
+ LOCAL_GL_LINE_STIPPLE_REPEAT = 0x0B26,
+ LOCAL_GL_LINE_WIDTH = 0x0B21,
+ LOCAL_GL_LINE_WIDTH_GRANULARITY = 0x0B23,
+ LOCAL_GL_LINE_WIDTH_RANGE = 0x0B22,
+
+ /* Polygons */
+ LOCAL_GL_POINT = 0x1B00,
+ LOCAL_GL_LINE = 0x1B01,
+ LOCAL_GL_FILL = 0x1B02,
+ LOCAL_GL_CCW = 0x0901,
+ LOCAL_GL_CW = 0x0900,
+ LOCAL_GL_FRONT = 0x0404,
+ LOCAL_GL_BACK = 0x0405,
+ LOCAL_GL_CULL_FACE = 0x0B44,
+ LOCAL_GL_CULL_FACE_MODE = 0x0B45,
+ LOCAL_GL_POLYGON_SMOOTH = 0x0B41,
+ LOCAL_GL_POLYGON_STIPPLE = 0x0B42,
+ LOCAL_GL_FRONT_FACE = 0x0B46,
+ LOCAL_GL_POLYGON_MODE = 0x0B40,
+ LOCAL_GL_POLYGON_OFFSET_FACTOR = 0x8038,
+ LOCAL_GL_POLYGON_OFFSET_UNITS = 0x2A00,
+ LOCAL_GL_POLYGON_OFFSET_POINT = 0x2A01,
+ LOCAL_GL_POLYGON_OFFSET_LINE = 0x2A02,
+ LOCAL_GL_POLYGON_OFFSET_FILL = 0x8037,
+
+ /* Display Lists */
+ LOCAL_GL_COMPILE = 0x1300,
+ LOCAL_GL_COMPILE_AND_EXECUTE = 0x1301,
+ LOCAL_GL_LIST_BASE = 0x0B32,
+ LOCAL_GL_LIST_INDEX = 0x0B33,
+ LOCAL_GL_LIST_MODE = 0x0B30,
+
+ /* Depth buffer */
+ LOCAL_GL_NEVER = 0x0200,
+ LOCAL_GL_LESS = 0x0201,
+ LOCAL_GL_GEQUAL = 0x0206,
+ LOCAL_GL_LEQUAL = 0x0203,
+ LOCAL_GL_GREATER = 0x0204,
+ LOCAL_GL_NOTEQUAL = 0x0205,
+ LOCAL_GL_EQUAL = 0x0202,
+ LOCAL_GL_ALWAYS = 0x0207,
+ LOCAL_GL_DEPTH_TEST = 0x0B71,
+ LOCAL_GL_DEPTH_BITS = 0x0D56,
+ LOCAL_GL_DEPTH_CLEAR_VALUE = 0x0B73,
+ LOCAL_GL_DEPTH_FUNC = 0x0B74,
+ LOCAL_GL_DEPTH_RANGE = 0x0B70,
+ LOCAL_GL_DEPTH_WRITEMASK = 0x0B72,
+ LOCAL_GL_DEPTH_COMPONENT = 0x1902,
+
+ /* Lighting */
+ LOCAL_GL_LIGHTING = 0x0B50,
+ LOCAL_GL_LIGHT0 = 0x4000,
+ LOCAL_GL_LIGHT1 = 0x4001,
+ LOCAL_GL_LIGHT2 = 0x4002,
+ LOCAL_GL_LIGHT3 = 0x4003,
+ LOCAL_GL_LIGHT4 = 0x4004,
+ LOCAL_GL_LIGHT5 = 0x4005,
+ LOCAL_GL_LIGHT6 = 0x4006,
+ LOCAL_GL_LIGHT7 = 0x4007,
+ LOCAL_GL_SPOT_EXPONENT = 0x1205,
+ LOCAL_GL_SPOT_CUTOFF = 0x1206,
+ LOCAL_GL_CONSTANT_ATTENUATION = 0x1207,
+ LOCAL_GL_LINEAR_ATTENUATION = 0x1208,
+ LOCAL_GL_QUADRATIC_ATTENUATION = 0x1209,
+ LOCAL_GL_AMBIENT = 0x1200,
+ LOCAL_GL_DIFFUSE = 0x1201,
+ LOCAL_GL_SPECULAR = 0x1202,
+ LOCAL_GL_SHININESS = 0x1601,
+ LOCAL_GL_EMISSION = 0x1600,
+ LOCAL_GL_POSITION = 0x1203,
+ LOCAL_GL_SPOT_DIRECTION = 0x1204,
+ LOCAL_GL_AMBIENT_AND_DIFFUSE = 0x1602,
+ LOCAL_GL_COLOR_INDEXES = 0x1603,
+ LOCAL_GL_LIGHT_MODEL_TWO_SIDE = 0x0B52,
+ LOCAL_GL_LIGHT_MODEL_LOCAL_VIEWER = 0x0B51,
+ LOCAL_GL_LIGHT_MODEL_AMBIENT = 0x0B53,
+ LOCAL_GL_FRONT_AND_BACK = 0x0408,
+ LOCAL_GL_SHADE_MODEL = 0x0B54,
+ LOCAL_GL_FLAT = 0x1D00,
+ LOCAL_GL_SMOOTH = 0x1D01,
+ LOCAL_GL_COLOR_MATERIAL = 0x0B57,
+ LOCAL_GL_COLOR_MATERIAL_FACE = 0x0B55,
+ LOCAL_GL_COLOR_MATERIAL_PARAMETER = 0x0B56,
+ LOCAL_GL_NORMALIZE = 0x0BA1,
+
+ /* User clipping planes */
+ LOCAL_GL_CLIP_PLANE0 = 0x3000,
+ LOCAL_GL_CLIP_PLANE1 = 0x3001,
+ LOCAL_GL_CLIP_PLANE2 = 0x3002,
+ LOCAL_GL_CLIP_PLANE3 = 0x3003,
+ LOCAL_GL_CLIP_PLANE4 = 0x3004,
+ LOCAL_GL_CLIP_PLANE5 = 0x3005,
+
+ /* Accumulation buffer */
+ LOCAL_GL_ACCUM_RED_BITS = 0x0D58,
+ LOCAL_GL_ACCUM_GREEN_BITS = 0x0D59,
+ LOCAL_GL_ACCUM_BLUE_BITS = 0x0D5A,
+ LOCAL_GL_ACCUM_ALPHA_BITS = 0x0D5B,
+ LOCAL_GL_ACCUM_CLEAR_VALUE = 0x0B80,
+ LOCAL_GL_ACCUM = 0x0100,
+ LOCAL_GL_ADD = 0x0104,
+ LOCAL_GL_LOAD = 0x0101,
+ LOCAL_GL_MULT = 0x0103,
+ LOCAL_GL_RETURN = 0x0102,
+
+ /* Alpha testing */
+ LOCAL_GL_ALPHA_TEST = 0x0BC0,
+ LOCAL_GL_ALPHA_TEST_REF = 0x0BC2,
+ LOCAL_GL_ALPHA_TEST_FUNC = 0x0BC1,
+
+ /* Blending */
+ LOCAL_GL_BLEND = 0x0BE2,
+ LOCAL_GL_BLEND_SRC = 0x0BE1,
+ LOCAL_GL_BLEND_DST = 0x0BE0,
+ LOCAL_GL_ZERO = 0,
+ LOCAL_GL_ONE = 1,
+ LOCAL_GL_SRC_COLOR = 0x0300,
+ LOCAL_GL_ONE_MINUS_SRC_COLOR = 0x0301,
+ LOCAL_GL_DST_COLOR = 0x0306,
+ LOCAL_GL_ONE_MINUS_DST_COLOR = 0x0307,
+ LOCAL_GL_SRC_ALPHA = 0x0302,
+ LOCAL_GL_ONE_MINUS_SRC_ALPHA = 0x0303,
+ LOCAL_GL_DST_ALPHA = 0x0304,
+ LOCAL_GL_ONE_MINUS_DST_ALPHA = 0x0305,
+ LOCAL_GL_SRC_ALPHA_SATURATE = 0x0308,
+ LOCAL_GL_CONSTANT_COLOR = 0x8001,
+ LOCAL_GL_ONE_MINUS_CONSTANT_COLOR = 0x8002,
+ LOCAL_GL_CONSTANT_ALPHA = 0x8003,
+ LOCAL_GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004,
+
+ /* Render Mode */
+ LOCAL_GL_FEEDBACK = 0x1C01,
+ LOCAL_GL_RENDER = 0x1C00,
+ LOCAL_GL_SELECT = 0x1C02,
+
+ /* Feedback */
+ LOCAL_GL_2D = 0x0600,
+ LOCAL_GL_3D = 0x0601,
+ LOCAL_GL_3D_COLOR = 0x0602,
+ LOCAL_GL_3D_COLOR_TEXTURE = 0x0603,
+ LOCAL_GL_4D_COLOR_TEXTURE = 0x0604,
+ LOCAL_GL_POINT_TOKEN = 0x0701,
+ LOCAL_GL_LINE_TOKEN = 0x0702,
+ LOCAL_GL_LINE_RESET_TOKEN = 0x0707,
+ LOCAL_GL_POLYGON_TOKEN = 0x0703,
+ LOCAL_GL_BITMAP_TOKEN = 0x0704,
+ LOCAL_GL_DRAW_PIXEL_TOKEN = 0x0705,
+ LOCAL_GL_COPY_PIXEL_TOKEN = 0x0706,
+ LOCAL_GL_PASS_THROUGH_TOKEN = 0x0700,
+ LOCAL_GL_FEEDBACK_BUFFER_POINTER = 0x0DF0,
+ LOCAL_GL_FEEDBACK_BUFFER_SIZE = 0x0DF1,
+ LOCAL_GL_FEEDBACK_BUFFER_TYPE = 0x0DF2,
+
+ /* Selection */
+ LOCAL_GL_SELECTION_BUFFER_POINTER = 0x0DF3,
+ LOCAL_GL_SELECTION_BUFFER_SIZE = 0x0DF4,
+
+ /* Fog */
+ LOCAL_GL_FOG = 0x0B60,
+ LOCAL_GL_FOG_MODE = 0x0B65,
+ LOCAL_GL_FOG_DENSITY = 0x0B62,
+ LOCAL_GL_FOG_COLOR = 0x0B66,
+ LOCAL_GL_FOG_INDEX = 0x0B61,
+ LOCAL_GL_FOG_START = 0x0B63,
+ LOCAL_GL_FOG_END = 0x0B64,
+ LOCAL_GL_LINEAR = 0x2601,
+ LOCAL_GL_EXP = 0x0800,
+ LOCAL_GL_EXP2 = 0x0801,
+
+ /* Logic Ops */
+ LOCAL_GL_LOGIC_OP = 0x0BF1,
+ LOCAL_GL_INDEX_LOGIC_OP = 0x0BF1,
+ LOCAL_GL_COLOR_LOGIC_OP = 0x0BF2,
+ LOCAL_GL_LOGIC_OP_MODE = 0x0BF0,
+ LOCAL_GL_CLEAR = 0x1500,
+ LOCAL_GL_SET = 0x150F,
+ LOCAL_GL_COPY = 0x1503,
+ LOCAL_GL_COPY_INVERTED = 0x150C,
+ LOCAL_GL_NOOP = 0x1505,
+ LOCAL_GL_INVERT = 0x150A,
+ LOCAL_GL_AND = 0x1501,
+ LOCAL_GL_NAND = 0x150E,
+ LOCAL_GL_OR = 0x1507,
+ LOCAL_GL_NOR = 0x1508,
+ LOCAL_GL_XOR = 0x1506,
+ LOCAL_GL_EQUIV = 0x1509,
+ LOCAL_GL_AND_REVERSE = 0x1502,
+ LOCAL_GL_AND_INVERTED = 0x1504,
+ LOCAL_GL_OR_REVERSE = 0x150B,
+ LOCAL_GL_OR_INVERTED = 0x150D,
+
+ /* Stencil */
+ LOCAL_GL_STENCIL_TEST = 0x0B90,
+ LOCAL_GL_STENCIL_WRITEMASK = 0x0B98,
+ LOCAL_GL_STENCIL_BITS = 0x0D57,
+ LOCAL_GL_STENCIL_FUNC = 0x0B92,
+ LOCAL_GL_STENCIL_VALUE_MASK = 0x0B93,
+ LOCAL_GL_STENCIL_REF = 0x0B97,
+ LOCAL_GL_STENCIL_FAIL = 0x0B94,
+ LOCAL_GL_STENCIL_PASS_DEPTH_PASS = 0x0B96,
+ LOCAL_GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95,
+ LOCAL_GL_STENCIL_CLEAR_VALUE = 0x0B91,
+ LOCAL_GL_STENCIL_INDEX = 0x1901,
+ LOCAL_GL_KEEP = 0x1E00,
+ LOCAL_GL_REPLACE = 0x1E01,
+ LOCAL_GL_INCR = 0x1E02,
+ LOCAL_GL_DECR = 0x1E03,
+
+ /* Buffers, Pixel Drawing/Reading */
+ LOCAL_GL_NONE = 0,
+ LOCAL_GL_LEFT = 0x0406,
+ LOCAL_GL_RIGHT = 0x0407,
+ /*LOCAL_GL_FRONT = 0x0404, */
+ /*LOCAL_GL_BACK = 0x0405, */
+ /*LOCAL_GL_FRONT_AND_BACK = 0x0408, */
+ LOCAL_GL_FRONT_LEFT = 0x0400,
+ LOCAL_GL_FRONT_RIGHT = 0x0401,
+ LOCAL_GL_BACK_LEFT = 0x0402,
+ LOCAL_GL_BACK_RIGHT = 0x0403,
+ LOCAL_GL_AUX0 = 0x0409,
+ LOCAL_GL_AUX1 = 0x040A,
+ LOCAL_GL_AUX2 = 0x040B,
+ LOCAL_GL_AUX3 = 0x040C,
+ LOCAL_GL_COLOR_INDEX = 0x1900,
+ LOCAL_GL_RED = 0x1903,
+ LOCAL_GL_GREEN = 0x1904,
+ LOCAL_GL_BLUE = 0x1905,
+ LOCAL_GL_ALPHA = 0x1906,
+ LOCAL_GL_LUMINANCE = 0x1909,
+ LOCAL_GL_LUMINANCE_ALPHA = 0x190A,
+ LOCAL_GL_ALPHA_BITS = 0x0D55,
+ LOCAL_GL_RED_BITS = 0x0D52,
+ LOCAL_GL_GREEN_BITS = 0x0D53,
+ LOCAL_GL_BLUE_BITS = 0x0D54,
+ LOCAL_GL_INDEX_BITS = 0x0D51,
+ LOCAL_GL_SUBPIXEL_BITS = 0x0D50,
+ LOCAL_GL_AUX_BUFFERS = 0x0C00,
+ LOCAL_GL_READ_BUFFER = 0x0C02,
+ LOCAL_GL_DRAW_BUFFER = 0x0C01,
+ LOCAL_GL_DOUBLEBUFFER = 0x0C32,
+ LOCAL_GL_STEREO = 0x0C33,
+ LOCAL_GL_BITMAP = 0x1A00,
+ LOCAL_GL_COLOR = 0x1800,
+ LOCAL_GL_DEPTH = 0x1801,
+ LOCAL_GL_STENCIL = 0x1802,
+ LOCAL_GL_DITHER = 0x0BD0,
+ LOCAL_GL_RGB = 0x1907,
+ LOCAL_GL_RGBA = 0x1908,
+
+ /* Implementation limits */
+ LOCAL_GL_MAX_LIST_NESTING = 0x0B31,
+ LOCAL_GL_MAX_ATTRIB_STACK_DEPTH = 0x0D35,
+ LOCAL_GL_MAX_MODELVIEW_STACK_DEPTH = 0x0D36,
+ LOCAL_GL_MAX_NAME_STACK_DEPTH = 0x0D37,
+ LOCAL_GL_MAX_PROJECTION_STACK_DEPTH = 0x0D38,
+ LOCAL_GL_MAX_TEXTURE_STACK_DEPTH = 0x0D39,
+ LOCAL_GL_MAX_EVAL_ORDER = 0x0D30,
+ LOCAL_GL_MAX_LIGHTS = 0x0D31,
+ LOCAL_GL_MAX_CLIP_PLANES = 0x0D32,
+ LOCAL_GL_MAX_TEXTURE_SIZE = 0x0D33,
+ LOCAL_GL_MAX_PIXEL_MAP_TABLE = 0x0D34,
+ LOCAL_GL_MAX_VIEWPORT_DIMS = 0x0D3A,
+ LOCAL_GL_MAX_CLIENT_ATTRIB_STACK_DEPTH= 0x0D3B,
+
+ /* Gets */
+ LOCAL_GL_ATTRIB_STACK_DEPTH = 0x0BB0,
+ LOCAL_GL_CLIENT_ATTRIB_STACK_DEPTH = 0x0BB1,
+ LOCAL_GL_COLOR_CLEAR_VALUE = 0x0C22,
+ LOCAL_GL_COLOR_WRITEMASK = 0x0C23,
+ LOCAL_GL_CURRENT_INDEX = 0x0B01,
+ LOCAL_GL_CURRENT_COLOR = 0x0B00,
+ LOCAL_GL_CURRENT_NORMAL = 0x0B02,
+ LOCAL_GL_CURRENT_RASTER_COLOR = 0x0B04,
+ LOCAL_GL_CURRENT_RASTER_DISTANCE = 0x0B09,
+ LOCAL_GL_CURRENT_RASTER_INDEX = 0x0B05,
+ LOCAL_GL_CURRENT_RASTER_POSITION = 0x0B07,
+ LOCAL_GL_CURRENT_RASTER_TEXTURE_COORDS = 0x0B06,
+ LOCAL_GL_CURRENT_RASTER_POSITION_VALID = 0x0B08,
+ LOCAL_GL_CURRENT_TEXTURE_COORDS = 0x0B03,
+ LOCAL_GL_INDEX_CLEAR_VALUE = 0x0C20,
+ LOCAL_GL_INDEX_MODE = 0x0C30,
+ LOCAL_GL_INDEX_WRITEMASK = 0x0C21,
+ LOCAL_GL_MODELVIEW_MATRIX = 0x0BA6,
+ LOCAL_GL_MODELVIEW_STACK_DEPTH = 0x0BA3,
+ LOCAL_GL_NAME_STACK_DEPTH = 0x0D70,
+ LOCAL_GL_PROJECTION_MATRIX = 0x0BA7,
+ LOCAL_GL_PROJECTION_STACK_DEPTH = 0x0BA4,
+ LOCAL_GL_RENDER_MODE = 0x0C40,
+ LOCAL_GL_RGBA_MODE = 0x0C31,
+ LOCAL_GL_TEXTURE_MATRIX = 0x0BA8,
+ LOCAL_GL_TEXTURE_STACK_DEPTH = 0x0BA5,
+ LOCAL_GL_VIEWPORT = 0x0BA2,
+
+
+ /* Evaluators */
+ LOCAL_GL_AUTO_NORMAL = 0x0D80,
+ LOCAL_GL_MAP1_COLOR_4 = 0x0D90,
+ LOCAL_GL_MAP1_GRID_DOMAIN = 0x0DD0,
+ LOCAL_GL_MAP1_GRID_SEGMENTS = 0x0DD1,
+ LOCAL_GL_MAP1_INDEX = 0x0D91,
+ LOCAL_GL_MAP1_NORMAL = 0x0D92,
+ LOCAL_GL_MAP1_TEXTURE_COORD_1 = 0x0D93,
+ LOCAL_GL_MAP1_TEXTURE_COORD_2 = 0x0D94,
+ LOCAL_GL_MAP1_TEXTURE_COORD_3 = 0x0D95,
+ LOCAL_GL_MAP1_TEXTURE_COORD_4 = 0x0D96,
+ LOCAL_GL_MAP1_VERTEX_3 = 0x0D97,
+ LOCAL_GL_MAP1_VERTEX_4 = 0x0D98,
+ LOCAL_GL_MAP2_COLOR_4 = 0x0DB0,
+ LOCAL_GL_MAP2_GRID_DOMAIN = 0x0DD2,
+ LOCAL_GL_MAP2_GRID_SEGMENTS = 0x0DD3,
+ LOCAL_GL_MAP2_INDEX = 0x0DB1,
+ LOCAL_GL_MAP2_NORMAL = 0x0DB2,
+ LOCAL_GL_MAP2_TEXTURE_COORD_1 = 0x0DB3,
+ LOCAL_GL_MAP2_TEXTURE_COORD_2 = 0x0DB4,
+ LOCAL_GL_MAP2_TEXTURE_COORD_3 = 0x0DB5,
+ LOCAL_GL_MAP2_TEXTURE_COORD_4 = 0x0DB6,
+ LOCAL_GL_MAP2_VERTEX_3 = 0x0DB7,
+ LOCAL_GL_MAP2_VERTEX_4 = 0x0DB8,
+ LOCAL_GL_COEFF = 0x0A00,
+ LOCAL_GL_DOMAIN = 0x0A02,
+ LOCAL_GL_ORDER = 0x0A01,
+
+ /* Hints */
+ LOCAL_GL_FOG_HINT = 0x0C54,
+ LOCAL_GL_LINE_SMOOTH_HINT = 0x0C52,
+ LOCAL_GL_PERSPECTIVE_CORRECTION_HINT = 0x0C50,
+ LOCAL_GL_POINT_SMOOTH_HINT = 0x0C51,
+ LOCAL_GL_POLYGON_SMOOTH_HINT = 0x0C53,
+ LOCAL_GL_DONT_CARE = 0x1100,
+ LOCAL_GL_FASTEST = 0x1101,
+ LOCAL_GL_NICEST = 0x1102,
+
+ /* Scissor box */
+ LOCAL_GL_SCISSOR_TEST = 0x0C11,
+ LOCAL_GL_SCISSOR_BOX = 0x0C10,
+
+ /* Pixel Mode / Transfer */
+ LOCAL_GL_MAP_COLOR = 0x0D10,
+ LOCAL_GL_MAP_STENCIL = 0x0D11,
+ LOCAL_GL_INDEX_SHIFT = 0x0D12,
+ LOCAL_GL_INDEX_OFFSET = 0x0D13,
+ LOCAL_GL_RED_SCALE = 0x0D14,
+ LOCAL_GL_RED_BIAS = 0x0D15,
+ LOCAL_GL_GREEN_SCALE = 0x0D18,
+ LOCAL_GL_GREEN_BIAS = 0x0D19,
+ LOCAL_GL_BLUE_SCALE = 0x0D1A,
+ LOCAL_GL_BLUE_BIAS = 0x0D1B,
+ LOCAL_GL_ALPHA_SCALE = 0x0D1C,
+ LOCAL_GL_ALPHA_BIAS = 0x0D1D,
+ LOCAL_GL_DEPTH_SCALE = 0x0D1E,
+ LOCAL_GL_DEPTH_BIAS = 0x0D1F,
+ LOCAL_GL_PIXEL_MAP_S_TO_S_SIZE = 0x0CB1,
+ LOCAL_GL_PIXEL_MAP_I_TO_I_SIZE = 0x0CB0,
+ LOCAL_GL_PIXEL_MAP_I_TO_R_SIZE = 0x0CB2,
+ LOCAL_GL_PIXEL_MAP_I_TO_G_SIZE = 0x0CB3,
+ LOCAL_GL_PIXEL_MAP_I_TO_B_SIZE = 0x0CB4,
+ LOCAL_GL_PIXEL_MAP_I_TO_A_SIZE = 0x0CB5,
+ LOCAL_GL_PIXEL_MAP_R_TO_R_SIZE = 0x0CB6,
+ LOCAL_GL_PIXEL_MAP_G_TO_G_SIZE = 0x0CB7,
+ LOCAL_GL_PIXEL_MAP_B_TO_B_SIZE = 0x0CB8,
+ LOCAL_GL_PIXEL_MAP_A_TO_A_SIZE = 0x0CB9,
+ LOCAL_GL_PIXEL_MAP_S_TO_S = 0x0C71,
+ LOCAL_GL_PIXEL_MAP_I_TO_I = 0x0C70,
+ LOCAL_GL_PIXEL_MAP_I_TO_R = 0x0C72,
+ LOCAL_GL_PIXEL_MAP_I_TO_G = 0x0C73,
+ LOCAL_GL_PIXEL_MAP_I_TO_B = 0x0C74,
+ LOCAL_GL_PIXEL_MAP_I_TO_A = 0x0C75,
+ LOCAL_GL_PIXEL_MAP_R_TO_R = 0x0C76,
+ LOCAL_GL_PIXEL_MAP_G_TO_G = 0x0C77,
+ LOCAL_GL_PIXEL_MAP_B_TO_B = 0x0C78,
+ LOCAL_GL_PIXEL_MAP_A_TO_A = 0x0C79,
+ LOCAL_GL_PACK_ALIGNMENT = 0x0D05,
+ LOCAL_GL_PACK_LSB_FIRST = 0x0D01,
+ LOCAL_GL_PACK_ROW_LENGTH = 0x0D02,
+ LOCAL_GL_PACK_SKIP_PIXELS = 0x0D04,
+ LOCAL_GL_PACK_SKIP_ROWS = 0x0D03,
+ LOCAL_GL_PACK_SWAP_BYTES = 0x0D00,
+ LOCAL_GL_UNPACK_ALIGNMENT = 0x0CF5,
+ LOCAL_GL_UNPACK_LSB_FIRST = 0x0CF1,
+ LOCAL_GL_UNPACK_ROW_LENGTH = 0x0CF2,
+ LOCAL_GL_UNPACK_SKIP_PIXELS = 0x0CF4,
+ LOCAL_GL_UNPACK_SKIP_ROWS = 0x0CF3,
+ LOCAL_GL_UNPACK_SWAP_BYTES = 0x0CF0,
+ LOCAL_GL_ZOOM_X = 0x0D16,
+ LOCAL_GL_ZOOM_Y = 0x0D17,
+
+ /* Texture mapping */
+ LOCAL_GL_TEXTURE_ENV = 0x2300,
+ LOCAL_GL_TEXTURE_ENV_MODE = 0x2200,
+ LOCAL_GL_TEXTURE_1D = 0x0DE0,
+ LOCAL_GL_TEXTURE_2D = 0x0DE1,
+ LOCAL_GL_TEXTURE_WRAP_S = 0x2802,
+ LOCAL_GL_TEXTURE_WRAP_T = 0x2803,
+ LOCAL_GL_TEXTURE_MAG_FILTER = 0x2800,
+ LOCAL_GL_TEXTURE_MIN_FILTER = 0x2801,
+ LOCAL_GL_TEXTURE_ENV_COLOR = 0x2201,
+ LOCAL_GL_TEXTURE_GEN_S = 0x0C60,
+ LOCAL_GL_TEXTURE_GEN_T = 0x0C61,
+ LOCAL_GL_TEXTURE_GEN_MODE = 0x2500,
+ LOCAL_GL_TEXTURE_BORDER_COLOR = 0x1004,
+ LOCAL_GL_TEXTURE_WIDTH = 0x1000,
+ LOCAL_GL_TEXTURE_HEIGHT = 0x1001,
+ LOCAL_GL_TEXTURE_BORDER = 0x1005,
+ LOCAL_GL_TEXTURE_COMPONENTS = 0x1003,
+ LOCAL_GL_TEXTURE_RED_SIZE = 0x805C,
+ LOCAL_GL_TEXTURE_GREEN_SIZE = 0x805D,
+ LOCAL_GL_TEXTURE_BLUE_SIZE = 0x805E,
+ LOCAL_GL_TEXTURE_ALPHA_SIZE = 0x805F,
+ LOCAL_GL_TEXTURE_LUMINANCE_SIZE = 0x8060,
+ LOCAL_GL_TEXTURE_INTENSITY_SIZE = 0x8061,
+ LOCAL_GL_NEAREST_MIPMAP_NEAREST = 0x2700,
+ LOCAL_GL_NEAREST_MIPMAP_LINEAR = 0x2702,
+ LOCAL_GL_LINEAR_MIPMAP_NEAREST = 0x2701,
+ LOCAL_GL_LINEAR_MIPMAP_LINEAR = 0x2703,
+ LOCAL_GL_OBJECT_LINEAR = 0x2401,
+ LOCAL_GL_OBJECT_PLANE = 0x2501,
+ LOCAL_GL_EYE_LINEAR = 0x2400,
+ LOCAL_GL_EYE_PLANE = 0x2502,
+ LOCAL_GL_SPHERE_MAP = 0x2402,
+ LOCAL_GL_DECAL = 0x2101,
+ LOCAL_GL_MODULATE = 0x2100,
+ LOCAL_GL_NEAREST = 0x2600,
+ LOCAL_GL_REPEAT = 0x2901,
+ LOCAL_GL_CLAMP = 0x2900,
+ LOCAL_GL_S = 0x2000,
+ LOCAL_GL_T = 0x2001,
+ LOCAL_GL_R = 0x2002,
+ LOCAL_GL_Q = 0x2003,
+ LOCAL_GL_TEXTURE_GEN_R = 0x0C62,
+ LOCAL_GL_TEXTURE_GEN_Q = 0x0C63,
+
+ /* GL 1.1 texturing */
+ LOCAL_GL_PROXY_TEXTURE_1D = 0x8063,
+ LOCAL_GL_PROXY_TEXTURE_2D = 0x8064,
+ LOCAL_GL_TEXTURE_PRIORITY = 0x8066,
+ LOCAL_GL_TEXTURE_RESIDENT = 0x8067,
+ LOCAL_GL_TEXTURE_BINDING_1D = 0x8068,
+ LOCAL_GL_TEXTURE_BINDING_2D = 0x8069,
+ LOCAL_GL_TEXTURE_INTERNAL_FORMAT = 0x1003,
+
+ /* GL 1.2 texturing */
+ LOCAL_GL_PACK_SKIP_IMAGES = 0x806B,
+ LOCAL_GL_PACK_IMAGE_HEIGHT = 0x806C,
+ LOCAL_GL_UNPACK_SKIP_IMAGES = 0x806D,
+ LOCAL_GL_UNPACK_IMAGE_HEIGHT = 0x806E,
+ LOCAL_GL_TEXTURE_3D = 0x806F,
+ LOCAL_GL_PROXY_TEXTURE_3D = 0x8070,
+ LOCAL_GL_TEXTURE_DEPTH = 0x8071,
+ LOCAL_GL_TEXTURE_WRAP_R = 0x8072,
+ LOCAL_GL_MAX_3D_TEXTURE_SIZE = 0x8073,
+ LOCAL_GL_TEXTURE_BINDING_3D = 0x806A,
+
+ /* Internal texture formats (GL 1.1) */
+ LOCAL_GL_ALPHA4 = 0x803B,
+ LOCAL_GL_ALPHA8 = 0x803C,
+ LOCAL_GL_ALPHA12 = 0x803D,
+ LOCAL_GL_ALPHA16 = 0x803E,
+ LOCAL_GL_LUMINANCE4 = 0x803F,
+ LOCAL_GL_LUMINANCE8 = 0x8040,
+ LOCAL_GL_LUMINANCE12 = 0x8041,
+ LOCAL_GL_LUMINANCE16 = 0x8042,
+ LOCAL_GL_LUMINANCE4_ALPHA4 = 0x8043,
+ LOCAL_GL_LUMINANCE6_ALPHA2 = 0x8044,
+ LOCAL_GL_LUMINANCE8_ALPHA8 = 0x8045,
+ LOCAL_GL_LUMINANCE12_ALPHA4 = 0x8046,
+ LOCAL_GL_LUMINANCE12_ALPHA12 = 0x8047,
+ LOCAL_GL_LUMINANCE16_ALPHA16 = 0x8048,
+ LOCAL_GL_INTENSITY = 0x8049,
+ LOCAL_GL_INTENSITY4 = 0x804A,
+ LOCAL_GL_INTENSITY8 = 0x804B,
+ LOCAL_GL_INTENSITY12 = 0x804C,
+ LOCAL_GL_INTENSITY16 = 0x804D,
+ LOCAL_GL_R3_G3_B2 = 0x2A10,
+ LOCAL_GL_RGB4 = 0x804F,
+ LOCAL_GL_RGB5 = 0x8050,
+ LOCAL_GL_RGB8 = 0x8051,
+ LOCAL_GL_RGB10 = 0x8052,
+ LOCAL_GL_RGB12 = 0x8053,
+ LOCAL_GL_RGB16 = 0x8054,
+ LOCAL_GL_RGBA2 = 0x8055,
+ LOCAL_GL_RGBA4 = 0x8056,
+ LOCAL_GL_RGB5_A1 = 0x8057,
+ LOCAL_GL_RGBA8 = 0x8058,
+ LOCAL_GL_RGB10_A2 = 0x8059,
+ LOCAL_GL_RGBA12 = 0x805A,
+ LOCAL_GL_RGBA16 = 0x805B,
+
+ /* Utility */
+ LOCAL_GL_VENDOR = 0x1F00,
+ LOCAL_GL_RENDERER = 0x1F01,
+ LOCAL_GL_VERSION = 0x1F02,
+ LOCAL_GL_EXTENSIONS = 0x1F03,
+
+ /* Errors */
+ LOCAL_GL_INVALID_VALUE = 0x0501,
+ LOCAL_GL_INVALID_ENUM = 0x0500,
+ LOCAL_GL_INVALID_OPERATION = 0x0502,
+ LOCAL_GL_STACK_OVERFLOW = 0x0503,
+ LOCAL_GL_STACK_UNDERFLOW = 0x0504,
+ LOCAL_GL_OUT_OF_MEMORY = 0x0505,
+
+ /*
+ * Extensions
+ */
+
+ /* LOCAL_GL_EXT_blend_minmax and LOCAL_GL_EXT_blend_color */
+ LOCAL_GL_CONSTANT_COLOR_EXT = 0x8001,
+ LOCAL_GL_ONE_MINUS_CONSTANT_COLOR_EXT = 0x8002,
+ LOCAL_GL_CONSTANT_ALPHA_EXT = 0x8003,
+ LOCAL_GL_ONE_MINUS_CONSTANT_ALPHA_EXT = 0x8004,
+ LOCAL_GL_BLEND_EQUATION_EXT = 0x8009,
+ LOCAL_GL_MIN_EXT = 0x8007,
+ LOCAL_GL_MAX_EXT = 0x8008,
+ LOCAL_GL_FUNC_ADD_EXT = 0x8006,
+ LOCAL_GL_FUNC_SUBTRACT_EXT = 0x800A,
+ LOCAL_GL_FUNC_REVERSE_SUBTRACT_EXT = 0x800B,
+ LOCAL_GL_BLEND_COLOR_EXT = 0x8005,
+
+ /* LOCAL_GL_EXT_polygon_offset */
+ LOCAL_GL_POLYGON_OFFSET_EXT = 0x8037,
+ LOCAL_GL_POLYGON_OFFSET_FACTOR_EXT = 0x8038,
+ LOCAL_GL_POLYGON_OFFSET_BIAS_EXT = 0x8039,
+
+ /* LOCAL_GL_EXT_vertex_array */
+ LOCAL_GL_VERTEX_ARRAY_EXT = 0x8074,
+ LOCAL_GL_NORMAL_ARRAY_EXT = 0x8075,
+ LOCAL_GL_COLOR_ARRAY_EXT = 0x8076,
+ LOCAL_GL_INDEX_ARRAY_EXT = 0x8077,
+ LOCAL_GL_TEXTURE_COORD_ARRAY_EXT = 0x8078,
+ LOCAL_GL_EDGE_FLAG_ARRAY_EXT = 0x8079,
+ LOCAL_GL_VERTEX_ARRAY_SIZE_EXT = 0x807A,
+ LOCAL_GL_VERTEX_ARRAY_TYPE_EXT = 0x807B,
+ LOCAL_GL_VERTEX_ARRAY_STRIDE_EXT = 0x807C,
+ LOCAL_GL_VERTEX_ARRAY_COUNT_EXT = 0x807D,
+ LOCAL_GL_NORMAL_ARRAY_TYPE_EXT = 0x807E,
+ LOCAL_GL_NORMAL_ARRAY_STRIDE_EXT = 0x807F,
+ LOCAL_GL_NORMAL_ARRAY_COUNT_EXT = 0x8080,
+ LOCAL_GL_COLOR_ARRAY_SIZE_EXT = 0x8081,
+ LOCAL_GL_COLOR_ARRAY_TYPE_EXT = 0x8082,
+ LOCAL_GL_COLOR_ARRAY_STRIDE_EXT = 0x8083,
+ LOCAL_GL_COLOR_ARRAY_COUNT_EXT = 0x8084,
+ LOCAL_GL_INDEX_ARRAY_TYPE_EXT = 0x8085,
+ LOCAL_GL_INDEX_ARRAY_STRIDE_EXT = 0x8086,
+ LOCAL_GL_INDEX_ARRAY_COUNT_EXT = 0x8087,
+ LOCAL_GL_TEXTURE_COORD_ARRAY_SIZE_EXT = 0x8088,
+ LOCAL_GL_TEXTURE_COORD_ARRAY_TYPE_EXT = 0x8089,
+ LOCAL_GL_TEXTURE_COORD_ARRAY_STRIDE_EXT = 0x808A,
+ LOCAL_GL_TEXTURE_COORD_ARRAY_COUNT_EXT = 0x808B,
+ LOCAL_GL_EDGE_FLAG_ARRAY_STRIDE_EXT = 0x808C,
+ LOCAL_GL_EDGE_FLAG_ARRAY_COUNT_EXT = 0x808D,
+ LOCAL_GL_VERTEX_ARRAY_POINTER_EXT = 0x808E,
+ LOCAL_GL_NORMAL_ARRAY_POINTER_EXT = 0x808F,
+ LOCAL_GL_COLOR_ARRAY_POINTER_EXT = 0x8090,
+ LOCAL_GL_INDEX_ARRAY_POINTER_EXT = 0x8091,
+ LOCAL_GL_TEXTURE_COORD_ARRAY_POINTER_EXT = 0x8092,
+ LOCAL_GL_EDGE_FLAG_ARRAY_POINTER_EXT = 0x8093,
+
+ /* LOCAL_GL_EXT_texture_object */
+ LOCAL_GL_TEXTURE_PRIORITY_EXT = 0x8066,
+ LOCAL_GL_TEXTURE_RESIDENT_EXT = 0x8067,
+ LOCAL_GL_TEXTURE_1D_BINDING_EXT = 0x8068,
+ LOCAL_GL_TEXTURE_2D_BINDING_EXT = 0x8069,
+
+ /* LOCAL_GL_EXT_texture3D */
+ LOCAL_GL_PACK_SKIP_IMAGES_EXT = 0x806B,
+ LOCAL_GL_PACK_IMAGE_HEIGHT_EXT = 0x806C,
+ LOCAL_GL_UNPACK_SKIP_IMAGES_EXT = 0x806D,
+ LOCAL_GL_UNPACK_IMAGE_HEIGHT_EXT = 0x806E,
+ LOCAL_GL_TEXTURE_3D_EXT = 0x806F,
+ LOCAL_GL_PROXY_TEXTURE_3D_EXT = 0x8070,
+ LOCAL_GL_TEXTURE_DEPTH_EXT = 0x8071,
+ LOCAL_GL_TEXTURE_WRAP_R_EXT = 0x8072,
+ LOCAL_GL_MAX_3D_TEXTURE_SIZE_EXT = 0x8073,
+ LOCAL_GL_TEXTURE_3D_BINDING_EXT = 0x806A,
+
+ /* LOCAL_GL_EXT_paletted_texture */
+ LOCAL_GL_TABLE_TOO_LARGE_EXT = 0x8031,
+ LOCAL_GL_COLOR_TABLE_FORMAT_EXT = 0x80D8,
+ LOCAL_GL_COLOR_TABLE_WIDTH_EXT = 0x80D9,
+ LOCAL_GL_COLOR_TABLE_RED_SIZE_EXT = 0x80DA,
+ LOCAL_GL_COLOR_TABLE_GREEN_SIZE_EXT = 0x80DB,
+ LOCAL_GL_COLOR_TABLE_BLUE_SIZE_EXT = 0x80DC,
+ LOCAL_GL_COLOR_TABLE_ALPHA_SIZE_EXT = 0x80DD,
+ LOCAL_GL_COLOR_TABLE_LUMINANCE_SIZE_EXT = 0x80DE,
+ LOCAL_GL_COLOR_TABLE_INTENSITY_SIZE_EXT = 0x80DF,
+ LOCAL_GL_TEXTURE_INDEX_SIZE_EXT = 0x80ED,
+ LOCAL_GL_COLOR_INDEX1_EXT = 0x80E2,
+ LOCAL_GL_COLOR_INDEX2_EXT = 0x80E3,
+ LOCAL_GL_COLOR_INDEX4_EXT = 0x80E4,
+ LOCAL_GL_COLOR_INDEX8_EXT = 0x80E5,
+ LOCAL_GL_COLOR_INDEX12_EXT = 0x80E6,
+ LOCAL_GL_COLOR_INDEX16_EXT = 0x80E7,
+
+ /* LOCAL_GL_EXT_shared_texture_palette */
+ LOCAL_GL_SHARED_TEXTURE_PALETTE_EXT = 0x81FB,
+
+ /* LOCAL_GL_EXT_point_parameters */
+ LOCAL_GL_POINT_SIZE_MIN_EXT = 0x8126,
+ LOCAL_GL_POINT_SIZE_MAX_EXT = 0x8127,
+ LOCAL_GL_POINT_FADE_THRESHOLD_SIZE_EXT = 0x8128,
+ LOCAL_GL_DISTANCE_ATTENUATION_EXT = 0x8129,
+
+ /* LOCAL_GL_EXT_rescale_normal */
+ LOCAL_GL_RESCALE_NORMAL_EXT = 0x803A,
+
+ /* LOCAL_GL_EXT_abgr */
+ LOCAL_GL_ABGR_EXT = 0x8000,
+
+ /* LOCAL_GL_SGIS_multitexture */
+ LOCAL_GL_SELECTED_TEXTURE_SGIS = 0x835C,
+ LOCAL_GL_SELECTED_TEXTURE_COORD_SET_SGIS = 0x835D,
+ LOCAL_GL_MAX_TEXTURES_SGIS = 0x835E,
+ LOCAL_GL_TEXTURE0_SGIS = 0x835F,
+ LOCAL_GL_TEXTURE1_SGIS = 0x8360,
+ LOCAL_GL_TEXTURE2_SGIS = 0x8361,
+ LOCAL_GL_TEXTURE3_SGIS = 0x8362,
+ LOCAL_GL_TEXTURE_COORD_SET_SOURCE_SGIS = 0x8363,
+
+ /* LOCAL_GL_EXT_multitexture */
+ LOCAL_GL_SELECTED_TEXTURE_EXT = 0x83C0,
+ LOCAL_GL_SELECTED_TEXTURE_COORD_SET_EXT = 0x83C1,
+ LOCAL_GL_SELECTED_TEXTURE_TRANSFORM_EXT = 0x83C2,
+ LOCAL_GL_MAX_TEXTURES_EXT = 0x83C3,
+ LOCAL_GL_MAX_TEXTURE_COORD_SETS_EXT = 0x83C4,
+ LOCAL_GL_TEXTURE_ENV_COORD_SET_EXT = 0x83C5,
+ LOCAL_GL_TEXTURE0_EXT = 0x83C6,
+ LOCAL_GL_TEXTURE1_EXT = 0x83C7,
+ LOCAL_GL_TEXTURE2_EXT = 0x83C8,
+ LOCAL_GL_TEXTURE3_EXT = 0x83C9,
+
+ /* LOCAL_GL_SGIS_texture_edge_clamp */
+ LOCAL_GL_CLAMP_TO_EDGE_SGIS = 0x812F,
+
+ /* OpenGL 1.2 */
+ LOCAL_GL_RESCALE_NORMAL = 0x803A,
+ LOCAL_GL_CLAMP_TO_EDGE = 0x812F,
+ LOCAL_GL_MAX_ELEMENTS_VERTICES = 0xF0E8,
+ LOCAL_GL_MAX_ELEMENTS_INDICES = 0xF0E9,
+ LOCAL_GL_BGR = 0x80E0,
+ LOCAL_GL_BGRA = 0x80E1,
+ LOCAL_GL_UNSIGNED_BYTE_3_3_2 = 0x8032,
+ LOCAL_GL_UNSIGNED_BYTE_2_3_3_REV = 0x8362,
+ LOCAL_GL_UNSIGNED_SHORT_5_6_5 = 0x8363,
+ LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV = 0x8364,
+ LOCAL_GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033,
+ LOCAL_GL_UNSIGNED_SHORT_4_4_4_4_REV = 0x8365,
+ LOCAL_GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034,
+ LOCAL_GL_UNSIGNED_SHORT_1_5_5_5_REV = 0x8366,
+ LOCAL_GL_UNSIGNED_INT_8_8_8_8 = 0x8035,
+ LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV = 0x8367,
+ LOCAL_GL_UNSIGNED_INT_10_10_10_2 = 0x8036,
+ LOCAL_GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368,
+ LOCAL_GL_LIGHT_MODEL_COLOR_CONTROL = 0x81F8,
+ LOCAL_GL_SINGLE_COLOR = 0x81F9,
+ LOCAL_GL_SEPARATE_SPECULAR_COLOR = 0x81FA,
+ LOCAL_GL_TEXTURE_MIN_LOD = 0x813A,
+ LOCAL_GL_TEXTURE_MAX_LOD = 0x813B,
+ LOCAL_GL_TEXTURE_BASE_LEVEL = 0x813C,
+ LOCAL_GL_TEXTURE_MAX_LEVEL = 0x813D
+};
+
+typedef struct { GLenum e; const char* name; } ENUM;
+#define EDEF(VAR) { (GLenum)(LOCAL_GL_##VAR), #VAR }
+
+static ENUM enums[] =
+ {
+ EDEF(BYTE),
+ EDEF(UNSIGNED_BYTE),
+ EDEF(SHORT),
+ EDEF(UNSIGNED_SHORT),
+ EDEF(INT),
+ EDEF(UNSIGNED_INT),
+ EDEF(FLOAT),
+ EDEF(DOUBLE),
+ EDEF(2_BYTES),
+ EDEF(3_BYTES),
+ EDEF(4_BYTES),
+/*
+ EDEF(LINES),
+ EDEF(POINTS),
+ EDEF(LINE_STRIP),
+ EDEF(LINE_LOOP),
+ EDEF(TRIANGLES),
+ EDEF(TRIANGLE_STRIP),
+ EDEF(TRIANGLE_FAN),
+ EDEF(QUADS),
+ EDEF(QUAD_STRIP),
+ EDEF(POLYGON),
+ EDEF(EDGE_FLAG),
+*/
+ EDEF(VERTEX_ARRAY),
+ EDEF(NORMAL_ARRAY),
+ EDEF(COLOR_ARRAY),
+ EDEF(INDEX_ARRAY),
+ EDEF(TEXTURE_COORD_ARRAY),
+ EDEF(EDGE_FLAG_ARRAY),
+ EDEF(VERTEX_ARRAY_SIZE),
+ EDEF(VERTEX_ARRAY_TYPE),
+ EDEF(VERTEX_ARRAY_STRIDE),
+ EDEF(NORMAL_ARRAY_TYPE),
+ EDEF(NORMAL_ARRAY_STRIDE),
+ EDEF(COLOR_ARRAY_SIZE),
+ EDEF(COLOR_ARRAY_TYPE),
+ EDEF(COLOR_ARRAY_STRIDE),
+ EDEF(INDEX_ARRAY_TYPE),
+ EDEF(INDEX_ARRAY_STRIDE),
+ EDEF(TEXTURE_COORD_ARRAY_SIZE),
+ EDEF(TEXTURE_COORD_ARRAY_TYPE),
+ EDEF(TEXTURE_COORD_ARRAY_STRIDE),
+ EDEF(EDGE_FLAG_ARRAY_STRIDE),
+ EDEF(VERTEX_ARRAY_POINTER),
+ EDEF(NORMAL_ARRAY_POINTER),
+ EDEF(COLOR_ARRAY_POINTER),
+ EDEF(INDEX_ARRAY_POINTER),
+ EDEF(TEXTURE_COORD_ARRAY_POINTER),
+ EDEF(EDGE_FLAG_ARRAY_POINTER),
+ EDEF(V2F),
+ EDEF(V3F),
+ EDEF(C4UB_V2F),
+ EDEF(C4UB_V3F),
+ EDEF(C3F_V3F),
+ EDEF(N3F_V3F),
+ EDEF(C4F_N3F_V3F),
+ EDEF(T2F_V3F),
+ EDEF(T4F_V4F),
+ EDEF(T2F_C4UB_V3F),
+ EDEF(T2F_C3F_V3F),
+ EDEF(T2F_N3F_V3F),
+ EDEF(T2F_C4F_N3F_V3F),
+ EDEF(T4F_C4F_N3F_V4F),
+ EDEF(MATRIX_MODE),
+ EDEF(MODELVIEW),
+ EDEF(PROJECTION),
+ EDEF(TEXTURE),
+ EDEF(POINT_SMOOTH),
+ EDEF(POINT_SIZE),
+ EDEF(POINT_SIZE_GRANULARITY),
+ EDEF(POINT_SIZE_RANGE),
+ EDEF(LINE_SMOOTH),
+ EDEF(LINE_STIPPLE),
+ EDEF(LINE_STIPPLE_PATTERN),
+ EDEF(LINE_STIPPLE_REPEAT),
+ EDEF(LINE_WIDTH),
+ EDEF(LINE_WIDTH_GRANULARITY),
+ EDEF(LINE_WIDTH_RANGE),
+ EDEF(POINT),
+ EDEF(LINE),
+ EDEF(FILL),
+ EDEF(CCW),
+ EDEF(CW),
+ EDEF(FRONT),
+ EDEF(BACK),
+ EDEF(CULL_FACE),
+ EDEF(CULL_FACE_MODE),
+ EDEF(POLYGON_SMOOTH),
+ EDEF(POLYGON_STIPPLE),
+ EDEF(FRONT_FACE),
+ EDEF(POLYGON_MODE),
+ EDEF(POLYGON_OFFSET_FACTOR),
+ EDEF(POLYGON_OFFSET_UNITS),
+ EDEF(POLYGON_OFFSET_POINT),
+ EDEF(POLYGON_OFFSET_LINE),
+ EDEF(POLYGON_OFFSET_FILL),
+ EDEF(COMPILE),
+ EDEF(COMPILE_AND_EXECUTE),
+ EDEF(LIST_BASE),
+ EDEF(LIST_INDEX),
+ EDEF(LIST_MODE),
+ EDEF(NEVER),
+ EDEF(LESS),
+ EDEF(GEQUAL),
+ EDEF(LEQUAL),
+ EDEF(GREATER),
+ EDEF(NOTEQUAL),
+ EDEF(EQUAL),
+ EDEF(ALWAYS),
+ EDEF(DEPTH_TEST),
+ EDEF(DEPTH_BITS),
+ EDEF(DEPTH_CLEAR_VALUE),
+ EDEF(DEPTH_FUNC),
+ EDEF(DEPTH_RANGE),
+ EDEF(DEPTH_WRITEMASK),
+ EDEF(DEPTH_COMPONENT),
+ EDEF(LIGHTING),
+ EDEF(LIGHT0),
+ EDEF(LIGHT1),
+ EDEF(LIGHT2),
+ EDEF(LIGHT3),
+ EDEF(LIGHT4),
+ EDEF(LIGHT5),
+ EDEF(LIGHT6),
+ EDEF(LIGHT7),
+ EDEF(SPOT_EXPONENT),
+ EDEF(SPOT_CUTOFF),
+ EDEF(CONSTANT_ATTENUATION),
+ EDEF(LINEAR_ATTENUATION),
+ EDEF(QUADRATIC_ATTENUATION),
+ EDEF(AMBIENT),
+ EDEF(DIFFUSE),
+ EDEF(SPECULAR),
+ EDEF(SHININESS),
+ EDEF(EMISSION),
+ EDEF(POSITION),
+ EDEF(SPOT_DIRECTION),
+ EDEF(AMBIENT_AND_DIFFUSE),
+ EDEF(COLOR_INDEXES),
+ EDEF(LIGHT_MODEL_TWO_SIDE),
+ EDEF(LIGHT_MODEL_LOCAL_VIEWER),
+ EDEF(LIGHT_MODEL_AMBIENT),
+ EDEF(FRONT_AND_BACK),
+ EDEF(SHADE_MODEL),
+ EDEF(FLAT),
+ EDEF(SMOOTH),
+ EDEF(COLOR_MATERIAL),
+ EDEF(COLOR_MATERIAL_FACE),
+ EDEF(COLOR_MATERIAL_PARAMETER),
+ EDEF(NORMALIZE),
+ EDEF(CLIP_PLANE0),
+ EDEF(CLIP_PLANE1),
+ EDEF(CLIP_PLANE2),
+ EDEF(CLIP_PLANE3),
+ EDEF(CLIP_PLANE4),
+ EDEF(CLIP_PLANE5),
+ EDEF(ACCUM_RED_BITS),
+ EDEF(ACCUM_GREEN_BITS),
+ EDEF(ACCUM_BLUE_BITS),
+ EDEF(ACCUM_ALPHA_BITS),
+ EDEF(ACCUM_CLEAR_VALUE),
+ EDEF(ACCUM),
+ EDEF(ADD),
+ EDEF(LOAD),
+ EDEF(MULT),
+ EDEF(RETURN),
+ EDEF(ALPHA_TEST),
+ EDEF(ALPHA_TEST_REF),
+ EDEF(ALPHA_TEST_FUNC),
+ EDEF(BLEND),
+ EDEF(BLEND_SRC),
+ EDEF(BLEND_DST),
+ EDEF(ZERO),
+ EDEF(ONE),
+ EDEF(SRC_COLOR),
+ EDEF(ONE_MINUS_SRC_COLOR),
+ EDEF(DST_COLOR),
+ EDEF(ONE_MINUS_DST_COLOR),
+ EDEF(SRC_ALPHA),
+ EDEF(ONE_MINUS_SRC_ALPHA),
+ EDEF(DST_ALPHA),
+ EDEF(ONE_MINUS_DST_ALPHA),
+ EDEF(SRC_ALPHA_SATURATE),
+ EDEF(CONSTANT_COLOR),
+ EDEF(ONE_MINUS_CONSTANT_COLOR),
+ EDEF(CONSTANT_ALPHA),
+ EDEF(ONE_MINUS_CONSTANT_ALPHA),
+ EDEF(FEEDBACK),
+ EDEF(RENDER),
+ EDEF(SELECT),
+ EDEF(2D),
+ EDEF(3D),
+ EDEF(3D_COLOR),
+ EDEF(3D_COLOR_TEXTURE),
+ EDEF(4D_COLOR_TEXTURE),
+ EDEF(POINT_TOKEN),
+ EDEF(LINE_TOKEN),
+ EDEF(LINE_RESET_TOKEN),
+ EDEF(POLYGON_TOKEN),
+ EDEF(BITMAP_TOKEN),
+ EDEF(DRAW_PIXEL_TOKEN),
+ EDEF(COPY_PIXEL_TOKEN),
+ EDEF(PASS_THROUGH_TOKEN),
+ EDEF(FEEDBACK_BUFFER_POINTER),
+ EDEF(FEEDBACK_BUFFER_SIZE),
+ EDEF(FEEDBACK_BUFFER_TYPE),
+ EDEF(SELECTION_BUFFER_POINTER),
+ EDEF(SELECTION_BUFFER_SIZE),
+ EDEF(FOG),
+ EDEF(FOG_MODE),
+ EDEF(FOG_DENSITY),
+ EDEF(FOG_COLOR),
+ EDEF(FOG_INDEX),
+ EDEF(FOG_START),
+ EDEF(FOG_END),
+ EDEF(LINEAR),
+ EDEF(EXP),
+ EDEF(EXP2),
+ EDEF(LOGIC_OP),
+ EDEF(INDEX_LOGIC_OP),
+ EDEF(COLOR_LOGIC_OP),
+ EDEF(LOGIC_OP_MODE),
+ EDEF(CLEAR),
+ EDEF(SET),
+ EDEF(COPY),
+ EDEF(COPY_INVERTED),
+ EDEF(NOOP),
+ EDEF(INVERT),
+ EDEF(AND),
+ EDEF(NAND),
+ EDEF(OR),
+ EDEF(NOR),
+ EDEF(XOR),
+ EDEF(EQUIV),
+ EDEF(AND_REVERSE),
+ EDEF(AND_INVERTED),
+ EDEF(OR_REVERSE),
+ EDEF(OR_INVERTED),
+ EDEF(STENCIL_TEST),
+ EDEF(STENCIL_WRITEMASK),
+ EDEF(STENCIL_BITS),
+ EDEF(STENCIL_FUNC),
+ EDEF(STENCIL_VALUE_MASK),
+ EDEF(STENCIL_REF),
+ EDEF(STENCIL_FAIL),
+ EDEF(STENCIL_PASS_DEPTH_PASS),
+ EDEF(STENCIL_PASS_DEPTH_FAIL),
+ EDEF(STENCIL_CLEAR_VALUE),
+ EDEF(STENCIL_INDEX),
+ EDEF(KEEP),
+ EDEF(REPLACE),
+ EDEF(INCR),
+ EDEF(DECR),
+ EDEF(NONE),
+ EDEF(LEFT),
+ EDEF(RIGHT),
+ EDEF(FRONT_LEFT),
+ EDEF(FRONT_RIGHT),
+ EDEF(BACK_LEFT),
+ EDEF(BACK_RIGHT),
+ EDEF(AUX0),
+ EDEF(AUX1),
+ EDEF(AUX2),
+ EDEF(AUX3),
+ EDEF(COLOR_INDEX),
+ EDEF(RED),
+ EDEF(GREEN),
+ EDEF(BLUE),
+ EDEF(ALPHA),
+ EDEF(LUMINANCE),
+ EDEF(LUMINANCE_ALPHA),
+ EDEF(ALPHA_BITS),
+ EDEF(RED_BITS),
+ EDEF(GREEN_BITS),
+ EDEF(BLUE_BITS),
+ EDEF(INDEX_BITS),
+ EDEF(SUBPIXEL_BITS),
+ EDEF(AUX_BUFFERS),
+ EDEF(READ_BUFFER),
+ EDEF(DRAW_BUFFER),
+ EDEF(DOUBLEBUFFER),
+ EDEF(STEREO),
+ EDEF(BITMAP),
+ EDEF(COLOR),
+ EDEF(DEPTH),
+ EDEF(STENCIL),
+ EDEF(DITHER),
+ EDEF(RGB),
+ EDEF(RGBA),
+ EDEF(MAX_LIST_NESTING),
+ EDEF(MAX_ATTRIB_STACK_DEPTH),
+ EDEF(MAX_MODELVIEW_STACK_DEPTH),
+ EDEF(MAX_NAME_STACK_DEPTH),
+ EDEF(MAX_PROJECTION_STACK_DEPTH),
+ EDEF(MAX_TEXTURE_STACK_DEPTH),
+ EDEF(MAX_EVAL_ORDER),
+ EDEF(MAX_LIGHTS),
+ EDEF(MAX_CLIP_PLANES),
+ EDEF(MAX_TEXTURE_SIZE),
+ EDEF(MAX_PIXEL_MAP_TABLE),
+ EDEF(MAX_VIEWPORT_DIMS),
+ EDEF(MAX_CLIENT_ATTRIB_STACK_DEPTH),
+ EDEF(ATTRIB_STACK_DEPTH),
+ EDEF(CLIENT_ATTRIB_STACK_DEPTH),
+ EDEF(COLOR_CLEAR_VALUE),
+ EDEF(COLOR_WRITEMASK),
+ EDEF(CURRENT_INDEX),
+ EDEF(CURRENT_COLOR),
+ EDEF(CURRENT_NORMAL),
+ EDEF(CURRENT_RASTER_COLOR),
+ EDEF(CURRENT_RASTER_DISTANCE),
+ EDEF(CURRENT_RASTER_INDEX),
+ EDEF(CURRENT_RASTER_POSITION),
+ EDEF(CURRENT_RASTER_TEXTURE_COORDS),
+ EDEF(CURRENT_RASTER_POSITION_VALID),
+ EDEF(CURRENT_TEXTURE_COORDS),
+ EDEF(INDEX_CLEAR_VALUE),
+ EDEF(INDEX_MODE),
+ EDEF(INDEX_WRITEMASK),
+ EDEF(MODELVIEW_MATRIX),
+ EDEF(MODELVIEW_STACK_DEPTH),
+ EDEF(NAME_STACK_DEPTH),
+ EDEF(PROJECTION_MATRIX),
+ EDEF(PROJECTION_STACK_DEPTH),
+ EDEF(RENDER_MODE),
+ EDEF(RGBA_MODE),
+ EDEF(TEXTURE_MATRIX),
+ EDEF(TEXTURE_STACK_DEPTH),
+ EDEF(VIEWPORT),
+ EDEF(AUTO_NORMAL),
+ EDEF(MAP1_COLOR_4),
+ EDEF(MAP1_GRID_DOMAIN),
+ EDEF(MAP1_GRID_SEGMENTS),
+ EDEF(MAP1_INDEX),
+ EDEF(MAP1_NORMAL),
+ EDEF(MAP1_TEXTURE_COORD_1),
+ EDEF(MAP1_TEXTURE_COORD_2),
+ EDEF(MAP1_TEXTURE_COORD_3),
+ EDEF(MAP1_TEXTURE_COORD_4),
+ EDEF(MAP1_VERTEX_3),
+ EDEF(MAP1_VERTEX_4),
+ EDEF(MAP2_COLOR_4),
+ EDEF(MAP2_GRID_DOMAIN),
+ EDEF(MAP2_GRID_SEGMENTS),
+ EDEF(MAP2_INDEX),
+ EDEF(MAP2_NORMAL),
+ EDEF(MAP2_TEXTURE_COORD_1),
+ EDEF(MAP2_TEXTURE_COORD_2),
+ EDEF(MAP2_TEXTURE_COORD_3),
+ EDEF(MAP2_TEXTURE_COORD_4),
+ EDEF(MAP2_VERTEX_3),
+ EDEF(MAP2_VERTEX_4),
+ EDEF(COEFF),
+ EDEF(DOMAIN),
+ EDEF(ORDER),
+ EDEF(FOG_HINT),
+ EDEF(LINE_SMOOTH_HINT),
+ EDEF(PERSPECTIVE_CORRECTION_HINT),
+ EDEF(POINT_SMOOTH_HINT),
+ EDEF(POLYGON_SMOOTH_HINT),
+ EDEF(DONT_CARE),
+ EDEF(FASTEST),
+ EDEF(NICEST),
+ EDEF(SCISSOR_TEST),
+ EDEF(SCISSOR_BOX),
+ EDEF(MAP_COLOR),
+ EDEF(MAP_STENCIL),
+ EDEF(INDEX_SHIFT),
+ EDEF(INDEX_OFFSET),
+ EDEF(RED_SCALE),
+ EDEF(RED_BIAS),
+ EDEF(GREEN_SCALE),
+ EDEF(GREEN_BIAS),
+ EDEF(BLUE_SCALE),
+ EDEF(BLUE_BIAS),
+ EDEF(ALPHA_SCALE),
+ EDEF(ALPHA_BIAS),
+ EDEF(DEPTH_SCALE),
+ EDEF(DEPTH_BIAS),
+ EDEF(PIXEL_MAP_S_TO_S_SIZE),
+ EDEF(PIXEL_MAP_I_TO_I_SIZE),
+ EDEF(PIXEL_MAP_I_TO_R_SIZE),
+ EDEF(PIXEL_MAP_I_TO_G_SIZE),
+ EDEF(PIXEL_MAP_I_TO_B_SIZE),
+ EDEF(PIXEL_MAP_I_TO_A_SIZE),
+ EDEF(PIXEL_MAP_R_TO_R_SIZE),
+ EDEF(PIXEL_MAP_G_TO_G_SIZE),
+ EDEF(PIXEL_MAP_B_TO_B_SIZE),
+ EDEF(PIXEL_MAP_A_TO_A_SIZE),
+ EDEF(PIXEL_MAP_S_TO_S),
+ EDEF(PIXEL_MAP_I_TO_I),
+ EDEF(PIXEL_MAP_I_TO_R),
+ EDEF(PIXEL_MAP_I_TO_G),
+ EDEF(PIXEL_MAP_I_TO_B),
+ EDEF(PIXEL_MAP_I_TO_A),
+ EDEF(PIXEL_MAP_R_TO_R),
+ EDEF(PIXEL_MAP_G_TO_G),
+ EDEF(PIXEL_MAP_B_TO_B),
+ EDEF(PIXEL_MAP_A_TO_A),
+ EDEF(PACK_ALIGNMENT),
+ EDEF(PACK_LSB_FIRST),
+ EDEF(PACK_ROW_LENGTH),
+ EDEF(PACK_SKIP_PIXELS),
+ EDEF(PACK_SKIP_ROWS),
+ EDEF(PACK_SWAP_BYTES),
+ EDEF(UNPACK_ALIGNMENT),
+ EDEF(UNPACK_LSB_FIRST),
+ EDEF(UNPACK_ROW_LENGTH),
+ EDEF(UNPACK_SKIP_PIXELS),
+ EDEF(UNPACK_SKIP_ROWS),
+ EDEF(UNPACK_SWAP_BYTES),
+ EDEF(ZOOM_X),
+ EDEF(ZOOM_Y),
+ EDEF(TEXTURE_ENV),
+ EDEF(TEXTURE_ENV_MODE),
+ EDEF(TEXTURE_1D),
+ EDEF(TEXTURE_2D),
+ EDEF(TEXTURE_WRAP_S),
+ EDEF(TEXTURE_WRAP_T),
+ EDEF(TEXTURE_MAG_FILTER),
+ EDEF(TEXTURE_MIN_FILTER),
+ EDEF(TEXTURE_ENV_COLOR),
+ EDEF(TEXTURE_GEN_S),
+ EDEF(TEXTURE_GEN_T),
+ EDEF(TEXTURE_GEN_MODE),
+ EDEF(TEXTURE_BORDER_COLOR),
+ EDEF(TEXTURE_WIDTH),
+ EDEF(TEXTURE_HEIGHT),
+ EDEF(TEXTURE_BORDER),
+ EDEF(TEXTURE_COMPONENTS),
+ EDEF(TEXTURE_RED_SIZE),
+ EDEF(TEXTURE_GREEN_SIZE),
+ EDEF(TEXTURE_BLUE_SIZE),
+ EDEF(TEXTURE_ALPHA_SIZE),
+ EDEF(TEXTURE_LUMINANCE_SIZE),
+ EDEF(TEXTURE_INTENSITY_SIZE),
+ EDEF(NEAREST_MIPMAP_NEAREST),
+ EDEF(NEAREST_MIPMAP_LINEAR),
+ EDEF(LINEAR_MIPMAP_NEAREST),
+ EDEF(LINEAR_MIPMAP_LINEAR),
+ EDEF(OBJECT_LINEAR),
+ EDEF(OBJECT_PLANE),
+ EDEF(EYE_LINEAR),
+ EDEF(EYE_PLANE),
+ EDEF(SPHERE_MAP),
+ EDEF(DECAL),
+ EDEF(MODULATE),
+ EDEF(NEAREST),
+ EDEF(REPEAT),
+ EDEF(CLAMP),
+ EDEF(S),
+ EDEF(T),
+ EDEF(R),
+ EDEF(Q),
+ EDEF(TEXTURE_GEN_R),
+ EDEF(TEXTURE_GEN_Q),
+ EDEF(PROXY_TEXTURE_1D),
+ EDEF(PROXY_TEXTURE_2D),
+ EDEF(TEXTURE_PRIORITY),
+ EDEF(TEXTURE_RESIDENT),
+ EDEF(TEXTURE_BINDING_1D),
+ EDEF(TEXTURE_BINDING_2D),
+ EDEF(TEXTURE_INTERNAL_FORMAT),
+ EDEF(PACK_SKIP_IMAGES),
+ EDEF(PACK_IMAGE_HEIGHT),
+ EDEF(UNPACK_SKIP_IMAGES),
+ EDEF(UNPACK_IMAGE_HEIGHT),
+ EDEF(TEXTURE_3D),
+ EDEF(PROXY_TEXTURE_3D),
+ EDEF(TEXTURE_DEPTH),
+ EDEF(TEXTURE_WRAP_R),
+ EDEF(MAX_3D_TEXTURE_SIZE),
+ EDEF(TEXTURE_BINDING_3D),
+ EDEF(ALPHA4),
+ EDEF(ALPHA8),
+ EDEF(ALPHA12),
+ EDEF(ALPHA16),
+ EDEF(LUMINANCE4),
+ EDEF(LUMINANCE8),
+ EDEF(LUMINANCE12),
+ EDEF(LUMINANCE16),
+ EDEF(LUMINANCE4_ALPHA4),
+ EDEF(LUMINANCE6_ALPHA2),
+ EDEF(LUMINANCE8_ALPHA8),
+ EDEF(LUMINANCE12_ALPHA4),
+ EDEF(LUMINANCE12_ALPHA12),
+ EDEF(LUMINANCE16_ALPHA16),
+ EDEF(INTENSITY),
+ EDEF(INTENSITY4),
+ EDEF(INTENSITY8),
+ EDEF(INTENSITY12),
+ EDEF(INTENSITY16),
+ EDEF(R3_G3_B2),
+ EDEF(RGB4),
+ EDEF(RGB5),
+ EDEF(RGB8),
+ EDEF(RGB10),
+ EDEF(RGB12),
+ EDEF(RGB16),
+ EDEF(RGBA2),
+ EDEF(RGBA4),
+ EDEF(RGB5_A1),
+ EDEF(RGBA8),
+ EDEF(RGB10_A2),
+ EDEF(RGBA12),
+ EDEF(RGBA16),
+ EDEF(VENDOR),
+ EDEF(RENDERER),
+ EDEF(VERSION),
+ EDEF(EXTENSIONS),
+ EDEF(INVALID_VALUE),
+ EDEF(INVALID_ENUM),
+ EDEF(INVALID_OPERATION),
+ EDEF(STACK_OVERFLOW),
+ EDEF(STACK_UNDERFLOW),
+ EDEF(OUT_OF_MEMORY),
+
+ /* extensions */
+ EDEF(CONSTANT_COLOR_EXT),
+ EDEF(ONE_MINUS_CONSTANT_COLOR_EXT),
+ EDEF(CONSTANT_ALPHA_EXT),
+ EDEF(ONE_MINUS_CONSTANT_ALPHA_EXT),
+ EDEF(BLEND_EQUATION_EXT),
+ EDEF(MIN_EXT),
+ EDEF(MAX_EXT),
+ EDEF(FUNC_ADD_EXT),
+ EDEF(FUNC_SUBTRACT_EXT),
+ EDEF(FUNC_REVERSE_SUBTRACT_EXT),
+ EDEF(BLEND_COLOR_EXT),
+ EDEF(POLYGON_OFFSET_EXT),
+ EDEF(POLYGON_OFFSET_FACTOR_EXT),
+ EDEF(POLYGON_OFFSET_BIAS_EXT),
+ EDEF(VERTEX_ARRAY_EXT),
+ EDEF(NORMAL_ARRAY_EXT),
+ EDEF(COLOR_ARRAY_EXT),
+ EDEF(INDEX_ARRAY_EXT),
+ EDEF(TEXTURE_COORD_ARRAY_EXT),
+ EDEF(EDGE_FLAG_ARRAY_EXT),
+ EDEF(VERTEX_ARRAY_SIZE_EXT),
+ EDEF(VERTEX_ARRAY_TYPE_EXT),
+ EDEF(VERTEX_ARRAY_STRIDE_EXT),
+ EDEF(VERTEX_ARRAY_COUNT_EXT),
+ EDEF(NORMAL_ARRAY_TYPE_EXT),
+ EDEF(NORMAL_ARRAY_STRIDE_EXT),
+ EDEF(NORMAL_ARRAY_COUNT_EXT),
+ EDEF(COLOR_ARRAY_SIZE_EXT),
+ EDEF(COLOR_ARRAY_TYPE_EXT),
+ EDEF(COLOR_ARRAY_STRIDE_EXT),
+ EDEF(COLOR_ARRAY_COUNT_EXT),
+ EDEF(INDEX_ARRAY_TYPE_EXT),
+ EDEF(INDEX_ARRAY_STRIDE_EXT),
+ EDEF(INDEX_ARRAY_COUNT_EXT),
+ EDEF(TEXTURE_COORD_ARRAY_SIZE_EXT),
+ EDEF(TEXTURE_COORD_ARRAY_TYPE_EXT),
+ EDEF(TEXTURE_COORD_ARRAY_STRIDE_EXT),
+ EDEF(TEXTURE_COORD_ARRAY_COUNT_EXT),
+ EDEF(EDGE_FLAG_ARRAY_STRIDE_EXT),
+ EDEF(EDGE_FLAG_ARRAY_COUNT_EXT),
+ EDEF(VERTEX_ARRAY_POINTER_EXT),
+ EDEF(NORMAL_ARRAY_POINTER_EXT),
+ EDEF(COLOR_ARRAY_POINTER_EXT),
+ EDEF(INDEX_ARRAY_POINTER_EXT),
+ EDEF(TEXTURE_COORD_ARRAY_POINTER_EXT),
+ EDEF(EDGE_FLAG_ARRAY_POINTER_EXT),
+ EDEF(TEXTURE_PRIORITY_EXT),
+ EDEF(TEXTURE_RESIDENT_EXT),
+ EDEF(TEXTURE_1D_BINDING_EXT),
+ EDEF(TEXTURE_2D_BINDING_EXT),
+ EDEF(PACK_SKIP_IMAGES_EXT),
+ EDEF(PACK_IMAGE_HEIGHT_EXT),
+ EDEF(UNPACK_SKIP_IMAGES_EXT),
+ EDEF(UNPACK_IMAGE_HEIGHT_EXT),
+ EDEF(TEXTURE_3D_EXT),
+ EDEF(PROXY_TEXTURE_3D_EXT),
+ EDEF(TEXTURE_DEPTH_EXT),
+ EDEF(TEXTURE_WRAP_R_EXT),
+ EDEF(MAX_3D_TEXTURE_SIZE_EXT),
+ EDEF(TEXTURE_3D_BINDING_EXT),
+ EDEF(TABLE_TOO_LARGE_EXT),
+ EDEF(COLOR_TABLE_FORMAT_EXT),
+ EDEF(COLOR_TABLE_WIDTH_EXT),
+ EDEF(COLOR_TABLE_RED_SIZE_EXT),
+ EDEF(COLOR_TABLE_GREEN_SIZE_EXT),
+ EDEF(COLOR_TABLE_BLUE_SIZE_EXT),
+ EDEF(COLOR_TABLE_ALPHA_SIZE_EXT),
+ EDEF(COLOR_TABLE_LUMINANCE_SIZE_EXT),
+ EDEF(COLOR_TABLE_INTENSITY_SIZE_EXT),
+ EDEF(TEXTURE_INDEX_SIZE_EXT),
+ EDEF(COLOR_INDEX1_EXT),
+ EDEF(COLOR_INDEX2_EXT),
+ EDEF(COLOR_INDEX4_EXT),
+ EDEF(COLOR_INDEX8_EXT),
+ EDEF(COLOR_INDEX12_EXT),
+ EDEF(COLOR_INDEX16_EXT),
+ EDEF(SHARED_TEXTURE_PALETTE_EXT),
+ EDEF(POINT_SIZE_MIN_EXT),
+ EDEF(POINT_SIZE_MAX_EXT),
+ EDEF(POINT_FADE_THRESHOLD_SIZE_EXT),
+ EDEF(DISTANCE_ATTENUATION_EXT),
+ EDEF(RESCALE_NORMAL_EXT),
+ EDEF(ABGR_EXT),
+ EDEF(SELECTED_TEXTURE_SGIS),
+ EDEF(SELECTED_TEXTURE_COORD_SET_SGIS),
+ EDEF(MAX_TEXTURES_SGIS),
+ EDEF(TEXTURE0_SGIS),
+ EDEF(TEXTURE1_SGIS),
+ EDEF(TEXTURE2_SGIS),
+ EDEF(TEXTURE3_SGIS),
+ EDEF(TEXTURE_COORD_SET_SOURCE_SGIS),
+ EDEF(SELECTED_TEXTURE_EXT),
+ EDEF(SELECTED_TEXTURE_COORD_SET_EXT),
+ EDEF(SELECTED_TEXTURE_TRANSFORM_EXT),
+ EDEF(MAX_TEXTURES_EXT),
+ EDEF(MAX_TEXTURE_COORD_SETS_EXT),
+ EDEF(TEXTURE_ENV_COORD_SET_EXT),
+ EDEF(TEXTURE0_EXT),
+ EDEF(TEXTURE1_EXT),
+ EDEF(TEXTURE2_EXT),
+ EDEF(TEXTURE3_EXT),
+ EDEF(CLAMP_TO_EDGE_SGIS),
+ EDEF(RESCALE_NORMAL),
+ EDEF(CLAMP_TO_EDGE),
+ EDEF(MAX_ELEMENTS_VERTICES),
+ EDEF(MAX_ELEMENTS_INDICES),
+ EDEF(BGR),
+ EDEF(BGRA),
+ EDEF(UNSIGNED_BYTE_3_3_2),
+ EDEF(UNSIGNED_BYTE_2_3_3_REV),
+ EDEF(UNSIGNED_SHORT_5_6_5),
+ EDEF(UNSIGNED_SHORT_5_6_5_REV),
+ EDEF(UNSIGNED_SHORT_4_4_4_4),
+ EDEF(UNSIGNED_SHORT_4_4_4_4_REV),
+ EDEF(UNSIGNED_SHORT_5_5_5_1),
+ EDEF(UNSIGNED_SHORT_1_5_5_5_REV),
+ EDEF(UNSIGNED_INT_8_8_8_8),
+ EDEF(UNSIGNED_INT_8_8_8_8_REV),
+ EDEF(UNSIGNED_INT_10_10_10_2),
+ EDEF(UNSIGNED_INT_2_10_10_10_REV),
+ EDEF(LIGHT_MODEL_COLOR_CONTROL),
+ EDEF(SINGLE_COLOR),
+ EDEF(SEPARATE_SPECULAR_COLOR),
+ EDEF(TEXTURE_MIN_LOD),
+ EDEF(TEXTURE_MAX_LOD),
+ EDEF(TEXTURE_BASE_LEVEL),
+ EDEF(TEXTURE_MAX_LEVEL)
+};
+
+#undef EDEF
+
+#define N_ENUMS (sizeof(enums) / sizeof(ENUM))
+
+/***************************************************************************/
+
+static void print_enum_name( FILE* OUT, GLenum e )
+{
+ int i, found= 0;
+ for( i= 0; i < N_ENUMS; ++i )
+ {
+ if( enums[i].e == e )
+ {
+ if( found )
+ fprintf( OUT, "/" );
+ found= 1;
+ fprintf( OUT, "%s", enums[i].name );
+ }
+ }
+ if( ! found )
+ fprintf( OUT, "*UNKNOWN* [%04x]", (int)e );
+ fprintf( OUT, "\n" );
+}
+
+#define BOOL_STRING(b) (b ? "true" : "false")
+
+#define VAR_ENUM(VAR) \
+ { \
+ GLint e= 0; \
+ glGetIntegerv(GL_##VAR,&e); \
+ fprintf( OUT, "%s: ", #VAR ); \
+ print_enum_name( OUT, (GLenum) e ); \
+ }
+
+#define VAR_FLOAT4(VAR) \
+ { \
+ GLfloat f[4]; \
+ f[0]= f[1]= f[2]= f[3]= 0.0; \
+ glGetFloatv(GL_##VAR,f); \
+ fprintf( OUT, "%s: [%f %f %f %f]\n", \
+ #VAR, f[0], f[1], f[2], f[3] ); \
+ }
+
+#define VAR_MAT_FLOAT4(VAR) \
+ { \
+ GLfloat f[4]; \
+ f[0]= f[1]= f[2]= f[3]= 0.0; \
+ glGetMaterialfv(GL_FRONT,GL_##VAR,f); \
+ fprintf( OUT, "FRONT_%s: [%f %f %f %f]\n", \
+ #VAR, f[0], f[1], f[2], f[3] ); \
+ glGetMaterialfv(GL_BACK,GL_##VAR,f); \
+ fprintf( OUT, " BACK_%s: [%f %f %f %f]\n", \
+ #VAR, f[0], f[1], f[2], f[3] ); \
+ }
+
+#define VAR_LIGHT_FLOAT4(LIGHT,VAR) \
+ { \
+ GLfloat f[4]; \
+ f[0]= f[1]= f[2]= f[3]= 0.0; \
+ glGetLightfv(GL_LIGHT0+LIGHT,GL_##VAR,f); \
+ fprintf( OUT, "LIGHT%d.%s: [%f %f %f %f]\n", \
+ LIGHT, #VAR, f[0], f[1], f[2], f[3] ); \
+ }
+
+#define VAR_LIGHT_FLOAT3(LIGHT,VAR) \
+ { \
+ GLfloat f[3]; \
+ f[0]= f[1]= f[2]= 0.0; \
+ glGetLightfv(GL_LIGHT0+LIGHT,GL_##VAR,f); \
+ fprintf( OUT, "LIGHT%d.%s: [%f %f %f]\n", \
+ LIGHT, #VAR, f[0], f[1], f[2] ); \
+ }
+
+#define VAR_FLOAT3(VAR) \
+ { \
+ GLfloat f[3]; \
+ f[0]= f[1]= f[2]= 0.0; \
+ glGetFloatv(GL_##VAR,f) ; \
+ fprintf( OUT, "%s: [%f %f %f]\n", \
+ #VAR, f[0], f[1], f[2] ); \
+ }
+#define VAR_FLOAT2(VAR) \
+ { \
+ GLfloat f[2]; \
+ f[0]= f[1]= 0.0; \
+ glGetFloatv(GL_##VAR,f); \
+ fprintf( OUT, "%s: [%f %f]\n", \
+ #VAR, f[0], f[1] ); \
+ }
+
+#define VAR_COLOR(VAR) VAR_FLOAT4(VAR)
+#define VAR_TEXCOORD(VAR) VAR_FLOAT4(VAR)
+#define VAR_NORMAL(VAR) VAR_FLOAT3(VAR)
+
+#define VAR_MAT_COLOR(VAR) VAR_MAT_FLOAT4(VAR)
+#define VAR_LIGHT_COLOR(LIGHT,VAR) VAR_LIGHT_FLOAT4(LIGHT,VAR)
+
+#define VAR_FLOAT(VAR) \
+ { \
+ GLfloat f= 0.0; \
+ glGetFloatv(GL_##VAR,&f); \
+ fprintf( OUT, "%s: %f\n", #VAR, f ); \
+ }
+
+#define VAR_MAT_FLOAT(VAR) \
+ { \
+ GLfloat f= 0.0; \
+ glGetMaterialfv(GL_FRONT,GL_##VAR,&f); \
+ fprintf( OUT, "FRONT_%s: %f\n", #VAR, f ); \
+ glGetMaterialfv(GL_BACK,GL_##VAR,&f); \
+ fprintf( OUT, " BACK_%s: %f\n", #VAR, f ); \
+ }
+
+#define VAR_LIGHT_FLOAT(LIGHT,VAR) \
+ { \
+ GLfloat f= 0.0; \
+ glGetLightfv(GL_LIGHT0+LIGHT,GL_##VAR,&f); \
+ fprintf( OUT, "LIGHT%d.%s: %f\n", \
+ LIGHT, #VAR, f ); \
+ }
+
+#define VAR_INT(VAR) \
+ { \
+ GLint i= 0; \
+ glGetIntegerv(GL_##VAR,&i); \
+ fprintf( OUT, "%s: %d\n", #VAR, (int)i ); \
+ }
+#define VAR_INTEGER(VAR) VAR_INT(VAR)
+#define VAR_INDEX(VAR) VAR_INT(VAR)
+#define VAR_HEXINT(VAR) \
+ { \
+ GLint i= 0; \
+ glGetIntegerv(GL_##VAR,&i); \
+ fprintf( OUT, "%s: 0x%04x\n", #VAR, (int)i ); \
+ }
+#define VAR_INT4(VAR) \
+ { \
+ GLint i[4]; \
+ i[0]= i[1]= i[2]= i[3]= 0; \
+ glGetIntegerv(GL_##VAR,i); \
+ fprintf( OUT, "%s: [%d %d %d %d]\n", \
+ #VAR, (int)i[0], (int)i[1], (int)i[2], (int)i[3] ); \
+ }
+#define VAR_BOOL(VAR) \
+ { \
+ GLboolean b= 0; \
+ glGetBooleanv(GL_##VAR,&b); \
+ fprintf( OUT, "%s: %s\n", #VAR, BOOL_STRING(b) ); \
+ }
+#define VAR_BOOL4(VAR) \
+ { \
+ GLboolean b[4]; \
+ b[0]= b[1]= b[2]= b[3]= 0; \
+ glGetBooleanv(GL_##VAR,b); \
+ fprintf( OUT, "%s: [%s %s %s %s]\n", \
+ #VAR, \
+ BOOL_STRING(b[0]), \
+ BOOL_STRING(b[1]), \
+ BOOL_STRING(b[2]), \
+ BOOL_STRING(b[3]) ); \
+ }
+#define VAR_PTR(VAR) \
+ { \
+ GLvoid* p= 0; \
+ glGetPointerv(GL_##VAR,&p); \
+ fprintf( OUT, "%s: %p\n", #VAR, p ); \
+ }
+#define VAR_MATRIX(VAR) \
+ { \
+ GLfloat m[16]; \
+ int i; \
+ for( i= 0; i < 16; ++i ) m[i]= 0.0; \
+ glGetFloatv(GL_##VAR,m); \
+ fprintf( OUT, \
+ "%s:\n\t[%+.6f %+.6f %+.6f %+.6f]\n\t[%+.6f %+.6f %+.6f
+%+.6f]\n\t[%+.6f %+.6f %+.6f %+.6f]\n\t[%+.6f %+.6f %+.6f %+.6f]\n", \
+ #VAR, \
+ m[0+0*4], m[0+1*4], m[0+2*4], m[0+3*4], \
+ m[1+0*4], m[1+1*4], m[1+2*4], m[1+3*4], \
+ m[2+0*4], m[2+1*4], m[2+2*4], m[2+3*4], \
+ m[3+0*4], m[3+1*4], m[3+2*4], m[3+3*4] ); \
+ }
+
+/***************************************************************************/
+
+/*
+#define OUT stderr
+*/
+void dump_opengl_state( FILE* OUT )
+{
+ int i;
+ GLint n_lights= 0;
+
+ glGetIntegerv( GL_MAX_LIGHTS, &n_lights );
+
+ VAR_COLOR(CURRENT_COLOR)
+ VAR_INDEX(CURRENT_INDEX)
+ VAR_TEXCOORD(CURRENT_TEXTURE_COORDS)
+ VAR_NORMAL(CURRENT_NORMAL)
+ VAR_FLOAT4(CURRENT_RASTER_POSITION)
+ VAR_FLOAT(CURRENT_RASTER_DISTANCE)
+ VAR_COLOR(CURRENT_RASTER_COLOR)
+ VAR_INDEX(CURRENT_RASTER_INDEX)
+ VAR_TEXCOORD(CURRENT_RASTER_TEXTURE_COORDS)
+ VAR_BOOL(CURRENT_RASTER_POSITION_VALID)
+ VAR_BOOL(EDGE_FLAG)
+
+ VAR_BOOL (VERTEX_ARRAY)
+ VAR_INTEGER(VERTEX_ARRAY_SIZE)
+ VAR_ENUM (VERTEX_ARRAY_TYPE)
+ VAR_INTEGER(VERTEX_ARRAY_STRIDE)
+ VAR_PTR (VERTEX_ARRAY_POINTER)
+
+ VAR_BOOL (NORMAL_ARRAY)
+ VAR_ENUM (NORMAL_ARRAY_TYPE)
+ VAR_INTEGER(NORMAL_ARRAY_STRIDE)
+ VAR_PTR (NORMAL_ARRAY_POINTER)
+
+ VAR_BOOL (COLOR_ARRAY)
+ VAR_INTEGER(COLOR_ARRAY_SIZE)
+ VAR_ENUM (COLOR_ARRAY_TYPE)
+ VAR_INTEGER(COLOR_ARRAY_STRIDE)
+ VAR_PTR (COLOR_ARRAY_POINTER)
+
+ VAR_BOOL (INDEX_ARRAY)
+ VAR_ENUM (INDEX_ARRAY_TYPE)
+ VAR_INTEGER(INDEX_ARRAY_STRIDE)
+ VAR_PTR (INDEX_ARRAY_POINTER)
+
+ VAR_BOOL (TEXTURE_COORD_ARRAY)
+ VAR_INTEGER(TEXTURE_COORD_ARRAY_SIZE)
+ VAR_ENUM (TEXTURE_COORD_ARRAY_TYPE)
+ VAR_INTEGER(TEXTURE_COORD_ARRAY_STRIDE)
+ VAR_PTR (TEXTURE_COORD_ARRAY_POINTER)
+
+ VAR_BOOL (EDGE_FLAG_ARRAY)
+ VAR_INTEGER(EDGE_FLAG_ARRAY_STRIDE)
+ VAR_PTR (EDGE_FLAG_ARRAY_POINTER)
+
+ VAR_MATRIX(MODELVIEW_MATRIX)
+ VAR_MATRIX(PROJECTION_MATRIX)
+ VAR_MATRIX(TEXTURE_MATRIX)
+ VAR_INT4(VIEWPORT)
+ VAR_FLOAT2(DEPTH_RANGE)
+ VAR_INT(MODELVIEW_STACK_DEPTH)
+ VAR_INT(PROJECTION_STACK_DEPTH)
+ VAR_INT(TEXTURE_STACK_DEPTH)
+ VAR_ENUM(MATRIX_MODE)
+ VAR_BOOL(NORMALIZE)
+ VAR_BOOL(RESCALE_NORMAL_EXT)
+ VAR_BOOL(CLIP_PLANE0)
+ VAR_BOOL(CLIP_PLANE1)
+ VAR_BOOL(CLIP_PLANE2)
+ VAR_BOOL(CLIP_PLANE3)
+ VAR_BOOL(CLIP_PLANE4)
+ VAR_BOOL(CLIP_PLANE5)
+ /* + glGetClipPlane() */
+
+ VAR_COLOR(FOG_COLOR)
+ VAR_INDEX(FOG_INDEX)
+ VAR_FLOAT(FOG_DENSITY)
+ VAR_FLOAT(FOG_START)
+ VAR_FLOAT(FOG_END)
+ VAR_ENUM(FOG_MODE)
+ VAR_BOOL(FOG)
+ VAR_ENUM(SHADE_MODEL)
+
+ VAR_BOOL(LIGHTING)
+ VAR_BOOL(COLOR_MATERIAL)
+ VAR_ENUM(COLOR_MATERIAL_PARAMETER)
+ VAR_ENUM(COLOR_MATERIAL_FACE)
+
+ VAR_MAT_COLOR(AMBIENT)
+ VAR_MAT_COLOR(DIFFUSE)
+ VAR_MAT_COLOR(SPECULAR)
+ VAR_MAT_COLOR(EMISSION)
+ VAR_MAT_FLOAT(SHININESS)
+
+ VAR_COLOR(LIGHT_MODEL_AMBIENT)
+ VAR_BOOL(LIGHT_MODEL_LOCAL_VIEWER)
+ VAR_BOOL(LIGHT_MODEL_TWO_SIDE)
+/* VAR_ENUM(LIGHT_MODEL_COLOR_CONTROL)*/
+
+ for( i= 0; i < n_lights; ++i )
+ {
+ GLboolean b= 0;
+
+ glGetBooleanv( GL_LIGHT0 + i, &b );
+ fprintf( OUT, "LIGHT%d: %s\n", i, BOOL_STRING(b) );
+
+ if( ! b )
+ continue;
+
+ VAR_LIGHT_COLOR(i,AMBIENT)
+ VAR_LIGHT_COLOR(i,DIFFUSE)
+ VAR_LIGHT_COLOR(i,SPECULAR)
+ VAR_LIGHT_FLOAT4(i,POSITION)
+ VAR_LIGHT_FLOAT(i,CONSTANT_ATTENUATION)
+ VAR_LIGHT_FLOAT(i,LINEAR_ATTENUATION)
+ VAR_LIGHT_FLOAT(i,QUADRATIC_ATTENUATION)
+ VAR_LIGHT_FLOAT3(i,SPOT_DIRECTION)
+ VAR_LIGHT_FLOAT(i,SPOT_EXPONENT)
+ VAR_LIGHT_FLOAT(i,SPOT_CUTOFF)
+ /* COLOR_INDEXES */
+ }
+
+ VAR_FLOAT(POINT_SIZE)
+ VAR_BOOL(POINT_SMOOTH)
+ VAR_FLOAT(LINE_WIDTH)
+ VAR_BOOL(LINE_SMOOTH)
+ VAR_HEXINT(LINE_STIPPLE_PATTERN)
+ VAR_INT(LINE_STIPPLE_REPEAT)
+ VAR_BOOL(LINE_STIPPLE)
+ VAR_BOOL(CULL_FACE)
+ VAR_ENUM(CULL_FACE_MODE)
+ VAR_ENUM(FRONT_FACE)
+ VAR_BOOL(POLYGON_SMOOTH)
+ VAR_ENUM(POLYGON_MODE)
+ VAR_FLOAT(POLYGON_OFFSET_FACTOR)
+ VAR_FLOAT(POLYGON_OFFSET_UNITS)
+ VAR_BOOL(POLYGON_OFFSET_POINT)
+ VAR_BOOL(POLYGON_OFFSET_LINE)
+ VAR_BOOL(POLYGON_OFFSET_FILL)
+ /* GetPolygonStipple */
+ VAR_BOOL(POLYGON_STIPPLE)
+
+ VAR_BOOL(TEXTURE_1D)
+ VAR_BOOL(TEXTURE_2D)
+/* VAR_BOOL(TEXTURE_3D)*/
+
+ VAR_INT(TEXTURE_BINDING_1D)
+ VAR_INT(TEXTURE_BINDING_2D)
+/* VAR_INT(TEXTURE_BINDING_3D)*/
+
+ /* GetTexImage() */
+ /* GetTexLevelParameter() */
+ /* GetTexEnv() */
+
+ VAR_BOOL(TEXTURE_GEN_S)
+ VAR_BOOL(TEXTURE_GEN_T)
+ VAR_BOOL(TEXTURE_GEN_R)
+ VAR_BOOL(TEXTURE_GEN_Q)
+
+ /* GetTexGen() */
+
+ VAR_BOOL(SCISSOR_TEST)
+ VAR_INT4(SCISSOR_BOX)
+ VAR_BOOL(ALPHA_TEST)
+ VAR_ENUM(ALPHA_TEST_FUNC)
+ VAR_FLOAT(ALPHA_TEST_REF)
+ VAR_BOOL(STENCIL_TEST)
+ VAR_ENUM(STENCIL_FUNC)
+ VAR_HEXINT(STENCIL_VALUE_MASK)
+ VAR_INT(STENCIL_REF)
+ VAR_ENUM(STENCIL_FAIL)
+ VAR_ENUM(STENCIL_PASS_DEPTH_FAIL)
+ VAR_ENUM(STENCIL_PASS_DEPTH_PASS)
+ VAR_BOOL(DEPTH_TEST)
+ VAR_ENUM(DEPTH_FUNC)
+ VAR_BOOL(BLEND)
+ VAR_ENUM(BLEND_SRC)
+ VAR_ENUM(BLEND_DST)
+
+ VAR_BOOL(DITHER)
+ VAR_BOOL(LOGIC_OP) /* INDEX_LOGIC_OP */
+ VAR_BOOL(COLOR_LOGIC_OP)
+
+ VAR_ENUM(DRAW_BUFFER)
+ VAR_INT(INDEX_WRITEMASK)
+ VAR_BOOL4(COLOR_WRITEMASK)
+ VAR_BOOL(DEPTH_WRITEMASK)
+ VAR_HEXINT(STENCIL_WRITEMASK)
+ VAR_COLOR(COLOR_CLEAR_VALUE)
+ VAR_INDEX(INDEX_CLEAR_VALUE)
+ VAR_FLOAT(DEPTH_CLEAR_VALUE)
+ VAR_INT(STENCIL_CLEAR_VALUE)
+ VAR_FLOAT(ACCUM_CLEAR_VALUE)
+
+ VAR_BOOL(UNPACK_SWAP_BYTES)
+ VAR_BOOL(UNPACK_LSB_FIRST)
+#ifdef UNPACK_IMAGE_HEIGHT
+ VAR_INT(UNPACK_IMAGE_HEIGHT)
+#endif
+#ifdef UNPACK_SKIP_IMAGES
+ VAR_INT(UNPACK_SKIP_IMAGES)
+#endif
+ VAR_INT(UNPACK_ROW_LENGTH)
+ VAR_INT(UNPACK_SKIP_ROWS)
+ VAR_INT(UNPACK_SKIP_PIXELS)
+ VAR_INT(UNPACK_ALIGNMENT)
+
+ VAR_BOOL(PACK_SWAP_BYTES)
+ VAR_BOOL(PACK_LSB_FIRST)
+#ifdef PACK_IMAGE_HEIGHT
+ VAR_INT(PACK_IMAGE_HEIGHT)
+#endif
+#ifdef PACK_SKIP_IMAGES
+ VAR_INT(PACK_SKIP_IMAGES)
+#endif
+ VAR_INT(PACK_ROW_LENGTH)
+ VAR_INT(PACK_SKIP_ROWS)
+ VAR_INT(PACK_SKIP_PIXELS)
+ VAR_INT(PACK_ALIGNMENT)
+
+ VAR_BOOL(MAP_COLOR)
+ VAR_BOOL(MAP_STENCIL)
+ VAR_INT(INDEX_SHIFT)
+ VAR_INT(INDEX_OFFSET)
+ VAR_FLOAT(RED_SCALE)
+ VAR_FLOAT(GREEN_SCALE)
+ VAR_FLOAT(BLUE_SCALE)
+ VAR_FLOAT(ALPHA_SCALE)
+ VAR_FLOAT(DEPTH_SCALE)
+ VAR_FLOAT(RED_BIAS)
+ VAR_FLOAT(GREEN_BIAS)
+ VAR_FLOAT(BLUE_BIAS)
+ VAR_FLOAT(ALPHA_BIAS)
+ VAR_FLOAT(DEPTH_BIAS)
+
+ VAR_FLOAT(ZOOM_X)
+ VAR_FLOAT(ZOOM_Y)
+
+ VAR_ENUM(READ_BUFFER)
+
+ VAR_BOOL(AUTO_NORMAL)
+
+ VAR_ENUM(PERSPECTIVE_CORRECTION_HINT)
+ VAR_ENUM(POINT_SMOOTH_HINT)
+ VAR_ENUM(LINE_SMOOTH_HINT)
+ VAR_ENUM(POLYGON_SMOOTH_HINT)
+ VAR_ENUM(FOG_HINT)
+
+ VAR_INT(MAX_LIGHTS)
+ VAR_INT(MAX_CLIP_PLANES)
+ VAR_INT(MAX_MODELVIEW_STACK_DEPTH)
+ VAR_INT(MAX_PROJECTION_STACK_DEPTH)
+ VAR_INT(MAX_TEXTURE_STACK_DEPTH)
+ VAR_INT(SUBPIXEL_BITS)
+#ifdef GL_MAX_3D_TEXTURE_SIZE
+ VAR_INT(MAX_3D_TEXTURE_SIZE)
+#endif
+ VAR_INT(MAX_TEXTURE_SIZE)
+ VAR_INT(MAX_PIXEL_MAP_TABLE)
+ VAR_INT(MAX_NAME_STACK_DEPTH)
+ VAR_INT(MAX_LIST_NESTING)
+ VAR_INT(MAX_EVAL_ORDER)
+ VAR_INT(MAX_VIEWPORT_DIMS)
+ VAR_INT(MAX_ATTRIB_STACK_DEPTH)
+ VAR_INT(MAX_CLIENT_ATTRIB_STACK_DEPTH)
+ VAR_INT(AUX_BUFFERS)
+ VAR_BOOL(RGBA_MODE)
+ VAR_BOOL(INDEX_MODE)
+ VAR_BOOL(DOUBLEBUFFER)
+ VAR_BOOL(STEREO)
+#ifdef GL_ALIASED_POINT_SIZE_RANGE
+ VAR_FLOAT2(ALIASED_POINT_SIZE_RANGE)
+#endif
+#ifdef GL_POINT_SIZE_RANGE
+ VAR_FLOAT2(POINT_SIZE_RANGE) /* SMOOTH_POINT_SIZE_RANGE */
+#endif
+ VAR_FLOAT(POINT_SIZE_GRANULARITY) /* SMOOTH_POINT_SIZE_GRANULARITY */
+#ifdef GL_ALIASED_LINE_WIDTH_RANGE
+ VAR_FLOAT2(ALIASED_LINE_WIDTH_RANGE)
+#endif
+ VAR_FLOAT2(LINE_WIDTH_RANGE) /* SMOOTH_LINE_WIDTH_RANGE */
+ VAR_FLOAT(LINE_WIDTH_GRANULARITY) /* SMOOTH_LINE_WIDTH_GRANULARITY */
+
+#ifdef GL_MAX_ELEMENTS_INDICES
+ VAR_INT(MAX_ELEMENTS_INDICES)
+#endif
+#ifdef GL_MAX_ELEMENTS_VERTICES
+ VAR_INT(MAX_ELEMENTS_VERTICES)
+#endif
+ VAR_INT(RED_BITS)
+ VAR_INT(GREEN_BITS)
+ VAR_INT(BLUE_BITS)
+ VAR_INT(ALPHA_BITS)
+ VAR_INT(INDEX_BITS)
+ VAR_INT(DEPTH_BITS)
+ VAR_INT(STENCIL_BITS)
+ VAR_INT(ACCUM_RED_BITS)
+ VAR_INT(ACCUM_GREEN_BITS)
+ VAR_INT(ACCUM_BLUE_BITS)
+ VAR_INT(ACCUM_ALPHA_BITS)
+
+ VAR_INT(LIST_BASE)
+ VAR_INT(LIST_INDEX)
+ VAR_ENUM(LIST_MODE)
+ VAR_INT(ATTRIB_STACK_DEPTH)
+ VAR_INT(CLIENT_ATTRIB_STACK_DEPTH)
+ VAR_INT(NAME_STACK_DEPTH)
+ VAR_ENUM(RENDER_MODE)
+ VAR_PTR(SELECTION_BUFFER_POINTER)
+ VAR_INT(SELECTION_BUFFER_SIZE)
+ VAR_PTR(FEEDBACK_BUFFER_POINTER)
+ VAR_INT(FEEDBACK_BUFFER_SIZE)
+ VAR_ENUM(FEEDBACK_BUFFER_TYPE)
+
+ /* glGetError() */
+}
+
+/***************************************************************************/
+
+/*#define TEST*/
+#ifdef TEST
+
+#include <GL/glut.h>
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(400, 300);
+ glutInitDisplayMode(GLUT_RGB);
+ glutCreateWindow(argv[0]);
+ dump_opengl_state(stdout);
+ return 0;
+}
+
+#endif
+
diff --git a/progs/util/errcheck.c b/progs/util/errcheck.c
new file mode 100644
index 00000000000..fe9c2973c33
--- /dev/null
+++ b/progs/util/errcheck.c
@@ -0,0 +1,27 @@
+/* errcheck.c */
+
+
+/*
+ * Call this function in your rendering loop to check for GL errors
+ * during development. Remove from release code.
+ *
+ * Written by Brian Paul and in the public domain.
+ */
+
+
+#include <GL/gl.h>
+#include <GL/glu.h>
+#incldue <stdio.h>
+
+
+
+GLboolean CheckError( const char *message )
+{
+ GLenum error = glGetError();
+ if (error) {
+ char *err = (char *) gluErrorString( error );
+ fprintf( stderr, "GL Error: %s at %s\n", err, message );
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
diff --git a/progs/util/glstate.c b/progs/util/glstate.c
new file mode 100644
index 00000000000..fe35c3d3beb
--- /dev/null
+++ b/progs/util/glstate.c
@@ -0,0 +1,504 @@
+/* $Id: glstate.c,v 1.1.1.1 1999/08/19 00:55:42 jtg Exp $ */
+
+/*
+ * Print GL state information (for debugging)
+ * Copyright (C) 1998 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+/*
+ * $Log: glstate.c,v $
+ * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
+ * Imported sources
+ *
+ * Revision 1.4 1999/06/19 01:36:43 brianp
+ * more features added
+ *
+ * Revision 1.3 1999/02/24 05:16:20 brianp
+ * added still more records to EnumTable
+ *
+ * Revision 1.2 1998/11/24 03:47:54 brianp
+ * added more records to EnumTable
+ *
+ * Revision 1.1 1998/11/24 03:41:16 brianp
+ * Initial revision
+ *
+ */
+
+
+
+#include <assert.h>
+#include <GL/gl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "glstate.h"
+
+
+#define FLOAT 1
+#define INT 2
+#define DOUBLE 3
+#define BOOLEAN 4
+#define ENUM 5
+#define VOID 6
+#define LAST_TOKEN ~0
+
+
+struct EnumRecord {
+ GLenum enumerator; /* GLenum constant */
+ const char *string; /* string name */
+ int getType; /* INT, FLOAT, DOUBLE, BOOLEAN, ENUM, or VOID */
+ int getCount; /* number of values returned by the glGet*v() call */
+};
+
+
+/* XXX Lots more records to add here! Help, anyone? */
+
+static struct EnumRecord EnumTable[] = {
+ { GL_ACCUM_RED_BITS, "GL_ACCUM_RED_BITS", INT, 1 },
+ { GL_ACCUM_GREEN_BITS, "GL_ACCUM_GREEN_BITS", INT, 1 },
+ { GL_ACCUM_BLUE_BITS, "GL_ACCUM_BLUE_BITS", INT, 1 },
+ { GL_ACCUM_ALPHA_BITS, "GL_ACCUM_ALPHA_BITS", INT, 1 },
+ { GL_ACCUM_CLEAR_VALUE, "GL_ACCUM_CLEAR_VALUE", FLOAT, 4 },
+ { GL_ALPHA_BIAS, "GL_ALPHA_BIAS", FLOAT, 1 },
+ { GL_ALPHA_BITS, "GL_ALPHA_BITS", INT, 1 },
+ { GL_ALPHA_SCALE, "GL_ALPHA_SCALE", FLOAT, 1 },
+ { GL_ALPHA_TEST, "GL_ALPHA_TEST", BOOLEAN, 1 },
+ { GL_ALPHA_TEST_FUNC, "GL_ALPHA_TEST_FUNC", ENUM, 1 },
+ { GL_ALWAYS, "GL_ALWAYS", ENUM, 0 },
+ { GL_ALPHA_TEST_REF, "GL_ALPHA_TEST_REF", FLOAT, 1 },
+ { GL_ATTRIB_STACK_DEPTH, "GL_ATTRIB_STACK_DEPTH", INT, 1 },
+ { GL_AUTO_NORMAL, "GL_AUTO_NORMAL", BOOLEAN, 1 },
+ { GL_AUX_BUFFERS, "GL_AUX_BUFFERS", INT, 1 },
+ { GL_BLEND, "GL_BLEND", BOOLEAN, 1 },
+ { GL_BLEND_DST, "GL_BLEND_DST", ENUM, 1 },
+ { GL_BLEND_SRC, "GL_BLEND_SRC", ENUM, 1 },
+ { GL_BLUE_BIAS, "GL_BLUE_BIAS", FLOAT, 1 },
+ { GL_BLUE_BITS, "GL_BLUE_BITS", INT, 1 },
+ { GL_BLUE_SCALE, "GL_BLUE_SCALE", FLOAT, 1 },
+
+ { GL_CLAMP_TO_EDGE, "GL_CLAMP_TO_EDGE", ENUM, 0 },
+ { GL_CLEAR, "GL_CLEAR", ENUM, 0 },
+ { GL_CLIENT_ATTRIB_STACK_DEPTH, "GL_CLIENT_ATTRIB_STACK_DEPTH", INT, 1 },
+ { GL_CLIP_PLANE0, "GL_CLIP_PLANE0", BOOLEAN, 1 },
+ { GL_CLIP_PLANE1, "GL_CLIP_PLANE1", BOOLEAN, 1 },
+ { GL_CLIP_PLANE2, "GL_CLIP_PLANE2", BOOLEAN, 1 },
+ { GL_CLIP_PLANE3, "GL_CLIP_PLANE3", BOOLEAN, 1 },
+ { GL_CLIP_PLANE4, "GL_CLIP_PLANE4", BOOLEAN, 1 },
+ { GL_CLIP_PLANE5, "GL_CLIP_PLANE5", BOOLEAN, 1 },
+ { GL_COEFF, "GL_COEEF", ENUM, 0 },
+ { GL_COLOR, "GL_COLOR", ENUM, 0 },
+ { GL_COLOR_BUFFER_BIT, "GL_COLOR_BUFFER_BIT", ENUM, 0 },
+ { GL_COLOR_CLEAR_VALUE, "GL_COLOR_CLEAR_VALUE", FLOAT, 4 },
+ { GL_COLOR_INDEX, "GL_COLOR_INDEX", ENUM, 0 },
+ { GL_COLOR_MATERIAL, "GL_COLOR_MATERIAL", BOOLEAN, 1 },
+ { GL_COLOR_MATERIAL_FACE, "GL_COLOR_MATERIAL_FACE", ENUM, 1 },
+ { GL_COLOR_MATERIAL_PARAMETER, "GL_COLOR_MATERIAL_PARAMETER", ENUM, 1 },
+ { GL_COLOR_WRITEMASK, "GL_COLOR_WRITEMASK", BOOLEAN, 4 },
+ { GL_COMPILE, "GL_COMPILE", ENUM, 0 },
+ { GL_COMPILE_AND_EXECUTE, "GL_COMPILE_AND_EXECUTE", ENUM, 0 },
+ { GL_COPY, "GL_COPY", ENUM, 0 },
+ { GL_COPY_INVERTED, "GL_COPY_INVERTED", ENUM, 0 },
+ { GL_COPY_PIXEL_TOKEN, "GL_COPY_PIXEL_TOKEN", ENUM, 0 },
+ { GL_CULL_FACE, "GL_CULL_FACE", BOOLEAN, 1 },
+ { GL_CULL_FACE_MODE, "GL_CULL_FACE_MODE", ENUM, 1 },
+ { GL_CURRENT_BIT, "GL_CURRENT_BIT", ENUM, 0 },
+ { GL_CURRENT_COLOR, "GL_CURRENT_COLOR", FLOAT, 4 },
+ { GL_CURRENT_INDEX, "GL_CURRENT_INDEX", INT, 1 },
+ { GL_CURRENT_NORMAL, "GL_CURRENT_NORMAL", FLOAT, 3 },
+ { GL_CURRENT_RASTER_COLOR, "GL_CURRENT_RASTER_COLOR", FLOAT, 4 },
+ { GL_CURRENT_RASTER_DISTANCE, "GL_CURRENT_RASTER_DISTANCE", FLOAT, 1 },
+ { GL_CURRENT_RASTER_INDEX, "GL_CURRENT_RASTER_INDEX", INT, 1 },
+ { GL_CURRENT_RASTER_POSITION, "GL_CURRENT_RASTER_POSITION", FLOAT, 4 },
+ { GL_CURRENT_RASTER_TEXTURE_COORDS, "GL_CURRENT_RASTER_TEXTURE_COORDS", FLOAT, 4 },
+ { GL_CURRENT_RASTER_POSITION_VALID, "GL_CURRENT_RASTER_POSITION_VALID", BOOLEAN, 1 },
+ { GL_CURRENT_TEXTURE_COORDS, "GL_CURRENT_TEXTURE_COORDS", FLOAT, 4 },
+ { GL_CW, "GL_CW", ENUM, 0 },
+ { GL_CCW, "GL_CCW", ENUM, 0 },
+
+ { GL_DECAL, "GL_DECAL", ENUM, 0 },
+ { GL_DECR, "GL_DECR", ENUM, 0 },
+ { GL_DEPTH, "GL_DEPTH", ENUM, 0 },
+ { GL_DEPTH_BIAS, "GL_DEPTH_BIAS", FLOAT, 1 },
+ { GL_DEPTH_BITS, "GL_DEPTH_BITS", INT, 1 },
+ { GL_DEPTH_BUFFER_BIT, "GL_DEPTH_BUFFER_BIT", ENUM, 0 },
+ { GL_DEPTH_CLEAR_VALUE, "GL_DEPTH_CLEAR_VALUE", FLOAT, 1 },
+ { GL_DEPTH_COMPONENT, "GL_DEPTH_COMPONENT", ENUM, 0 },
+ { GL_DEPTH_FUNC, "GL_DEPTH_FUNC", ENUM, 1 },
+ { GL_DEPTH_RANGE, "GL_DEPTH_RANGE", FLOAT, 2 },
+ { GL_DEPTH_SCALE, "GL_DEPTH_SCALE", FLOAT, 1 },
+ { GL_DEPTH_TEST, "GL_DEPTH_TEST", ENUM, 1 },
+ { GL_DEPTH_WRITEMASK, "GL_DEPTH_WRITEMASK", BOOLEAN, 1 },
+ { GL_DIFFUSE, "GL_DIFFUSE", ENUM, 0 }, /*XXX*/
+ { GL_DITHER, "GL_DITHER", BOOLEAN, 1 },
+ { GL_DOMAIN, "GL_DOMAIN", ENUM, 0 },
+ { GL_DONT_CARE, "GL_DONT_CARE", ENUM, 0 },
+ { GL_DOUBLE, "GL_DOUBLE", ENUM, 0 },
+ { GL_DOUBLEBUFFER, "GL_DOUBLEBUFFER", BOOLEAN, 1},
+ { GL_DRAW_BUFFER, "GL_DRAW_BUFFER", ENUM, 1 },
+ { GL_DRAW_PIXEL_TOKEN, "GL_DRAW_PIXEL_TOKEN", ENUM, 0 },
+ { GL_DST_ALPHA, "GL_DST_ALPHA", ENUM, 0 },
+ { GL_DST_COLOR, "GL_DST_COLOR", ENUM, 0 },
+
+ { GL_EDGE_FLAG, "GL_EDGE_FLAG", BOOLEAN, 1 },
+ /* XXX GL_EDGE_FLAG_ARRAY_* */
+ { GL_EMISSION, "GL_EMISSION", ENUM, 0 }, /* XXX */
+ { GL_ENABLE_BIT, "GL_ENABLE_BIT", ENUM, 0 },
+ { GL_EQUAL, "GL_EQUAL", ENUM, 0 },
+ { GL_EQUIV, "GL_EQUIV", ENUM, 0 },
+ { GL_EVAL_BIT, "GL_EVAL_BIT", ENUM, 0 },
+ { GL_EXP, "GL_EXP", ENUM, 0 },
+ { GL_EXP2, "GL_EXP2", ENUM, 0 },
+ { GL_EXTENSIONS, "GL_EXTENSIONS", ENUM, 0 },
+ { GL_EYE_LINEAR, "GL_EYE_LINEAR", ENUM, 0 },
+ { GL_EYE_PLANE, "GL_EYE_PLANE", ENUM, 0 },
+
+ { GL_FALSE, "GL_FALSE", ENUM, 0 },
+ { GL_FASTEST, "GL_FASTEST", ENUM, 0 },
+ { GL_FEEDBACK, "GL_FEEDBACK", ENUM, 0 },
+ { GL_FEEDBACK_BUFFER_POINTER, "GL_FEEDBACK_BUFFER_POINTER", VOID, 0 },
+ { GL_FEEDBACK_BUFFER_SIZE, "GL_FEEDBACK_BUFFER_SIZE", INT, 1 },
+ { GL_FEEDBACK_BUFFER_TYPE, "GL_FEEDBACK_BUFFER_TYPE", INT, 1 },
+ { GL_FILL, "GL_FILL", ENUM, 0 },
+ { GL_FLAT, "GL_FLAT", ENUM, 0 },
+ { GL_FLOAT, "GL_FLOAT", ENUM, 0 },
+ { GL_FOG, "GL_FOG", BOOLEAN, 1 },
+ { GL_FOG_BIT, "GL_FOG_BIT", ENUM, 0 },
+ { GL_FOG_COLOR, "GL_FOG_COLOR", FLOAT, 4 },
+ { GL_FOG_DENSITY, "GL_FOG_DENSITY", FLOAT, 1 },
+ { GL_FOG_END, "GL_FOG_END", FLOAT, 1 },
+ { GL_FOG_HINT, "GL_FOG_HINT", ENUM, 1 },
+ { GL_FOG_INDEX, "GL_FOG_INDEX", INT, 1 },
+ { GL_FOG_MODE, "GL_FOG_MODE", ENUM, 1 },
+ { GL_FOG_START, "GL_FOG_START", FLOAT, 1 },
+ { GL_FRONT, "GL_FRONT", ENUM, 0 },
+ { GL_FRONT_AND_BACK, "GL_FRONT_AND_BACK", ENUM, 0 },
+ { GL_FRONT_FACE, "GL_FRONT_FACE", ENUM, 1 },
+ { GL_FRONT_LEFT, "GL_FRONT_LEFT", ENUM, 0 },
+ { GL_FRONT_RIGHT, "GL_FRONT_RIGHT", ENUM, 0 },
+
+ { GL_GEQUAL, "GL_GEQUAL", ENUM, 0 },
+ { GL_GREATER, "GL_GREATER", ENUM, 0 },
+ { GL_GREEN, "GL_GREEN", ENUM, 0 },
+ { GL_GREEN_BIAS, "GL_GREEN_BIAS", FLOAT, 1 },
+ { GL_GREEN_BITS, "GL_GREEN_BITS", INT, 1 },
+ { GL_GREEN_SCALE, "GL_GREEN_SCALE", FLOAT, 1 },
+
+
+
+ { GL_LESS, "GL_LESS", ENUM, 0 },
+ { GL_LEQUAL, "GL_LEQUAL", ENUM, 0 },
+ { GL_LIGHTING, "GL_LIGHTING", BOOLEAN, 1 },
+ { GL_LINE_SMOOTH, "GL_LINE_SMOOTH", BOOLEAN, 1 },
+ { GL_LINE_STIPPLE, "GL_LINE_STIPPLE", BOOLEAN, 1 },
+ { GL_LINE_STIPPLE_PATTERN, "GL_LINE_STIPPLE_PATTERN", INT, 1 },
+ { GL_LINE_STIPPLE_REPEAT, "GL_LINE_STIPPLE_REPEAT", INT, 1 },
+ { GL_LINE_WIDTH, "GL_LINE_WIDTH", FLOAT, 1 },
+
+ { GL_MODELVIEW_MATRIX, "GL_MODELVIEW_MATRIX", DOUBLE, 16 },
+
+ { GL_NEVER, "GL_NEVER", ENUM, 0 },
+ { GL_NOTEQUAL, "GL_NOTEQUAL", ENUM, 0 },
+
+ { GL_PROJECTION_MATRIX, "GL_PROJECTION_MATRIX", FLOAT, 16 },
+
+ { GL_PACK_SWAP_BYTES, "GL_PACK_SWAP_BYTES", INT, 1 },
+ { GL_PACK_LSB_FIRST, "GL_PACK_LSB_FIRST", INT, 1 },
+ { GL_PACK_ROW_LENGTH, "GL_PACK_ROW_LENGTH", INT, 1 },
+ { GL_PACK_SKIP_PIXELS, "GL_PACK_SKIP_PIXELS", INT, 1 },
+ { GL_PACK_SKIP_ROWS, "GL_PACK_SKIP_ROWS", INT, 1 },
+ { GL_PACK_ALIGNMENT, "GL_PACK_ALIGNMENT", INT, 1 },
+
+ { GL_TRUE, "GL_TRUE", ENUM, 0 },
+
+ { GL_UNPACK_SWAP_BYTES, "GL_UNPACK_SWAP_BYTES", INT, 1 },
+ { GL_UNPACK_LSB_FIRST, "GL_UNPACK_LSB_FIRST", INT, 1 },
+ { GL_UNPACK_ROW_LENGTH, "GL_UNPACK_ROW_LENGTH", INT, 1 },
+ { GL_UNPACK_SKIP_PIXELS, "GL_UNPACK_SKIP_PIXELS", INT, 1 },
+ { GL_UNPACK_SKIP_ROWS, "GL_UNPACK_SKIP_ROWS", INT, 1 },
+ { GL_UNPACK_ALIGNMENT, "GL_UNPACK_ALIGNMENT", INT, 1 },
+
+ { GL_VIEWPORT, "GL_VIEWPORT", INT, 4 },
+
+
+ /*
+ * Extensions
+ */
+
+#if defined(GL_EXT_blend_minmax)
+ { GL_BLEND_EQUATION_EXT, "GL_BLEND_EQUATION_EXT", ENUM, 1 },
+#endif
+#if defined(GL_EXT_blend_color)
+ { GL_BLEND_COLOR_EXT, "GL_BLEND_COLOR_EXT", FLOAT, 4 },
+#endif
+#if defined(GL_EXT_point_parameters)
+ { GL_DISTANCE_ATTENUATION_EXT, "GL_DISTANCE_ATTENUATION_EXT", FLOAT, 1 },
+#endif
+#if defined(GL_INGR_blend_func_separate)
+ { GL_BLEND_SRC_RGB_INGR, "GL_BLEND_SRC_RGB_INGR", ENUM, 1 },
+ { GL_BLEND_DST_RGB_INGR, "GL_BLEND_DST_RGB_INGR", ENUM, 1 },
+ { GL_BLEND_SRC_ALPHA_INGR, "GL_BLEND_SRC_ALPHA_INGR", ENUM, 1 },
+ { GL_BLEND_DST_ALPHA_INGR, "GL_BLEND_DST_ALPHA_INGR", ENUM, 1 },
+#endif
+
+
+ { LAST_TOKEN, "", 0, 0 }
+};
+
+
+static const struct EnumRecord *FindRecord( GLenum var )
+{
+ int i;
+ for (i = 0; EnumTable[i].enumerator != LAST_TOKEN; i++) {
+ if (EnumTable[i].enumerator == var) {
+ return &EnumTable[i];
+ }
+ }
+ return NULL;
+}
+
+
+
+/*
+ * Return the string label for the given enum.
+ */
+const char *GetEnumString( GLenum var )
+{
+ const struct EnumRecord *rec = FindRecord(var);
+ if (rec)
+ return rec->string;
+ else
+ return NULL;
+}
+
+
+
+/*
+ * Print current value of the given state variable.
+ */
+void PrintState( int indent, GLenum var )
+{
+ const struct EnumRecord *rec = FindRecord(var);
+
+ while (indent-- > 0)
+ putchar(' ');
+
+ if (rec) {
+ if (rec->getCount <= 0) {
+ assert(rec->getType == ENUM);
+ printf("%s is not a state variable\n", rec->string);
+ }
+ else {
+ switch (rec->getType) {
+ case INT:
+ {
+ GLint values[100];
+ int i;
+ glGetIntegerv(rec->enumerator, values);
+ printf("%s = ", rec->string);
+ for (i = 0; i < rec->getCount; i++)
+ printf("%d ", values[i]);
+ printf("\n");
+ }
+ break;
+ case FLOAT:
+ {
+ GLfloat values[100];
+ int i;
+ glGetFloatv(rec->enumerator, values);
+ printf("%s = ", rec->string);
+ for (i = 0; i < rec->getCount; i++)
+ printf("%f ", values[i]);
+ printf("\n");
+ }
+ break;
+ case DOUBLE:
+ {
+ GLdouble values[100];
+ int i;
+ glGetDoublev(rec->enumerator, values);
+ printf("%s = ", rec->string);
+ for (i = 0; i < rec->getCount; i++)
+ printf("%f ", (float) values[i]);
+ printf("\n");
+ }
+ break;
+ case BOOLEAN:
+ {
+ GLboolean values[100];
+ int i;
+ glGetBooleanv(rec->enumerator, values);
+ printf("%s = ", rec->string);
+ for (i = 0; i < rec->getCount; i++)
+ printf("%s ", values[i] ? "GL_TRUE" : "GL_FALSE");
+ printf("\n");
+ }
+ break;
+ case ENUM:
+ {
+ GLint values[100];
+ int i;
+ glGetIntegerv(rec->enumerator, values);
+ printf("%s = ", rec->string);
+ for (i = 0; i < rec->getCount; i++) {
+ const char *str = GetEnumString((GLenum) values[i]);
+ if (str)
+ printf("%s ", str);
+ else
+ printf("??? ");
+ }
+ printf("\n");
+ }
+ break;
+ case VOID:
+ {
+ GLvoid *values[100];
+ int i;
+ glGetPointerv(rec->enumerator, values);
+ printf("%s = ", rec->string);
+ for (i = 0; i < rec->getCount; i++) {
+ printf("%p ", values[i]);
+ }
+ printf("\n");
+ }
+ break;
+ default:
+ printf("fatal error in PrintState()\n");
+ abort();
+ }
+ }
+ }
+ else {
+ printf("Unknown GLenum passed to PrintState()\n");
+ }
+}
+
+
+
+/*
+ * Print all glPixelStore-related state.
+ * NOTE: Should write similar functions for lighting, texturing, etc.
+ */
+void PrintPixelStoreState( void )
+{
+ const GLenum enums[] = {
+ GL_PACK_SWAP_BYTES,
+ GL_PACK_LSB_FIRST,
+ GL_PACK_ROW_LENGTH,
+ GL_PACK_SKIP_PIXELS,
+ GL_PACK_SKIP_ROWS,
+ GL_PACK_ALIGNMENT,
+ GL_UNPACK_SWAP_BYTES,
+ GL_UNPACK_LSB_FIRST,
+ GL_UNPACK_ROW_LENGTH,
+ GL_UNPACK_SKIP_PIXELS,
+ GL_UNPACK_SKIP_ROWS,
+ GL_UNPACK_ALIGNMENT,
+ 0
+ };
+ int i;
+ printf("Pixel pack/unpack state:\n");
+ for (i = 0; enums[i]; i++) {
+ PrintState(3, enums[i]);
+ }
+}
+
+
+
+
+/*
+ * Print all state for the given attribute group.
+ */
+void PrintAttribState( GLbitfield attrib )
+{
+ static const GLenum depth_buffer_enums[] = {
+ GL_DEPTH_FUNC,
+ GL_DEPTH_CLEAR_VALUE,
+ GL_DEPTH_TEST,
+ GL_DEPTH_WRITEMASK,
+ 0
+ };
+ static const GLenum fog_enums[] = {
+ GL_FOG,
+ GL_FOG_COLOR,
+ GL_FOG_DENSITY,
+ GL_FOG_START,
+ GL_FOG_END,
+ GL_FOG_INDEX,
+ GL_FOG_MODE,
+ 0
+ };
+ static const GLenum line_enums[] = {
+ GL_LINE_SMOOTH,
+ GL_LINE_STIPPLE,
+ GL_LINE_STIPPLE_PATTERN,
+ GL_LINE_STIPPLE_REPEAT,
+ GL_LINE_WIDTH,
+ 0
+ };
+
+ const GLenum *enumList = NULL;
+
+ switch (attrib) {
+ case GL_DEPTH_BUFFER_BIT:
+ enumList = depth_buffer_enums;
+ printf("GL_DEPTH_BUFFER_BIT state:\n");
+ break;
+ case GL_FOG_BIT:
+ enumList = fog_enums;
+ printf("GL_FOG_BIT state:\n");
+ break;
+ case GL_LINE_BIT:
+ enumList = line_enums;
+ printf("GL_LINE_BIT state:\n");
+ break;
+ default:
+ printf("Bad value in PrintAttribState()\n");
+ }
+
+ if (enumList) {
+ int i;
+ for (i = 0; enumList[i]; i++)
+ PrintState(3, enumList[i]);
+ }
+}
+
+
+/*#define TEST*/
+#ifdef TEST
+
+#include <GL/glut.h>
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(400, 300);
+ glutInitDisplayMode(GLUT_RGB);
+ glutCreateWindow(argv[0]);
+ PrintAttribState(GL_DEPTH_BUFFER_BIT);
+ PrintAttribState(GL_FOG_BIT);
+ PrintAttribState(GL_LINE_BIT);
+ PrintState(0, GL_ALPHA_BITS);
+ PrintState(0, GL_VIEWPORT);
+ PrintState(0, GL_ALPHA_TEST_FUNC);
+ PrintState(0, GL_MODELVIEW_MATRIX);
+ PrintState(0, GL_ALWAYS);
+ PrintPixelStoreState();
+ return 0;
+}
+
+#endif
diff --git a/progs/util/glstate.h b/progs/util/glstate.h
new file mode 100644
index 00000000000..75f0238c591
--- /dev/null
+++ b/progs/util/glstate.h
@@ -0,0 +1,53 @@
+/* $Id: glstate.h,v 1.1.1.1 1999/08/19 00:55:42 jtg Exp $ */
+
+/*
+ * Print GL state information (for debugging)
+ * Copyright (C) 1998 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+/*
+ * $Log: glstate.h,v $
+ * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
+ * Imported sources
+ *
+ * Revision 1.2 1999/06/19 01:36:43 brianp
+ * more features added
+ *
+ * Revision 1.1 1998/11/24 03:41:16 brianp
+ * Initial revision
+ *
+ */
+
+
+#ifndef GLSTATE_H
+#define GLSTATE_H
+
+
+#include <GL/gl.h>
+
+
+extern const char *GetNameString( GLenum var );
+
+extern void PrintState( int indent, GLenum var );
+
+extern void PrintAttribState( GLbitfield attrib );
+
+extern void PrintPixelStoreState( void );
+
+
+#endif
diff --git a/progs/util/glutskel.c b/progs/util/glutskel.c
new file mode 100644
index 00000000000..b203a507a4c
--- /dev/null
+++ b/progs/util/glutskel.c
@@ -0,0 +1,157 @@
+/* $Id: glutskel.c,v 1.2 2004/04/22 00:47:28 brianp Exp $ */
+
+/*
+ * A skeleton/template GLUT program
+ *
+ * Written by Brian Paul and in the public domain.
+ */
+
+
+/*
+ * $Log: glutskel.c,v $
+ * Revision 1.2 2004/04/22 00:47:28 brianp
+ * minor clean-ups
+ *
+ * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
+ * Imported sources
+ *
+ * Revision 1.2 1998/11/07 14:20:14 brianp
+ * added simple rotation, animation of cube
+ *
+ * Revision 1.1 1998/11/07 14:14:37 brianp
+ * Initial revision
+ *
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
+static GLboolean Anim = GL_FALSE;
+
+
+static void
+Idle(void)
+{
+ Xrot += 3.0;
+ Yrot += 4.0;
+ Zrot += 2.0;
+ glutPostRedisplay();
+}
+
+
+static void
+Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glRotatef(Zrot, 0, 0, 1);
+
+ glutSolidCube(2.0);
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -15.0);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'z':
+ Zrot -= step;
+ break;
+ case 'Z':
+ Zrot += step;
+ break;
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+SpecialKey(int key, int x, int y)
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot += step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+ /* setup lighting, etc */
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(400, 400);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutSpecialFunc(SpecialKey);
+ glutDisplayFunc(Draw);
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/util/idproj.c b/progs/util/idproj.c
new file mode 100644
index 00000000000..d5ee3409f38
--- /dev/null
+++ b/progs/util/idproj.c
@@ -0,0 +1,26 @@
+/* idproj.c */
+
+
+/*
+ * Setup an identity projection such that glVertex(x,y) maps to
+ * window coordinate (x,y).
+ *
+ * Written by Brian Paul and in the public domain.
+ */
+
+
+
+
+
+void IdentityProjection( GLint x, GLint y, GLsizei width, GLsizei height )
+{
+ glViewport( x, y, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho( (GLdouble) x, (GLdouble) y,
+ (GLdouble) width, (GLdouble) height,
+ -1.0, 1.0 );
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+}
+
diff --git a/progs/util/imagesgi.h b/progs/util/imagesgi.h
new file mode 100644
index 00000000000..e5ecece49dc
--- /dev/null
+++ b/progs/util/imagesgi.h
@@ -0,0 +1,55 @@
+/******************************************************************************
+** Filename : imageSgi.h
+** UNCLASSIFIED
+**
+** Description : Utility to read SGI image format files. This code was
+** originally a SGI image loading utility provided with the
+** Mesa 3D library @ http://www.mesa3d.org by Brain Paul.
+** This has been extended to read all SGI image formats
+** (e.g. INT, INTA, RGB, RGBA).
+**
+** Revision History:
+** Date Name Description
+** 06/08/99 BRC Initial Release
+**
+******************************************************************************/
+
+#ifndef __IMAGESGI_H
+#define __IMAGESGI_H
+
+#define IMAGE_SGI_TYPE_VERBATIM 0
+#define IMAGE_SGI_TYPE_RLE 1
+
+struct sImageSgiHeader // 512 bytes
+{
+ short magic; // IRIS image file magic number (474)
+ char type; // Storage format (e.g. RLE or VERBATIM)
+ char numBytesPerPixelChannel; // Number of bytes per pixel channel
+ unsigned short dim; // Number of dimensions (1 to 3)
+ unsigned short xsize; // Width (in pixels)
+ unsigned short ysize; // Height (in pixels)
+ unsigned short zsize; // Number of channels (1 to 4)
+ int minimumPixelValue; // Minimum pixel value (0 to 255)
+ int maximumPixelValue; // Maximum pixel value (0 to 255)
+ char padding1[4]; // (ignored)
+ char imageName[80]; // Image name
+ int colormap; // colormap ID (0=normal, 0=dithered,
+ // 2=screen, 3=colormap)
+ char padding2[404]; // (ignored)
+};
+
+struct sImageSgi
+{
+ struct sImageSgiHeader header;
+ unsigned char *data;
+};
+
+#ifndef __IMAGESGI_CPP
+
+// RGB image load utility
+extern struct sImageSgi *ImageSgiOpen(char const * const fileName);
+extern void ImageSgiClose(struct sImageSgi *image);
+
+#endif
+
+#endif /* __IMAGESGI_H */
diff --git a/progs/util/matrix.c b/progs/util/matrix.c
new file mode 100644
index 00000000000..8be2c3111f4
--- /dev/null
+++ b/progs/util/matrix.c
@@ -0,0 +1,181 @@
+/*
+ * matrix.c
+ *
+ * Some useful matrix functions.
+ *
+ * Brian Paul
+ * 10 Feb 2004
+ */
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+/**
+ * Pretty-print the given matrix.
+ */
+void
+PrintMatrix(const float p[16])
+{
+ printf("[ %6.3f %6.3f %6.3f %6.3f ]\n", p[0], p[4], p[8], p[12]);
+ printf("[ %6.3f %6.3f %6.3f %6.3f ]\n", p[1], p[5], p[9], p[13]);
+ printf("[ %6.3f %6.3f %6.3f %6.3f ]\n", p[2], p[6], p[10], p[14]);
+ printf("[ %6.3f %6.3f %6.3f %6.3f ]\n", p[3], p[7], p[11], p[15]);
+}
+
+
+/**
+ * Build a glFrustum matrix.
+ */
+void
+Frustum(float left, float right, float bottom, float top, float nearZ, float farZ, float *m)
+{
+ float x = (2.0F*nearZ) / (right-left);
+ float y = (2.0F*nearZ) / (top-bottom);
+ float a = (right+left) / (right-left);
+ float b = (top+bottom) / (top-bottom);
+ float c = -(farZ+nearZ) / ( farZ-nearZ);
+ float d = -(2.0F*farZ*nearZ) / (farZ-nearZ);
+
+#define M(row,col) m[col*4+row]
+ M(0,0) = x; M(0,1) = 0.0F; M(0,2) = a; M(0,3) = 0.0F;
+ M(1,0) = 0.0F; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0F;
+ M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = c; M(2,3) = d;
+ M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = -1.0F; M(3,3) = 0.0F;
+#undef M
+}
+
+
+/**
+ * Build a glOrtho marix.
+ */
+void
+Ortho(float left, float right, float bottom, float top, float nearZ, float farZ, float *m)
+{
+#define M(row,col) m[col*4+row]
+ M(0,0) = 2.0F / (right-left);
+ M(0,1) = 0.0F;
+ M(0,2) = 0.0F;
+ M(0,3) = -(right+left) / (right-left);
+
+ M(1,0) = 0.0F;
+ M(1,1) = 2.0F / (top-bottom);
+ M(1,2) = 0.0F;
+ M(1,3) = -(top+bottom) / (top-bottom);
+
+ M(2,0) = 0.0F;
+ M(2,1) = 0.0F;
+ M(2,2) = -2.0F / (farZ-nearZ);
+ M(2,3) = -(farZ+nearZ) / (farZ-nearZ);
+
+ M(3,0) = 0.0F;
+ M(3,1) = 0.0F;
+ M(3,2) = 0.0F;
+ M(3,3) = 1.0F;
+#undef M
+}
+
+
+/**
+ * Decompose a projection matrix to determine original glFrustum or
+ * glOrtho parameters.
+ */
+void
+DecomposeProjection( const float *m,
+ int *isPerspective,
+ float *leftOut, float *rightOut,
+ float *botOut, float *topOut,
+ float *nearOut, float *farOut)
+{
+ if (m[15] == 0.0) {
+ /* perspective */
+ float p[16];
+ const float x = m[0]; /* 2N / (R-L) */
+ const float y = m[5]; /* 2N / (T-B) */
+ const float a = m[8]; /* (R+L) / (R-L) */
+ const float b = m[9]; /* (T+B) / (T-B) */
+ const float c = m[10]; /* -(F+N) / (F-N) */
+ const float d = m[14]; /* -2FN / (F-N) */
+
+ /* These equations found with simple algebra, knowing the arithmetic
+ * use to set up a typical perspective projection matrix in OpenGL.
+ */
+ const float nearZ = -d / (1.0 - c);
+ const float farZ = (c - 1.0) * nearZ / (c + 1.0);
+ const float left = nearZ * (a - 1.0) / x;
+ const float right = 2.0 * nearZ / x + left;
+ const float bottom = nearZ * (b - 1.0) / y;
+ const float top = 2.0 * nearZ / y + bottom;
+
+ *isPerspective = 1;
+ *leftOut = left;
+ *rightOut = right;
+ *botOut = bottom;
+ *topOut = top;
+ *nearOut = nearZ;
+ *farOut = farZ;
+ }
+ else {
+ /* orthographic */
+ const float x = m[0]; /* 2 / (R-L) */
+ const float y = m[5]; /* 2 / (T-B) */
+ const float z = m[10]; /* -2 / (F-N) */
+ const float a = m[12]; /* -(R+L) / (R-L) */
+ const float b = m[13]; /* -(T+B) / (T-B) */
+ const float c = m[14]; /* -(F+N) / (F-N) */
+ /* again, simple algebra */
+ const float right = -(a - 1.0) / x;
+ const float left = right - 2.0 / x;
+ const float top = -(b - 1.0) / y;
+ const float bottom = top - 2.0 / y;
+ const float farZ = (c - 1.0) / z;
+ const float nearZ = farZ + 2.0 / z;
+
+ *isPerspective = 0;
+ *leftOut = left;
+ *rightOut = right;
+ *botOut = bottom;
+ *topOut = top;
+ *nearOut = nearZ;
+ *farOut = farZ;
+ }
+}
+
+
+#if 0
+/* test harness */
+int
+main(int argc, char *argv[])
+{
+ float m[16], p[16];
+ float l, r, b, t, n, f;
+ int persp;
+ int i;
+
+#if 0
+ l = -.9;
+ r = 1.2;
+ b = -0.5;
+ t = 1.4;
+ n = 30;
+ f = 84;
+ printf(" Frustum(%f, %f, %f, %f, %f, %f\n",l+1, r+1.2, b+.5, t+.3, n, f);
+ Frustum(l+1, r+1.2, b+.5, t+.3, n, f, p);
+ DecomposeProjection(p, &persp, &l, &r, &b, &t, &n, &f);
+ printf("glFrustum(%f, %f, %f, %f, %f, %f)\n",
+ l, r, b, t, n, f);
+ PrintMatrix(p);
+#else
+ printf("Ortho(-1, 1, -1, 1, 10, 84)\n");
+ Ortho(-1, 1, -1, 1, 10, 84, m);
+ PrintMatrix(m);
+ DecomposeProjection(m, &persp, &l, &r, &b, &t, &n, &f);
+ printf("Ortho(%f, %f, %f, %f, %f, %f) %d\n", l, r, b, t, n, f, persp);
+#endif
+
+ return 0;
+}
+#endif
diff --git a/progs/util/mwmborder.c b/progs/util/mwmborder.c
new file mode 100644
index 00000000000..b61ffb50bc2
--- /dev/null
+++ b/progs/util/mwmborder.c
@@ -0,0 +1,91 @@
+/* mwmborder.c */
+
+
+/*
+ * This function shows how to remove the border, title bar, resize button,
+ * etc from a Motif window frame from inside an Xlib-based application.
+ *
+ * Brian Paul 19 Sep 1995 [email protected]
+ *
+ * This code is in the public domain.
+ */
+
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+
+#define HAVE_MOTIF
+#ifdef HAVE_MOTIF
+
+#include <X11/Xm/MwmUtil.h>
+
+#else
+
+/* bit definitions for MwmHints.flags */
+#define MWM_HINTS_FUNCTIONS (1L << 0)
+#define MWM_HINTS_DECORATIONS (1L << 1)
+#define MWM_HINTS_INPUT_MODE (1L << 2)
+#define MWM_HINTS_STATUS (1L << 3)
+
+/* bit definitions for MwmHints.decorations */
+#define MWM_DECOR_ALL (1L << 0)
+#define MWM_DECOR_BORDER (1L << 1)
+#define MWM_DECOR_RESIZEH (1L << 2)
+#define MWM_DECOR_TITLE (1L << 3)
+#define MWM_DECOR_MENU (1L << 4)
+#define MWM_DECOR_MINIMIZE (1L << 5)
+#define MWM_DECOR_MAXIMIZE (1L << 6)
+
+typedef struct
+{
+ unsigned long flags;
+ unsigned long functions;
+ unsigned long decorations;
+ long inputMode;
+ unsigned long status;
+} PropMotifWmHints;
+
+#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
+
+#endif
+
+
+
+/*
+ * Specify which Motif window manager border decorations to put on a
+ * top-level window. For example, you can specify that a window is not
+ * resizabe, or omit the titlebar, or completely remove all decorations.
+ * Input: dpy - the X display
+ * w - the X window
+ * flags - bitwise-OR of the MWM_DECOR_xxx symbols in X11/Xm/MwmUtil.h
+ * indicating what decoration elements to enable. Zero would
+ * be no decoration.
+ */
+void set_mwm_border( Display *dpy, Window w, unsigned long flags )
+{
+ PropMotifWmHints motif_hints;
+ Atom prop, proptype;
+
+ /* setup the property */
+ motif_hints.flags = MWM_HINTS_DECORATIONS;
+ motif_hints.decorations = flags;
+
+ /* get the atom for the property */
+ prop = XInternAtom( dpy, "_MOTIF_WM_HINTS", True );
+ if (!prop) {
+ /* something went wrong! */
+ return;
+ }
+
+ /* not sure this is correct, seems to work, XA_WM_HINTS didn't work */
+ proptype = prop;
+
+ XChangeProperty( dpy, w, /* display, window */
+ prop, proptype, /* property, type */
+ 32, /* format: 32-bit datums */
+ PropModeReplace, /* mode */
+ (unsigned char *) &motif_hints, /* data */
+ PROP_MOTIF_WM_HINTS_ELEMENTS /* nelements */
+ );
+}
+
diff --git a/progs/util/readtex.c b/progs/util/readtex.c
new file mode 100644
index 00000000000..280d6c811d9
--- /dev/null
+++ b/progs/util/readtex.c
@@ -0,0 +1,451 @@
+/* readtex.c */
+
+/*
+ * Read an SGI .rgb image file and generate a mipmap texture set.
+ * Much of this code was borrowed from SGI's tk OpenGL toolkit.
+ */
+
+
+
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "readtex.h"
+
+
+#ifndef SEEK_SET
+# define SEEK_SET 0
+#endif
+
+
+/*
+** RGB Image Structure
+*/
+
+typedef struct _TK_RGBImageRec {
+ GLint sizeX, sizeY;
+ GLint components;
+ unsigned char *data;
+} TK_RGBImageRec;
+
+
+
+/******************************************************************************/
+
+typedef struct _rawImageRec {
+ unsigned short imagic;
+ unsigned short type;
+ unsigned short dim;
+ unsigned short sizeX, sizeY, sizeZ;
+ unsigned long min, max;
+ unsigned long wasteBytes;
+ char name[80];
+ unsigned long colorMap;
+ FILE *file;
+ unsigned char *tmp, *tmpR, *tmpG, *tmpB, *tmpA;
+ unsigned long rleEnd;
+ GLuint *rowStart;
+ GLint *rowSize;
+} rawImageRec;
+
+/******************************************************************************/
+
+static void ConvertShort(unsigned short *array, long length)
+{
+ unsigned long b1, b2;
+ unsigned char *ptr;
+
+ ptr = (unsigned char *)array;
+ while (length--) {
+ b1 = *ptr++;
+ b2 = *ptr++;
+ *array++ = (unsigned short) ((b1 << 8) | (b2));
+ }
+}
+
+static void ConvertLong(GLuint *array, long length)
+{
+ unsigned long b1, b2, b3, b4;
+ unsigned char *ptr;
+
+ ptr = (unsigned char *)array;
+ while (length--) {
+ b1 = *ptr++;
+ b2 = *ptr++;
+ b3 = *ptr++;
+ b4 = *ptr++;
+ *array++ = (b1 << 24) | (b2 << 16) | (b3 << 8) | (b4);
+ }
+}
+
+static rawImageRec *RawImageOpen(const char *fileName)
+{
+ union {
+ int testWord;
+ char testByte[4];
+ } endianTest;
+ rawImageRec *raw;
+ GLenum swapFlag;
+ int x;
+
+ endianTest.testWord = 1;
+ if (endianTest.testByte[0] == 1) {
+ swapFlag = GL_TRUE;
+ } else {
+ swapFlag = GL_FALSE;
+ }
+
+ raw = (rawImageRec *)malloc(sizeof(rawImageRec));
+ if (raw == NULL) {
+ fprintf(stderr, "Out of memory!\n");
+ return NULL;
+ }
+ if ((raw->file = fopen(fileName, "rb")) == NULL) {
+ perror(fileName);
+ return NULL;
+ }
+
+ fread(raw, 1, 12, raw->file);
+
+ if (swapFlag) {
+ ConvertShort(&raw->imagic, 6);
+ }
+
+ raw->tmp = (unsigned char *)malloc(raw->sizeX*256);
+ raw->tmpR = (unsigned char *)malloc(raw->sizeX*256);
+ raw->tmpG = (unsigned char *)malloc(raw->sizeX*256);
+ raw->tmpB = (unsigned char *)malloc(raw->sizeX*256);
+ if (raw->sizeZ==4) {
+ raw->tmpA = (unsigned char *)malloc(raw->sizeX*256);
+ }
+ if (raw->tmp == NULL || raw->tmpR == NULL || raw->tmpG == NULL ||
+ raw->tmpB == NULL) {
+ fprintf(stderr, "Out of memory!\n");
+ return NULL;
+ }
+
+ if ((raw->type & 0xFF00) == 0x0100) {
+ x = raw->sizeY * raw->sizeZ * sizeof(GLuint);
+ raw->rowStart = (GLuint *)malloc(x);
+ raw->rowSize = (GLint *)malloc(x);
+ if (raw->rowStart == NULL || raw->rowSize == NULL) {
+ fprintf(stderr, "Out of memory!\n");
+ return NULL;
+ }
+ raw->rleEnd = 512 + (2 * x);
+ fseek(raw->file, 512, SEEK_SET);
+ fread(raw->rowStart, 1, x, raw->file);
+ fread(raw->rowSize, 1, x, raw->file);
+ if (swapFlag) {
+ ConvertLong(raw->rowStart, (long) (x/sizeof(GLuint)));
+ ConvertLong((GLuint *)raw->rowSize, (long) (x/sizeof(GLint)));
+ }
+ }
+ return raw;
+}
+
+static void RawImageClose(rawImageRec *raw)
+{
+
+ fclose(raw->file);
+ free(raw->tmp);
+ free(raw->tmpR);
+ free(raw->tmpG);
+ free(raw->tmpB);
+ if (raw->sizeZ>3) {
+ free(raw->tmpA);
+ }
+ free(raw);
+}
+
+static void RawImageGetRow(rawImageRec *raw, unsigned char *buf, int y, int z)
+{
+ unsigned char *iPtr, *oPtr, pixel;
+ int count, done = 0;
+
+ if ((raw->type & 0xFF00) == 0x0100) {
+ fseek(raw->file, (long) raw->rowStart[y+z*raw->sizeY], SEEK_SET);
+ fread(raw->tmp, 1, (unsigned int)raw->rowSize[y+z*raw->sizeY],
+ raw->file);
+
+ iPtr = raw->tmp;
+ oPtr = buf;
+ while (!done) {
+ pixel = *iPtr++;
+ count = (int)(pixel & 0x7F);
+ if (!count) {
+ done = 1;
+ return;
+ }
+ if (pixel & 0x80) {
+ while (count--) {
+ *oPtr++ = *iPtr++;
+ }
+ } else {
+ pixel = *iPtr++;
+ while (count--) {
+ *oPtr++ = pixel;
+ }
+ }
+ }
+ } else {
+ fseek(raw->file, 512+(y*raw->sizeX)+(z*raw->sizeX*raw->sizeY),
+ SEEK_SET);
+ fread(buf, 1, raw->sizeX, raw->file);
+ }
+}
+
+
+static void RawImageGetData(rawImageRec *raw, TK_RGBImageRec *final)
+{
+ unsigned char *ptr;
+ int i, j;
+
+ final->data = (unsigned char *)malloc((raw->sizeX+1)*(raw->sizeY+1)*4);
+ if (final->data == NULL) {
+ fprintf(stderr, "Out of memory!\n");
+ }
+
+ ptr = final->data;
+ for (i = 0; i < (int)(raw->sizeY); i++) {
+ RawImageGetRow(raw, raw->tmpR, i, 0);
+ RawImageGetRow(raw, raw->tmpG, i, 1);
+ RawImageGetRow(raw, raw->tmpB, i, 2);
+ if (raw->sizeZ>3) {
+ RawImageGetRow(raw, raw->tmpA, i, 3);
+ }
+ for (j = 0; j < (int)(raw->sizeX); j++) {
+ *ptr++ = *(raw->tmpR + j);
+ *ptr++ = *(raw->tmpG + j);
+ *ptr++ = *(raw->tmpB + j);
+ if (raw->sizeZ>3) {
+ *ptr++ = *(raw->tmpA + j);
+ }
+ }
+ }
+}
+
+
+static TK_RGBImageRec *tkRGBImageLoad(const char *fileName)
+{
+ rawImageRec *raw;
+ TK_RGBImageRec *final;
+
+ raw = RawImageOpen(fileName);
+ if (!raw) {
+ fprintf(stderr, "File not found\n");
+ return NULL;
+ }
+ final = (TK_RGBImageRec *)malloc(sizeof(TK_RGBImageRec));
+ if (final == NULL) {
+ fprintf(stderr, "Out of memory!\n");
+ return NULL;
+ }
+ final->sizeX = raw->sizeX;
+ final->sizeY = raw->sizeY;
+ final->components = raw->sizeZ;
+ RawImageGetData(raw, final);
+ RawImageClose(raw);
+ return final;
+}
+
+
+static void FreeImage( TK_RGBImageRec *image )
+{
+ free(image->data);
+ free(image);
+}
+
+
+/*
+ * Load an SGI .rgb file and generate a set of 2-D mipmaps from it.
+ * Input: imageFile - name of .rgb to read
+ * intFormat - internal texture format to use, or number of components
+ * Return: GL_TRUE if success, GL_FALSE if error.
+ */
+GLboolean LoadRGBMipmaps( const char *imageFile, GLint intFormat )
+{
+ GLint w, h;
+ return LoadRGBMipmaps2( imageFile, GL_TEXTURE_2D, intFormat, &w, &h );
+}
+
+
+
+GLboolean LoadRGBMipmaps2( const char *imageFile, GLenum target,
+ GLint intFormat, GLint *width, GLint *height )
+{
+ GLint error;
+ GLenum format;
+ TK_RGBImageRec *image;
+
+ image = tkRGBImageLoad( imageFile );
+ if (!image) {
+ return GL_FALSE;
+ }
+
+ if (image->components==3) {
+ format = GL_RGB;
+ }
+ else if (image->components==4) {
+ format = GL_RGBA;
+ }
+ else {
+ /* not implemented */
+ fprintf(stderr,
+ "Error in LoadRGBMipmaps %d-component images not implemented\n",
+ image->components );
+ return GL_FALSE;
+ }
+
+ error = gluBuild2DMipmaps( target,
+ intFormat,
+ image->sizeX, image->sizeY,
+ format,
+ GL_UNSIGNED_BYTE,
+ image->data );
+
+ *width = image->sizeX;
+ *height = image->sizeY;
+
+ FreeImage(image);
+
+ return error ? GL_FALSE : GL_TRUE;
+}
+
+
+
+/*
+ * Load an SGI .rgb file and return a pointer to the image data.
+ * Input: imageFile - name of .rgb to read
+ * Output: width - width of image
+ * height - height of image
+ * format - format of image (GL_RGB or GL_RGBA)
+ * Return: pointer to image data or NULL if error
+ */
+GLubyte *LoadRGBImage( const char *imageFile, GLint *width, GLint *height,
+ GLenum *format )
+{
+ TK_RGBImageRec *image;
+ GLint bytes;
+ GLubyte *buffer;
+
+ image = tkRGBImageLoad( imageFile );
+ if (!image) {
+ return NULL;
+ }
+
+ if (image->components==3) {
+ *format = GL_RGB;
+ }
+ else if (image->components==4) {
+ *format = GL_RGBA;
+ }
+ else {
+ /* not implemented */
+ fprintf(stderr,
+ "Error in LoadRGBImage %d-component images not implemented\n",
+ image->components );
+ return NULL;
+ }
+
+ *width = image->sizeX;
+ *height = image->sizeY;
+
+ bytes = image->sizeX * image->sizeY * image->components;
+ buffer = (GLubyte *) malloc(bytes);
+ if (!buffer)
+ return NULL;
+
+ memcpy( (void *) buffer, (void *) image->data, bytes );
+
+ FreeImage(image);
+
+ return buffer;
+}
+
+#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
+
+
+static void ConvertRGBtoYUV(GLint w, GLint h, GLint texel_bytes,
+ const GLubyte *src,
+ GLushort *dest)
+{
+ GLint i, j;
+
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ const GLfloat r = (src[0]) / 255.0;
+ const GLfloat g = (src[1]) / 255.0;
+ const GLfloat b = (src[2]) / 255.0;
+ GLfloat y, cr, cb;
+ GLint iy, icr, icb;
+
+ y = r * 65.481 + g * 128.553 + b * 24.966 + 16;
+ cb = r * -37.797 + g * -74.203 + b * 112.0 + 128;
+ cr = r * 112.0 + g * -93.786 + b * -18.214 + 128;
+ /*printf("%f %f %f -> %f %f %f\n", r, g, b, y, cb, cr);*/
+ iy = (GLint) CLAMP(y, 0, 254);
+ icb = (GLint) CLAMP(cb, 0, 254);
+ icr = (GLint) CLAMP(cr, 0, 254);
+
+ if (j & 1) {
+ /* odd */
+ *dest = (iy << 8) | icr;
+ }
+ else {
+ /* even */
+ *dest = (iy << 8) | icb;
+ }
+ dest++;
+ src += texel_bytes;
+ }
+ }
+}
+
+
+/*
+ * Load an SGI .rgb file and return a pointer to the image data, converted
+ * to 422 yuv.
+ *
+ * Input: imageFile - name of .rgb to read
+ * Output: width - width of image
+ * height - height of image
+ * Return: pointer to image data or NULL if error
+ */
+GLushort *LoadYUVImage( const char *imageFile, GLint *width, GLint *height )
+{
+ TK_RGBImageRec *image;
+ GLushort *buffer;
+
+ image = tkRGBImageLoad( imageFile );
+ if (!image) {
+ return NULL;
+ }
+
+ if (image->components != 3 && image->components !=4 ) {
+ /* not implemented */
+ fprintf(stderr,
+ "Error in LoadYUVImage %d-component images not implemented\n",
+ image->components );
+ return NULL;
+ }
+
+ *width = image->sizeX;
+ *height = image->sizeY;
+
+ buffer = (GLushort *) malloc( image->sizeX * image->sizeY * 2 );
+
+ if (buffer)
+ ConvertRGBtoYUV( image->sizeX,
+ image->sizeY,
+ image->components,
+ image->data,
+ buffer );
+
+
+ FreeImage(image);
+ return buffer;
+}
+
diff --git a/progs/util/readtex.h b/progs/util/readtex.h
new file mode 100644
index 00000000000..6c9a3828d38
--- /dev/null
+++ b/progs/util/readtex.h
@@ -0,0 +1,26 @@
+/* readtex.h */
+
+#ifndef READTEX_H
+#define READTEX_H
+
+
+#include <GL/gl.h>
+
+
+extern GLboolean
+LoadRGBMipmaps( const char *imageFile, GLint intFormat );
+
+
+extern GLboolean
+LoadRGBMipmaps2( const char *imageFile, GLenum target,
+ GLint intFormat, GLint *width, GLint *height );
+
+
+extern GLubyte *
+LoadRGBImage( const char *imageFile,
+ GLint *width, GLint *height, GLenum *format );
+
+extern GLushort *
+LoadYUVImage( const char *imageFile, GLint *width, GLint *height );
+
+#endif
diff --git a/progs/util/sampleMakefile b/progs/util/sampleMakefile
new file mode 100644
index 00000000000..a7e510f66de
--- /dev/null
+++ b/progs/util/sampleMakefile
@@ -0,0 +1,49 @@
+# $Id: sampleMakefile,v 1.1.1.1 1999/08/19 00:55:42 jtg Exp $
+
+# Sample makefile for compiling OpenGL/Mesa applications on Unix.
+# This example assumes Linux with gcc.
+
+# This makefile is in the public domain
+
+# $Log: sampleMakefile,v $
+# Revision 1.1.1.1 1999/08/19 00:55:42 jtg
+# Imported sources
+#
+# Revision 1.1 1999/02/24 05:20:45 brianp
+# Initial revision
+#
+
+
+CC = gcc
+
+CFLAGS = -c -g -ansi -pedantic -Wall
+
+INCDIRS = -I. -I../include
+
+LIBDIRS = -L../lib -L/usr/X11/lib
+
+LIBS = -lglut -lMesaGLU -lMesaGL -lX11 -lXext -lXmu -lXt -lXi -lSM -lICE -lm
+
+OBJECTS = main.o \
+ file1.o \
+ file2.o \
+ file3.o
+
+
+PROGRAMS = myprogram
+
+
+.c.o:
+ $(CC) $(CFLAGS) $(INCDIRS) $< -o $@
+
+
+
+default: $(PROGRAMS)
+
+
+dtenvmap: $(OBJECTS)
+ $(CC) $(OBJECTS) $(LIBDIRS) $(LIBS) -o $@
+
+
+clean:
+ rm -f *.o
diff --git a/progs/util/showbuffer.c b/progs/util/showbuffer.c
new file mode 100644
index 00000000000..17f84dc62bd
--- /dev/null
+++ b/progs/util/showbuffer.c
@@ -0,0 +1,192 @@
+/* showbuffer.c */
+
+
+/*
+ * Copy the depth buffer to the color buffer as a grayscale image.
+ * Useful for inspecting the depth buffer values.
+ *
+ * This program is in the public domain.
+ *
+ * Brian Paul November 4, 1998
+ */
+
+
+#include <assert.h>
+#include <stdlib.h>
+#include <GL/gl.h>
+#include "showbuffer.h"
+
+
+
+/*
+ * Copy the depth buffer values into the current color buffer as a
+ * grayscale image.
+ * Input: winWidth, winHeight - size of the window
+ * zBlack - the Z value which should map to black (usually 1)
+ * zWhite - the Z value which should map to white (usually 0)
+ */
+void
+ShowDepthBuffer( GLsizei winWidth, GLsizei winHeight,
+ GLfloat zBlack, GLfloat zWhite )
+{
+ GLfloat *depthValues;
+
+ assert(zBlack >= 0.0);
+ assert(zBlack <= 1.0);
+ assert(zWhite >= 0.0);
+ assert(zWhite <= 1.0);
+ assert(zBlack != zWhite);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+
+ /* Read depth values */
+ depthValues = (GLfloat *) malloc(winWidth * winHeight * sizeof(GLfloat));
+ assert(depthValues);
+ glReadPixels(0, 0, winWidth, winHeight, GL_DEPTH_COMPONENT,
+ GL_FLOAT, depthValues);
+
+ /* Map Z values from [zBlack, zWhite] to gray levels in [0, 1] */
+ /* Not using glPixelTransfer() because it's broke on some systems! */
+ if (zBlack != 0.0 || zWhite != 1.0) {
+ GLfloat scale = 1.0 / (zWhite - zBlack);
+ GLfloat bias = -zBlack * scale;
+ int n = winWidth * winHeight;
+ int i;
+ for (i = 0; i < n; i++)
+ depthValues[i] = depthValues[i] * scale + bias;
+ }
+
+ /* save GL state */
+ glPushAttrib(GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT |
+ GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
+
+ /* setup raster pos for glDrawPixels */
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glOrtho(0.0, (GLdouble) winWidth, 0.0, (GLdouble) winHeight, -1.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glDisable(GL_STENCIL_TEST);
+ glDisable(GL_DEPTH_TEST);
+ glRasterPos2f(0, 0);
+
+ glDrawPixels(winWidth, winHeight, GL_LUMINANCE, GL_FLOAT, depthValues);
+
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ free(depthValues);
+
+ glPopAttrib();
+}
+
+
+
+
+/*
+ * Copy the alpha channel values into the current color buffer as a
+ * grayscale image.
+ * Input: winWidth, winHeight - size of the window
+ */
+void
+ShowAlphaBuffer( GLsizei winWidth, GLsizei winHeight )
+{
+ GLubyte *alphaValues;
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+
+ /* Read alpha values */
+ alphaValues = (GLubyte *) malloc(winWidth * winHeight * sizeof(GLubyte));
+ assert(alphaValues);
+ glReadPixels(0, 0, winWidth, winHeight, GL_ALPHA, GL_UNSIGNED_BYTE, alphaValues);
+
+ /* save GL state */
+ glPushAttrib(GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL |
+ GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
+
+ /* setup raster pos for glDrawPixels */
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glOrtho(0.0, (GLdouble) winWidth, 0.0, (GLdouble) winHeight, -1.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glDisable(GL_STENCIL_TEST);
+ glDisable(GL_DEPTH_TEST);
+ glRasterPos2f(0, 0);
+
+ glDrawPixels(winWidth, winHeight, GL_LUMINANCE, GL_UNSIGNED_BYTE, alphaValues);
+
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ free(alphaValues);
+
+ glPopAttrib();
+}
+
+
+
+/*
+ * Copy the stencil buffer values into the current color buffer as a
+ * grayscale image.
+ * Input: winWidth, winHeight - size of the window
+ * scale, bias - scale and bias to apply to stencil values for display
+ */
+void
+ShowStencilBuffer( GLsizei winWidth, GLsizei winHeight,
+ GLfloat scale, GLfloat bias )
+{
+ GLubyte *stencilValues;
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+
+ /* Read stencil values */
+ stencilValues = (GLubyte *) malloc(winWidth * winHeight * sizeof(GLubyte));
+ assert(stencilValues);
+ glReadPixels(0, 0, winWidth, winHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilValues);
+
+ /* save GL state */
+ glPushAttrib(GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT |
+ GL_PIXEL_MODE_BIT | GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
+
+ /* setup raster pos for glDrawPixels */
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glOrtho(0.0, (GLdouble) winWidth, 0.0, (GLdouble) winHeight, -1.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glDisable(GL_STENCIL_TEST);
+ glDisable(GL_DEPTH_TEST);
+ glRasterPos2f(0, 0);
+
+ glPixelTransferf(GL_RED_SCALE, scale);
+ glPixelTransferf(GL_RED_BIAS, bias);
+ glPixelTransferf(GL_GREEN_SCALE, scale);
+ glPixelTransferf(GL_GREEN_BIAS, bias);
+ glPixelTransferf(GL_BLUE_SCALE, scale);
+ glPixelTransferf(GL_BLUE_BIAS, bias);
+
+ glDrawPixels(winWidth, winHeight, GL_LUMINANCE, GL_UNSIGNED_BYTE, stencilValues);
+
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ free(stencilValues);
+
+ glPopAttrib();
+}
diff --git a/progs/util/showbuffer.h b/progs/util/showbuffer.h
new file mode 100644
index 00000000000..63533d8e9b5
--- /dev/null
+++ b/progs/util/showbuffer.h
@@ -0,0 +1,36 @@
+/* showbuffer. h*/
+
+/*
+ * Copy the depth buffer to the color buffer as a grayscale image.
+ * Useful for inspecting the depth buffer values.
+ *
+ * This program is in the public domain.
+ *
+ * Brian Paul November 4, 1998
+ */
+
+
+#ifndef SHOWBUFFER_H
+#define SHOWBUFFER_H
+
+
+#include <GL/gl.h>
+
+
+
+extern void
+ShowDepthBuffer( GLsizei winWidth, GLsizei winHeight,
+ GLfloat zBlack, GLfloat zWhite );
+
+
+extern void
+ShowAlphaBuffer( GLsizei winWidth, GLsizei winHeight );
+
+
+extern void
+ShowStencilBuffer( GLsizei winWidth, GLsizei winHeight,
+ GLfloat scale, GLfloat bias );
+
+
+
+#endif
diff --git a/progs/util/winpos.c b/progs/util/winpos.c
new file mode 100644
index 00000000000..5ad98fd2704
--- /dev/null
+++ b/progs/util/winpos.c
@@ -0,0 +1,42 @@
+/* winpos.c */
+
+
+/*
+ * Set the current raster position to a specific window
+ * coordinate. Also see the GL_MESA_window_pos extension.
+ *
+ * Written by Brian Paul and in the public domain.
+ */
+
+
+void WindowPos( GLfloat x, GLfloat y, GLfloat z )
+{
+ GLfloat fx, fy;
+
+ /* Push current matrix mode and viewport attributes */
+ glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT );
+
+ /* Setup projection parameters */
+ glMatrixMode( GL_PROJECTION );
+ glPushMatrix();
+ glLoadIdentity();
+ glMatrixMode( GL_MODELVIEW );
+ glPushMatrix();
+ glLoadIdentity();
+
+ glDepthRange( z, z );
+ glViewport( (int) x - 1, (int) y - 1, 2, 2 );
+
+ /* set the raster (window) position */
+ fx = x - (int) x;
+ fy = y - (int) y;
+ glRasterPos3f( fx, fy, 0.0 );
+
+ /* restore matrices, viewport and matrix mode */
+ glPopMatrix();
+ glMatrixMode( GL_PROJECTION );
+ glPopMatrix();
+
+ glPopAttrib();
+}
+