3 * GLX Hardware Device Driver for Sun Creator/Creator3D
4 * Copyright (C) 2000, 2001 David S. Miller
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * David S. Miller <davem@redhat.com>
32 #include "ffb_depth.h"
33 #include "ffb_context.h"
35 #include "ffb_lines.h"
38 #include "extensions.h"
42 #define FFB_LINE_FLAT_BIT 0x01
43 #define FFB_LINE_ALPHA_BIT 0x02
44 #define MAX_FFB_LINE_FUNCS 0x04
46 static ffb_line_func ffb_line_tab
[MAX_FFB_LINE_FUNCS
];
48 /* If the line is not wide, we can support all of the line
49 * patterning and smooth shading features of OpenGL fully.
54 #include "ffb_linetmp.h"
56 #define IND (FFB_LINE_FLAT_BIT)
57 #define TAG(x) x##_flat
58 #include "ffb_linetmp.h"
60 #define IND (FFB_LINE_ALPHA_BIT)
61 #define TAG(x) x##_alpha
62 #include "ffb_linetmp.h"
64 #define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_FLAT_BIT)
65 #define TAG(x) x##_alpha_flat
66 #include "ffb_linetmp.h"
68 void ffbDDLinefuncInit(void)
76 static void ffb_dd_line( GLcontext
*ctx
, GLuint e0
, GLuint e1
)
78 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
79 ffb_vertex
*v0
= &fmesa
->verts
[e0
];
80 ffb_vertex
*v1
= &fmesa
->verts
[e1
];
81 fmesa
->draw_line( ctx
, v0
, v1
);
84 void ffbChooseLineState(GLcontext
*ctx
)
86 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
87 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
88 GLuint flags
= ctx
->_TriangleCaps
;
91 tnl
->Driver
.Render
.Line
= ffb_dd_line
;
93 if (flags
& DD_FLATSHADE
)
94 ind
|= FFB_LINE_FLAT_BIT
;
96 if ((flags
& DD_LINE_STIPPLE
) != 0 &&
97 fmesa
->lpat
== FFB_LPAT_BAD
) {
98 fmesa
->draw_line
= ffb_fallback_line
;
102 /* If blending or the alpha test is enabled we need to
103 * provide alpha components to the chip, else we can
104 * do without it and thus feed vertex data to the chip
107 if (ctx
->Color
.BlendEnabled
|| ctx
->Color
.AlphaEnabled
)
108 ind
|= FFB_LINE_ALPHA_BIT
;
110 fmesa
->draw_line
= ffb_line_tab
[ind
];