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

  1. /* $Id: vb.h,v 1.14 1996/05/08 16:48:04 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: vb.h,v $
  26.  * Revision 1.14  1996/05/08  16:48:04  brianp
  27.  * added Win2 field for Mondello driver per Peter McDermott
  28.  *
  29.  * Revision 1.13  1996/04/25  20:42:33  brianp
  30.  * increased VB_MAX to 480
  31.  *
  32.  * Revision 1.12  1995/12/30  01:02:15  brianp
  33.  * changed vertex colors from floating point to fixed point integers
  34.  *
  35.  * Revision 1.11  1995/12/20  15:25:50  brianp
  36.  * changed VB color indexes to GLuint
  37.  *
  38.  * Revision 1.10  1995/10/17  21:43:56  brianp
  39.  * updated a few comments because of new device driver
  40.  *
  41.  * Revision 1.9  1995/09/28  19:38:44  brianp
  42.  * replaced ClipFlag[] with Unclipped[]
  43.  *
  44.  * Revision 1.8  1995/09/25  19:24:33  brianp
  45.  * added per-vertex glMaterial data structures
  46.  *
  47.  * Revision 1.7  1995/09/22  16:48:55  brianp
  48.  * added AnyClipped and prototype Unclipped[[] and MonoColor fields to VB
  49.  *
  50.  * Revision 1.6  1995/09/13  14:48:18  brianp
  51.  * updated VB struct for "vectorized" draw.c
  52.  *
  53.  * Revision 1.5  1995/06/20  16:19:54  brianp
  54.  * unconditionally include integer win coord arrays
  55.  *
  56.  * Revision 1.4  1995/06/15  19:37:28  brianp
  57.  * added integer window coords arrays, an experiment
  58.  *
  59.  * Revision 1.3  1995/06/02  13:55:34  brianp
  60.  * changed from MAX_VERTICES to VB_MAX and VB_SIZE
  61.  *
  62.  * Revision 1.2  1995/05/22  20:59:34  brianp
  63.  * Release 1.2
  64.  *
  65.  * Revision 1.1  1995/03/24  15:32:17  brianp
  66.  * Initial revision
  67.  *
  68.  */
  69.  
  70.  
  71. /*
  72.  * Vertex buffer:  vertices from glVertex* are accumulated here until
  73.  * the buffer is full or glEnd() is called.  Then the buffer is flushed
  74.  * (rendered) and reset.
  75.  */
  76.  
  77.  
  78. #ifndef VB_H
  79. #define VB_H
  80.  
  81.  
  82. #include "context.h"
  83.  
  84.  
  85.  
  86. /*
  87.  * Used in the bitmask for recording glMaterial calls between glBegin/glEnd:
  88.  */
  89. #define FRONT_AMBIENT_BIT     0x1
  90. #define BACK_AMBIENT_BIT      0x2
  91. #define FRONT_DIFFUSE_BIT     0x4
  92. #define BACK_DIFFUSE_BIT      0x8
  93. #define FRONT_SPECULAR_BIT   0x10
  94. #define BACK_SPECULAR_BIT    0x20
  95. #define FRONT_EMISSION_BIT   0x40
  96. #define BACK_EMISSION_BIT    0x80
  97. #define FRONT_SHININESS_BIT 0x100
  98. #define BACK_SHININESS_BIT  0x200
  99. #define FRONT_INDEXES_BIT   0x400
  100. #define BACK_INDEXES_BIT    0x800
  101.  
  102.  
  103.  
  104. /* Flush VB when this number of vertices is accumulated:  (a multiple of 12) */
  105. #define VB_MAX 480
  106.  
  107. /* Arrays must also accomodate new vertices from clipping: */
  108. #define VB_SIZE  (VB_MAX + 2 * (6 + MAX_CLIP_PLANES))
  109.  
  110.  
  111. /*
  112.  * Vertex buffer (not saved/restored on context switches)
  113.  */
  114. struct vertex_buffer {
  115.         GLfloat Obj[VB_SIZE][4];        /* Object coords */
  116.     GLfloat Eye[VB_SIZE][4];    /* Eye coords */
  117.     GLfloat Clip[VB_SIZE][4];    /* Clip coords */
  118.     GLfloat Win[VB_SIZE][3];    /* Window coords */
  119. #ifdef MONDELLO
  120.         GLint   Win2[VB_SIZE][3];       /* Integer window coords -PFM */
  121.                                         /* NOTE: on mondello uses correctly */
  122. #endif
  123.  
  124.         GLfloat Normal[VB_SIZE][3];     /* Normal vectors */
  125.  
  126.         /* Colors are values in [0..RedScale], [0..GreenScale], [0,BlueScale],
  127.          * [0,AlphScale] and stored as integers if flat shading or as fixed
  128.          * point numbers if smooth shading.
  129.          */
  130.     GLfixed Fcolor[VB_SIZE][4];    /* Front colors */
  131.     GLfixed Bcolor[VB_SIZE][4];    /* Back colors */
  132.     GLfixed (*Color)[4];        /* == Fcolor or Bcolor */
  133.  
  134.     GLuint Findex[VB_SIZE];         /* Front color indexes */
  135.     GLuint Bindex[VB_SIZE];         /* Back color indexes */
  136.     GLuint *Index;            /* == Findex or Bindex */
  137.  
  138.     GLboolean Edgeflag[VB_SIZE];    /* Polygon edge flag */
  139.  
  140.         GLfloat TexCoord[VB_SIZE][4];   /* Texture coords */
  141.  
  142.         GLubyte Unclipped[VB_SIZE];    /* 0=clipped, 1=not clipped */
  143.         GLboolean AnyClipped;        /* Were any vertices clipped? */
  144.  
  145.     GLuint Start;            /* First vertex to process */
  146.     GLuint Count;            /* Number of vertexes in buffer */
  147.     GLuint Free;            /* Next empty position for clipping */
  148.  
  149.         /* to handle glMaterial calls inside glBegin/glEnd: */
  150.     GLboolean MaterialChanges;    /* True if any glMaterial was called */
  151.         GLuint MaterialMask[VB_SIZE];    /* What material values to change */
  152.     struct gl_material Material[VB_SIZE][2]; /* New material settings */
  153.  
  154.         GLboolean MonoColor;        /* Do all vertices have same color? */
  155.  
  156. #ifdef LEAVEOUT
  157.     /* NEW for 1.2.? */
  158.     GLint WinX[VB_SIZE];    /* Scaled integer window coords */
  159.     GLint WinY[VB_SIZE];
  160.     GLint WinZ[VB_SIZE];
  161. #endif
  162. };
  163.  
  164.  
  165.  
  166.  
  167. extern struct vertex_buffer VB;
  168.  
  169.  
  170. extern void gl_init_vb( void );
  171.  
  172.  
  173. #endif
  174.  
  175.