| 1 |
/* $Id: vertex.c,v 1.2 2000/10/27 15:21:40 mholst Exp $ */ |
| 2 |
|
| 3 |
/* |
| 4 |
* Mesa 3-D graphics library |
| 5 |
* Version: 2.0 |
| 6 |
* Copyright (C) 1995-1996 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 |
#include <assert.h> |
| 24 |
#include "draw.h" |
| 25 |
#include "light.h" |
| 26 |
#include "dlist.h" |
| 27 |
#include "macros.h" |
| 28 |
#include "types.h" |
| 29 |
#include "vb.h" |
| 30 |
#include "vertex.h" |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
#ifdef DEBUG |
| 35 |
# define ASSERT(X) assert(X) |
| 36 |
#else |
| 37 |
# define ASSERT(X) |
| 38 |
#endif |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
void gl_Normal3f( GLcontext *ctx, GLfloat nx, GLfloat ny, GLfloat nz ) |
| 43 |
{ |
| 44 |
ctx->Current.Normal[0] = nx; |
| 45 |
ctx->Current.Normal[1] = ny; |
| 46 |
ctx->Current.Normal[2] = nz; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
void gl_Normal3fv( GLcontext *ctx, const GLfloat *n ) |
| 52 |
{ |
| 53 |
ctx->Current.Normal[0] = n[0]; |
| 54 |
ctx->Current.Normal[1] = n[1]; |
| 55 |
ctx->Current.Normal[2] = n[2]; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
void gl_Indexf( GLcontext *ctx, GLfloat c ) |
| 62 |
{ |
| 63 |
ctx->Current.Index = (GLuint) (GLint) c; |
| 64 |
ctx->VB->MonoColor = GL_FALSE; |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
void gl_Indexi( GLcontext *ctx, GLint c ) |
| 69 |
{ |
| 70 |
ctx->Current.Index = (GLuint) c; |
| 71 |
ctx->VB->MonoColor = GL_FALSE; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
void gl_Color4f( GLcontext *ctx, |
| 78 |
GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) |
| 79 |
{ |
| 80 |
ctx->Current.IntColor[0] = red * ctx->Visual->RedScale; |
| 81 |
ctx->Current.IntColor[1] = green * ctx->Visual->GreenScale; |
| 82 |
ctx->Current.IntColor[2] = blue * ctx->Visual->BlueScale; |
| 83 |
ctx->Current.IntColor[3] = alpha * ctx->Visual->AlphaScale; |
| 84 |
ASSERT( !ctx->Light.ColorMaterialEnabled ); |
| 85 |
ctx->VB->MonoColor = GL_FALSE; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
/* glColor() which modifies (a) material(s) */ |
| 91 |
void gl_ColorMat4f( GLcontext *ctx, |
| 92 |
GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) |
| 93 |
{ |
| 94 |
GLfloat color[4]; |
| 95 |
ctx->Current.IntColor[0] = red * ctx->Visual->RedScale; |
| 96 |
ctx->Current.IntColor[1] = green * ctx->Visual->GreenScale; |
| 97 |
ctx->Current.IntColor[2] = blue * ctx->Visual->BlueScale; |
| 98 |
ctx->Current.IntColor[3] = alpha * ctx->Visual->AlphaScale; |
| 99 |
/* update material */ |
| 100 |
ASSERT( ctx->Light.ColorMaterialEnabled ); |
| 101 |
ASSIGN_4V( color, red, green, blue, alpha ); |
| 102 |
gl_set_material( ctx, ctx->Light.ColorMaterialBitmask, color ); |
| 103 |
ctx->VB->MonoColor = GL_FALSE; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
/* |
| 109 |
* Used when colors are not scaled to [0,255] |
| 110 |
*/ |
| 111 |
void gl_Color4ub( GLcontext *ctx, |
| 112 |
GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) |
| 113 |
{ |
| 114 |
ctx->Current.IntColor[0] = red * ctx->Visual->RedScale * (1.0F/255.0F); |
| 115 |
ctx->Current.IntColor[1] = green * ctx->Visual->GreenScale * (1.0F/255.0F); |
| 116 |
ctx->Current.IntColor[2] = blue * ctx->Visual->BlueScale * (1.0F/255.0F); |
| 117 |
ctx->Current.IntColor[3] = alpha * ctx->Visual->AlphaScale * (1.0F/255.0F); |
| 118 |
ASSERT( !ctx->Light.ColorMaterialEnabled ); |
| 119 |
ctx->VB->MonoColor = GL_FALSE; |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
/* |
| 124 |
* Used when colors are scaled to [0,255]. |
| 125 |
*/ |
| 126 |
void gl_Color4ub8bit( GLcontext *ctx, |
| 127 |
GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) |
| 128 |
{ |
| 129 |
ASSIGN_4V( ctx->Current.IntColor, red, green, blue, alpha ); |
| 130 |
ASSERT( !ctx->Light.ColorMaterialEnabled ); |
| 131 |
ctx->VB->MonoColor = GL_FALSE; |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
/* glColor() which modifies (a) material(s) */ |
| 137 |
void gl_ColorMat4ub( GLcontext *ctx, |
| 138 |
GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) |
| 139 |
{ |
| 140 |
GLfloat color[4]; |
| 141 |
if (ctx->Visual->EightBitColor) { |
| 142 |
ASSIGN_4V( ctx->Current.IntColor, red, green, blue, alpha ); |
| 143 |
} |
| 144 |
else { |
| 145 |
ctx->Current.IntColor[0] = red * ctx->Visual->RedScale * (1.0F/255.0F); |
| 146 |
ctx->Current.IntColor[1] = green * ctx->Visual->GreenScale * (1.0F/255.0F); |
| 147 |
ctx->Current.IntColor[2] = blue * ctx->Visual->BlueScale * (1.0F/255.0F); |
| 148 |
ctx->Current.IntColor[3] = alpha * ctx->Visual->AlphaScale * (1.0F/255.0F); |
| 149 |
} |
| 150 |
/* update material */ |
| 151 |
ASSERT( ctx->Light.ColorMaterialEnabled ); |
| 152 |
color[0] = red * (1.0F/255.0F); |
| 153 |
color[1] = green * (1.0F/255.0F); |
| 154 |
color[2] = blue * (1.0F/255.0F); |
| 155 |
color[3] = alpha * (1.0F/255.0F); |
| 156 |
gl_set_material( ctx, ctx->Light.ColorMaterialBitmask, color ); |
| 157 |
ctx->VB->MonoColor = GL_FALSE; |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
void gl_TexCoord4f( GLcontext *ctx, |
| 164 |
GLfloat s, GLfloat t, GLfloat r, GLfloat q ) |
| 165 |
{ |
| 166 |
ctx->Current.TexCoord[0] = s; |
| 167 |
ctx->Current.TexCoord[1] = t; |
| 168 |
ctx->Current.TexCoord[2] = r; |
| 169 |
ctx->Current.TexCoord[3] = q; |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
void gl_EdgeFlag( GLcontext *ctx, GLboolean flag ) |
| 175 |
{ |
| 176 |
ctx->Current.EdgeFlag = flag; |
| 177 |
} |
| 178 |
|