7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 * \param width line width in pixels.
47 * Verifies the parameter and updates gl_line_attrib::Width. On a change,
48 * flushes the vertices, updates the clamped line width and marks the
49 * DD_LINE_WIDTH flag in __GLcontextRec::_TriangleCaps for the drivers if the
50 * width is different from one. Notifies the driver via the
51 * dd_function_table::LineWidth callback.
54 _mesa_LineWidth( GLfloat width
)
56 GET_CURRENT_CONTEXT(ctx
);
57 ASSERT_OUTSIDE_BEGIN_END(ctx
);
60 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLineWidth" );
64 if (ctx
->Line
.Width
== width
)
67 FLUSH_VERTICES(ctx
, _NEW_LINE
);
68 ctx
->Line
.Width
= width
;
69 ctx
->Line
._Width
= CLAMP(width
,
70 ctx
->Const
.MinLineWidth
,
71 ctx
->Const
.MaxLineWidth
);
75 ctx
->_TriangleCaps
|= DD_LINE_WIDTH
;
77 ctx
->_TriangleCaps
&= ~DD_LINE_WIDTH
;
79 if (ctx
->Driver
.LineWidth
)
80 (*ctx
->Driver
.LineWidth
)(ctx
, width
);
85 * Set the line stipple pattern.
87 * \param factor pattern scale factor.
88 * \param pattern bit pattern.
90 * \sa glLineStipple().
92 * Updates gl_line_attrib::StippleFactor and gl_line_attrib::StipplePattern. On
93 * change flushes the vertices and notifies the driver via
94 * the dd_function_table::LineStipple callback.
97 _mesa_LineStipple( GLint factor
, GLushort pattern
)
99 GET_CURRENT_CONTEXT(ctx
);
100 ASSERT_OUTSIDE_BEGIN_END(ctx
);
102 factor
= CLAMP( factor
, 1, 256 );
104 if (ctx
->Line
.StippleFactor
== factor
&&
105 ctx
->Line
.StipplePattern
== pattern
)
108 FLUSH_VERTICES(ctx
, _NEW_LINE
);
109 ctx
->Line
.StippleFactor
= factor
;
110 ctx
->Line
.StipplePattern
= pattern
;
112 if (ctx
->Driver
.LineStipple
)
113 ctx
->Driver
.LineStipple( ctx
, factor
, pattern
);
118 * Initialize the context line state.
120 * \param ctx GL context.
122 * Initializes __GLcontextRec::Line and line related constants in
123 * __GLcontextRec::Const.
125 void GLAPIENTRY
_mesa_init_line( GLcontext
* ctx
)
128 ctx
->Line
.SmoothFlag
= GL_FALSE
;
129 ctx
->Line
.StippleFlag
= GL_FALSE
;
130 ctx
->Line
.Width
= 1.0;
131 ctx
->Line
._Width
= 1.0;
132 ctx
->Line
.StipplePattern
= 0xffff;
133 ctx
->Line
.StippleFactor
= 1;