From 46b0988c673b28e072fd0cbf477632a9ab6f9f18 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 16 Feb 2001 18:14:41 +0000 Subject: Allow swrast to cope (fairly) cleanly with GL_SEPERATE_SPECULAR when texturing is not enabled, and without requiring the two colors be added externally. As a part of this, collapsed the decomposition of quads into triangles inside swrast to be hardwired into _swrast_Quad; removed s_quads.[ch]. Removed checks on texture state from t_vb_light.c, which was previously required by swrast. Moved the t_dd_ templates to a new directory. --- src/mesa/drivers/common/t_dd_unfilled.h | 135 ++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 src/mesa/drivers/common/t_dd_unfilled.h (limited to 'src/mesa/drivers/common/t_dd_unfilled.h') diff --git a/src/mesa/drivers/common/t_dd_unfilled.h b/src/mesa/drivers/common/t_dd_unfilled.h new file mode 100644 index 0000000000..c1f3a92b00 --- /dev/null +++ b/src/mesa/drivers/common/t_dd_unfilled.h @@ -0,0 +1,135 @@ + +static void tdfx_unfilled_tri( GLcontext *ctx, + GLenum mode, + GLuint e0, GLuint e1, GLuint e2 ) +{ + tdfxContextPtr imesa = TDFX_CONTEXT(ctx); + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + GLubyte *ef = VB->EdgeFlag; + GLubyte *tdfxverts = (GLubyte *)imesa->verts; + GLuint shift = imesa->vertex_stride_shift; + tdfxVertex *v0 = (tdfxVertex *)(tdfxverts + (e0 << shift)); + tdfxVertex *v1 = (tdfxVertex *)(tdfxverts + (e1 << shift)); + tdfxVertex *v2 = (tdfxVertex *)(tdfxverts + (e2 << shift)); + GLuint c[2]; + GLuint s[2]; + GLuint coloroffset = 0; + +/* fprintf(stderr, "%s %s %d %d %d (vertsize %d)\n", __FUNCTION__, */ +/* gl_lookup_enum_by_nr(mode), e0, e1, e2, imesa->vertsize); */ + + if (ctx->_TriangleCaps & DD_FLATSHADE) { + coloroffset = (imesa->vertsize == 4) ? 3 : 4; + TDFX_COPY_COLOR(c[0], v0->ui[coloroffset]); + TDFX_COPY_COLOR(c[1], v1->ui[coloroffset]); + TDFX_COPY_COLOR(v0->ui[coloroffset], v2->ui[coloroffset]); + TDFX_COPY_COLOR(v1->ui[coloroffset], v2->ui[coloroffset]); + + if (coloroffset == 4) { + TDFX_COPY_COLOR(s[0], v0->v.specular); + TDFX_COPY_COLOR(s[1], v1->v.specular); + TDFX_COPY_COLOR(v0->v.specular, v2->v.specular); + TDFX_COPY_COLOR(v1->v.specular, v2->v.specular); + } + } + + if (mode == GL_POINT) { + tdfxRasterPrimitive( ctx, GL_POINTS, PR_LINES ); + if (ef[e0]) imesa->draw_point( imesa, v0 ); + if (ef[e1]) imesa->draw_point( imesa, v1 ); + if (ef[e2]) imesa->draw_point( imesa, v2 ); + } + else { + tdfxRasterPrimitive( ctx, GL_LINES, PR_LINES ); + + if (imesa->render_primitive == GL_POLYGON) { + if (ef[e2]) imesa->draw_line( imesa, v2, v0 ); + if (ef[e0]) imesa->draw_line( imesa, v0, v1 ); + if (ef[e1]) imesa->draw_line( imesa, v1, v2 ); + } + else { + if (ef[e0]) imesa->draw_line( imesa, v0, v1 ); + if (ef[e1]) imesa->draw_line( imesa, v1, v2 ); + if (ef[e2]) imesa->draw_line( imesa, v2, v0 ); + } + } + + if (ctx->_TriangleCaps & DD_FLATSHADE) { + TDFX_COPY_COLOR(v0->ui[coloroffset], c[0]); + TDFX_COPY_COLOR(v1->ui[coloroffset], c[1]); + if (coloroffset == 4) { + TDFX_COPY_COLOR(v0->v.specular, s[0]); + TDFX_COPY_COLOR(v1->v.specular, s[1]); + } + } +} + + +static void tdfx_unfilled_quad( GLcontext *ctx, + GLenum mode, + GLuint e0, GLuint e1, + GLuint e2, GLuint e3 ) +{ + tdfxContextPtr imesa = TDFX_CONTEXT(ctx); + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + GLubyte *ef = VB->EdgeFlag; + GLubyte *tdfxverts = (GLubyte *)imesa->verts; + GLuint shift = imesa->vertex_stride_shift; + tdfxVertex *v0 = (tdfxVertex *)(tdfxverts + (e0 << shift)); + tdfxVertex *v1 = (tdfxVertex *)(tdfxverts + (e1 << shift)); + tdfxVertex *v2 = (tdfxVertex *)(tdfxverts + (e2 << shift)); + tdfxVertex *v3 = (tdfxVertex *)(tdfxverts + (e3 << shift)); + GLuint c[3]; + GLuint s[3]; + GLuint coloroffset = 0; + + if (ctx->_TriangleCaps & DD_FLATSHADE) { + coloroffset = (imesa->vertsize == 4) ? 3 : 4; + + TDFX_COPY_COLOR(c[0], v0->ui[coloroffset]); + TDFX_COPY_COLOR(c[1], v1->ui[coloroffset]); + TDFX_COPY_COLOR(c[2], v2->ui[coloroffset]); + TDFX_COPY_COLOR(v0->ui[coloroffset], v3->ui[coloroffset]); + TDFX_COPY_COLOR(v1->ui[coloroffset], v3->ui[coloroffset]); + TDFX_COPY_COLOR(v2->ui[coloroffset], v3->ui[coloroffset]); + + if (coloroffset == 4) { + TDFX_COPY_COLOR(s[0], v0->v.specular); + TDFX_COPY_COLOR(s[1], v1->v.specular); + TDFX_COPY_COLOR(s[2], v2->v.specular); + TDFX_COPY_COLOR(v0->v.specular, v3->v.specular); + TDFX_COPY_COLOR(v1->v.specular, v3->v.specular); + TDFX_COPY_COLOR(v2->v.specular, v3->v.specular); + } + } + + if (mode == GL_POINT) { + if (imesa->reduced_primitive != GL_POINTS) + tdfxRasterPrimitive( ctx, GL_POINTS, PR_LINES ); + + if (ef[e0]) imesa->draw_point( imesa, v0 ); + if (ef[e1]) imesa->draw_point( imesa, v1 ); + if (ef[e2]) imesa->draw_point( imesa, v2 ); + if (ef[e3]) imesa->draw_point( imesa, v3 ); + } + else { + if (imesa->reduced_primitive != GL_LINES) + tdfxRasterPrimitive( ctx, GL_LINES, PR_LINES ); + + if (ef[e0]) imesa->draw_line( imesa, v0, v1 ); + if (ef[e1]) imesa->draw_line( imesa, v1, v2 ); + if (ef[e2]) imesa->draw_line( imesa, v2, v3 ); + if (ef[e3]) imesa->draw_line( imesa, v3, v0 ); + } + + if (ctx->_TriangleCaps & DD_FLATSHADE) { + TDFX_COPY_COLOR(v0->ui[coloroffset], c[0]); + TDFX_COPY_COLOR(v1->ui[coloroffset], c[1]); + TDFX_COPY_COLOR(v2->ui[coloroffset], c[2]); + if (coloroffset == 4) { + TDFX_COPY_COLOR(v0->v.specular, s[0]); + TDFX_COPY_COLOR(v1->v.specular, s[1]); + TDFX_COPY_COLOR(v2->v.specular, s[2]); + } + } +} -- cgit v1.2.3