-/* $Id: gl.h,v 1.49 2000/12/09 20:36:18 brianp Exp $ */
+/* $Id: gl.h,v 1.50 2001/01/06 22:46:13 gareth Exp $ */
/*
* Mesa 3-D graphics library
#endif /* GL_MESA_resize_bufffers */
+
+/*
+ * 220. GL_EXT_texture_env_dot3
+ */
+#ifndef GL_EXT_texture_env_dot3
+#define GL_EXT_texture_env_dot3 1
+
+#define GL_DOT3_RGB_EXT 0x8740
+#define GL_DOT3_RGBA_EXT 0x8741
+
+#endif /* GL_EXT_texture_env_dot3 */
+
+
#else /* GL_GLEXT_LEGACY */
#include <GL/glext.h>
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
+**
** http://oss.sgi.com/projects/FreeB
-**
+**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
+**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
-**
+**
** Additional Notice Provisions: This software was created using the
** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
** not been independently verified as being compliant with the OpenGL(R)
#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF
#endif
+#ifndef GL_EXT_texture_env_dot3
+#define GL_DOT3_RGB_EXT 0x8740
+#define GL_DOT3_RGBA_EXT 0x8741
+#endif
+
/*************************************************************/
-/* $Id: enums.c,v 1.9 2000/06/27 21:42:13 brianp Exp $ */
+/* $Id: enums.c,v 1.10 2001/01/06 22:46:13 gareth Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.3
- *
+ *
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
#endif
-typedef struct {
- const char *c;
- int n;
+typedef struct {
+ const char *c;
+ int n;
} enum_elt;
-enum_elt all_enums[] =
+enum_elt all_enums[] =
{
/* Boolean values */
{ "GL_FALSE", 0 },
{ "GL_INTERPOLATE_EXT", 0x8575 },
{ "GL_CONSTANT_EXT", 0x8576 },
{ "GL_PRIMARY_COLOR_EXT", 0x8577 },
- { "GL_PREVIOUS_EXT", 0x8578 }
+ { "GL_PREVIOUS_EXT", 0x8578 },
+
+ /* GL_EXT_texture_env_dot3 */
+ { "GL_DOT3_RGB_EXT", 0x8740 },
+ { "GL_DOT3_RGBA_EXT", 0x8741 },
};
static enum_elt **index1 = 0;
static int sorted = 0;
-static int compar_name( const enum_elt *a, const enum_elt *b )
+static int compar_name( const enum_elt *a, const enum_elt *b )
{
return strcmp(a->c, b->c);
}
/* note the extra level of indirection
*/
-static int compar_nr( const enum_elt **a, const enum_elt **b )
+static int compar_nr( const enum_elt **a, const enum_elt **b )
{
return (*a)->n - (*b)->n;
}
index1 = (enum_elt **)MALLOC( Elements(all_enums) * sizeof(enum_elt *) );
sorted = 1;
- qsort( all_enums, Elements(all_enums), sizeof(*all_enums),
+ qsort( all_enums, Elements(all_enums), sizeof(*all_enums),
(cfunc) compar_name );
- for (i = 0 ; i < Elements(all_enums) ; i++)
+ for (i = 0 ; i < Elements(all_enums) ; i++)
index1[i] = &all_enums[i];
qsort( index1, Elements(all_enums), sizeof(*index1), (cfunc) compar_nr );
enum_elt tmp;
enum_elt *e;
- if (!sorted)
+ if (!sorted)
sort_enums();
- if (!symbol)
+ if (!symbol)
return 0;
tmp.c = symbol;
- e = (enum_elt *)bsearch( &tmp, all_enums, Elements(all_enums),
+ e = (enum_elt *)bsearch( &tmp, all_enums, Elements(all_enums),
sizeof(*all_enums), (cfunc) compar_name );
return e ? e->n : -1;
{
enum_elt tmp, *e, **f;
- if (!sorted)
+ if (!sorted)
sort_enums();
tmp.n = nr;
e = &tmp;
- f = (enum_elt **)bsearch( &e, index1, Elements(all_enums),
+ f = (enum_elt **)bsearch( &e, index1, Elements(all_enums),
sizeof(*index1), (cfunc) compar_nr );
return f ? (*f)->c : "(unknown)";
for (i = 0 ; i < Elements(test) ; i++) {
int d = gl_lookup_enum_by_name( test[i] );
printf("%s --> %d --> %s\n", test[i], d, gl_lookup_enum_by_nr( d ));
- }
+ }
}
#endif
-/* $Id: extensions.c,v 1.43 2000/12/08 00:20:15 brianp Exp $ */
+/* $Id: extensions.c,v 1.44 2001/01/06 22:46:13 gareth Exp $ */
/*
* Mesa 3-D graphics library
{ OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) },
{ ON, "GL_EXT_texture_env_add", F(EXT_texture_env_add) },
{ OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) },
+ { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) },
{ ON, "GL_EXT_texture_object", F(EXT_texture_object) },
{ ON, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) },
{ ON, "GL_EXT_vertex_array", 0 },
gl_extensions_enable(ctx, "GL_ARB_texture_cube_map");
gl_extensions_enable(ctx, "GL_EXT_bgra");
gl_extensions_enable(ctx, "GL_EXT_texture_env_combine");
+ gl_extensions_enable(ctx, "GL_EXT_texture_env_dot3");
gl_extensions_enable(ctx, "GL_HP_occlusion_test");
gl_extensions_enable(ctx, "GL_NV_blend_square");
gl_extensions_enable(ctx, "GL_MESA_sprite_point");
-/* $Id: mtypes.h,v 1.10 2001/01/05 02:26:48 keithw Exp $ */
+/* $Id: mtypes.h,v 1.11 2001/01/06 22:46:13 gareth Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
- *
+ *
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
#ifndef TYPES_H
#define TYPES_H
-
+
#include "glheader.h"
#include "config.h" /* Hardwired parameters */
GLfloat _VP_inf_norm[3]; /* Norm direction to infinite light */
GLfloat _h_inf_norm[3]; /* Norm( _VP_inf_norm + <0,0,1> ) */
GLfloat _NormDirection[4]; /* normalized spotlight direction */
- GLfloat _VP_inf_spot_attenuation;
+ GLfloat _VP_inf_spot_attenuation;
GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /* to replace a pow() call */
GLfloat _MatAmbient[2][3]; /* material ambient * light ambient */
};
-struct gl_material
+struct gl_material
{
GLfloat Ambient[4];
GLfloat Diffuse[4];
GLuint Index; /* Current color index */
GLboolean EdgeFlag; /* Current edge flag */
GLfloat Texcoord[MAX_TEXTURE_UNITS][4]; /* Current texture coords */
-
+
/* These values are always valid.
*/
GLfloat RasterPos[4]; /* Current raster position */
#define ENABLE_TEXMAT1 0x200
#define ENABLE_TEXMAT2 0x400
#define ENABLE_TEXMAT3 0x800
-#define ENABLE_TEXMAT4 0x1000
+#define ENABLE_TEXMAT4 0x1000
#define ENABLE_TEXMAT5 0x2000
#define ENABLE_TEXMAT6 0x4000
#define ENABLE_TEXMAT7 0x8000
GLuint _GenFlags; /* for texgen */
struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
-
+
struct gl_texture_object *Proxy1D;
struct gl_texture_object *Proxy2D;
struct gl_texture_object *Proxy3D;
GLfloat u1, u2, du; /* u1, u2, 1.0/(u2-u1) */
GLfloat *Points; /* Points to contiguous control points */
};
-
+
/*
* 2-D Evaluator control points
GLboolean EXT_texture_compression_s3tc;
GLboolean EXT_texture_env_add;
GLboolean EXT_texture_env_combine;
+ GLboolean EXT_texture_env_dot3;
GLboolean EXT_texture_object;
GLboolean EXT_texture_lod_bias;
GLboolean EXT_vertex_array_set;
/* Bits to track array state changes (also used to summarize array enabled)
*/
-#define _NEW_ARRAY_VERTEX 0x1
-#define _NEW_ARRAY_COLOR 0x2
-#define _NEW_ARRAY_NORMAL 0x4
-#define _NEW_ARRAY_INDEX 0x8
+#define _NEW_ARRAY_VERTEX 0x1
+#define _NEW_ARRAY_COLOR 0x2
+#define _NEW_ARRAY_NORMAL 0x4
+#define _NEW_ARRAY_INDEX 0x8
#define _NEW_ARRAY_EDGEFLAG 0x10
#define _NEW_ARRAY_SECONDARYCOLOR 0x20
#define _NEW_ARRAY_FOGCOORD 0x40
-#define _NEW_ARRAY_TEXCOORD_0 0x80
+#define _NEW_ARRAY_TEXCOORD_0 0x80
#define _NEW_ARRAY_TEXCOORD_1 0x100
#define _NEW_ARRAY_TEXCOORD_2 0x200
#define _NEW_ARRAY_TEXCOORD_3 0x400
-#define _NEW_ARRAY_TEXCOORD_4 0x800
+#define _NEW_ARRAY_TEXCOORD_4 0x800
#define _NEW_ARRAY_TEXCOORD_5 0x1000
#define _NEW_ARRAY_TEXCOORD_6 0x2000
#define _NEW_ARRAY_TEXCOORD_7 0x4000
#define DD_POINT_ATTEN 0x10000
#define DD_TRI_CULL_FRONT_BACK 0x400000 /* special case on some hw */
#define DD_Z_NEVER 0x800000 /* special case on some hw */
-#define DD_STENCIL 0x1000000
+#define DD_STENCIL 0x1000000
/* Define the state changes under which each of these bits might change
*/
#define _DD_NEW_POINT_SIZE _NEW_POINT
#define _DD_NEW_POINT_ATTEN _NEW_POINT
#define _DD_NEW_LIGHTING_CULL _NEW_LIGHT
-#define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
+#define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
#define _DD_NEW_Z_NEVER _NEW_DEPTH
#define _DD_NEW_STENCIL _NEW_STENCIL
#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT| \
_NEW_TEXTURE| \
_NEW_POINT| \
- _NEW_MODELVIEW)
+ _NEW_MODELVIEW)
#define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT| \
_NEW_TEXTURE)
/*
- * The library context:
+ * The library context:
*/
struct __GLcontextRec {
/*
struct _glapi_table *Save; /* Display list save funcs */
struct _glapi_table *Exec; /* Execute funcs */
struct _glapi_table *CurrentDispatch; /* == Save or Exec !! */
-
+
GLboolean ExecPrefersFloat; /* What preference for color conversion? */
GLboolean SavePrefersFloat;
/* Should 3Dfx Glide driver catch signals? */
GLboolean CatchSignals;
-
+
/* For debugging/development only */
GLboolean NoRaster;
GLboolean FirstTimeCurrent;
#ifdef MESA_DEBUG
-extern int MESA_VERBOSE;
+extern int MESA_VERBOSE;
extern int MESA_DEBUG_FLAGS;
#else
# define MESA_VERBOSE 0
VERBOSE_API = 0x40,
VERBOSE_DISPLAY_LIST = 0x200,
VERBOSE_LIGHTING = 0x400
-};
+};
enum _debug {
DEBUG_ALWAYS_FLUSH = 0x1
-};
+};
-/* $Id: texstate.c,v 1.26 2000/12/26 05:09:29 keithw Exp $ */
+/* $Id: texstate.c,v 1.27 2001/01/06 22:46:13 gareth Exp $ */
/*
* Mesa 3-D graphics library
}
if (texUnit->EnvMode == mode)
- return;
+ return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->EnvMode = mode;
break;
COPY_4FV(texUnit->EnvColor, tmp);
break;
}
- case GL_COMBINE_RGB_EXT:
+ case GL_COMBINE_RGB_EXT:
if (ctx->Extensions.EXT_texture_env_combine) {
GLenum mode = (GLenum) (GLint) *param;
switch (mode) {
case GL_ADD_SIGNED_EXT:
case GL_INTERPOLATE_EXT:
break;
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGBA_EXT:
+ if (!ctx->Extensions.EXT_texture_env_dot3) {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
+ return;
+ }
+ break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
return;
}
if (texUnit->CombineModeRGB == mode)
- return;
+ return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->CombineModeRGB = mode;
}
gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
return;
}
- case GL_COMBINE_ALPHA_EXT:
+ case GL_COMBINE_ALPHA_EXT:
if (ctx->Extensions.EXT_texture_env_combine) {
GLenum mode = (GLenum) (GLint) *param;
switch (mode) {
case GL_ADD_SIGNED_EXT:
case GL_INTERPOLATE_EXT:
if (texUnit->CombineModeA == mode)
- return;
+ return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->CombineModeA = mode;
break;
gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(coord)" );
return;
}
-
+
if (ctx->Driver.TexGen)
ctx->Driver.TexGen( ctx, coord, pname, params );
}
-/* $Id: s_texture.c,v 1.7 2001/01/05 21:28:31 brianp Exp $ */
+/* $Id: s_texture.c,v 1.8 2001/01/06 22:46:13 gareth Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
- *
+ *
* Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
}
-
+
/*
* Bitflags for texture border color sampling.
#define PROD(A,B) ( (GLuint)(A) * ((GLuint)(B)+1) )
+#define S_PROD(A,B) ( (GLint)(A) * ((GLint)(B)+1) )
static INLINE void
_mesa_texture_combine(const GLcontext *ctx,
}
}
break;
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGBA_EXT:
+ {
+ const GLubyte (*arg0)[4] = (const GLubyte (*)[4]) argRGB[0];
+ const GLubyte (*arg1)[4] = (const GLubyte (*)[4]) argRGB[1];
+ /* ATI's EXT extension has a constant scale by 4. The ARB
+ * one will likely remove this restriction, and we should
+ * drop the EXT extension in favour of the ARB one.
+ */
+ for (i = 0; i < n; i++) {
+ GLint dot = (S_PROD((GLint)arg0[i][RCOMP] - 128,
+ (GLint)arg1[i][RCOMP] - 128) +
+ S_PROD((GLint)arg0[i][GCOMP] - 128,
+ (GLint)arg1[i][GCOMP] - 128) +
+ S_PROD((GLint)arg0[i][BCOMP] - 128,
+ (GLint)arg1[i][BCOMP] - 128)) >> 6;
+ rgba[i][RCOMP] = (GLubyte) CLAMP(dot, 0, 255);
+ rgba[i][GCOMP] = (GLubyte) CLAMP(dot, 0, 255);
+ rgba[i][BCOMP] = (GLubyte) CLAMP(dot, 0, 255);
+ }
+ }
+ break;
default:
gl_problem(NULL, "invalid combine mode");
}
default:
gl_problem(NULL, "invalid combine mode");
}
+
+ /* Fix the alpha component for GL_DOT3_RGBA_EXT combining.
+ */
+ if (textureUnit->CombineModeRGB == GL_DOT3_RGBA_EXT) {
+ for (i = 0; i < n; i++) {
+ rgba[i][ACOMP] = rgba[i][RCOMP];
+ }
+ }
}
#undef PROD
/* Sample the texture. */
SWRAST_CONTEXT(ctx)->TextureSample[texUnit]( ctx, texUnit,
- textureUnit->_Current,
- n, s, t, r,
+ textureUnit->_Current,
+ n, s, t, r,
lambda, texel );
apply_texture( ctx, textureUnit, n, primary_rgba, texel, rgba );