summaryrefslogtreecommitdiff
path: root/src/mesa/swrast
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_aaline.c4
-rw-r--r--src/mesa/swrast/s_aatriangle.c7
-rw-r--r--src/mesa/swrast/s_aatritemp.h4
-rw-r--r--src/mesa/swrast/s_accum.c76
-rw-r--r--src/mesa/swrast/s_alpha.c5
-rw-r--r--src/mesa/swrast/s_alphabuf.c8
-rw-r--r--src/mesa/swrast/s_buffers.c18
-rw-r--r--src/mesa/swrast/s_context.c74
-rw-r--r--src/mesa/swrast/s_context.h26
-rw-r--r--src/mesa/swrast/s_depth.c10
-rw-r--r--src/mesa/swrast/s_drawpix.c74
-rw-r--r--src/mesa/swrast/s_feedback.c36
-rw-r--r--src/mesa/swrast/s_lines.c4
-rw-r--r--src/mesa/swrast/s_points.c19
-rw-r--r--src/mesa/swrast/s_readpix.c26
-rw-r--r--src/mesa/swrast/s_span.c25
-rw-r--r--src/mesa/swrast/s_stencil.c24
-rw-r--r--src/mesa/swrast/s_triangle.c6
-rw-r--r--src/mesa/swrast/s_tritemp.h12
-rw-r--r--src/mesa/swrast/swrast.h7
20 files changed, 292 insertions, 173 deletions
diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c
index 377e6072c7..48bb2f6109 100644
--- a/src/mesa/swrast/s_aaline.c
+++ b/src/mesa/swrast/s_aaline.c
@@ -1,4 +1,4 @@
-/* $Id: s_aaline.c,v 1.1 2000/11/05 23:15:16 brianp Exp $ */
+/* $Id: s_aaline.c,v 1.2 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -489,7 +489,7 @@ _swrast_choose_aa_line_function(GLcontext *ctx)
if (ctx->Visual.RGBAflag) {
/* RGBA */
if (ctx->Texture._ReallyEnabled) {
- if (ctx->Texture._MultiTextureEnabled
+ if (swrast->_MultiTextureEnabled
|| ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR
|| ctx->Fog.ColorSumEnabled)
/* Multitextured! */
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index c8f321c0c6..a261f5dc82 100644
--- a/src/mesa/swrast/s_aatriangle.c
+++ b/src/mesa/swrast/s_aatriangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_aatriangle.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
+/* $Id: s_aatriangle.c,v 1.3 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -400,13 +400,14 @@ spec_multitex_aa_tri(GLcontext *ctx,
void
_mesa_set_aa_triangle_function(GLcontext *ctx)
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
ASSERT(ctx->Polygon.SmoothFlag);
if (ctx->Texture._ReallyEnabled) {
if (ctx->Light.Enabled &&
(ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ||
ctx->Fog.ColorSumEnabled)) {
- if (ctx->Texture._MultiTextureEnabled) {
+ if (swrast->_MultiTextureEnabled) {
SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri;
}
else {
@@ -414,7 +415,7 @@ _mesa_set_aa_triangle_function(GLcontext *ctx)
}
}
else {
- if (ctx->Texture._MultiTextureEnabled) {
+ if (swrast->_MultiTextureEnabled) {
SWRAST_CONTEXT(ctx)->Triangle = multitex_aa_tri;
}
else {
diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h
index bc4fe74497..ccece6cab8 100644
--- a/src/mesa/swrast/s_aatritemp.h
+++ b/src/mesa/swrast/s_aatritemp.h
@@ -1,4 +1,4 @@
-/* $Id: s_aatritemp.h,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
+/* $Id: s_aatritemp.h,v 1.3 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -86,7 +86,7 @@
GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH];
GLfloat lambda[MAX_TEXTURE_UNITS][MAX_WIDTH];
#endif
- GLfloat bf = ctx->_backface_sign;
+ GLfloat bf = SWRAST_CONTEXT(ctx)->_backface_sign;
/* determine bottom to top order of vertices */
{
diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c
index ff12c53050..dd47e198ab 100644
--- a/src/mesa/swrast/s_accum.c
+++ b/src/mesa/swrast/s_accum.c
@@ -1,4 +1,4 @@
-/* $Id: s_accum.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
+/* $Id: s_accum.c,v 1.3 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -68,6 +68,7 @@
void
_mesa_alloc_accum_buffer( GLcontext *ctx )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLint n;
if (ctx->DrawBuffer->Accum) {
@@ -83,11 +84,11 @@ _mesa_alloc_accum_buffer( GLcontext *ctx )
gl_error( ctx, GL_OUT_OF_MEMORY, "glAccum" );
}
#ifdef USE_OPTIMIZED_ACCUM
- ctx->IntegerAccumMode = GL_TRUE;
+ swrast->_IntegerAccumMode = GL_TRUE;
#else
- ctx->IntegerAccumMode = GL_FALSE;
+ swrast->_IntegerAccumMode = GL_FALSE;
#endif
- ctx->IntegerAccumScaler = 0.0;
+ swrast->_IntegerAccumScaler = 0.0;
}
@@ -102,20 +103,21 @@ _mesa_alloc_accum_buffer( GLcontext *ctx )
*/
static void rescale_accum( GLcontext *ctx )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLuint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height * 4;
const GLfloat fChanMax = (1 << (sizeof(GLchan) * 8)) - 1;
- const GLfloat s = ctx->IntegerAccumScaler * (32767.0 / fChanMax);
+ const GLfloat s = swrast->_IntegerAccumScaler * (32767.0 / fChanMax);
GLaccum *accum = ctx->DrawBuffer->Accum;
GLuint i;
- assert(ctx->IntegerAccumMode);
+ assert(swrast->_IntegerAccumMode);
assert(accum);
for (i = 0; i < n; i++) {
accum[i] = (GLaccum) (accum[i] * s);
}
- ctx->IntegerAccumMode = GL_FALSE;
+ swrast->_IntegerAccumMode = GL_FALSE;
}
@@ -129,6 +131,7 @@ static void rescale_accum( GLcontext *ctx )
void
_mesa_clear_accum_buffer( GLcontext *ctx )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint buffersize;
GLfloat acc_scale;
@@ -169,12 +172,12 @@ _mesa_clear_accum_buffer( GLcontext *ctx )
b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
/* size of region to clear */
- width = 4 * (ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin);
- height = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin;
+ width = 4 * (ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin);
+ height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
/* ptr to first element to clear */
row = ctx->DrawBuffer->Accum
- + 4 * (ctx->DrawBuffer->Ymin * ctx->DrawBuffer->Width
- + ctx->DrawBuffer->Xmin);
+ + 4 * (ctx->DrawBuffer->_Ymin * ctx->DrawBuffer->Width
+ + ctx->DrawBuffer->_Xmin);
for (j=0;j<height;j++) {
for (i=0;i<width;i+=4) {
row[i+0] = r;
@@ -217,14 +220,14 @@ _mesa_clear_accum_buffer( GLcontext *ctx )
if (ctx->Accum.ClearColor[0] == 0.0 && ctx->Accum.ClearColor[1] == 0.0 &&
ctx->Accum.ClearColor[2] == 0.0 && ctx->Accum.ClearColor[3] == 0.0) {
#ifdef USE_OPTIMIZED_ACCUM
- ctx->IntegerAccumMode = GL_TRUE;
+ swrast->_IntegerAccumMode = GL_TRUE;
#else
- ctx->IntegerAccumMode = GL_FALSE;
+ swrast->_IntegerAccumMode = GL_FALSE;
#endif
- ctx->IntegerAccumScaler = 0.0; /* denotes empty accum buffer */
+ swrast->_IntegerAccumScaler = 0.0; /* denotes empty accum buffer */
}
else {
- ctx->IntegerAccumMode = GL_FALSE;
+ swrast->_IntegerAccumMode = GL_FALSE;
}
}
}
@@ -236,6 +239,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
GLint width, GLint height )
{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint width4;
GLfloat acc_scale;
GLchan rgba[MAX_WIDTH][4];
@@ -273,7 +277,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
const GLaccum intVal = (GLaccum) (value * acc_scale);
GLuint j;
/* Leave optimized accum buffer mode */
- if (ctx->IntegerAccumMode)
+ if (swrast->_IntegerAccumMode)
rescale_accum(ctx);
for (j = 0; j < height; j++) {
GLaccum * acc = ctx->DrawBuffer->Accum + ypos * width4 + 4 * xpos;
@@ -290,7 +294,7 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
if (value != 1.0F) {
GLuint j;
/* Leave optimized accum buffer mode */
- if (ctx->IntegerAccumMode)
+ if (swrast->_IntegerAccumMode)
rescale_accum(ctx);
for (j = 0; j < height; j++) {
GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + 4 * xpos;
@@ -311,19 +315,19 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
ctx->Pixel.DriverReadBuffer );
/* May have to leave optimized accum buffer mode */
- if (ctx->IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0)
- ctx->IntegerAccumScaler = value;
- if (ctx->IntegerAccumMode && value != ctx->IntegerAccumScaler)
+ if (swrast->_IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0)
+ swrast->_IntegerAccumScaler = value;
+ if (swrast->_IntegerAccumMode && value != swrast->_IntegerAccumScaler)
rescale_accum(ctx);
RENDER_START(ctx);
- if (ctx->IntegerAccumMode) {
+ if (swrast->_IntegerAccumMode) {
/* simply add integer color values into accum buffer */
GLuint j;
GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
- assert(ctx->IntegerAccumScaler > 0.0);
- assert(ctx->IntegerAccumScaler <= 1.0);
+ assert(swrast->_IntegerAccumScaler > 0.0);
+ assert(swrast->_IntegerAccumScaler <= 1.0);
for (j = 0; j < height; j++) {
GLuint i, i4;
@@ -371,24 +375,24 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
/* This is a change to go into optimized accum buffer mode */
if (value > 0.0 && value <= 1.0) {
#ifdef USE_OPTIMIZED_ACCUM
- ctx->IntegerAccumMode = GL_TRUE;
+ swrast->_IntegerAccumMode = GL_TRUE;
#else
- ctx->IntegerAccumMode = GL_FALSE;
+ swrast->_IntegerAccumMode = GL_FALSE;
#endif
- ctx->IntegerAccumScaler = value;
+ swrast->_IntegerAccumScaler = value;
}
else {
- ctx->IntegerAccumMode = GL_FALSE;
- ctx->IntegerAccumScaler = 0.0;
+ swrast->_IntegerAccumMode = GL_FALSE;
+ swrast->_IntegerAccumScaler = 0.0;
}
RENDER_START(ctx);
- if (ctx->IntegerAccumMode) {
+ if (swrast->_IntegerAccumMode) {
/* just copy values into accum buffer */
GLuint j;
GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
- assert(ctx->IntegerAccumScaler > 0.0);
- assert(ctx->IntegerAccumScaler <= 1.0);
+ assert(swrast->_IntegerAccumScaler > 0.0);
+ assert(swrast->_IntegerAccumScaler <= 1.0);
for (j = 0; j < height; j++) {
GLuint i, i4;
gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
@@ -431,15 +435,15 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
case GL_RETURN:
/* May have to leave optimized accum buffer mode */
- if (ctx->IntegerAccumMode && value != 1.0)
+ if (swrast->_IntegerAccumMode && value != 1.0)
rescale_accum(ctx);
RENDER_START(ctx);
- if (ctx->IntegerAccumMode && ctx->IntegerAccumScaler > 0) {
+ if (swrast->_IntegerAccumMode && swrast->_IntegerAccumScaler > 0) {
/* build lookup table to avoid many floating point multiplies */
static GLchan multTable[32768];
static GLfloat prevMult = 0.0;
- const GLfloat mult = ctx->IntegerAccumScaler;
+ const GLfloat mult = swrast->_IntegerAccumScaler;
const GLint max = MIN2((GLint) (256 / mult), 32767);
GLuint j;
if (mult != prevMult) {
@@ -448,8 +452,8 @@ _swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
prevMult = mult;
}
- assert(ctx->IntegerAccumScaler > 0.0);
- assert(ctx->IntegerAccumScaler <= 1.0);
+ assert(swrast->_IntegerAccumScaler > 0.0);
+ assert(swrast->_IntegerAccumScaler <= 1.0);
for (j = 0; j < height; j++) {
const GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos*4;
GLuint i, i4;
diff --git a/src/mesa/swrast/s_alpha.c b/src/mesa/swrast/s_alpha.c
index 07e8dacd4a..6440ffb18f 100644
--- a/src/mesa/swrast/s_alpha.c
+++ b/src/mesa/swrast/s_alpha.c
@@ -1,4 +1,4 @@
-/* $Id: s_alpha.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
+/* $Id: s_alpha.c,v 1.2 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -60,9 +60,8 @@ _mesa_alpha_test( const GLcontext *ctx,
}
return 1;
case GL_LEQUAL:
- for (i=0;i<n;i++) {
+ for (i=0;i<n;i++)
mask[i] &= (rgba[i][ACOMP] <= ref);
- }
return 1;
case GL_GEQUAL:
for (i=0;i<n;i++) {
diff --git a/src/mesa/swrast/s_alphabuf.c b/src/mesa/swrast/s_alphabuf.c
index ed7b9cbded..11b782e787 100644
--- a/src/mesa/swrast/s_alphabuf.c
+++ b/src/mesa/swrast/s_alphabuf.c
@@ -161,11 +161,11 @@ _mesa_clear_alpha_buffers( GLcontext *ctx )
if (ctx->Scissor.Enabled) {
/* clear scissor region */
GLint j;
- GLint rowLen = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin + 1;
- GLint rows = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin + 1;
+ GLint rowLen = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin + 1;
+ GLint rows = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin + 1;
GLchan *aptr = buffer
- + ctx->DrawBuffer->Ymin * ctx->DrawBuffer->Width
- + ctx->DrawBuffer->Xmin;
+ + ctx->DrawBuffer->_Ymin * ctx->DrawBuffer->Width
+ + ctx->DrawBuffer->_Xmin;
for (j = 0; j < rows; j++) {
#if CHAN_BITS == 8
MEMSET( aptr, aclear, rowLen );
diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c
index b62198f091..c0564e0b6a 100644
--- a/src/mesa/swrast/s_buffers.c
+++ b/src/mesa/swrast/s_buffers.c
@@ -1,4 +1,4 @@
-/* $Id: s_buffers.c,v 1.1 2000/10/31 18:00:04 keithw Exp $ */
+/* $Id: s_buffers.c,v 1.2 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -44,10 +44,10 @@
static void
clear_color_buffer_with_masking( GLcontext *ctx )
{
- const GLint x = ctx->DrawBuffer->Xmin;
- const GLint y = ctx->DrawBuffer->Ymin;
- const GLint height = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin;
- const GLint width = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin;
+ const GLint x = ctx->DrawBuffer->_Xmin;
+ const GLint y = ctx->DrawBuffer->_Ymin;
+ const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+ const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
if (ctx->Visual.RGBAflag) {
/* RGBA mode */
@@ -94,10 +94,10 @@ clear_color_buffer_with_masking( GLcontext *ctx )
static void
clear_color_buffer(GLcontext *ctx)
{
- const GLint x = ctx->DrawBuffer->Xmin;
- const GLint y = ctx->DrawBuffer->Ymin;
- const GLint height = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin;
- const GLint width = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin;
+ const GLint x = ctx->DrawBuffer->_Xmin;
+ const GLint y = ctx->DrawBuffer->_Ymin;
+ const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+ const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
if (ctx->Visual.RGBAflag) {
/* RGBA mode */
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index ca6b05c486..f1dfef3cc4 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -1,4 +1,4 @@
-/* $Id: s_context.c,v 1.3 2000/11/10 17:45:16 brianp Exp $ */
+/* $Id: s_context.c,v 1.4 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -114,6 +114,44 @@ _swrast_update_rasterflags( GLcontext *ctx )
}
+static void
+_swrast_update_polygon( GLcontext *ctx )
+{
+ GLfloat backface_sign = 1;
+
+ if (ctx->Polygon.CullFlag) {
+ backface_sign = 1;
+ switch(ctx->Polygon.CullFaceMode) {
+ case GL_BACK:
+ if(ctx->Polygon.FrontFace==GL_CCW)
+ backface_sign = -1;
+ break;
+ case GL_FRONT:
+ if(ctx->Polygon.FrontFace!=GL_CCW)
+ backface_sign = -1;
+ break;
+ default:
+ case GL_FRONT_AND_BACK:
+ backface_sign = 0;
+ break;
+ }
+ }
+ else {
+ backface_sign = 0;
+ }
+
+ SWRAST_CONTEXT(ctx)->_backface_sign = backface_sign;
+}
+
+
+static void
+_swrast_update_hint( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ swrast->_PreferPixelFog = (!swrast->AllowVertexFog ||
+ (ctx->Hint.Fog == GL_NICEST &&
+ swrast->AllowPixelFog));
+}
#define _SWRAST_NEW_TRIANGLE (_NEW_RENDERMODE| \
_NEW_POLYGON| \
@@ -282,7 +320,17 @@ _swrast_validate_derived( GLcontext *ctx )
if (swrast->NewState)
{
if (swrast->NewState & _SWRAST_NEW_RASTERMASK)
- _swrast_update_rasterflags( ctx );
+ _swrast_update_rasterflags( ctx );
+
+ if (swrast->NewState & _NEW_TEXTURE)
+ swrast->_MultiTextureEnabled = (ctx->Texture._ReallyEnabled &
+ ~ENABLE_TEX0);
+
+ if (swrast->NewState & _NEW_POLYGON)
+ _swrast_update_polygon( ctx );
+
+ if (swrast->NewState & _NEW_HINT)
+ _swrast_update_hint( ctx );
swrast->NewState = 0;
swrast->StateChanges = 0;
@@ -332,6 +380,20 @@ _swrast_get_stipple_counter_ref( GLcontext *ctx )
return &SWRAST_CONTEXT(ctx)->StippleCounter;
}
+void
+_swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value )
+{
+ SWRAST_CONTEXT(ctx)->InvalidateState( ctx, _NEW_HINT );
+ SWRAST_CONTEXT(ctx)->AllowVertexFog = value;
+}
+
+void
+_swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value )
+{
+ SWRAST_CONTEXT(ctx)->InvalidateState( ctx, _NEW_HINT );
+ SWRAST_CONTEXT(ctx)->AllowPixelFog = value;
+}
+
GLboolean
_swrast_CreateContext( GLcontext *ctx )
@@ -366,6 +428,14 @@ _swrast_CreateContext( GLcontext *ctx )
swrast->InvalidateState = _swrast_sleep;
swrast->BlendFunc = _swrast_validate_blend_func;
+ swrast->AllowVertexFog = GL_TRUE;
+ swrast->AllowPixelFog = GL_TRUE;
+
+ /* Optimized Accum buffer */
+ swrast->_IntegerAccumMode = GL_TRUE;
+ swrast->_IntegerAccumScaler = 0.0;
+
+
for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++)
swrast->TextureSample[i] = _swrast_validate_texture_sample;
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index 493758ad69..10e162b705 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -93,16 +93,34 @@ typedef void (*swrast_point_func)( GLcontext *ctx, SWvertex *);
typedef struct
{
- GLuint NewState;
- GLuint StateChanges;
+ /* Configuration mechanisms to make software rasterizer match
+ * characteristics of the hardware rasterizer (if present):
+ */
+ GLboolean AllowVertexFog;
+ GLboolean AllowPixelFog;
+ /* Derived values, invalidated on statechanges, updated from
+ * _swrast_validate_derived():
+ */
GLuint _RasterMask;
+ GLboolean _MultiTextureEnabled;
GLuint _MinMagThresh[MAX_TEXTURE_UNITS];
+ GLfloat _backface_sign;
+ GLboolean _PreferPixelFog;
+
+ /* Accum buffer temporaries.
+ */
+ GLboolean _IntegerAccumMode; /* Storing unscaled integers? */
+ GLfloat _IntegerAccumScaler; /* Implicit scale factor */
+
+ /* Working values:
+ */
struct pixel_buffer* PB;
GLuint StippleCounter; /* Line stipple counter */
-
-
+ GLuint NewState;
+ GLuint StateChanges;
+
/* Mechanism to allow driver (like X11) to register further
* software rasterization routines.
*/
diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
index 3186f8ea27..1199f67dd8 100644
--- a/src/mesa/swrast/s_depth.c
+++ b/src/mesa/swrast/s_depth.c
@@ -1,4 +1,4 @@
-/* $Id: s_depth.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
+/* $Id: s_depth.c,v 1.3 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -1538,10 +1538,10 @@ _mesa_clear_depth_buffer( GLcontext *ctx )
/* only clear scissor region */
if (ctx->Visual.DepthBits <= 16) {
const GLushort clearValue = (GLushort) (ctx->Depth.Clear * ctx->Visual.DepthMax);
- const GLint rows = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin;
+ const GLint rows = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
const GLint width = ctx->DrawBuffer->Width;
GLushort *dRow = (GLushort *) ctx->DrawBuffer->DepthBuffer
- + ctx->DrawBuffer->Ymin * width + ctx->DrawBuffer->Xmin;
+ + ctx->DrawBuffer->_Ymin * width + ctx->DrawBuffer->_Xmin;
GLint i, j;
for (i = 0; i < rows; i++) {
for (j = 0; j < width; j++) {
@@ -1552,10 +1552,10 @@ _mesa_clear_depth_buffer( GLcontext *ctx )
}
else {
const GLuint clearValue = (GLuint) (ctx->Depth.Clear * ctx->Visual.DepthMax);
- const GLint rows = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin;
+ const GLint rows = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
const GLint width = ctx->DrawBuffer->Width;
GLuint *dRow = (GLuint *) ctx->DrawBuffer->DepthBuffer
- + ctx->DrawBuffer->Ymin * width + ctx->DrawBuffer->Xmin;
+ + ctx->DrawBuffer->_Ymin * width + ctx->DrawBuffer->_Xmin;
GLint i, j;
for (i = 0; i < rows; i++) {
for (j = 0; j < width; j++) {
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index d646bd4b28..dc15e598f5 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: s_drawpix.c,v 1.3 2000/11/10 17:45:16 brianp Exp $ */
+/* $Id: s_drawpix.c,v 1.4 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -61,27 +61,27 @@ _mesa_clip_pixelrect(const GLcontext *ctx,
const GLframebuffer *buffer = ctx->DrawBuffer;
/* left clipping */
- if (*destX < buffer->Xmin) {
- *skipPixels += (buffer->Xmin - *destX);
- *width -= (buffer->Xmin - *destX);
- *destX = buffer->Xmin;
+ if (*destX < buffer->_Xmin) {
+ *skipPixels += (buffer->_Xmin - *destX);
+ *width -= (buffer->_Xmin - *destX);
+ *destX = buffer->_Xmin;
}
/* right clipping */
- if (*destX + *width > buffer->Xmax)
- *width -= (*destX + *width - buffer->Xmax);
+ if (*destX + *width > buffer->_Xmax)
+ *width -= (*destX + *width - buffer->_Xmax);
if (*width <= 0)
return GL_FALSE;
/* bottom clipping */
- if (*destY < buffer->Ymin) {
- *skipRows += (buffer->Ymin - *destY);
- *height -= (buffer->Ymin - *destY);
- *destY = buffer->Ymin;
+ if (*destY < buffer->_Ymin) {
+ *skipRows += (buffer->_Ymin - *destY);
+ *height -= (buffer->_Ymin - *destY);
+ *destY = buffer->_Ymin;
}
/* top clipping */
- if (*destY + *height > buffer->Ymax)
- *height -= (*destY + *height - buffer->Ymax);
+ if (*destY + *height > buffer->_Ymax)
+ *height -= (*destY + *height - buffer->_Ymax);
if (*height <= 0)
return GL_TRUE;
@@ -139,48 +139,48 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
*/
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* horizontal clipping */
- if (destX < ctx->DrawBuffer->Xmin) {
- skipPixels += (ctx->DrawBuffer->Xmin - destX);
- drawWidth -= (ctx->DrawBuffer->Xmin - destX);
- destX = ctx->DrawBuffer->Xmin;
+ if (destX < ctx->DrawBuffer->_Xmin) {
+ skipPixels += (ctx->DrawBuffer->_Xmin - destX);
+ drawWidth -= (ctx->DrawBuffer->_Xmin - destX);
+ destX = ctx->DrawBuffer->_Xmin;
}
- if (destX + drawWidth > ctx->DrawBuffer->Xmax)
- drawWidth -= (destX + drawWidth - ctx->DrawBuffer->Xmax);
+ if (destX + drawWidth > ctx->DrawBuffer->_Xmax)
+ drawWidth -= (destX + drawWidth - ctx->DrawBuffer->_Xmax);
if (drawWidth <= 0)
return GL_TRUE;
/* vertical clipping */
- if (destY < ctx->DrawBuffer->Ymin) {
- skipRows += (ctx->DrawBuffer->Ymin - destY);
- drawHeight -= (ctx->DrawBuffer->Ymin - destY);
- destY = ctx->DrawBuffer->Ymin;
+ if (destY < ctx->DrawBuffer->_Ymin) {
+ skipRows += (ctx->DrawBuffer->_Ymin - destY);
+ drawHeight -= (ctx->DrawBuffer->_Ymin - destY);
+ destY = ctx->DrawBuffer->_Ymin;
}
- if (destY + drawHeight > ctx->DrawBuffer->Ymax)
- drawHeight -= (destY + drawHeight - ctx->DrawBuffer->Ymax);
+ if (destY + drawHeight > ctx->DrawBuffer->_Ymax)
+ drawHeight -= (destY + drawHeight - ctx->DrawBuffer->_Ymax);
if (drawHeight <= 0)
return GL_TRUE;
}
else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
/* upside-down image */
/* horizontal clipping */
- if (destX < ctx->DrawBuffer->Xmin) {
- skipPixels += (ctx->DrawBuffer->Xmin - destX);
- drawWidth -= (ctx->DrawBuffer->Xmin - destX);
- destX = ctx->DrawBuffer->Xmin;
+ if (destX < ctx->DrawBuffer->_Xmin) {
+ skipPixels += (ctx->DrawBuffer->_Xmin - destX);
+ drawWidth -= (ctx->DrawBuffer->_Xmin - destX);
+ destX = ctx->DrawBuffer->_Xmin;
}
- if (destX + drawWidth > ctx->DrawBuffer->Xmax)
- drawWidth -= (destX + drawWidth - ctx->DrawBuffer->Xmax);
+ if (destX + drawWidth > ctx->DrawBuffer->_Xmax)
+ drawWidth -= (destX + drawWidth - ctx->DrawBuffer->_Xmax);
if (drawWidth <= 0)
return GL_TRUE;
/* vertical clipping */
- if (destY > ctx->DrawBuffer->Ymax) {
- skipRows += (destY - ctx->DrawBuffer->Ymax);
- drawHeight -= (destY - ctx->DrawBuffer->Ymax);
- destY = ctx->DrawBuffer->Ymax;
+ if (destY > ctx->DrawBuffer->_Ymax) {
+ skipRows += (destY - ctx->DrawBuffer->_Ymax);
+ drawHeight -= (destY - ctx->DrawBuffer->_Ymax);
+ destY = ctx->DrawBuffer->_Ymax;
}
- if (destY - drawHeight < ctx->DrawBuffer->Ymin)
- drawHeight -= (ctx->DrawBuffer->Ymin - (destY - drawHeight));
+ if (destY - drawHeight < ctx->DrawBuffer->_Ymin)
+ drawHeight -= (ctx->DrawBuffer->_Ymin - (destY - drawHeight));
if (drawHeight <= 0)
return GL_TRUE;
}
diff --git a/src/mesa/swrast/s_feedback.c b/src/mesa/swrast/s_feedback.c
index 501f3721c6..e14c6a8e21 100644
--- a/src/mesa/swrast/s_feedback.c
+++ b/src/mesa/swrast/s_feedback.c
@@ -1,4 +1,4 @@
-/* $Id: s_feedback.c,v 1.1 2000/11/05 18:24:40 keithw Exp $ */
+/* $Id: s_feedback.c,v 1.2 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -46,7 +46,7 @@
-static void feedback_vertex( GLcontext *ctx, SWvertex *v )
+static void feedback_vertex( GLcontext *ctx, SWvertex *v, SWvertex *pv )
{
GLfloat win[4];
GLfloat color[4];
@@ -59,10 +59,10 @@ static void feedback_vertex( GLcontext *ctx, SWvertex *v )
win[2] = v->win[2] / ctx->Visual.DepthMaxF;
win[3] = 1.0 / v->win[3];
- color[0] = CHAN_TO_FLOAT(v->color[0]);
- color[1] = CHAN_TO_FLOAT(v->color[1]);
- color[2] = CHAN_TO_FLOAT(v->color[2]);
- color[3] = CHAN_TO_FLOAT(v->color[3]);
+ color[0] = CHAN_TO_FLOAT(pv->color[0]);
+ color[1] = CHAN_TO_FLOAT(pv->color[1]);
+ color[2] = CHAN_TO_FLOAT(pv->color[2]);
+ color[3] = CHAN_TO_FLOAT(pv->color[3]);
if (v->texcoord[texUnit][3] != 1.0 &&
v->texcoord[texUnit][3] != 0.0) {
@@ -92,9 +92,15 @@ void gl_feedback_triangle( GLcontext *ctx, SWvertex *v0, SWvertex *v1,
FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_POLYGON_TOKEN );
FEEDBACK_TOKEN( ctx, (GLfloat) 3 ); /* three vertices */
- feedback_vertex( ctx, v0 );
- feedback_vertex( ctx, v1 );
- feedback_vertex( ctx, v2 );
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ feedback_vertex( ctx, v0, v0 );
+ feedback_vertex( ctx, v1, v1 );
+ feedback_vertex( ctx, v2, v2 );
+ } else {
+ feedback_vertex( ctx, v0, v0 );
+ feedback_vertex( ctx, v1, v0 );
+ feedback_vertex( ctx, v2, v0 );
+ }
}
}
@@ -109,8 +115,13 @@ void gl_feedback_line( GLcontext *ctx, SWvertex *v0, SWvertex *v1 )
FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) token );
- feedback_vertex( ctx, v0 );
- feedback_vertex( ctx, v1 );
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ feedback_vertex( ctx, v0, v0 );
+ feedback_vertex( ctx, v1, v1 );
+ } else {
+ feedback_vertex( ctx, v0, v0 );
+ feedback_vertex( ctx, v1, v0 );
+ }
swrast->StippleCounter++;
}
@@ -119,7 +130,7 @@ void gl_feedback_line( GLcontext *ctx, SWvertex *v0, SWvertex *v1 )
void gl_feedback_point( GLcontext *ctx, SWvertex *v )
{
FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_POINT_TOKEN );
- feedback_vertex( ctx, v );
+ feedback_vertex( ctx, v, v );
}
@@ -128,6 +139,7 @@ void gl_select_triangle( GLcontext *ctx, SWvertex *v0, SWvertex *v1,
{
if (gl_cull_triangle( ctx, v0, v1, v2 )) {
const GLfloat zs = 1.0F / ctx->Visual.DepthMaxF;
+
gl_update_hitflag( ctx, v0->win[2] * zs );
gl_update_hitflag( ctx, v1->win[2] * zs );
gl_update_hitflag( ctx, v2->win[2] * zs );
diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c
index c25a385175..e460a77f18 100644
--- a/src/mesa/swrast/s_lines.c
+++ b/src/mesa/swrast/s_lines.c
@@ -1,4 +1,4 @@
-/* $Id: s_lines.c,v 1.4 2000/11/10 17:45:16 brianp Exp $ */
+/* $Id: s_lines.c,v 1.5 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -979,7 +979,7 @@ _swrast_choose_line( GLcontext *ctx )
ASSERT(swrast->Triangle);
}
else if (ctx->Texture._ReallyEnabled) {
- if (ctx->Texture._MultiTextureEnabled
+ if (swrast->_MultiTextureEnabled
|| ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR
|| ctx->Fog.ColorSumEnabled) {
/* multi-texture and/or separate specular color */
diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c
index 59fadfb8e9..e5360dff7d 100644
--- a/src/mesa/swrast/s_points.c
+++ b/src/mesa/swrast/s_points.c
@@ -1,4 +1,4 @@
-/* $Id: s_points.c,v 1.3 2000/11/10 17:45:16 brianp Exp $ */
+/* $Id: s_points.c,v 1.4 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -362,7 +362,8 @@ multitextured_rgba_point( GLcontext *ctx, SWvertex *vert )
static void
antialiased_rgba_point( GLcontext *ctx, SWvertex *vert )
{
- struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct pixel_buffer *PB = swrast->PB;
const GLfloat radius = ctx->Point.Size * 0.5F;
const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
const GLfloat rmax = radius + 0.7071F;
@@ -421,7 +422,7 @@ antialiased_rgba_point( GLcontext *ctx, SWvertex *vert )
/* coverage is in [0,256] */
alpha = (alpha * coverage) >> 8;
}
- if (ctx->Texture._MultiTextureEnabled) {
+ if (swrast->_MultiTextureEnabled) {
PB_WRITE_MULTITEX_PIXEL( PB, x,y,z, fog,
red, green, blue,
alpha, texcoord );
@@ -614,7 +615,8 @@ dist_atten_general_rgba_point( GLcontext *ctx, SWvertex *vert )
static void
dist_atten_textured_rgba_point( GLcontext *ctx, SWvertex *vert )
{
- struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct pixel_buffer *PB = swrast->PB;
const GLfloat psize = ctx->Point.Size;
GLfloat dist = attenuation_distance( ctx, vert->eye );
@@ -683,7 +685,7 @@ dist_atten_textured_rgba_point( GLcontext *ctx, SWvertex *vert )
for (iy = y0; iy <= y1; iy++) {
for (ix = x0; ix <= x1; ix++) {
- if (ctx->Texture._MultiTextureEnabled) {
+ if (swrast->_MultiTextureEnabled) {
PB_WRITE_MULTITEX_PIXEL( PB, ix, iy, z, fog,
red, green, blue, alpha,
texcoord );
@@ -706,7 +708,8 @@ dist_atten_textured_rgba_point( GLcontext *ctx, SWvertex *vert )
static void
dist_atten_antialiased_rgba_point( GLcontext *ctx, SWvertex *vert )
{
- struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB;
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct pixel_buffer *PB = swrast->PB;
const GLfloat psize = ctx->Point.Size;
GLfloat dist = attenuation_distance( ctx, vert->eye );
@@ -775,7 +778,7 @@ dist_atten_antialiased_rgba_point( GLcontext *ctx, SWvertex *vert )
alpha = (alpha * coverage) >> 8;
}
alpha = (GLint) (alpha * alphaf);
- if (ctx->Texture._MultiTextureEnabled) {
+ if (swrast->_MultiTextureEnabled) {
PB_WRITE_MULTITEX_PIXEL( PB, x, y, z, fog,
red, green, blue, alpha,
texcoord );
@@ -906,7 +909,7 @@ _swrast_choose_point( GLcontext *ctx )
swrast->Point = antialiased_rgba_point;
}
else if (ctx->Texture._ReallyEnabled) {
- if (ctx->Texture._MultiTextureEnabled ||
+ if (swrast->_MultiTextureEnabled ||
ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR ||
ctx->Fog.ColorSumEnabled) {
swrast->Point = multitextured_rgba_point;
diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c
index ba3aca5392..ac91dadcf3 100644
--- a/src/mesa/swrast/s_readpix.c
+++ b/src/mesa/swrast/s_readpix.c
@@ -1,4 +1,4 @@
-/* $Id: s_readpix.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
+/* $Id: s_readpix.c,v 1.3 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -520,24 +520,24 @@ read_fast_rgba_pixels( GLcontext *ctx,
rowLength = width;
/* horizontal clipping */
- if (srcX < ctx->ReadBuffer->Xmin) {
- skipPixels += (ctx->ReadBuffer->Xmin - srcX);
- readWidth -= (ctx->ReadBuffer->Xmin - srcX);
- srcX = ctx->ReadBuffer->Xmin;
+ if (srcX < ctx->ReadBuffer->_Xmin) {
+ skipPixels += (ctx->ReadBuffer->_Xmin - srcX);
+ readWidth -= (ctx->ReadBuffer->_Xmin - srcX);
+ srcX = ctx->ReadBuffer->_Xmin;
}
- if (srcX + readWidth > ctx->ReadBuffer->Xmax)
- readWidth -= (srcX + readWidth - ctx->ReadBuffer->Xmax);
+ if (srcX + readWidth > ctx->ReadBuffer->_Xmax)
+ readWidth -= (srcX + readWidth - ctx->ReadBuffer->_Xmax);
if (readWidth <= 0)
return GL_TRUE;
/* vertical clipping */
- if (srcY < ctx->ReadBuffer->Ymin) {
- skipRows += (ctx->ReadBuffer->Ymin - srcY);
- readHeight -= (ctx->ReadBuffer->Ymin - srcY);
- srcY = ctx->ReadBuffer->Ymin;
+ if (srcY < ctx->ReadBuffer->_Ymin) {
+ skipRows += (ctx->ReadBuffer->_Ymin - srcY);
+ readHeight -= (ctx->ReadBuffer->_Ymin - srcY);
+ srcY = ctx->ReadBuffer->_Ymin;
}
- if (srcY + readHeight > ctx->ReadBuffer->Ymax)
- readHeight -= (srcY + readHeight - ctx->ReadBuffer->Ymax);
+ if (srcY + readHeight > ctx->ReadBuffer->_Ymax)
+ readHeight -= (srcY + readHeight - ctx->ReadBuffer->_Ymax);
if (readHeight <= 0)
return GL_TRUE;
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index a115199ab8..019534710e 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1,4 +1,4 @@
-/* $Id: s_span.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
+/* $Id: s_span.c,v 1.3 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -206,7 +206,7 @@ void gl_write_index_span( GLcontext *ctx,
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
- if (fog && ctx->Hint.Fog != GL_NICEST)
+ if (fog && !swrast->_PreferPixelFog)
_mesa_fog_ci_pixels( ctx, n, fog, index );
else
_mesa_depth_fog_ci_pixels( ctx, n, z, index );
@@ -323,7 +323,7 @@ void gl_write_monoindex_span( GLcontext *ctx,
}
if (ctx->Fog.Enabled) {
- if (fog && ctx->Hint.Fog != GL_NICEST)
+ if (fog && !swrast->_PreferPixelFog)
_mesa_fog_ci_pixels( ctx, n, fog, indexes );
else
_mesa_depth_fog_ci_pixels( ctx, n, z, indexes );
@@ -476,7 +476,7 @@ void gl_write_rgba_span( GLcontext *ctx,
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
- if (fog && ctx->Hint.Fog != GL_NICEST)
+ if (fog && !swrast->_PreferPixelFog)
_mesa_fog_rgba_pixels( ctx, n, fog, rgba );
else
_mesa_depth_fog_rgba_pixels( ctx, n, z, rgba );
@@ -660,7 +660,7 @@ void gl_write_monocolor_span( GLcontext *ctx,
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
- if (fog && ctx->Hint.Fog != GL_NICEST)
+ if (fog && !swrast->_PreferPixelFog)
_mesa_fog_rgba_pixels( ctx, n, fog, rgba );
else
_mesa_depth_fog_rgba_pixels( ctx, n, z, rgba );
@@ -796,13 +796,14 @@ void gl_write_texture_span( GLcontext *ctx,
gl_texture_pixels( ctx, 0, n, s, t, u, lambda, rgba, rgba );
/* Add base and specular colors */
- if (spec && ctx->Light.Enabled
- && ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+ if (spec &&
+ (ctx->Fog.ColorSumEnabled ||
+ (ctx->Light.Enabled && ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)))
add_colors( n, rgba, spec ); /* rgba = rgba + spec */
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
- if (fog && ctx->Hint.Fog != GL_NICEST)
+ if (fog && !swrast->_PreferPixelFog)
_mesa_fog_rgba_pixels( ctx, n, fog, rgba );
else
_mesa_depth_fog_rgba_pixels( ctx, n, z, rgba );
@@ -932,13 +933,15 @@ gl_write_multitexture_span( GLcontext *ctx,
gl_texture_pixels( ctx, i, n, s[i], t[i], u[i], lambda[i], rgbaIn, rgba );
/* Add base and specular colors */
- if (spec && ctx->Light.Enabled
- && ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+ if (spec &&
+ (ctx->Fog.ColorSumEnabled ||
+ (ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)))
add_colors( n, rgba, spec ); /* rgba = rgba + spec */
/* Per-pixel fog */
if (ctx->Fog.Enabled) {
- if (fog && ctx->Hint.Fog != GL_NICEST)
+ if (fog && !swrast->_PreferPixelFog)
_mesa_fog_rgba_pixels( ctx, n, fog, rgba );
else
_mesa_depth_fog_rgba_pixels( ctx, n, z, rgba );
diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c
index 80839451cb..aed107ca00 100644
--- a/src/mesa/swrast/s_stencil.c
+++ b/src/mesa/swrast/s_stencil.c
@@ -1,4 +1,4 @@
-/* $Id: s_stencil.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
+/* $Id: s_stencil.c,v 1.3 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -1137,15 +1137,15 @@ clear_software_stencil_buffer( GLcontext *ctx )
if (ctx->Scissor.Enabled) {
/* clear scissor region only */
- const GLint width = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin;
+ const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
if (ctx->Stencil.WriteMask != STENCIL_MAX) {
/* must apply mask to the clear */
GLint y;
- for (y = ctx->DrawBuffer->Ymin; y < ctx->DrawBuffer->Ymax; y++) {
+ for (y = ctx->DrawBuffer->_Ymin; y < ctx->DrawBuffer->_Ymax; y++) {
const GLstencil mask = ctx->Stencil.WriteMask;
const GLstencil invMask = ~mask;
const GLstencil clearVal = (ctx->Stencil.Clear & mask);
- GLstencil *stencil = STENCIL_ADDRESS( ctx->DrawBuffer->Xmin, y );
+ GLstencil *stencil = STENCIL_ADDRESS( ctx->DrawBuffer->_Xmin, y );
GLint i;
for (i = 0; i < width; i++) {
stencil[i] = (stencil[i] & invMask) | clearVal;
@@ -1155,8 +1155,8 @@ clear_software_stencil_buffer( GLcontext *ctx )
else {
/* no masking */
GLint y;
- for (y = ctx->DrawBuffer->Ymin; y < ctx->DrawBuffer->Ymax; y++) {
- GLstencil *stencil = STENCIL_ADDRESS( ctx->DrawBuffer->Xmin, y );
+ for (y = ctx->DrawBuffer->_Ymin; y < ctx->DrawBuffer->_Ymax; y++) {
+ GLstencil *stencil = STENCIL_ADDRESS( ctx->DrawBuffer->_Xmin, y );
#if STENCIL_BITS==8
MEMSET( stencil, ctx->Stencil.Clear, width * sizeof(GLstencil) );
#else
@@ -1217,12 +1217,12 @@ clear_hardware_stencil_buffer( GLcontext *ctx )
if (ctx->Scissor.Enabled) {
/* clear scissor region only */
- const GLint x = ctx->DrawBuffer->Xmin;
- const GLint width = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin;
+ const GLint x = ctx->DrawBuffer->_Xmin;
+ const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
if (ctx->Stencil.WriteMask != STENCIL_MAX) {
/* must apply mask to the clear */
GLint y;
- for (y = ctx->DrawBuffer->Ymin; y < ctx->DrawBuffer->Ymax; y++) {
+ for (y = ctx->DrawBuffer->_Ymin; y < ctx->DrawBuffer->_Ymax; y++) {
const GLstencil mask = ctx->Stencil.WriteMask;
const GLstencil invMask = ~mask;
const GLstencil clearVal = (ctx->Stencil.Clear & mask);
@@ -1242,7 +1242,7 @@ clear_hardware_stencil_buffer( GLcontext *ctx )
for (i = 0; i < width; i++) {
stencil[i] = ctx->Stencil.Clear;
}
- for (y = ctx->DrawBuffer->Ymin; y < ctx->DrawBuffer->Ymax; y++) {
+ for (y = ctx->DrawBuffer->_Ymin; y < ctx->DrawBuffer->_Ymax; y++) {
(*ctx->Driver.WriteStencilSpan)(ctx, x, y, width, stencil, NULL);
}
}
@@ -1256,7 +1256,7 @@ clear_hardware_stencil_buffer( GLcontext *ctx )
const GLstencil clearVal = (ctx->Stencil.Clear & mask);
const GLint width = ctx->DrawBuffer->Width;
const GLint height = ctx->DrawBuffer->Height;
- const GLint x = ctx->DrawBuffer->Xmin;
+ const GLint x = ctx->DrawBuffer->_Xmin;
GLint y;
for (y = 0; y < height; y++) {
GLstencil stencil[MAX_WIDTH];
@@ -1272,7 +1272,7 @@ clear_hardware_stencil_buffer( GLcontext *ctx )
/* clear whole buffer without masking */
const GLint width = ctx->DrawBuffer->Width;
const GLint height = ctx->DrawBuffer->Width;
- const GLint x = ctx->DrawBuffer->Xmin;
+ const GLint x = ctx->DrawBuffer->_Xmin;
GLstencil stencil[MAX_WIDTH];
GLint y, i;
for (i = 0; i < width; i++) {
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 267a0f2c8e..8ca640610e 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_triangle.c,v 1.2 2000/11/05 18:24:41 keithw Exp $ */
+/* $Id: s_triangle.c,v 1.3 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -58,7 +58,7 @@ GLboolean gl_cull_triangle( GLcontext *ctx,
GLfloat fy = v2->win[1] - v0->win[1];
GLfloat c = ex*fy-ey*fx;
- if (c * ctx->_backface_sign > 0)
+ if (c * SWRAST_CONTEXT(ctx)->_backface_sign > 0)
return 0;
return 1;
@@ -2378,7 +2378,7 @@ _swrast_choose_triangle( GLcontext *ctx )
needLambda = GL_TRUE;
else
needLambda = GL_FALSE;
- if (ctx->Texture._MultiTextureEnabled) {
+ if (swrast->_MultiTextureEnabled) {
swrast->Triangle = lambda_multitextured_triangle;
dputs("lambda_multitextured_triangle");
}
diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
index a87b24c40c..8fdbec9d18 100644
--- a/src/mesa/swrast/s_tritemp.h
+++ b/src/mesa/swrast/s_tritemp.h
@@ -1,4 +1,4 @@
-/* $Id: s_tritemp.h,v 1.2 2000/11/05 18:24:41 keithw Exp $ */
+/* $Id: s_tritemp.h,v 1.3 2000/11/13 20:02:57 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -96,7 +96,7 @@
EdgeT eMaj, eTop, eBot;
GLfloat oneOverArea;
SWvertex *vMin, *vMid, *vMax; /* Y(vMin)<=Y(vMid)<=Y(vMax) */
- float bf = ctx->_backface_sign;
+ float bf = SWRAST_CONTEXT(ctx)->_backface_sign;
/* find the order of the 3 vertices along the Y axis */
{
@@ -713,8 +713,10 @@
dZRowOuter = (ctx->DrawBuffer->Width + idxOuter) * sizeof(DEPTH_TYPE);
# endif
}
- ffog = FloatToFixed(vLower->fog) * 256 + dfogdx * adjx + dfogdy * adjy + FIXED_HALF;
- fdfogOuter = SignedFloatToFixed(dfogdy + dxOuter * dfogdx);
+ {
+ ffog = FloatToFixed(vLower->fog) * 256 + dfogdx * adjx + dfogdy * adjy + FIXED_HALF;
+ fdfogOuter = SignedFloatToFixed(dfogdy + dxOuter * dfogdx);
+ }
#endif
#ifdef INTERP_RGB
fr = (GLfixed)(IntToFixed(vLower->color[0])
@@ -980,7 +982,7 @@
zRow = (DEPTH_TYPE *) ((GLubyte*)zRow + dZRowOuter);
# endif
fz += fdzOuter;
- ffog += fdfogOuter;
+ ffog += fdfogOuter;
#endif
#ifdef INTERP_RGB
fr += fdrOuter; fg += fdgOuter; fb += fdbOuter;
diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
index 88689499fd..82a0add00e 100644
--- a/src/mesa/swrast/swrast.h
+++ b/src/mesa/swrast/swrast.h
@@ -150,5 +150,12 @@ _swrast_flush( GLcontext *ctx );
extern void
_swrast_InvalidateState( GLcontext *ctx, GLuint new_state );
+/* Configure software rasterizer to match hardware rasterizer characteristics:
+ */
+extern void
+_swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value );
+
+extern void
+_swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value );
#endif