992bc4f396a163fdbbd5be2b9031f08c266988ed
2 * Mesa 3-D graphics library
5 * Copyright (C) 1999 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Keith Whitwell <keithw@valinux.com>
32 #include "ss_triangle.h"
33 #include "ss_context.h"
35 #define SS_FLAT_BIT 0x1
36 #define SS_OFFSET_BIT 0x2
37 #define SS_TWOSIDE_BIT 0x4
38 #define SS_UNFILLED_BIT 0x10
39 #define SS_MAX_TRIFUNC 0x20
41 static triangle_func tri_tab
[SS_MAX_TRIFUNC
];
42 static line_func line_tab
[SS_MAX_TRIFUNC
];
43 static points_func points_tab
[SS_MAX_TRIFUNC
];
44 static quad_func quad_tab
[SS_MAX_TRIFUNC
];
47 #define SS_COLOR(a,b) COPY_4UBV(a,b)
48 #define SS_SPEC(a,b) COPY_4UBV(a,b)
49 #define SS_IND(a,b) (a = b)
53 #include "ss_tritmp.h"
55 #define IND (SS_FLAT_BIT)
56 #define TAG(x) x##_flat
57 #include "ss_tritmp.h"
59 #define IND (SS_OFFSET_BIT)
60 #define TAG(x) x##_offset
61 #include "ss_tritmp.h"
63 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT)
64 #define TAG(x) x##_flat_offset
65 #include "ss_tritmp.h"
67 #define IND (SS_TWOSIDE_BIT)
68 #define TAG(x) x##_twoside
69 #include "ss_tritmp.h"
71 #define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT)
72 #define TAG(x) x##_flat_twoside
73 #include "ss_tritmp.h"
75 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT)
76 #define TAG(x) x##_offset_twoside
77 #include "ss_tritmp.h"
79 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT)
80 #define TAG(x) x##_flat_offset_twoside
81 #include "ss_tritmp.h"
83 #define IND (SS_UNFILLED_BIT)
84 #define TAG(x) x##_unfilled
85 #include "ss_tritmp.h"
87 #define IND (SS_FLAT_BIT|SS_UNFILLED_BIT)
88 #define TAG(x) x##_flat_unfilled
89 #include "ss_tritmp.h"
91 #define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT)
92 #define TAG(x) x##_offset_unfilled
93 #include "ss_tritmp.h"
95 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_UNFILLED_BIT)
96 #define TAG(x) x##_flat_offset_unfilled
97 #include "ss_tritmp.h"
99 #define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
100 #define TAG(x) x##_twoside_unfilled
101 #include "ss_tritmp.h"
103 #define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
104 #define TAG(x) x##_flat_twoside_unfilled
105 #include "ss_tritmp.h"
107 #define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
108 #define TAG(x) x##_offset_twoside_unfilled
109 #include "ss_tritmp.h"
111 #define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
112 #define TAG(x) x##_flat_offset_twoside_unfilled
113 #include "ss_tritmp.h"
116 void _swsetup_trifuncs_init( GLcontext
*ctx
)
126 init_offset_twoside();
127 init_flat_offset_twoside();
129 init_flat_unfilled();
130 init_offset_unfilled();
131 init_flat_offset_unfilled();
132 init_twoside_unfilled();
133 init_flat_twoside_unfilled();
134 init_offset_twoside_unfilled();
135 init_flat_offset_twoside_unfilled();
139 void _swsetup_choose_trifuncs( GLcontext
*ctx
)
141 SScontext
*swsetup
= SWSETUP_CONTEXT(ctx
);
144 if (ctx
->Light
.ShadeModel
== GL_FLAT
)
147 if (ctx
->Polygon
._OffsetAny
)
148 ind
|= SS_OFFSET_BIT
;
150 if (ctx
->Light
.Enabled
&& ctx
->Light
.Model
.TwoSide
)
151 ind
|= SS_TWOSIDE_BIT
;
153 if (ctx
->Polygon
._Unfilled
)
154 ind
|= SS_UNFILLED_BIT
;
156 swsetup
->Triangle
= tri_tab
[ind
];
157 swsetup
->Line
= line_tab
[ind
];
158 swsetup
->Points
= points_tab
[ind
];
159 swsetup
->Quad
= quad_tab
[ind
];