home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / mesa-1.2.8 / src / context.h < prev    next >
C/C++ Source or Header  |  1996-05-27  |  30KB  |  1,014 lines

  1. /* $Id: context.h,v 1.59 1996/05/20 15:02:44 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  1.2
  6.  * Copyright (C) 1995-1996  Brian Paul  (brianp@ssec.wisc.edu)
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25. $Log: context.h,v $
  26.  * Revision 1.59  1996/05/20  15:02:44  brianp
  27.  * Removed Reserved[] display list array
  28.  *
  29.  * Revision 1.58  1996/05/09  16:32:27  brianp
  30.  * removed ComputePlane field
  31.  *
  32.  * Revision 1.57  1996/05/08  16:48:45  brianp
  33.  * added LineFunc2 field for Mondello driver per Peter McDermott
  34.  *
  35.  * Revision 1.56  1996/04/25  20:47:02  brianp
  36.  * added prototype for future gl_new_context() and new CC fields
  37.  *
  38.  * Revision 1.55  1996/03/22  20:54:47  brianp
  39.  * replaced CC.ClipSpans with WINCLIP_BIT RasterMask flag
  40.  *
  41.  * Revision 1.54  1996/02/26  15:14:32  brianp
  42.  * removed CC.Current.Color, replaced by CC.Current.IntColor
  43.  *
  44.  * Revision 1.53  1996/02/26  15:13:24  brianp
  45.  * added lookup tables and code for optimized lighting
  46.  *
  47.  * Revision 1.52  1996/02/19  21:49:26  brianp
  48.  * added support for software alpha buffering
  49.  *
  50.  * Revision 1.51  1996/02/15  16:01:20  brianp
  51.  * added vertex array extension support
  52.  *
  53.  * Revision 1.50  1996/02/13  17:46:21  brianp
  54.  * added fields to gl_light_attrib struct for lighting optimizations
  55.  *
  56.  * Revision 1.49  1996/02/06  04:13:02  brianp
  57.  * added CC.Polygon.CullBits code
  58.  *
  59.  * Revision 1.48  1996/02/06  03:24:36  brianp
  60.  * removed gamma correction code
  61.  *
  62.  * Revision 1.47  1996/01/29  19:05:44  brianp
  63.  * added Orientation field for unfilled polygons
  64.  *
  65.  * Revision 1.46  1996/01/22  15:35:12  brianp
  66.  * rename MutableColors to MutablePixels, added MonoPixels flag
  67.  *
  68.  * Revision 1.45  1996/01/19  18:08:49  brianp
  69.  * use a smaller FIXED_SHIFT if using 32-bit depth buffer
  70.  *
  71.  * Revision 1.44  1996/01/11  20:14:22  brianp
  72.  * use new GLstencil datatype
  73.  *
  74.  * Revision 1.43  1996/01/05  01:21:20  brianp
  75.  * added profiling
  76.  *
  77.  * Revision 1.42  1996/01/02  22:13:40  brianp
  78.  * removed old fixed-point macros
  79.  *
  80.  * Revision 1.41  1995/12/30  00:47:55  brianp
  81.  * added EightBitColor, ColorShift, IntColor fields to CC
  82.  *
  83.  * Revision 1.40  1995/12/19  22:15:12  brianp
  84.  * added RasterOffsetX and RasterOffsetY fields
  85.  *
  86.  * Revision 1.39  1995/12/18  17:11:50  brianp
  87.  * added GLdepth and GLaccum datatypes
  88.  *
  89.  * Revision 1.38  1995/12/14  19:57:23  brianp
  90.  * added GLfixed datatype and macros
  91.  *
  92.  * Revision 1.37  1995/11/22  13:34:49  brianp
  93.  * added MutableColors flag
  94.  *
  95.  * Revision 1.36  1995/11/13  21:28:24  brianp
  96.  * added comment about TextureWidth/Height
  97.  *
  98.  * Revision 1.35  1995/11/02  14:57:14  brianp
  99.  * changed LastEnabled to GLint type
  100.  *
  101.  * Revision 1.34  1995/11/01  21:44:15  brianp
  102.  * added CC.Light.LastEnabled
  103.  *
  104.  * Revision 1.33  1995/10/27  20:28:27  brianp
  105.  * added glPolygonOffsetEXT() support
  106.  *
  107.  * Revision 1.32  1995/10/19  15:45:38  brianp
  108.  * added gamma support
  109.  * new arguments to gl_new_context()
  110.  *
  111.  * Revision 1.31  1995/10/17  21:34:03  brianp
  112.  * added typedefs for points_func, line_func, and polygon_func
  113.  *
  114.  * Revision 1.30  1995/10/14  16:26:13  brianp
  115.  * enable dithering by default
  116.  * added SWmasking code
  117.  *
  118.  * Revision 1.29  1995/09/25  16:31:29  brianp
  119.  * reorganized front and back material indexing
  120.  *
  121.  * Revision 1.28  1995/09/15  18:48:52  brianp
  122.  * introduced CC.NewState convention
  123.  * cleaned up comments, removed dead code
  124.  *
  125.  * Revision 1.27  1995/08/01  22:36:12  brianp
  126.  * fixed an extension-compatibility symbol problem
  127.  *
  128.  * Revision 1.26  1995/08/01  22:23:04  brianp
  129.  * added definitions for extension symbols when using non-Mesa header files
  130.  *
  131.  * Revision 1.25  1995/07/25  16:41:54  brianp
  132.  * made changes for using CC.VertexFunc pointer
  133.  *
  134.  * Revision 1.24  1995/07/17  22:32:31  brianp
  135.  * added ClipSpans flag to handle viewports which extend beyond the window
  136.  *
  137.  * Revision 1.23  1995/06/05  20:26:24  brianp
  138.  * added Unfilled field to gl_polygon struct
  139.  *
  140.  * Revision 1.22  1995/05/31  14:32:37  brianp
  141.  * changed BufferWidth, BufferHeight to GLint
  142.  *
  143.  * Revision 1.21  1995/05/22  20:59:34  brianp
  144.  * Release 1.2
  145.  *
  146.  * Revision 1.20  1995/05/17  13:52:37  brianp
  147.  * implemented glIndexMask(0) and glColorMask(0,0,0,0)
  148.  *
  149.  * Revision 1.19  1995/05/17  13:17:22  brianp
  150.  * changed default CC.Mode value to allow use of real OpenGL headers
  151.  * removed need for CC.MajorMode variable
  152.  *
  153.  * Revision 1.18  1995/05/15  16:06:28  brianp
  154.  * implemented shared/nonshared display lists
  155.  *
  156.  * Revision 1.17  1995/05/12  16:30:14  brianp
  157.  * Texture images stored as bytes, not floats
  158.  *
  159.  * Revision 1.16  1995/04/17  13:51:19  brianp
  160.  * added gl_copy_context() function
  161.  *
  162.  * Revision 1.15  1995/04/11  14:04:05  brianp
  163.  * moved CC.write... functions to dd
  164.  *
  165.  * Revision 1.14  1995/03/30  21:08:04  brianp
  166.  * updated to use pointers to CC.write_* functions
  167.  *
  168.  * Revision 1.13  1995/03/27  20:31:26  brianp
  169.  * new Texture.Enabled scheme
  170.  *
  171.  * Revision 1.12  1995/03/24  16:59:41  brianp
  172.  * added gl_update_pixel_logic
  173.  *
  174.  * Revision 1.11  1995/03/24  15:30:10  brianp
  175.  * cleaned up CC struct and removed vertex buffer arrays
  176.  *
  177.  * Revision 1.10  1995/03/22  21:37:22  brianp
  178.  * removed BufferDepth from CC
  179.  *
  180.  * Revision 1.9  1995/03/10  16:26:43  brianp
  181.  * updated for bleding extensions
  182.  *
  183.  * Revision 1.8  1995/03/09  21:39:51  brianp
  184.  * added ModelViewInvValid flag
  185.  *
  186.  * Revision 1.7  1995/03/08  15:10:02  brianp
  187.  * added support for dd_logicop
  188.  *
  189.  * Revision 1.6  1995/03/07  14:20:28  brianp
  190.  * removed ClearColorInt field
  191.  *
  192.  * Revision 1.5  1995/03/04  19:25:29  brianp
  193.  * 1.1 beta revision
  194.  *
  195.  * Revision 1.4  1995/03/02  19:17:02  brianp
  196.  * new RasterMask logic, fixed some comments
  197.  *
  198.  * Revision 1.3  1995/02/27  22:48:33  brianp
  199.  * modified for PB
  200.  *
  201.  * Revision 1.2  1995/02/27  15:07:32  brianp
  202.  * added Vcolor/Vindex scheme
  203.  *
  204.  * Revision 1.1  1995/02/24  14:18:47  brianp
  205.  * Initial revision
  206.  *
  207.  */
  208.  
  209.  
  210. #ifndef CONTEXT_H
  211. #define CONTEXT_H
  212.  
  213.  
  214. #include "GL/gl.h"
  215. #include "config.h"
  216.  
  217.  
  218.  
  219.  
  220. /*
  221.  * Depth buffer data type:
  222.  */
  223. #if DEPTH_BITS==16
  224.    typedef GLushort GLdepth;
  225. #elif DEPTH_BITS==32
  226.    typedef GLint GLdepth;
  227. #else
  228.    illegal number of depth bits
  229. #endif
  230.  
  231.  
  232. /*
  233.  * Accumulation buffer data type:
  234.  */
  235. #if ACCUM_BITS==8
  236.    typedef GLubyte GLaccum;
  237. #elif ACCUM_BITS==16
  238.    typedef GLushort GLaccum;
  239. #else
  240.    illegal number of accumulation bits
  241. #endif
  242.  
  243.  
  244. /*
  245.  * Stencil buffer data type:
  246.  */
  247. #if STENCIL_BITS==8
  248.    typedef GLubyte GLstencil;
  249. #else
  250.    illegal number of stencil bits
  251. #endif
  252.  
  253.  
  254.  
  255. /*
  256.  * Fixed point arithmetic type:
  257.  */
  258. typedef int GLfixed;
  259.  
  260. #if DEPTH_BITS==32
  261. #  define FIXED_SHIFT      7
  262. #  define FixedToUns(F)    ((unsigned)(F) >> 7u)
  263. #  define FloatToFixed(X)  ( (int) ((X) * 128.0F) )
  264. #else
  265. #  define FIXED_SHIFT      15
  266. #  define FixedToUns(F)    ((unsigned)(F) >> 15u)
  267. #  define FloatToFixed(X)  ( (int) ((X) * 32768.0F) )
  268. #endif
  269. #define IntToFixed(I)    ((I) << FIXED_SHIFT)
  270. #define FixedToInt(F)    ((F) >> FIXED_SHIFT)
  271.  
  272.  
  273.  
  274. /*
  275.  * Specular exponent and material shininess lookup table sizes:
  276.  */
  277. #define EXP_TABLE_SIZE 512
  278. #define SHINE_TABLE_SIZE 200
  279.  
  280. struct gl_light {
  281.     GLfloat Ambient[4];        /* ambient color */
  282.     GLfloat Diffuse[4];        /* diffuse color */
  283.     GLfloat Specular[4];        /* specular color */
  284.     GLfloat Position[4];        /* position in eye coordinates */
  285.     GLfloat NormPosition[3];    /* normalized position */
  286.     GLfloat Direction[4];        /* spotlight dir in eye coordinates */
  287.         GLfloat NormDirection[3];    /* normalized direction */
  288.     GLfloat SpotExponent;
  289.         GLfloat SpotExpTable[EXP_TABLE_SIZE][2];  /* to replace a pow() call */
  290.     GLfloat SpotCutoff;        /* in degress */
  291.         GLfloat CosCutoff;        /* = cos(SpotCutoff) */
  292.     GLfloat ConstantAttenuation;
  293.     GLfloat LinearAttenuation;
  294.     GLfloat QuadraticAttenuation;
  295.     GLboolean Enabled;        /* On/off flag */
  296. };
  297.  
  298.  
  299. struct gl_lightmodel {
  300.     GLfloat Ambient[4];        /* ambient color */
  301.     GLboolean LocalViewer;        /* Local (or infinite) view point? */
  302.     GLboolean TwoSide;        /* Two (or one) sided lighting? */
  303. };
  304.  
  305.  
  306. struct gl_material {
  307.     GLfloat Ambient[4];
  308.     GLfloat Diffuse[4];
  309.     GLfloat Specular[4];
  310.     GLfloat Emission[4];
  311.     GLfloat Shininess;
  312.     GLfloat AmbientIndex;    /* for color index lighting */
  313.     GLfloat DiffuseIndex;    /* for color index lighting */
  314.     GLfloat SpecularIndex;    /* for color index lighting */
  315.         GLfloat ShineTable[SHINE_TABLE_SIZE];  /* to replace a pow() call */
  316. };
  317.  
  318.  
  319.  
  320. /*
  321.  * Attribute structures:
  322.  *    We define a struct for each attribute group to make pushing and
  323.  *    popping attributes easy.  Also it's a good organization.
  324.  */
  325.  
  326.  
  327. struct gl_accum_attrib {
  328.     GLfloat ClearColor[4];    /* Accumulation buffer clear color */
  329. };
  330.  
  331.  
  332. /* Vertex array extension */
  333. struct gl_array_attrib {
  334.     GLint VertexSize;
  335.     GLenum VertexType;
  336.     GLsizei VertexStride;        /* user-specified stride */
  337.     GLsizei VertexStrideB;        /* actual stride in bytes */
  338.     GLsizei VertexCount;
  339.     void *VertexPtr;
  340.     GLboolean VertexEnabled;
  341.  
  342.     GLenum NormalType;
  343.     GLsizei NormalStride;        /* user-specified stride */
  344.     GLsizei NormalStrideB;        /* actual stride in bytes */
  345.     GLsizei NormalCount;
  346.     void *NormalPtr;
  347.     GLboolean NormalEnabled;
  348.  
  349.     GLint ColorSize;
  350.     GLenum ColorType;
  351.     GLsizei ColorStride;        /* user-specified stride */
  352.     GLsizei ColorStrideB;        /* actual stride in bytes */
  353.     GLsizei ColorCount;
  354.     void *ColorPtr;
  355.     GLboolean ColorEnabled;
  356.  
  357.     GLenum IndexType;
  358.     GLsizei IndexStride;        /* user-specified stride */
  359.     GLsizei IndexStrideB;        /* actual stride in bytes */
  360.     GLsizei IndexCount;
  361.     void *IndexPtr;
  362.     GLboolean IndexEnabled;
  363.  
  364.     GLint TexCoordSize;
  365.     GLenum TexCoordType;
  366.     GLsizei TexCoordStride;        /* user-specified stride */
  367.     GLsizei TexCoordStrideB;    /* actual stride in bytes */
  368.     GLsizei TexCoordCount;
  369.     void *TexCoordPtr;
  370.     GLboolean TexCoordEnabled;
  371.  
  372.     GLsizei EdgeFlagStride;        /* user-specified stride */
  373.     GLsizei EdgeFlagStrideB;    /* actual stride in bytes */
  374.     GLsizei EdgeFlagCount;
  375.     GLboolean *EdgeFlagPtr;
  376.     GLboolean EdgeFlagEnabled;
  377. };
  378.  
  379.  
  380. struct gl_colorbuffer_attrib {
  381.     GLuint ClearIndex;        /* Index to use for glClear */
  382.     GLfloat ClearColor[4];        /* Color to use for glClear */
  383.  
  384.     GLuint IndexMask;        /* Color index write mask */
  385.     GLuint ColorMask;        /* bit 3=red,2=green,1=blue,0=alpha*/
  386.         GLboolean SWmasking;        /* Do color/CI masking in software? */
  387.  
  388.     GLenum DrawBuffer;        /* Which buffer to draw into */
  389.  
  390.     /* alpha testing */
  391.     GLboolean AlphaEnabled;        /* Alpha test enabled flag */
  392.     GLenum AlphaFunc;        /* Alpha test function */
  393.     GLfloat AlphaRef;        /* Alpha reference value */
  394.     GLint AlphaRefInt;        /* AlphaRef scaled to an integer */
  395.  
  396.     /* blending */
  397.     GLboolean BlendEnabled;        /* Blending enabled flag */
  398.     GLenum BlendSrc;        /* Blending source operator */
  399.     GLenum BlendDst;        /* Blending destination operator */
  400.     GLenum BlendEquation;        /* BlendEquation EXTENSION */
  401.     GLfloat BlendColor[4];        /* BlendColor EXTENSION */
  402.  
  403.     /* logic op */
  404.     GLboolean LogicOpEnabled;    /* Logic op enabled flag */
  405.     GLboolean SWLogicOpEnabled;    /* Do logic ops in software? */
  406.     GLenum LogicOp;            /* Logic operator */
  407.  
  408.     GLboolean DitherFlag;        /* Dither enable flag */
  409. };
  410.  
  411.  
  412. struct gl_current_attrib {
  413.     GLint IntColor[4];        /* Current RGBA color as scaled ints*/
  414.     GLuint Index;            /* Current color index */
  415.     GLfloat Normal[3];        /* Current normal vector */
  416.     GLfloat TexCoord[4];        /* Current texture coordinate */
  417.     GLfloat RasterPos[4];        /* Current raster position */
  418.     GLfloat RasterDistance;        /* Current raster distance */
  419.     GLfloat RasterColor[4];        /* Current raster color */
  420.     GLuint RasterIndex;        /* Current raster index */
  421.     GLfloat RasterTexCoord[4];    /* Current raster texture coord */
  422.     GLboolean RasterPosValid;    /* Raster position valid flag */
  423.     GLboolean EdgeFlag;        /* Current edge flag */
  424. };
  425.  
  426.  
  427. struct gl_depthbuffer_attrib {
  428.     GLenum Func;        /* Function for depth buffer compare */
  429.     GLfloat Clear;        /* Value to clear depth buffer to */
  430.     GLboolean Test;        /* Depth buffering enabled flag */
  431.     GLboolean Mask;        /* Depth buffer writable? */
  432. };
  433.  
  434.  
  435. struct gl_enable_attrib {
  436.     GLboolean AlphaTest;
  437.     GLboolean AutoNormal;
  438.     GLboolean Blend;
  439.     GLboolean ClipPlane[MAX_CLIP_PLANES];
  440.     GLboolean ColorMaterial;
  441.     GLboolean CullFace;
  442.     GLboolean DepthTest;
  443.     GLboolean Dither;
  444.     GLboolean Fog;
  445.     GLboolean Light[MAX_LIGHTS];
  446.     GLboolean Lighting;
  447.     GLboolean LineSmooth;
  448.     GLboolean LineStipple;
  449.     GLboolean LogicOp;
  450.     GLboolean Map1Color4;
  451.     GLboolean Map1Index;
  452.     GLboolean Map1Normal;
  453.     GLboolean Map1TextureCoord1;
  454.     GLboolean Map1TextureCoord2;
  455.     GLboolean Map1TextureCoord3;
  456.     GLboolean Map1TextureCoord4;
  457.     GLboolean Map1Vertex3;
  458.     GLboolean Map1Vertex4;
  459.     GLboolean Map2Color4;
  460.     GLboolean Map2Index;
  461.     GLboolean Map2Normal;
  462.     GLboolean Map2TextureCoord1;
  463.     GLboolean Map2TextureCoord2;
  464.     GLboolean Map2TextureCoord3;
  465.     GLboolean Map2TextureCoord4;
  466.     GLboolean Map2Vertex3;
  467.     GLboolean Map2Vertex4;
  468.     GLboolean Normalize;
  469.     GLboolean PointSmooth;
  470.     GLboolean PolygonOffset;
  471.     GLboolean PolygonSmooth;
  472.     GLboolean PolygonStipple;
  473.     GLboolean Scissor;
  474.     GLboolean Stencil;
  475.     GLuint Texture;
  476.     GLuint TexGen;
  477. };
  478.  
  479.  
  480. struct gl_eval_attrib {
  481.     /* Enable bits */
  482.     GLboolean Map1Color4;
  483.     GLboolean Map1Index;
  484.     GLboolean Map1Normal;
  485.     GLboolean Map1TextureCoord1;
  486.     GLboolean Map1TextureCoord2;
  487.     GLboolean Map1TextureCoord3;
  488.     GLboolean Map1TextureCoord4;
  489.     GLboolean Map1Vertex3;
  490.     GLboolean Map1Vertex4;
  491.     GLboolean Map2Color4;
  492.     GLboolean Map2Index;
  493.     GLboolean Map2Normal;
  494.     GLboolean Map2TextureCoord1;
  495.     GLboolean Map2TextureCoord2;
  496.     GLboolean Map2TextureCoord3;
  497.     GLboolean Map2TextureCoord4;
  498.     GLboolean Map2Vertex3;
  499.     GLboolean Map2Vertex4;
  500.     GLboolean AutoNormal;
  501.     /* Map Grid endpoints and divisions */
  502.     GLuint MapGrid1un;
  503.     GLfloat MapGrid1u1, MapGrid1u2;
  504.     GLuint MapGrid2un, MapGrid2vn;
  505.     GLfloat MapGrid2u1, MapGrid2u2;
  506.     GLfloat MapGrid2v1, MapGrid2v2;
  507. };
  508.  
  509.  
  510. struct gl_fog_attrib {
  511.     GLboolean Enabled;        /* Fog enabled flag */
  512.     GLfloat Color[4];        /* Fog color */
  513.     GLfloat Density;        /* Density >= 0.0 */
  514.     GLfloat Start;            /* Start distance in eye coords */
  515.     GLfloat End;            /* End distance in eye coords */
  516.     GLfloat Index;            /* Fog index */
  517.     GLenum Mode;            /* Fog mode */
  518. };
  519.  
  520.  
  521. struct gl_hint_attrib {
  522.     /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */
  523.     GLenum PerspectiveCorrection;
  524.     GLenum PointSmooth;
  525.     GLenum LineSmooth;
  526.     GLenum PolygonSmooth;
  527.     GLenum Fog;
  528. };
  529.  
  530.  
  531. struct gl_light_attrib {
  532.     struct gl_light Light[MAX_LIGHTS];    /* Array of lights */
  533.     struct gl_lightmodel Model;        /* Lighting model */
  534.     struct gl_material Material[2];        /* Material 0=front, 1=back */
  535.     GLboolean Enabled;            /* Lighting enabled flag */
  536.     GLenum ShadeModel;            /* GL_FLAT or GL_SMOOTH */
  537.     GLenum ColorMaterialFace;        /* see glColorMaterial */
  538.     GLenum ColorMaterialMode;        /* see glColorMaterial */
  539.     GLboolean ColorMaterialEnabled;        /* see glColorMaterial */
  540.  
  541.     /* Derived for optimizations: */
  542.     GLint LastEnabled;            /* no. of last enabled light */
  543.     GLboolean Fast;                /* Use fast shader? */
  544.     GLfloat BaseColor[4];
  545.     GLfloat Diffuse[MAX_LIGHTS][3];
  546.     GLfloat Specular[MAX_LIGHTS][3];
  547. };
  548.  
  549.  
  550. struct gl_line_attrib {
  551.     GLboolean SmoothFlag;        /* GL_LINE_SMOOTH enabled? */
  552.     GLboolean StippleFlag;        /* GL_LINE_STIPPLE enabled? */
  553.     GLushort StipplePattern;    /* Stipple pattern */
  554.     GLint StippleFactor;        /* Stipple repeat factor */
  555.     GLfloat Width;            /* Line width */
  556. };
  557.  
  558.  
  559. struct gl_list_attrib {
  560.     GLuint ListBase;
  561. };
  562.  
  563.  
  564. struct gl_pixel_attrib {
  565.     GLenum ReadBuffer;
  566.     GLfloat RedBias, RedScale;    /* Pixel xfer bias & scale values */
  567.     GLfloat GreenBias, GreenScale;
  568.     GLfloat BlueBias, BlueScale;
  569.     GLfloat AlphaBias, AlphaScale;
  570.     GLfloat DepthBias, DepthScale;
  571.     GLint IndexShift;
  572.     GLint IndexOffset;
  573.     GLboolean MapColorFlag;
  574.     GLboolean MapStencilFlag;
  575.     GLfloat ZoomX;            /* Pixel zoom X factor */
  576.     GLfloat ZoomY;            /* Pixel zoom Y factor */
  577.     /* TODO: Do the following belong here??? */
  578.     GLint MapStoSsize;            /* Size of each pixel map */
  579.     GLint MapItoIsize;
  580.     GLint MapItoRsize;
  581.     GLint MapItoGsize;
  582.     GLint MapItoBsize;
  583.     GLint MapItoAsize;
  584.     GLint MapRtoRsize;
  585.     GLint MapGtoGsize;
  586.     GLint MapBtoBsize;
  587.     GLint MapAtoAsize;
  588.     GLint MapStoS[MAX_PIXEL_MAP_TABLE];    /* Pixel map tables */
  589.     GLint MapItoI[MAX_PIXEL_MAP_TABLE];
  590.     GLfloat MapItoR[MAX_PIXEL_MAP_TABLE];
  591.     GLfloat MapItoG[MAX_PIXEL_MAP_TABLE];
  592.     GLfloat MapItoB[MAX_PIXEL_MAP_TABLE];
  593.     GLfloat MapItoA[MAX_PIXEL_MAP_TABLE];
  594.     GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE];
  595.     GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE];
  596.     GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE];
  597.     GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE];
  598. };
  599.  
  600.  
  601. struct gl_point_attrib {
  602.     GLboolean SmoothFlag;    /* True if GL_POINT_SMOOTH is enabled */
  603.     GLfloat Size;        /* Point size */
  604. };
  605.  
  606.  
  607. struct gl_polygon_attrib {
  608.     GLenum FrontFace;    /* Either GL_CW or GL_CCW */
  609.     GLenum FrontMode;    /* Either GL_POINT, GL_LINE or GL_FILL */
  610.     GLenum BackMode;    /* Either GL_POINT, GL_LINE or GL_FILL */
  611.     GLboolean Unfilled;    /* True if back or front mode is not GL_FILL */
  612.     GLenum CullFaceMode;    /* Culling mode GL_FRONT or GL_BACK */
  613.     GLboolean CullFlag;    /* Culling on/off flag */
  614.         GLuint CullBits;    /* Used for cull testing */
  615.     GLboolean SmoothFlag;    /* True if GL_POLYGON_SMOOTH is enabled */
  616.     GLboolean StippleFlag;    /* True if GL_POLYGON_STIPPLE is enabled */
  617.         GLfloat OffsetFactor;   /* Polygon offset factor */
  618.         GLfloat OffsetBias;     /* Polygon offset bias */
  619.         GLboolean OffsetEnabled;/* Polygon offset enable */
  620. };
  621.  
  622.  
  623. struct gl_scissor_attrib {
  624.     GLboolean    Enabled;        /* Scissor test enabled? */
  625.     GLint        X, Y;            /* Lower left corner of box */
  626.     GLsizei        Width, Height;        /* Size of box */
  627.     GLint        Xmin, Xmax, Ymin, Ymax;    /* Bounds in window coords */
  628. };
  629.  
  630.  
  631. struct gl_stencil_attrib {
  632.     GLboolean    Enabled;    /* Enabled flag */
  633.     GLenum        Function;    /* Stencil function */
  634.     GLenum        FailFunc;    /* Fail function */
  635.     GLenum        ZPassFunc;    /* Depth buffer pass function */
  636.     GLenum        ZFailFunc;    /* Depth buffer fail function */
  637.     GLstencil    Ref;        /* Reference value */
  638.     GLstencil    ValueMask;    /* Value mask */
  639.     GLstencil    Clear;        /* Clear value */
  640.     GLstencil    WriteMask;    /* Write mask */
  641. };
  642.  
  643.  
  644. #define Q_BIT 1
  645. #define R_BIT 2
  646. #define S_BIT 4
  647. #define T_BIT 8
  648.  
  649.  
  650. struct gl_texture_attrib {
  651.     GLuint Enabled;            /* Bitwise-OR of 1 and 2 */
  652.     GLenum EnvMode;            /* GL_MODULATE, GL_DECAL, GL_BLEND */
  653.     GLfloat EnvColor[4];
  654.     GLfloat BorderColor[4];        /* TODO: border color 1-D and 2-D */
  655.     GLuint TexGenEnabled;        /* Bitwise-OR of [QRST]_BIT values */
  656.     GLenum GenModeS;        /* Tex coord generation mode, either */
  657.     GLenum GenModeT;        /*    GL_OBJECT_LINEAR, or */
  658.     GLenum GenModeR;        /*    GL_EYE_LINEAR, or    */
  659.     GLenum GenModeQ;        /*      GL_SPHERE_MAP        */
  660.     GLfloat ObjectPlaneS[4];
  661.     GLfloat ObjectPlaneT[4];
  662.     GLfloat ObjectPlaneR[4];
  663.     GLfloat ObjectPlaneQ[4];
  664.     GLfloat EyePlaneS[4];
  665.     GLfloat EyePlaneT[4];
  666.     GLfloat EyePlaneR[4];
  667.     GLfloat EyePlaneQ[4];
  668.     GLenum WrapS1D;            /* GL_CLAMP or GL_REPEAT */
  669.     GLenum WrapT1D;            /* GL_CLAMP or GL_REPEAT */
  670.     GLenum WrapS2D;            /* GL_CLAMP or GL_REPEAT */
  671.     GLenum WrapT2D;            /* GL_CLAMP or GL_REPEAT */
  672.     GLenum MinFilter1D;        /* 1-D minification filter */
  673.     GLenum MagFilter1D;        /* 1-D magnification filter */
  674.     GLenum MinFilter2D;        /* 2-D minification filter */
  675.     GLenum MagFilter2D;        /* 2-D magnification filter */
  676. };
  677.  
  678.  
  679. struct gl_transform_attrib {
  680.     GLenum MatrixMode;            /* Matrix mode */
  681.     GLboolean Normalize;            /* Normalize all normals? */
  682.     GLfloat ClipEquation[MAX_CLIP_PLANES][4];
  683.     GLboolean ClipEnabled[MAX_CLIP_PLANES];
  684.     GLboolean AnyClip;            /* Any ClipEnabled[] true? */
  685.  
  686. };
  687.  
  688.  
  689. struct gl_viewport_attrib {
  690.     GLint X, Y;        /* position */
  691.     GLsizei Width, Height;    /* size */
  692.     GLfloat Near, Far;    /* Depth buffer range */
  693.     GLfloat Sx, Sy, Sz;    /* NDC to WinCoord scaling */
  694.     GLfloat Tx, Ty, Tz;    /* NDC to WinCoord translation */
  695. };
  696.  
  697.  
  698. /* For the attribute stack: */
  699. struct gl_attrib_node {
  700.     GLbitfield kind;
  701.     void *data;
  702.     struct gl_attrib_node *next;
  703. };
  704.  
  705.  
  706. /* Display list info shared by multiple contexts: */
  707. struct gl_list_group {
  708.     union node *List[MAX_DISPLAYLISTS];    /* The display lists */
  709.     GLint RefCount;                /* Reference count */
  710. };
  711.  
  712.  
  713.  
  714.  
  715. /*
  716.  * Bitmasks to indicate what auxillary information must be interpolated
  717.  * when clipping (CC.ClipMask).
  718.  */
  719. #define CLIP_FCOLOR_BIT        0x01
  720. #define CLIP_BCOLOR_BIT        0x02
  721. #define CLIP_FINDEX_BIT        0x04
  722. #define CLIP_BINDEX_BIT        0x08
  723. #define CLIP_TEXTURE_BIT    0x10
  724.  
  725.  
  726.  
  727. /*
  728.  * Bitmasks to indicate which rasterization options are enabled (CC.RasterMask)
  729.  */
  730. #define ALPHATEST_BIT    0x001    /* Alpha-test pixels? */
  731. #define BLEND_BIT    0x002    /* Blend pixels? */
  732. #define DEPTH_BIT    0x004    /* Depth-test pixels? */
  733. #define FOG_BIT        0x008    /* Per-pixel fog? */
  734. #define LOGIC_OP_BIT    0x010    /* Apply logic op in software? */
  735. #define SCISSOR_BIT    0x020    /* Scissor pixels? */
  736. #define STENCIL_BIT    0x040    /* Stencil pixels? */
  737. #define MASKING_BIT    0x080    /* Need to apply glColorMask()? */
  738. #define ALPHABUF_BIT    0x100    /* Using software alpha buffer? */
  739. #define WINCLIP_BIT    0x200    /* Clip pixels/primitives to window? */
  740.  
  741.  
  742.  
  743. /*
  744.  * Point, line and polygon rasterizer functions:
  745.  */
  746. typedef void (*points_func)( GLuint first, GLuint last );
  747. typedef void (*line_func)( GLuint v1, GLuint v2, GLuint pv );
  748. typedef void (*polygon_func)( GLuint n, GLuint vlist[], GLuint pv );
  749. typedef void (*triangle_func)( GLuint v1, GLuint v2, GLuint v3, GLuint pv );
  750.  
  751.  
  752.  
  753. /*
  754.  * The library context: 
  755.  */
  756.  
  757. struct gl_context {
  758.     /* Modelview matrix and stack */
  759.     GLfloat ModelViewMatrix[16];
  760.     GLfloat ModelViewInv[16];    /* Inverse of ModelViewMatrix */
  761.     GLboolean ModelViewInvValid;    /* Is the inverse matrix now valid? */
  762.     GLuint ModelViewStackDepth;
  763.     GLfloat ModelViewStack[MAX_MODELVIEW_STACK_DEPTH][16];
  764.  
  765.     /* Projection matrix and stack */
  766.     GLfloat ProjectionMatrix[16];
  767.     GLuint ProjectionStackDepth;
  768.     GLfloat ProjectionStack[MAX_PROJECTION_STACK_DEPTH][16];
  769.  
  770.     /* Texture matrix and stack */
  771.     GLfloat TextureMatrix[16];
  772.         GLboolean IdentityTexMat;    /* Is TextureMatrix==Identity? */
  773.     GLuint TextureStackDepth;
  774.     GLfloat TextureStack[MAX_TEXTURE_STACK_DEPTH][16];
  775.  
  776.     /* Display List stuff */
  777.     GLuint CallDepth;    /* Current recursion calling depth */
  778.     GLboolean ExecuteFlag;    /* Execute GL commands? */
  779.     GLboolean CompileFlag;    /* Compile GL commands into display list? */
  780.     struct gl_list_group *ListGroup;    /* Shared display list group */
  781.  
  782.     /* Attribute stack */
  783.     GLuint AttribStackDepth;
  784.     struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
  785.  
  786.     /* Attribute groups */
  787.     struct gl_accum_attrib        Accum;
  788.     struct gl_array_attrib        Array;
  789.     struct gl_colorbuffer_attrib    Color;
  790.     struct gl_current_attrib    Current;
  791.     struct gl_depthbuffer_attrib    Depth;
  792.     struct gl_eval_attrib        Eval;
  793.     struct gl_fog_attrib        Fog;
  794.     struct gl_hint_attrib        Hint;
  795.     struct gl_light_attrib        Light;
  796.     struct gl_line_attrib        Line;
  797.     struct gl_list_attrib        List;
  798.     struct gl_pixel_attrib        Pixel;
  799.     struct gl_point_attrib        Point;
  800.     struct gl_polygon_attrib    Polygon;
  801.     GLuint PolygonStipple[32];
  802.     struct gl_scissor_attrib    Scissor;
  803.     struct gl_stencil_attrib    Stencil;
  804.     struct gl_texture_attrib    Texture;
  805.     struct gl_transform_attrib    Transform;
  806.     struct gl_viewport_attrib    Viewport;
  807.  
  808.     /* PixelStore parameters */
  809.     GLint PackAlignment;
  810.     GLint PackRowLength;
  811.     GLint PackSkipPixels;
  812.     GLint PackSkipRows;
  813.     GLboolean PackSwapBytes;
  814.     GLboolean PackLSBFirst;
  815.     GLint UnpackAlignment;
  816.     GLint UnpackRowLength;
  817.     GLint UnpackSkipPixels;
  818.     GLint UnpackSkipRows;
  819.     GLboolean UnpackSwapBytes;
  820.     GLboolean UnpackLSBFirst;
  821.  
  822.     /* Feedback */
  823.     GLenum FeedbackType;
  824.     GLuint FeedbackMask;
  825.     GLfloat *FeedbackBuffer;
  826.     GLuint FeedbackBufferSize;
  827.     GLuint FeedbackCount;
  828.  
  829.     /* Selection */
  830.     GLuint *SelectBuffer;
  831.     GLuint SelectBufferSize;    /* size of SelectBuffer */
  832.     GLuint SelectBufferCount;    /* number of values in SelectBuffer */
  833.     GLuint SelectHits;        /* number of records in SelectBuffer */
  834.     GLuint NameStackDepth;
  835.     GLuint NameStack[MAX_NAME_STACK_DEPTH];
  836.     GLboolean HitFlag;
  837.     GLfloat HitMinZ, HitMaxZ;
  838.  
  839.     /* Current 1-D texture map */
  840.     GLuint TextureComponents1D[MAX_TEXTURE_LEVELS];
  841.     GLuint TextureWidth1D[MAX_TEXTURE_LEVELS];  /* includes border */
  842.     GLuint TextureBorder1D[MAX_TEXTURE_LEVELS];
  843.     GLubyte *TextureImage1D[MAX_TEXTURE_LEVELS];
  844.     GLboolean TextureImage1DDeleteFlag[MAX_TEXTURE_LEVELS];
  845.  
  846.     /* Current 2-D texture map */
  847.     GLuint TextureComponents2D[MAX_TEXTURE_LEVELS];
  848.     GLuint TextureWidth2D[MAX_TEXTURE_LEVELS];  /* includes border */
  849.     GLuint TextureHeight2D[MAX_TEXTURE_LEVELS]; /* includes border */
  850.     GLuint TextureBorder2D[MAX_TEXTURE_LEVELS];
  851.     GLubyte *TextureImage2D[MAX_TEXTURE_LEVELS];
  852.     GLboolean TextureImage2DDeleteFlag[MAX_TEXTURE_LEVELS];
  853.  
  854.     /* Miscellaneous */
  855.         GLboolean NewState;     /* If GL_TRUE, must call gl_update_state() */
  856.     GLenum RenderMode;    /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
  857.     GLenum Mode;        /* glBegin primitive or GL_BITMAP */
  858.  
  859.     GLuint StippleCounter;    /* Line stipple counter */
  860.     GLuint ClipMask;    /* OR of CLIP_* values from above */
  861.     GLuint RasterMask;    /* OR of rasterization flags */
  862.     GLuint LightTwoSide;    /* Compute two-sided lighting? */
  863.     GLfloat PlaneA, PlaneB;    /* Eq. of plane of current polygon */
  864.     GLfloat PlaneC, PlaneD;
  865.         GLuint Orientation;     /* Polygon orientation: 0=front, 1=back face */
  866.  
  867.     GLboolean NeedNormals;     /* Are vertex normal vectors needed? */
  868.         GLboolean FastDrawPixels;/* Use optimized glDrawPixels? */
  869.         GLboolean MutablePixels; /* Can rasterization change pixel's color? */
  870.         GLboolean MonoPixels;    /* Are all pixels likely to be same color? */
  871.  
  872.         GLfloat RasterOffsetX;  /* added to window coords before rasterizing */
  873.         GLfloat RasterOffsetY;  /* added to window coords before rasterizing */
  874.  
  875.         GLint ColorShift;    /* If flat shading ColorShift=0 */
  876.                 /* If smooth shading ColorShift=FIXED_SHIFT */
  877.  
  878.     GLboolean RGBAflag;    /* Is frame buffer in RGBA mode, not CI? */
  879.     GLboolean DBflag;    /* Is frame buffer double buffered? */
  880.     GLint BufferWidth;    /* Width of frame buffer in pixels */
  881.     GLint BufferHeight;    /* Height of frame buffer in pixels */
  882.  
  883.     GLfloat RedScale;    /* These values are used to scale color */
  884.     GLfloat GreenScale;    /* components from the range [0,1] to */
  885.     GLfloat BlueScale;    /* integer values.  It should be the case */
  886.     GLfloat AlphaScale;    /* that: scale = 2^bits - 1 where bits is */
  887.                 /* the number of bits for the component */
  888.                 /* in the frame buffer. */
  889.         GLboolean EightBitColor;/* TRUE if all the above scales are 255.0 */
  890.  
  891. #ifdef FUTURE
  892.         /* Ancillary buffers */
  893.         GLint DepthBufferBits;        /* really just true/false */
  894.         GLint AccumBufferBits;        /* really just true/false */
  895.         GLint StencilBufferBits;    /* really just true/false */
  896. #endif
  897.  
  898.     /* Special buffers (BS = BufferWidth * BufferHeight): */
  899.     GLdepth *DepthBuffer;      /* Zbuffer: array [BS] of depth values */
  900.     GLstencil *StencilBuffer; /* Stencil buffer: array [BS] of ubytes */
  901.     GLaccum *AccumBuffer;      /* Acc. buffer: array [4*BS] of components */
  902.  
  903.         /* Sofware alpha planes: */
  904.         GLboolean FrontAlphaEnabled;
  905.         GLboolean BackAlphaEnabled;
  906.         GLubyte *FrontAlphaBuffer;
  907.         GLubyte *BackAlphaBuffer;
  908.         GLubyte *AlphaBuffer;    /* Points to front or back alpha buffer */
  909.  
  910.     GLenum ErrorValue;
  911.  
  912.     /* Current Primitive functions */
  913.     void (*VertexFunc)( GLfloat x, GLfloat y, GLfloat z, GLfloat w );
  914.         points_func PointsFunc;
  915.         line_func LineFunc;
  916. #ifdef MONDELLO
  917.         line_func LineFunc2;
  918. #endif
  919.         polygon_func PolygonFunc;
  920.         polygon_func AuxPolygonFunc;
  921.         triangle_func TriangleFunc;
  922.  
  923. #ifdef PROFILE
  924.         /* Performance measurments */
  925.         GLuint BeginEndCount;    /* number of glBegin/glEnd pairs */
  926.         GLdouble BeginEndTime;    /* seconds spent between glBegin/glEnd */
  927.         GLuint VertexCount;    /* number of vertices processed */
  928.         GLdouble VertexTime;    /* total time in seconds */
  929.         GLuint PointCount;    /* number of points rendered */
  930.         GLdouble PointTime;    /* total time in seconds */
  931.         GLuint LineCount;    /* number of lines rendered */
  932.         GLdouble LineTime;    /* total time in seconds */
  933.         GLuint PolygonCount;    /* number of polygons rendered */
  934.         GLdouble PolygonTime;    /* total time in seconds */
  935.         GLuint ClearCount;    /* number of glClear calls */
  936.         GLdouble ClearTime;    /* seconds spent in glClear */
  937.         GLuint SwapCount;    /* number of swap-buffer calls */
  938.         GLdouble SwapTime;    /* seconds spent in swap-buffers */
  939. #endif
  940. };
  941.  
  942.  
  943.  
  944.  
  945. extern struct gl_context CC;
  946.  
  947.  
  948.  
  949. /*
  950.  * Context creation, initialization, etc.
  951.  */
  952.  
  953. extern void gl_initialize_context( struct gl_context *c );
  954.  
  955. /*
  956. extern struct gl_context *gl_new_context( struct gl_context *shareList );
  957. */
  958.  
  959. extern struct gl_context *
  960. gl_new_context( GLboolean rgb_flag,
  961.                 GLfloat redscale,
  962.                 GLfloat greenscale,
  963.                 GLfloat bluescale,
  964.                 GLfloat alphascale,
  965.                 GLboolean db_flag,
  966.                 struct gl_context *shareList );
  967.  
  968. /*
  969.  * FUTURE CHANGES:
  970.  *   New args for requesting alpha buffer, stencil buffer, and accum buffer.
  971.  */
  972. #ifdef FUTURE
  973. extern struct gl_context *
  974. gl_new_context( GLboolean rgb_flag,
  975.                 GLboolean alpha_flag,
  976.                 GLboolean db_flag,
  977.                 GLint depth_size,
  978.                 GLint stencil_size,
  979.                 GLint accum_size,
  980.                 GLfloat red_scale,
  981.                 GLfloat green_scale,
  982.                 GLfloat blue_scale,
  983.                 GLfloat alpha_scale,
  984.                 struct gl_context *share_list );
  985. #endif
  986.  
  987.  
  988. extern void gl_destroy_context( struct gl_context *c );
  989.  
  990. extern void gl_set_context( struct gl_context *c );
  991.  
  992. extern void gl_copy_context( struct gl_context *src, struct gl_context *dst,
  993.                  GLuint mask );
  994.  
  995.  
  996.  
  997. /*
  998.  * Miscellaneous
  999.  */
  1000.  
  1001. extern void gl_error( GLenum error, char *s );
  1002.  
  1003.  
  1004. extern void gl_update_state( void );
  1005.  
  1006.  
  1007.  
  1008. #ifdef PROFILE
  1009. extern GLdouble gl_time( void );
  1010. #endif
  1011.  
  1012.  
  1013. #endif
  1014.