Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5563 | serge | 1 | /* |
2 | * Mesa 3-D graphics library |
||
3 | * |
||
4 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. |
||
5 | * |
||
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: |
||
12 | * |
||
13 | * The above copyright notice and this permission notice shall be included |
||
14 | * in all copies or substantial portions of the Software. |
||
15 | * |
||
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 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
||
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
||
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
||
22 | * OTHER DEALINGS IN THE SOFTWARE. |
||
23 | */ |
||
24 | |||
25 | |||
26 | #include "glheader.h" |
||
27 | #include "context.h" |
||
28 | #include "lines.h" |
||
29 | #include "macros.h" |
||
30 | #include "mtypes.h" |
||
31 | |||
32 | |||
33 | /** |
||
34 | * Set the line width. |
||
35 | * |
||
36 | * \param width line width in pixels. |
||
37 | * |
||
38 | * \sa glLineWidth(). |
||
39 | */ |
||
40 | void GLAPIENTRY |
||
41 | _mesa_LineWidth( GLfloat width ) |
||
42 | { |
||
43 | GET_CURRENT_CONTEXT(ctx); |
||
44 | |||
45 | if (MESA_VERBOSE & VERBOSE_API) |
||
46 | _mesa_debug(ctx, "glLineWidth %f\n", width); |
||
47 | |||
48 | if (width<=0.0) { |
||
49 | _mesa_error( ctx, GL_INVALID_VALUE, "glLineWidth" ); |
||
50 | return; |
||
51 | } |
||
52 | |||
53 | /* Page 407 (page 423 of the PDF) of the OpenGL 3.0 spec says (in the list |
||
54 | * of deprecated functionality): |
||
55 | * |
||
56 | * "Wide lines and line stipple - LineWidth is not deprecated, but |
||
57 | * values greater than 1.0 will generate an INVALID_VALUE error;" |
||
58 | * |
||
59 | * This is one of the very few cases where functionality was deprecated but |
||
60 | * *NOT* removed in a later spec. Therefore, we only disallow this in a |
||
61 | * forward compatible context. |
||
62 | */ |
||
63 | if (ctx->API == API_OPENGL_CORE |
||
64 | && ((ctx->Const.ContextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) |
||
65 | != 0)) { |
||
66 | _mesa_error( ctx, GL_INVALID_VALUE, "glLineWidth" ); |
||
67 | return; |
||
68 | } |
||
69 | |||
70 | if (ctx->Line.Width == width) |
||
71 | return; |
||
72 | |||
73 | FLUSH_VERTICES(ctx, _NEW_LINE); |
||
74 | ctx->Line.Width = width; |
||
75 | |||
76 | if (ctx->Driver.LineWidth) |
||
77 | ctx->Driver.LineWidth(ctx, width); |
||
78 | } |
||
79 | |||
80 | |||
81 | /** |
||
82 | * Set the line stipple pattern. |
||
83 | * |
||
84 | * \param factor pattern scale factor. |
||
85 | * \param pattern bit pattern. |
||
86 | * |
||
87 | * \sa glLineStipple(). |
||
88 | * |
||
89 | * Updates gl_line_attrib::StippleFactor and gl_line_attrib::StipplePattern. On |
||
90 | * change flushes the vertices and notifies the driver via |
||
91 | * the dd_function_table::LineStipple callback. |
||
92 | */ |
||
93 | void GLAPIENTRY |
||
94 | _mesa_LineStipple( GLint factor, GLushort pattern ) |
||
95 | { |
||
96 | GET_CURRENT_CONTEXT(ctx); |
||
97 | |||
98 | if (MESA_VERBOSE & VERBOSE_API) |
||
99 | _mesa_debug(ctx, "glLineStipple %d %u\n", factor, pattern); |
||
100 | |||
101 | factor = CLAMP( factor, 1, 256 ); |
||
102 | |||
103 | if (ctx->Line.StippleFactor == factor && |
||
104 | ctx->Line.StipplePattern == pattern) |
||
105 | return; |
||
106 | |||
107 | FLUSH_VERTICES(ctx, _NEW_LINE); |
||
108 | ctx->Line.StippleFactor = factor; |
||
109 | ctx->Line.StipplePattern = pattern; |
||
110 | |||
111 | if (ctx->Driver.LineStipple) |
||
112 | ctx->Driver.LineStipple( ctx, factor, pattern ); |
||
113 | } |
||
114 | |||
115 | |||
116 | /** |
||
117 | * Initialize the context line state. |
||
118 | * |
||
119 | * \param ctx GL context. |
||
120 | * |
||
121 | * Initializes __struct gl_contextRec::Line and line related constants in |
||
122 | * __struct gl_contextRec::Const. |
||
123 | */ |
||
124 | void GLAPIENTRY |
||
125 | _mesa_init_line( struct gl_context * ctx ) |
||
126 | { |
||
127 | ctx->Line.SmoothFlag = GL_FALSE; |
||
128 | ctx->Line.StippleFlag = GL_FALSE; |
||
129 | ctx->Line.Width = 1.0; |
||
130 | ctx->Line.StipplePattern = 0xffff; |
||
131 | ctx->Line.StippleFactor = 1; |
||
132 | }=0.0)> |