summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2000-02-25 03:55:39 +0000
committerKeith Whitwell <[email protected]>2000-02-25 03:55:39 +0000
commite828bc8f61736f6ba2eff7b2d3dd24056c8b86e0 (patch)
tree7e8ff2fef8cec0988b77074b9591e692464931a9
parent8ceb5c34dd4c0da73f9cb58b803a84e17e545c4b (diff)
Fog coordinate stage which drivers may use to replace standard fogging
mechanism. LogicOp state change callback
-rw-r--r--src/mesa/drivers/x11/glxapi.c4
-rw-r--r--src/mesa/main/attrib.c6
-rw-r--r--src/mesa/main/clip.c83
-rw-r--r--src/mesa/main/dd.h3
-rw-r--r--src/mesa/main/dlist.c9
-rw-r--r--src/mesa/main/extensions.c7
-rw-r--r--src/mesa/main/fog.c85
-rw-r--r--src/mesa/main/lines.c8
-rw-r--r--src/mesa/main/varray.c5
9 files changed, 165 insertions, 45 deletions
diff --git a/src/mesa/drivers/x11/glxapi.c b/src/mesa/drivers/x11/glxapi.c
index f46e36062b2..05b484d52ac 100644
--- a/src/mesa/drivers/x11/glxapi.c
+++ b/src/mesa/drivers/x11/glxapi.c
@@ -1,4 +1,4 @@
-/* $Id: glxapi.c,v 1.11 2000/02/23 23:09:12 brianp Exp $ */
+/* $Id: glxapi.c,v 1.12 2000/02/25 03:55:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -170,7 +170,7 @@ XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *list)
void glXCopyContext(Display *dpy, GLXContext src, GLXContext dst,
- unsigned long mask)
+ GLuint mask)
{
struct _glxapi_table *t = get_dispatch(dpy);
if (!t)
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index d7a6ad74253..57489b59f23 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.15 2000/02/02 22:03:31 brianp Exp $ */
+/* $Id: attrib.c,v 1.16 2000/02/25 03:55:39 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -423,6 +423,7 @@ _mesa_PopAttrib(void)
GLubyte oldAlphaRef = ctx->Color.AlphaRef;
GLenum oldBlendSrc = ctx->Color.BlendSrcRGB;
GLenum oldBlendDst = ctx->Color.BlendDstRGB;
+ GLenum oldLogicOp = ctx->Color.LogicOp;
MEMCPY( &ctx->Color, attr->data,
sizeof(struct gl_colorbuffer_attrib) );
if (ctx->Color.DrawBuffer != oldDrawBuffer) {
@@ -438,6 +439,9 @@ _mesa_PopAttrib(void)
ctx->Driver.BlendFunc)
(*ctx->Driver.BlendFunc)( ctx, ctx->Color.BlendSrcRGB,
ctx->Color.BlendDstRGB);
+ if (ctx->Color.LogicOp != oldLogicOp &&
+ ctx->Driver.LogicOpcode)
+ ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp );
}
break;
case GL_CURRENT_BIT:
diff --git a/src/mesa/main/clip.c b/src/mesa/main/clip.c
index acecb60b6bf..5aaf6c663c5 100644
--- a/src/mesa/main/clip.c
+++ b/src/mesa/main/clip.c
@@ -1,4 +1,4 @@
-/* $Id: clip.c,v 1.5 1999/11/11 01:22:25 brianp Exp $ */
+/* $Id: clip.c,v 1.6 2000/02/25 03:55:39 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -42,6 +42,15 @@
+#define CLIP_RGBA0 0x1
+#define CLIP_RGBA1 0x2
+#define CLIP_TEX0 0x4
+#define CLIP_TEX1 0x8
+#define CLIP_INDEX0 0x10
+#define CLIP_INDEX1 0x20
+#define CLIP_FOG_COORD 0x40
+
+
/* Linear interpolation between A and B: */
#define LINTERP( T, A, B ) ( (A) + (T) * ( (B) - (A) ) )
@@ -58,16 +67,7 @@ do { \
} while(0)
-
-
-#define CLIP_RGBA0 0x1
-#define CLIP_RGBA1 0x2
-#define CLIP_TEX0 0x4
-#define CLIP_TEX1 0x8
-#define CLIP_INDEX0 0x10
-#define CLIP_INDEX1 0x20
-
-static clip_interp_func clip_interp_tab[0x40];
+static clip_interp_func clip_interp_tab[0x80];
#define IND 0
#define NAME clip_nil
@@ -113,6 +113,50 @@ static clip_interp_func clip_interp_tab[0x40];
#define NAME clipINDEX0_INDEX1
#include "interp_tmp.h"
+#define IND (CLIP_FOG_COORD)
+#define NAME clip_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_RGBA0|CLIP_FOG_COORD)
+#define NAME clipRGBA0_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD)
+#define NAME clipRGBA0_RGBA1_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD)
+#define NAME clipTEX0_RGBA0_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD)
+#define NAME clipTEX0_RGBA0_RGBA1_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD)
+#define NAME clipTEX1_TEX0_RGBA0_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_TEX0|CLIP_FOG_COORD)
+#define NAME clipTEX0_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_FOG_COORD)
+#define NAME clipTEX1_TEX0_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD)
+#define NAME clipTEX1_TEX0_RGBA0_RGBA1_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_INDEX0|CLIP_FOG_COORD)
+#define NAME clipINDEX0_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_INDEX0|CLIP_INDEX1|CLIP_FOG_COORD)
+#define NAME clipINDEX0_INDEX1_FOG
+#include "interp_tmp.h"
+
@@ -353,6 +397,8 @@ void gl_update_clipmask( GLcontext *ctx )
mask |= CLIP_INDEX1;
}
+ if (ctx->FogMode == FOG_FRAGMENT && (ctx->TriangleCaps & DD_CLIP_FOG_COORD))
+ mask |= CLIP_FOG_COORD;
ctx->ClipInterpFunc = clip_interp_tab[mask];
ctx->poly_clip_tab = gl_poly_clip_tab[0];
@@ -448,11 +494,22 @@ void gl_init_clip(void)
clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0] = clipTEX1_TEX0_RGBA0;
clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1] =
clipTEX1_TEX0_RGBA0_RGBA1;
-
clip_interp_tab[CLIP_TEX0] = clipTEX0;
clip_interp_tab[CLIP_TEX1|CLIP_TEX0] = clipTEX1_TEX0;
-
clip_interp_tab[CLIP_INDEX0] = clipINDEX0;
clip_interp_tab[CLIP_INDEX0|CLIP_INDEX1] = clipINDEX0_INDEX1;
+
+ clip_interp_tab[CLIP_FOG_COORD] = clip_FOG;
+ clip_interp_tab[CLIP_RGBA0|CLIP_FOG_COORD] = clipRGBA0_FOG;
+ clip_interp_tab[CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD] = clipRGBA0_RGBA1_FOG;
+ clip_interp_tab[CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD] = clipTEX0_RGBA0_FOG;
+ clip_interp_tab[CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD] = clipTEX0_RGBA0_RGBA1_FOG;
+ clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD] = clipTEX1_TEX0_RGBA0_FOG;
+ clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD] =
+ clipTEX1_TEX0_RGBA0_RGBA1_FOG;
+ clip_interp_tab[CLIP_TEX0|CLIP_FOG_COORD] = clipTEX0_FOG;
+ clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_FOG_COORD] = clipTEX1_TEX0_FOG;
+ clip_interp_tab[CLIP_INDEX0|CLIP_FOG_COORD] = clipINDEX0_FOG;
+ clip_interp_tab[CLIP_INDEX0|CLIP_INDEX1|CLIP_FOG_COORD] = clipINDEX0_INDEX1_FOG;
}
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 63dcd6fdb38..423cdffc19e 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1,4 +1,4 @@
-/* $Id: dd.h,v 1.10 2000/02/17 20:53:48 brianp Exp $ */
+/* $Id: dd.h,v 1.11 2000/02/25 03:55:39 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -705,6 +705,7 @@ struct dd_function_table {
void (*Lightfv)(GLcontext *ctx, GLenum light,
GLenum pname, const GLfloat *params, GLint nparams );
void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
+ void (*LogicOpcode)(GLcontext *ctx, GLenum opcode);
void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode);
void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
void (*ShadeModel)(GLcontext *ctx, GLenum mode);
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 71c4996a1b2..672773f124a 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -1,4 +1,4 @@
-/* $Id: dlist.c,v 1.31 2000/02/24 22:04:03 brianp Exp $ */
+/* $Id: dlist.c,v 1.32 2000/02/25 03:55:39 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -3365,10 +3365,12 @@ static void execute_list( GLcontext *ctx, GLuint list )
(MESA_VERBOSE & VERBOSE_IMMEDIATE))
gl_print_cassette( (struct immediate *) n[1].data );
- if (0)
- fprintf(stderr, "Run cassette %d, rows %d..%d, beginstate %x\n",
+ if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) {
+ fprintf(stderr, "Run cassette %d, rows %d..%d, beginstate %x ",
IM->id,
IM->Start, IM->Count, IM->BeginState);
+ gl_print_vert_flags("orflag", IM->OrFlag);
+ }
gl_fixup_cassette( ctx, (struct immediate *) n[1].data );
gl_execute_cassette( ctx, (struct immediate *) n[1].data );
@@ -4789,6 +4791,7 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
((struct immediate *) n[1].data)->id,
n[2].ui,
n[3].ui);
+ gl_print_cassette( (struct immediate *) n[1].data );
break;
case OPCODE_CONTINUE:
fprintf(f,"DISPLAY-LIST-CONTINUE\n");
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 48b6dc90d48..b3b7a05382e 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -1,4 +1,4 @@
-/* $Id: extensions.c,v 1.17 2000/02/23 22:31:35 brianp Exp $ */
+/* $Id: extensions.c,v 1.18 2000/02/25 03:55:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -62,7 +62,7 @@ static struct { int enabled; const char *name; } default_extensions[] = {
{ DEFAULT_ON, "GL_EXT_texture3D" },
{ ALWAYS_ENABLED, "GL_MESA_window_pos" },
{ ALWAYS_ENABLED, "GL_MESA_resize_buffers" },
- { ALWAYS_ENABLED, "GL_EXT_shared_texture_palette" },
+ { DEFAULT_ON, "GL_EXT_shared_texture_palette" },
{ ALWAYS_ENABLED, "GL_EXT_rescale_normal" },
{ ALWAYS_ENABLED, "GL_EXT_abgr" },
{ ALWAYS_ENABLED, "GL_SGIS_texture_edge_clamp" },
@@ -72,10 +72,11 @@ static struct { int enabled; const char *name; } default_extensions[] = {
{ ALWAYS_ENABLED, "GL_NV_texgen_reflection" },
{ DEFAULT_ON, "GL_PGI_misc_hints" },
{ DEFAULT_ON, "GL_EXT_compiled_vertex_array" },
- { DEFAULT_OFF, "GL_EXT_vertex_array_set" },
{ DEFAULT_ON, "GL_EXT_clip_volume_hint" },
{ DEFAULT_ON, "GL_EXT_texture_env_add" },
{ ALWAYS_ENABLED, "GL_ARB_tranpose_matrix" },
+ { DEFAULT_OFF, "GL_EXT_vertex_array_set" },
+ { DEFAULT_OFF, "GL_EXT_texture_env" },
};
diff --git a/src/mesa/main/fog.c b/src/mesa/main/fog.c
index 9a2520d6066..0644d6ec5ca 100644
--- a/src/mesa/main/fog.c
+++ b/src/mesa/main/fog.c
@@ -1,4 +1,4 @@
-/* $Id: fog.c,v 1.6 2000/02/02 22:22:59 brianp Exp $ */
+/* $Id: fog.c,v 1.7 2000/02/25 03:55:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -34,6 +34,7 @@
#include "macros.h"
#include "mmath.h"
#include "types.h"
+#include "xform.h"
#endif
@@ -106,23 +107,9 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
}
break;
case GL_FOG_START:
-#if 0
- /* Prior to OpenGL 1.1, this was an error */
- if (*params<0.0F) {
- gl_error( ctx, GL_INVALID_VALUE, "glFog(GL_FOG_START)" );
- return;
- }
-#endif
ctx->Fog.Start = *params;
break;
case GL_FOG_END:
-#if 0
- /* Prior to OpenGL 1.1, this was an error */
- if (*params<0.0F) {
- gl_error( ctx, GL_INVALID_VALUE, "glFog(GL_FOG_END)" );
- return;
- }
-#endif
ctx->Fog.End = *params;
break;
case GL_FOG_INDEX:
@@ -150,9 +137,13 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
typedef void (*fog_func)( struct vertex_buffer *VB, GLuint side,
GLubyte flag );
+typedef void (*fog_coord_func)( struct vertex_buffer *VB,
+ const GLvector4f *from,
+ GLubyte flag );
static fog_func fog_ci_tab[2];
static fog_func fog_rgba_tab[2];
+static fog_coord_func make_fog_coord_tab[2];
/*
* Compute the fogged color for an array of vertices.
@@ -210,6 +201,70 @@ _mesa_fog_vertices( struct vertex_buffer *VB )
}
}
+
+static void check_fog_coords( GLcontext *ctx, struct gl_pipeline_stage *d )
+{
+ d->type = 0;
+
+ if (ctx->FogMode==FOG_FRAGMENT)
+ {
+ d->type = PIPE_IMMEDIATE|PIPE_PRECALC;
+ d->inputs = VERT_OBJ_ANY;
+ d->outputs = VERT_FOG_COORD;
+ }
+}
+
+void gl_make_fog_coords( struct vertex_buffer *VB )
+{
+ GLcontext *ctx = VB->ctx;
+
+ /* If full eye coords weren't required, just calculate the eye Z
+ * values.
+ */
+ if (!ctx->NeedEyeCoords) {
+ GLfloat *m = ctx->ModelView.m;
+ GLfloat plane[4];
+
+ plane[0] = m[2];
+ plane[1] = m[6];
+ plane[2] = m[10];
+ plane[3] = m[14];
+
+ gl_dotprod_tab[0][VB->ObjPtr->size](&VB->Eye,
+ 2, /* fill z coordinates */
+ VB->ObjPtr,
+ plane,
+ 0 );
+
+ make_fog_coord_tab[0]( VB, &VB->Eye, 0 );
+ }
+ else
+ {
+ make_fog_coord_tab[0]( VB, VB->EyePtr, 0 );
+ }
+}
+
+
+/* Drivers that want fog coordinates in VB->Spec[0] alpha, can substitute this
+ * stage for the default PIPE_OP_FOG pipeline stage.
+ */
+struct gl_pipeline_stage gl_fog_coord_stage = {
+ "build fog coordinates",
+ PIPE_OP_FOG,
+ PIPE_PRECALC|PIPE_IMMEDIATE,
+ 0,
+ NEW_FOG,
+ NEW_LIGHTING|NEW_RASTER_OPS|NEW_FOG|NEW_MODELVIEW,
+ 0, 0,
+ 0, 0, 0,
+ check_fog_coords,
+ gl_make_fog_coords
+};
+
+
+
+
+
/*
* Apply fog to an array of RGBA pixels.
* Input: n - number of pixels
diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c
index 199686f60f3..52e9dca7d66 100644
--- a/src/mesa/main/lines.c
+++ b/src/mesa/main/lines.c
@@ -1,4 +1,4 @@
-/* $Id: lines.c,v 1.6 1999/11/11 01:22:27 brianp Exp $ */
+/* $Id: lines.c,v 1.7 2000/02/25 03:55:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -1024,8 +1024,7 @@ void gl_set_line_function( GLcontext *ctx )
else {
if (ctx->Light.ShadeModel==GL_SMOOTH) {
/* Width==1, non-stippled, smooth-shaded */
- if (ctx->Depth.Test
- || (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) {
+ if (ctx->Depth.Test || ctx->FogMode == FOG_FRAGMENT) {
if (rgbmode)
ctx->Driver.LineFunc = smooth_rgba_z_line;
else
@@ -1040,8 +1039,7 @@ void gl_set_line_function( GLcontext *ctx )
}
else {
/* Width==1, non-stippled, flat-shaded */
- if (ctx->Depth.Test
- || (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) {
+ if (ctx->Depth.Test || ctx->FogMode == FOG_FRAGMENT) {
if (rgbmode)
ctx->Driver.LineFunc = flat_rgba_z_line;
else
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 328f22d97c8..5b069c5e76f 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1,4 +1,4 @@
-/* $Id: varray.c,v 1.20 2000/02/05 02:05:14 brianp Exp $ */
+/* $Id: varray.c,v 1.21 2000/02/25 03:55:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -681,6 +681,7 @@ _mesa_DrawArrays(GLenum mode, GLint start, GLsizei count)
VB->NextPrimitive[VB->CopyStart] = VB->Count;
VB->Primitive[VB->CopyStart] = mode;
+ ctx->Array.Flag[count] |= VERT_END_VB;
/* Transform and render.
*/
@@ -816,7 +817,7 @@ _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indice
return;
}
- if (mode > GL_POLYGON) {
+ if (mode < 0 || mode > GL_POLYGON) {
gl_error( ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" );
return;
}