source: trunk/src/opengl/mesa/polygon.c@ 3721

Last change on this file since 3721 was 3598, checked in by jeroen, 25 years ago

* empty log message *

File size: 5.1 KB
Line 
1/* $Id: polygon.c,v 1.3 2000-05-23 20:40:51 jeroen Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28/* $XFree86: xc/lib/GL/mesa/src/polygon.c,v 1.3 1999/04/04 00:20:29 dawes Exp $ */
29
30#ifdef PC_HEADER
31#include "all.h"
32#else
33#include "glheader.h"
34#include "types.h"
35#include "context.h"
36#include "image.h"
37#include "enums.h"
38#include "macros.h"
39#include "polygon.h"
40#include "mem.h"
41#endif
42
43
44
45void
46_mesa_CullFace( GLenum mode )
47{
48 GET_CURRENT_CONTEXT(ctx);
49 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCullFace");
50
51 if (MESA_VERBOSE&VERBOSE_API)
52 fprintf(stderr, "glCullFace %s\n", gl_lookup_enum_by_nr(mode));
53
54 if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) {
55 gl_error( ctx, GL_INVALID_ENUM, "glCullFace" );
56 return;
57 }
58
59 ctx->Polygon.CullFaceMode = mode;
60 ctx->NewState |= NEW_POLYGON;
61
62 if (ctx->Driver.CullFace)
63 ctx->Driver.CullFace( ctx, mode );
64}
65
66
67
68void
69_mesa_FrontFace( GLenum mode )
70{
71 GET_CURRENT_CONTEXT(ctx);
72 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glFrontFace");
73
74 if (MESA_VERBOSE&VERBOSE_API)
75 fprintf(stderr, "glFrontFace %s\n", gl_lookup_enum_by_nr(mode));
76
77 if (mode!=GL_CW && mode!=GL_CCW) {
78 gl_error( ctx, GL_INVALID_ENUM, "glFrontFace" );
79 return;
80 }
81
82 ctx->Polygon.FrontFace = mode;
83 ctx->Polygon.FrontBit = (GLboolean) (mode == GL_CW);
84 ctx->NewState |= NEW_POLYGON;
85
86 if (ctx->Driver.FrontFace)
87 ctx->Driver.FrontFace( ctx, mode );
88}
89
90
91
92void
93_mesa_PolygonMode( GLenum face, GLenum mode )
94{
95 GET_CURRENT_CONTEXT(ctx);
96 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonMode");
97
98 if (MESA_VERBOSE&VERBOSE_API)
99 fprintf(stderr, "glPolygonMode %s %s\n",
100 gl_lookup_enum_by_nr(face),
101 gl_lookup_enum_by_nr(mode));
102
103 if (face!=GL_FRONT && face!=GL_BACK && face!=GL_FRONT_AND_BACK) {
104 gl_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
105 return;
106 }
107 else if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) {
108 gl_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" );
109 return;
110 }
111
112 if (face==GL_FRONT || face==GL_FRONT_AND_BACK) {
113 ctx->Polygon.FrontMode = mode;
114 }
115 if (face==GL_BACK || face==GL_FRONT_AND_BACK) {
116 ctx->Polygon.BackMode = mode;
117 }
118
119 /* Compute a handy "shortcut" value: */
120 ctx->TriangleCaps &= ~DD_TRI_UNFILLED;
121 ctx->Polygon.Unfilled = GL_FALSE;
122
123 if (ctx->Polygon.FrontMode!=GL_FILL || ctx->Polygon.BackMode!=GL_FILL) {
124 ctx->Polygon.Unfilled = GL_TRUE;
125 ctx->TriangleCaps |= DD_TRI_UNFILLED;
126 }
127
128 ctx->NewState |= (NEW_POLYGON | NEW_RASTER_OPS);
129
130 if (ctx->Driver.PolygonMode) {
131 (*ctx->Driver.PolygonMode)( ctx, face, mode );
132 }
133}
134
135
136
137void
138_mesa_PolygonStipple( const GLubyte *pattern )
139{
140 GET_CURRENT_CONTEXT(ctx);
141 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonStipple");
142
143 if (MESA_VERBOSE&VERBOSE_API)
144 fprintf(stderr, "glPolygonStipple\n");
145
146 _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack);
147
148 if (ctx->Polygon.StippleFlag) {
149 ctx->NewState |= NEW_RASTER_OPS;
150 }
151
152 if (ctx->Driver.PolygonStipple)
153 ctx->Driver.PolygonStipple( ctx, (const GLubyte *) ctx->PolygonStipple );
154}
155
156
157
158void
159_mesa_GetPolygonStipple( GLubyte *dest )
160{
161 GET_CURRENT_CONTEXT(ctx);
162 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonOffset");
163
164 if (MESA_VERBOSE&VERBOSE_API)
165 fprintf(stderr, "glGetPolygonStipple\n");
166
167 _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack);
168}
169
170
171
172void
173_mesa_PolygonOffset( GLfloat factor, GLfloat units )
174{
175 GET_CURRENT_CONTEXT(ctx);
176 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonOffset");
177
178 if (MESA_VERBOSE&VERBOSE_API)
179 fprintf(stderr, "glPolygonOffset %f %f\n", factor, units);
180
181 ctx->Polygon.OffsetFactor = factor;
182 ctx->Polygon.OffsetUnits = units;
183}
184
185
186
187void
188_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
189{
190 GET_CURRENT_CONTEXT(ctx);
191 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonOffsetEXT");
192 _mesa_PolygonOffset(factor, bias * ctx->Visual->DepthMaxF );
193}
Note: See TracBrowser for help on using the repository browser.