/*@}*/
+
+/**
+ * Macros to help evaluate current state conditions
+ */
+
+/*@{*/
+
+/**
+ * Is the secondary color needed?
+ */
+#define NEED_SECONDARY_COLOR(CTX) \
+ (((CTX)->Light.Enabled && \
+ (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) \
+ || (CTX)->Fog.ColorSumEnabled)
+
+
+/**
+ * Is two-sided lighting in effect?
+ */
+#define NEED_TWO_SIDED_LIGHTING(CTX) \
+ (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
+
+
+/*@}*/
+
+
#endif
ASSERT(ctx->Polygon.SmoothFlag);
if (ctx->Texture._EnabledCoordUnits != 0) {
- if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
+ if (NEED_SECONDARY_COLOR(ctx)) {
if (ctx->Texture._EnabledCoordUnits > 1) {
SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri;
}
_swrast_validate_derived( ctx );
swrast->choose_triangle( ctx );
- if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
- ctx->Texture._EnabledUnits == 0) {
+ if (ctx->Texture._EnabledUnits == 0 && NEED_SECONDARY_COLOR(ctx)) {
+ /* separate specular color, but no texture */
swrast->SpecTriangle = swrast->Triangle;
swrast->Triangle = _swrast_add_spec_terms_triangle;
}
_swrast_validate_derived( ctx );
swrast->choose_line( ctx );
- if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
- ctx->Texture._EnabledUnits == 0) {
+ if (ctx->Texture._EnabledUnits == 0 && NEED_SECONDARY_COLOR(ctx)) {
swrast->SpecLine = swrast->Line;
swrast->Line = _swrast_add_spec_terms_line;
}
_swrast_validate_derived( ctx );
swrast->choose_point( ctx );
- if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
- ctx->Texture._EnabledUnits == 0) {
+ if (ctx->Texture._EnabledUnits == 0 && NEED_SECONDARY_COLOR(ctx)) {
swrast->SpecPoint = swrast->Point;
swrast->Point = _swrast_add_spec_terms_point;
}
#include "glheader.h"
+#include "context.h"
#include "colormac.h"
#include "macros.h"
#include "s_aaline.h"
else if (ctx->Texture._EnabledCoordUnits) {
/* textured lines */
if (ctx->Texture._EnabledCoordUnits > 0x1
- || (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)) {
+ || NEED_SECONDARY_COLOR(ctx)) {
/* multi-texture and/or separate specular color */
USE(multitextured_line);
}
return;
}
- if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ if (ctx->Light.ShadeModel == GL_FLAT) {
COPY_CHAN4(c[0], v0->color);
COPY_CHAN4(c[1], v1->color);
COPY_CHAN4(s[0], v0->specular);
if (ef[e2]) _swrast_Line( ctx, v2, v0 );
}
- if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ if (ctx->Light.ShadeModel == GL_FLAT) {
COPY_CHAN4(v0->color, c[0]);
COPY_CHAN4(v1->color, c[1]);
COPY_CHAN4(v0->specular, s[0]);
return;
}
- if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ if (ctx->Light.ShadeModel == GL_FLAT) {
+ /* save colors/indexes for v0, v1 vertices */
COPY_CHAN4(c[0], v0->color);
COPY_CHAN4(c[1], v1->color);
COPY_CHAN4(s[0], v0->specular);
i[0] = v0->index;
i[1] = v1->index;
+ /* copy v2 color/indexes to v0, v1 indexes */
COPY_CHAN4(v0->color, v2->color);
COPY_CHAN4(v1->color, v2->color);
COPY_CHAN4(v0->specular, v2->specular);
if (ef[e1]) _swrast_Point( ctx, v1 );
if (ef[e2]) _swrast_Point( ctx, v2 );
- if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ if (ctx->Light.ShadeModel == GL_FLAT) {
+ /* restore v0, v1 colores/indexes */
COPY_CHAN4(v0->color, c[0]);
COPY_CHAN4(v1->color, c[1]);
COPY_CHAN4(v0->specular, s[0]);
/* We piggyback the two-sided stencil front/back determination on the
* unfilled triangle path.
*/
- if ((ctx->_TriangleCaps & DD_TRI_UNFILLED) ||
+ if (ctx->Polygon.FrontMode != GL_FILL ||
+ ctx->Polygon.BackMode != GL_FILL ||
(ctx->Stencil.Enabled && ctx->Stencil.TestTwoSide))
ind |= SS_UNFILLED_BIT;
else if (ctx->Texture._EnabledCoordUnits == 1)
funcindex |= TEX0; /* only unit 0 is enabled */
- if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ if (NEED_SECONDARY_COLOR(ctx))
funcindex |= SPEC;
}
else {
swsetup->SetupIndex = funcindex;
tnl->Driver.Render.BuildVertices = setup_tab[funcindex];
- if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ if (NEED_TWO_SIDED_LIGHTING(ctx) ||
+ ctx->Polygon.FrontMode != GL_FILL ||
+ ctx->Polygon.BackMode != GL_FILL) {
tnl->Driver.Render.Interp = interp_extras;
tnl->Driver.Render.CopyPV = copy_pv_extras;
}
/* Clip and render whole begin/end objects */
/**********************************************************************/
-#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED)
+#define NEED_EDGEFLAG_SETUP (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL)
#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
/* Render whole begin/end objects */
/**********************************************************************/
-#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED)
+#define NEED_EDGEFLAG_SETUP (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL)
#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
if (ctx->Visual.rgbMode) {
inputs |= VERT_BIT_COLOR0;
- if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ if (NEED_SECONDARY_COLOR(ctx))
inputs |= VERT_BIT_COLOR1;
if (ctx->Texture._EnabledCoordUnits) {
if (ctx->Fog.Enabled)
inputs |= VERT_BIT_FOG;
- if (ctx->_TriangleCaps & DD_TRI_UNFILLED)
+ if (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL)
inputs |= VERT_BIT_EDGEFLAG;
if (ctx->RenderMode==GL_FEEDBACK)