summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/fog.c
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 /src/mesa/main/fog.c
parent8ceb5c34dd4c0da73f9cb58b803a84e17e545c4b (diff)
Fog coordinate stage which drivers may use to replace standard fogging
mechanism. LogicOp state change callback
Diffstat (limited to 'src/mesa/main/fog.c')
-rw-r--r--src/mesa/main/fog.c85
1 files changed, 70 insertions, 15 deletions
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