home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 5 / MA_Cover_5.iso / ppc / mesa / src / vb.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-07  |  4.9 KB  |  164 lines

  1. /* $Id: vb.h,v 1.12 1997/08/13 02:07:17 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.4
  6.  * Copyright (C) 1995-1997  Brian Paul
  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.12  1997/08/13 02:07:17  brianp
  27.  * set VB_MAX to 72 is using Glide for better performance (David Bucciarelli)
  28.  *
  29.  * Revision 1.11  1997/06/21 21:30:59  brianp
  30.  * updated many comments
  31.  *
  32.  * Revision 1.10  1997/06/20 02:08:23  brianp
  33.  * changed color components from GLfixed to GLubyte
  34.  *
  35.  * Revision 1.9  1997/05/09 22:41:55  brianp
  36.  * replaced gl_init_vb() with gl_alloc_vb()
  37.  *
  38.  * Revision 1.8  1997/04/24 00:29:36  brianp
  39.  * added TexCoordSize
  40.  *
  41.  * Revision 1.7  1997/04/20 15:59:30  brianp
  42.  * removed VERTEX2_BIT stuff
  43.  *
  44.  * Revision 1.6  1997/04/12 16:21:35  brianp
  45.  * added CLIP_* flags and gl_init_vb()
  46.  *
  47.  * Revision 1.5  1997/04/07 02:59:59  brianp
  48.  * added VertexSizeMask
  49.  *
  50.  * Revision 1.4  1997/04/02 03:13:12  brianp
  51.  * removed Unclipped[], added ClipMask[], ClipOrMask, ClipAndMask
  52.  *
  53.  * Revision 1.3  1996/12/18 19:59:44  brianp
  54.  * removed the material bitmask constants
  55.  *
  56.  * Revision 1.2  1996/09/27 01:31:17  brianp
  57.  * added gl_init_vb() prototype
  58.  *
  59.  * Revision 1.1  1996/09/13 01:38:16  brianp
  60.  * Initial revision
  61.  *
  62.  */
  63.  
  64.  
  65. /*
  66.  * OVERVIEW:  The vertices defined between glBegin() and glEnd()
  67.  * are accumulated in the vertex buffer.  When either the
  68.  * vertex buffer becomes filled or glEnd() is called, we must flush
  69.  * the buffer.  That is, we apply the vertex transformations, compute
  70.  * lighting, fog, texture coordinates etc.  Then, we can render the
  71.  * vertices as points, lines or polygons by calling the gl_render_vb()
  72.  * function in render.c
  73.  *
  74.  */
  75.  
  76.  
  77. #ifndef VB_H
  78. #define VB_H
  79.  
  80.  
  81. #include "types.h"
  82.  
  83.  
  84.  
  85. /* Flush VB when this number of vertices is accumulated:  (a multiple of 12) */
  86. #ifdef FX
  87. #define VB_MAX 72   /* better performance */
  88. #else
  89. #define VB_MAX 480
  90. #endif
  91.  
  92. /* Arrays must also accomodate new vertices from clipping: */
  93. #define VB_SIZE  (VB_MAX + 2 * (6 + MAX_CLIP_PLANES))
  94.  
  95.  
  96. /* Bit values for VertexSizeMask, below. */
  97. /*#define VERTEX2_BIT  1*/
  98. #define VERTEX3_BIT  2
  99. #define VERTEX4_BIT  4
  100.  
  101.  
  102.  
  103. struct vertex_buffer {
  104.    GLfloat Obj[VB_SIZE][4];     /* Object coords */
  105.    GLfloat Eye[VB_SIZE][4];     /* Eye coords */
  106.    GLfloat Clip[VB_SIZE][4];    /* Clip coords */
  107.    GLfloat Win[VB_SIZE][3];     /* Window coords */
  108.  
  109.    GLfloat Normal[VB_SIZE][3];  /* Normal vectors */
  110.  
  111.    GLubyte Fcolor[VB_SIZE][4];  /* Front colors (RGBA) */
  112.    GLubyte Bcolor[VB_SIZE][4];  /* Back colors (RGBA) */
  113.    GLubyte (*Color)[4];         /* == Fcolor or Bcolor */
  114.  
  115.    GLuint Findex[VB_SIZE];      /* Front color indexes */
  116.    GLuint Bindex[VB_SIZE];      /* Back color indexes */
  117.    GLuint *Index;               /* == Findex or Bindex */
  118.  
  119.    GLboolean Edgeflag[VB_SIZE]; /* Polygon edge flags */
  120.  
  121.    GLfloat TexCoord[VB_SIZE][4];/* Texture coords */
  122.  
  123.    GLubyte ClipMask[VB_SIZE];   /* bitwise-OR of CLIP_* values, below */
  124.    GLubyte ClipOrMask;          /* bitwise-OR of all ClipMask[] values */
  125.    GLubyte ClipAndMask;         /* bitwise-AND of all ClipMask[] values */
  126.    GLboolean STORM_PADDING_1[2];
  127.  
  128.    GLuint Start;                /* First vertex to process */
  129.    GLuint Count;                /* Number of vertexes in buffer */
  130.    GLuint Free;                 /* Next empty position for clipping */
  131.  
  132.    GLuint VertexSizeMask;       /* Bitwise-or of VERTEX[234]_BIT */
  133.    GLuint TexCoordSize;         /* Either 2 or 4 */
  134.    GLboolean MonoColor;         /* Do all vertices have same color? */
  135.    GLboolean MonoNormal;        /* Do all vertices have same normal? */
  136.    GLboolean MonoMaterial;      /* Do all vertices have same material? */
  137.  
  138.    /* to handle glMaterial calls inside glBegin/glEnd: */
  139.    GLuint MaterialMask[VB_SIZE];        /* Which material values to change */
  140.    struct gl_material Material[VB_SIZE][2]; /* New material values */
  141. };
  142.  
  143.  
  144.  
  145. /* Vertex buffer clipping flags */
  146. #define CLIP_RIGHT_BIT   0x01
  147. #define CLIP_LEFT_BIT    0x02
  148. #define CLIP_TOP_BIT     0x04
  149. #define CLIP_BOTTOM_BIT  0x08
  150. #define CLIP_NEAR_BIT    0x10
  151. #define CLIP_FAR_BIT     0x20
  152. #define CLIP_USER_BIT    0x40
  153. #define CLIP_ALL_BITS    0x3f
  154.  
  155. #define CLIP_ALL   1
  156. #define CLIP_NONE  2
  157. #define CLIP_SOME  3
  158.  
  159.  
  160. extern struct vertex_buffer *gl_alloc_vb(void);
  161.  
  162.  
  163. #endif
  164.