[PROPSYS]
[reactos.git] / reactos / dll / opengl / mesa / main / lines.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.3
4 *
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 */
24
25 #include <precomp.h>
26
27 /**
28 * Set the line width.
29 *
30 * \param width line width in pixels.
31 *
32 * \sa glLineWidth().
33 */
34 void GLAPIENTRY
35 _mesa_LineWidth( GLfloat width )
36 {
37 GET_CURRENT_CONTEXT(ctx);
38 ASSERT_OUTSIDE_BEGIN_END(ctx);
39
40 if (MESA_VERBOSE & VERBOSE_API)
41 _mesa_debug(ctx, "glLineWidth %f\n", width);
42
43 if (width<=0.0) {
44 _mesa_error( ctx, GL_INVALID_VALUE, "glLineWidth" );
45 return;
46 }
47
48 if (ctx->Line.Width == width)
49 return;
50
51 FLUSH_VERTICES(ctx, _NEW_LINE);
52 ctx->Line.Width = width;
53
54 if (ctx->Driver.LineWidth)
55 ctx->Driver.LineWidth(ctx, width);
56 }
57
58
59 /**
60 * Set the line stipple pattern.
61 *
62 * \param factor pattern scale factor.
63 * \param pattern bit pattern.
64 *
65 * \sa glLineStipple().
66 *
67 * Updates gl_line_attrib::StippleFactor and gl_line_attrib::StipplePattern. On
68 * change flushes the vertices and notifies the driver via
69 * the dd_function_table::LineStipple callback.
70 */
71 void GLAPIENTRY
72 _mesa_LineStipple( GLint factor, GLushort pattern )
73 {
74 GET_CURRENT_CONTEXT(ctx);
75 ASSERT_OUTSIDE_BEGIN_END(ctx);
76
77 if (MESA_VERBOSE & VERBOSE_API)
78 _mesa_debug(ctx, "glLineStipple %d %u\n", factor, pattern);
79
80 factor = CLAMP( factor, 1, 256 );
81
82 if (ctx->Line.StippleFactor == factor &&
83 ctx->Line.StipplePattern == pattern)
84 return;
85
86 FLUSH_VERTICES(ctx, _NEW_LINE);
87 ctx->Line.StippleFactor = factor;
88 ctx->Line.StipplePattern = pattern;
89
90 if (ctx->Driver.LineStipple)
91 ctx->Driver.LineStipple( ctx, factor, pattern );
92 }
93
94
95 /**
96 * Initialize the context line state.
97 *
98 * \param ctx GL context.
99 *
100 * Initializes __struct gl_contextRec::Line and line related constants in
101 * __struct gl_contextRec::Const.
102 */
103 void GLAPIENTRY
104 _mesa_init_line( struct gl_context * ctx )
105 {
106 ctx->Line.SmoothFlag = GL_FALSE;
107 ctx->Line.StippleFlag = GL_FALSE;
108 ctx->Line.Width = 1.0;
109 ctx->Line.StipplePattern = 0xffff;
110 ctx->Line.StippleFactor = 1;
111 }