xref: /third_party/mesa3d/src/mesa/main/polygon.c (revision bf215546)
1bf215546Sopenharmony_ci/**
2bf215546Sopenharmony_ci * \file polygon.c
3bf215546Sopenharmony_ci * Polygon operations.
4bf215546Sopenharmony_ci */
5bf215546Sopenharmony_ci
6bf215546Sopenharmony_ci/*
7bf215546Sopenharmony_ci * Mesa 3-D graphics library
8bf215546Sopenharmony_ci *
9bf215546Sopenharmony_ci * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
12bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
13bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
14bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
16bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
17bf215546Sopenharmony_ci *
18bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included
19bf215546Sopenharmony_ci * in all copies or substantial portions of the Software.
20bf215546Sopenharmony_ci *
21bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
24bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
28bf215546Sopenharmony_ci */
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ci#include "glheader.h"
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci#include "context.h"
34bf215546Sopenharmony_ci#include "draw_validate.h"
35bf215546Sopenharmony_ci#include "image.h"
36bf215546Sopenharmony_ci#include "enums.h"
37bf215546Sopenharmony_ci#include "pack.h"
38bf215546Sopenharmony_ci#include "pbo.h"
39bf215546Sopenharmony_ci#include "polygon.h"
40bf215546Sopenharmony_ci#include "mtypes.h"
41bf215546Sopenharmony_ci#include "api_exec_decl.h"
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ci#include "state_tracker/st_context.h"
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ci/**
46bf215546Sopenharmony_ci * Specify whether to cull front- or back-facing facets.
47bf215546Sopenharmony_ci *
48bf215546Sopenharmony_ci * \param mode culling mode.
49bf215546Sopenharmony_ci *
50bf215546Sopenharmony_ci * \sa glCullFace().
51bf215546Sopenharmony_ci *
52bf215546Sopenharmony_ci * Verifies the parameter and updates gl_polygon_attrib::CullFaceMode. On
53bf215546Sopenharmony_ci * change, flushes the vertices and notifies the driver via
54bf215546Sopenharmony_ci * the dd_function_table::CullFace callback.
55bf215546Sopenharmony_ci */
56bf215546Sopenharmony_cistatic ALWAYS_INLINE void
57bf215546Sopenharmony_cicull_face(struct gl_context *ctx, GLenum mode, bool no_error)
58bf215546Sopenharmony_ci{
59bf215546Sopenharmony_ci   if (ctx->Polygon.CullFaceMode == mode)
60bf215546Sopenharmony_ci      return;
61bf215546Sopenharmony_ci
62bf215546Sopenharmony_ci   if (!no_error &&
63bf215546Sopenharmony_ci       mode != GL_FRONT && mode != GL_BACK && mode != GL_FRONT_AND_BACK) {
64bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_ENUM, "glCullFace");
65bf215546Sopenharmony_ci      return;
66bf215546Sopenharmony_ci   }
67bf215546Sopenharmony_ci
68bf215546Sopenharmony_ci   FLUSH_VERTICES(ctx, 0,
69bf215546Sopenharmony_ci                  GL_POLYGON_BIT);
70bf215546Sopenharmony_ci   ctx->NewDriverState |= ST_NEW_RASTERIZER;
71bf215546Sopenharmony_ci   ctx->Polygon.CullFaceMode = mode;
72bf215546Sopenharmony_ci}
73bf215546Sopenharmony_ci
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_civoid GLAPIENTRY
76bf215546Sopenharmony_ci_mesa_CullFace_no_error(GLenum mode)
77bf215546Sopenharmony_ci{
78bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
79bf215546Sopenharmony_ci   cull_face(ctx, mode, true);
80bf215546Sopenharmony_ci}
81bf215546Sopenharmony_ci
82bf215546Sopenharmony_ci
83bf215546Sopenharmony_civoid GLAPIENTRY
84bf215546Sopenharmony_ci_mesa_CullFace(GLenum mode)
85bf215546Sopenharmony_ci{
86bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
87bf215546Sopenharmony_ci
88bf215546Sopenharmony_ci   if (MESA_VERBOSE & VERBOSE_API)
89bf215546Sopenharmony_ci      _mesa_debug(ctx, "glCullFace %s\n", _mesa_enum_to_string(mode));
90bf215546Sopenharmony_ci
91bf215546Sopenharmony_ci   cull_face(ctx, mode, false);
92bf215546Sopenharmony_ci}
93bf215546Sopenharmony_ci
94bf215546Sopenharmony_ci
95bf215546Sopenharmony_ci/**
96bf215546Sopenharmony_ci * Define front- and back-facing
97bf215546Sopenharmony_ci *
98bf215546Sopenharmony_ci * \param mode orientation of front-facing polygons.
99bf215546Sopenharmony_ci *
100bf215546Sopenharmony_ci * \sa glFrontFace().
101bf215546Sopenharmony_ci *
102bf215546Sopenharmony_ci * Verifies the parameter and updates gl_polygon_attrib::FrontFace. On change
103bf215546Sopenharmony_ci * flushes the vertices and notifies the driver via
104bf215546Sopenharmony_ci * the dd_function_table::FrontFace callback.
105bf215546Sopenharmony_ci */
106bf215546Sopenharmony_cistatic ALWAYS_INLINE void
107bf215546Sopenharmony_cifront_face(struct gl_context *ctx, GLenum mode, bool no_error)
108bf215546Sopenharmony_ci{
109bf215546Sopenharmony_ci   if (ctx->Polygon.FrontFace == mode)
110bf215546Sopenharmony_ci      return;
111bf215546Sopenharmony_ci
112bf215546Sopenharmony_ci   if (!no_error && mode != GL_CW && mode != GL_CCW) {
113bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_ENUM, "glFrontFace");
114bf215546Sopenharmony_ci      return;
115bf215546Sopenharmony_ci   }
116bf215546Sopenharmony_ci
117bf215546Sopenharmony_ci   FLUSH_VERTICES(ctx, 0,
118bf215546Sopenharmony_ci                  GL_POLYGON_BIT);
119bf215546Sopenharmony_ci   ctx->NewDriverState |= ST_NEW_RASTERIZER;
120bf215546Sopenharmony_ci   ctx->Polygon.FrontFace = mode;
121bf215546Sopenharmony_ci}
122bf215546Sopenharmony_ci
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_civoid GLAPIENTRY
125bf215546Sopenharmony_ci_mesa_FrontFace_no_error(GLenum mode)
126bf215546Sopenharmony_ci{
127bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
128bf215546Sopenharmony_ci   front_face(ctx, mode, true);
129bf215546Sopenharmony_ci}
130bf215546Sopenharmony_ci
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_civoid GLAPIENTRY
133bf215546Sopenharmony_ci_mesa_FrontFace(GLenum mode)
134bf215546Sopenharmony_ci{
135bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
136bf215546Sopenharmony_ci
137bf215546Sopenharmony_ci   if (MESA_VERBOSE & VERBOSE_API)
138bf215546Sopenharmony_ci      _mesa_debug(ctx, "glFrontFace %s\n", _mesa_enum_to_string(mode));
139bf215546Sopenharmony_ci
140bf215546Sopenharmony_ci   front_face(ctx, mode, false);
141bf215546Sopenharmony_ci}
142bf215546Sopenharmony_ci
143bf215546Sopenharmony_ci
144bf215546Sopenharmony_ci/**
145bf215546Sopenharmony_ci * Set the polygon rasterization mode.
146bf215546Sopenharmony_ci *
147bf215546Sopenharmony_ci * \param face the polygons which \p mode applies to.
148bf215546Sopenharmony_ci * \param mode how polygons should be rasterized.
149bf215546Sopenharmony_ci *
150bf215546Sopenharmony_ci * \sa glPolygonMode().
151bf215546Sopenharmony_ci *
152bf215546Sopenharmony_ci * Verifies the parameters and updates gl_polygon_attrib::FrontMode and
153bf215546Sopenharmony_ci * gl_polygon_attrib::BackMode. On change flushes the vertices and notifies the
154bf215546Sopenharmony_ci * driver via the dd_function_table::PolygonMode callback.
155bf215546Sopenharmony_ci */
156bf215546Sopenharmony_cistatic ALWAYS_INLINE void
157bf215546Sopenharmony_cipolygon_mode(struct gl_context *ctx, GLenum face, GLenum mode, bool no_error)
158bf215546Sopenharmony_ci{
159bf215546Sopenharmony_ci   bool old_mode_has_fill_rectangle =
160bf215546Sopenharmony_ci      ctx->Polygon.FrontMode == GL_FILL_RECTANGLE_NV ||
161bf215546Sopenharmony_ci      ctx->Polygon.BackMode == GL_FILL_RECTANGLE_NV;
162bf215546Sopenharmony_ci
163bf215546Sopenharmony_ci   if (MESA_VERBOSE & VERBOSE_API)
164bf215546Sopenharmony_ci      _mesa_debug(ctx, "glPolygonMode %s %s\n",
165bf215546Sopenharmony_ci                  _mesa_enum_to_string(face),
166bf215546Sopenharmony_ci                  _mesa_enum_to_string(mode));
167bf215546Sopenharmony_ci
168bf215546Sopenharmony_ci   if (!no_error) {
169bf215546Sopenharmony_ci      switch (mode) {
170bf215546Sopenharmony_ci      case GL_POINT:
171bf215546Sopenharmony_ci      case GL_LINE:
172bf215546Sopenharmony_ci      case GL_FILL:
173bf215546Sopenharmony_ci         break;
174bf215546Sopenharmony_ci      case GL_FILL_RECTANGLE_NV:
175bf215546Sopenharmony_ci         if (ctx->Extensions.NV_fill_rectangle)
176bf215546Sopenharmony_ci            break;
177bf215546Sopenharmony_ci         FALLTHROUGH;
178bf215546Sopenharmony_ci      default:
179bf215546Sopenharmony_ci         _mesa_error(ctx, GL_INVALID_ENUM, "glPolygonMode(mode)");
180bf215546Sopenharmony_ci         return;
181bf215546Sopenharmony_ci      }
182bf215546Sopenharmony_ci   }
183bf215546Sopenharmony_ci
184bf215546Sopenharmony_ci   switch (face) {
185bf215546Sopenharmony_ci   case GL_FRONT:
186bf215546Sopenharmony_ci      if (!no_error && ctx->API == API_OPENGL_CORE) {
187bf215546Sopenharmony_ci         _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
188bf215546Sopenharmony_ci         return;
189bf215546Sopenharmony_ci      }
190bf215546Sopenharmony_ci      if (ctx->Polygon.FrontMode == mode)
191bf215546Sopenharmony_ci         return;
192bf215546Sopenharmony_ci      FLUSH_VERTICES(ctx, 0,
193bf215546Sopenharmony_ci                     GL_POLYGON_BIT);
194bf215546Sopenharmony_ci      ctx->NewDriverState |= ST_NEW_RASTERIZER;
195bf215546Sopenharmony_ci      ctx->Polygon.FrontMode = mode;
196bf215546Sopenharmony_ci      break;
197bf215546Sopenharmony_ci   case GL_FRONT_AND_BACK:
198bf215546Sopenharmony_ci      if (ctx->Polygon.FrontMode == mode && ctx->Polygon.BackMode == mode)
199bf215546Sopenharmony_ci         return;
200bf215546Sopenharmony_ci      FLUSH_VERTICES(ctx, 0,
201bf215546Sopenharmony_ci                     GL_POLYGON_BIT);
202bf215546Sopenharmony_ci      ctx->NewDriverState |= ST_NEW_RASTERIZER;
203bf215546Sopenharmony_ci      ctx->Polygon.FrontMode = mode;
204bf215546Sopenharmony_ci      ctx->Polygon.BackMode = mode;
205bf215546Sopenharmony_ci      break;
206bf215546Sopenharmony_ci   case GL_BACK:
207bf215546Sopenharmony_ci      if (!no_error && ctx->API == API_OPENGL_CORE) {
208bf215546Sopenharmony_ci         _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
209bf215546Sopenharmony_ci         return;
210bf215546Sopenharmony_ci      }
211bf215546Sopenharmony_ci      if (ctx->Polygon.BackMode == mode)
212bf215546Sopenharmony_ci         return;
213bf215546Sopenharmony_ci      FLUSH_VERTICES(ctx, 0,
214bf215546Sopenharmony_ci                     GL_POLYGON_BIT);
215bf215546Sopenharmony_ci      ctx->NewDriverState |= ST_NEW_RASTERIZER;
216bf215546Sopenharmony_ci      ctx->Polygon.BackMode = mode;
217bf215546Sopenharmony_ci      break;
218bf215546Sopenharmony_ci   default:
219bf215546Sopenharmony_ci      if (!no_error)
220bf215546Sopenharmony_ci         _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
221bf215546Sopenharmony_ci      return;
222bf215546Sopenharmony_ci   }
223bf215546Sopenharmony_ci
224bf215546Sopenharmony_ci   if (ctx->Extensions.INTEL_conservative_rasterization ||
225bf215546Sopenharmony_ci       (mode == GL_FILL_RECTANGLE_NV || old_mode_has_fill_rectangle))
226bf215546Sopenharmony_ci      _mesa_update_valid_to_render_state(ctx);
227bf215546Sopenharmony_ci}
228bf215546Sopenharmony_ci
229bf215546Sopenharmony_ci
230bf215546Sopenharmony_civoid GLAPIENTRY
231bf215546Sopenharmony_ci_mesa_PolygonMode_no_error(GLenum face, GLenum mode)
232bf215546Sopenharmony_ci{
233bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
234bf215546Sopenharmony_ci   polygon_mode(ctx, face, mode, true);
235bf215546Sopenharmony_ci}
236bf215546Sopenharmony_ci
237bf215546Sopenharmony_ci
238bf215546Sopenharmony_civoid GLAPIENTRY
239bf215546Sopenharmony_ci_mesa_PolygonMode(GLenum face, GLenum mode)
240bf215546Sopenharmony_ci{
241bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
242bf215546Sopenharmony_ci   polygon_mode(ctx, face, mode, false);
243bf215546Sopenharmony_ci}
244bf215546Sopenharmony_ci
245bf215546Sopenharmony_ci
246bf215546Sopenharmony_ci/**
247bf215546Sopenharmony_ci * Called by glPolygonStipple.
248bf215546Sopenharmony_ci */
249bf215546Sopenharmony_civoid GLAPIENTRY
250bf215546Sopenharmony_ci_mesa_PolygonStipple(const GLubyte *pattern)
251bf215546Sopenharmony_ci{
252bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
253bf215546Sopenharmony_ci
254bf215546Sopenharmony_ci   if (MESA_VERBOSE & VERBOSE_API)
255bf215546Sopenharmony_ci      _mesa_debug(ctx, "glPolygonStipple\n");
256bf215546Sopenharmony_ci
257bf215546Sopenharmony_ci   FLUSH_VERTICES(ctx, 0, GL_POLYGON_STIPPLE_BIT);
258bf215546Sopenharmony_ci   ctx->NewDriverState |= ST_NEW_POLY_STIPPLE;
259bf215546Sopenharmony_ci
260bf215546Sopenharmony_ci   pattern = _mesa_map_validate_pbo_source(ctx, 2,
261bf215546Sopenharmony_ci                                           &ctx->Unpack, 32, 32, 1,
262bf215546Sopenharmony_ci                                           GL_COLOR_INDEX, GL_BITMAP,
263bf215546Sopenharmony_ci                                           INT_MAX, pattern,
264bf215546Sopenharmony_ci                                           "glPolygonStipple");
265bf215546Sopenharmony_ci   if (!pattern)
266bf215546Sopenharmony_ci      return;
267bf215546Sopenharmony_ci
268bf215546Sopenharmony_ci   _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack);
269bf215546Sopenharmony_ci
270bf215546Sopenharmony_ci   _mesa_unmap_pbo_source(ctx, &ctx->Unpack);
271bf215546Sopenharmony_ci}
272bf215546Sopenharmony_ci
273bf215546Sopenharmony_ci
274bf215546Sopenharmony_ci/**
275bf215546Sopenharmony_ci * Called by glPolygonStipple.
276bf215546Sopenharmony_ci */
277bf215546Sopenharmony_civoid GLAPIENTRY
278bf215546Sopenharmony_ci_mesa_GetnPolygonStippleARB( GLsizei bufSize, GLubyte *dest )
279bf215546Sopenharmony_ci{
280bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
281bf215546Sopenharmony_ci
282bf215546Sopenharmony_ci   if (MESA_VERBOSE&VERBOSE_API)
283bf215546Sopenharmony_ci      _mesa_debug(ctx, "glGetPolygonStipple\n");
284bf215546Sopenharmony_ci
285bf215546Sopenharmony_ci   if (ctx->Pack.BufferObj)
286bf215546Sopenharmony_ci      ctx->Pack.BufferObj->UsageHistory |= USAGE_PIXEL_PACK_BUFFER;
287bf215546Sopenharmony_ci
288bf215546Sopenharmony_ci   dest = _mesa_map_validate_pbo_dest(ctx, 2,
289bf215546Sopenharmony_ci                                      &ctx->Pack, 32, 32, 1,
290bf215546Sopenharmony_ci                                      GL_COLOR_INDEX, GL_BITMAP,
291bf215546Sopenharmony_ci                                      bufSize, dest, "glGetPolygonStipple");
292bf215546Sopenharmony_ci   if (!dest)
293bf215546Sopenharmony_ci      return;
294bf215546Sopenharmony_ci
295bf215546Sopenharmony_ci   _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack);
296bf215546Sopenharmony_ci
297bf215546Sopenharmony_ci   _mesa_unmap_pbo_dest(ctx, &ctx->Pack);
298bf215546Sopenharmony_ci}
299bf215546Sopenharmony_ci
300bf215546Sopenharmony_ci
301bf215546Sopenharmony_civoid GLAPIENTRY
302bf215546Sopenharmony_ci_mesa_GetPolygonStipple( GLubyte *dest )
303bf215546Sopenharmony_ci{
304bf215546Sopenharmony_ci   _mesa_GetnPolygonStippleARB(INT_MAX, dest);
305bf215546Sopenharmony_ci}
306bf215546Sopenharmony_ci
307bf215546Sopenharmony_civoid
308bf215546Sopenharmony_ci_mesa_polygon_offset_clamp(struct gl_context *ctx,
309bf215546Sopenharmony_ci                           GLfloat factor, GLfloat units, GLfloat clamp)
310bf215546Sopenharmony_ci{
311bf215546Sopenharmony_ci   if (ctx->Polygon.OffsetFactor == factor &&
312bf215546Sopenharmony_ci       ctx->Polygon.OffsetUnits == units &&
313bf215546Sopenharmony_ci       ctx->Polygon.OffsetClamp == clamp)
314bf215546Sopenharmony_ci      return;
315bf215546Sopenharmony_ci
316bf215546Sopenharmony_ci   FLUSH_VERTICES(ctx, 0,
317bf215546Sopenharmony_ci                  GL_POLYGON_BIT);
318bf215546Sopenharmony_ci   ctx->NewDriverState |= ST_NEW_RASTERIZER;
319bf215546Sopenharmony_ci   ctx->Polygon.OffsetFactor = factor;
320bf215546Sopenharmony_ci   ctx->Polygon.OffsetUnits = units;
321bf215546Sopenharmony_ci   ctx->Polygon.OffsetClamp = clamp;
322bf215546Sopenharmony_ci}
323bf215546Sopenharmony_ci
324bf215546Sopenharmony_civoid GLAPIENTRY
325bf215546Sopenharmony_ci_mesa_PolygonOffset( GLfloat factor, GLfloat units )
326bf215546Sopenharmony_ci{
327bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
328bf215546Sopenharmony_ci
329bf215546Sopenharmony_ci   if (MESA_VERBOSE&VERBOSE_API)
330bf215546Sopenharmony_ci      _mesa_debug(ctx, "glPolygonOffset %f %f\n", factor, units);
331bf215546Sopenharmony_ci
332bf215546Sopenharmony_ci   _mesa_polygon_offset_clamp(ctx, factor, units, 0.0);
333bf215546Sopenharmony_ci}
334bf215546Sopenharmony_ci
335bf215546Sopenharmony_civoid GLAPIENTRY
336bf215546Sopenharmony_ci_mesa_PolygonOffsetClampEXT( GLfloat factor, GLfloat units, GLfloat clamp )
337bf215546Sopenharmony_ci{
338bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
339bf215546Sopenharmony_ci
340bf215546Sopenharmony_ci   if (!ctx->Extensions.ARB_polygon_offset_clamp) {
341bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_OPERATION,
342bf215546Sopenharmony_ci                  "unsupported function (%s) called", "glPolygonOffsetClamp");
343bf215546Sopenharmony_ci      return;
344bf215546Sopenharmony_ci   }
345bf215546Sopenharmony_ci
346bf215546Sopenharmony_ci   if (MESA_VERBOSE&VERBOSE_API)
347bf215546Sopenharmony_ci      _mesa_debug(ctx, "glPolygonOffsetClamp %f %f %f\n", factor, units, clamp);
348bf215546Sopenharmony_ci
349bf215546Sopenharmony_ci   _mesa_polygon_offset_clamp(ctx, factor, units, clamp);
350bf215546Sopenharmony_ci}
351bf215546Sopenharmony_ci
352bf215546Sopenharmony_ci/**********************************************************************/
353bf215546Sopenharmony_ci/** \name Initialization */
354bf215546Sopenharmony_ci/*@{*/
355bf215546Sopenharmony_ci
356bf215546Sopenharmony_ci/**
357bf215546Sopenharmony_ci * Initialize the context polygon state.
358bf215546Sopenharmony_ci *
359bf215546Sopenharmony_ci * \param ctx GL context.
360bf215546Sopenharmony_ci *
361bf215546Sopenharmony_ci * Initializes __struct gl_contextRec::Polygon and __struct gl_contextRec::PolygonStipple
362bf215546Sopenharmony_ci * attribute groups.
363bf215546Sopenharmony_ci */
364bf215546Sopenharmony_civoid _mesa_init_polygon( struct gl_context * ctx )
365bf215546Sopenharmony_ci{
366bf215546Sopenharmony_ci   /* Polygon group */
367bf215546Sopenharmony_ci   ctx->Polygon.CullFlag = GL_FALSE;
368bf215546Sopenharmony_ci   ctx->Polygon.CullFaceMode = GL_BACK;
369bf215546Sopenharmony_ci   ctx->Polygon.FrontFace = GL_CCW;
370bf215546Sopenharmony_ci   ctx->Polygon.FrontMode = GL_FILL;
371bf215546Sopenharmony_ci   ctx->Polygon.BackMode = GL_FILL;
372bf215546Sopenharmony_ci   ctx->Polygon.SmoothFlag = GL_FALSE;
373bf215546Sopenharmony_ci   ctx->Polygon.StippleFlag = GL_FALSE;
374bf215546Sopenharmony_ci   ctx->Polygon.OffsetFactor = 0.0F;
375bf215546Sopenharmony_ci   ctx->Polygon.OffsetUnits = 0.0F;
376bf215546Sopenharmony_ci   ctx->Polygon.OffsetClamp = 0.0F;
377bf215546Sopenharmony_ci   ctx->Polygon.OffsetPoint = GL_FALSE;
378bf215546Sopenharmony_ci   ctx->Polygon.OffsetLine = GL_FALSE;
379bf215546Sopenharmony_ci   ctx->Polygon.OffsetFill = GL_FALSE;
380bf215546Sopenharmony_ci
381bf215546Sopenharmony_ci
382bf215546Sopenharmony_ci   /* Polygon Stipple group */
383bf215546Sopenharmony_ci   memset( ctx->PolygonStipple, 0xff, 32*sizeof(GLuint) );
384bf215546Sopenharmony_ci}
385bf215546Sopenharmony_ci
386bf215546Sopenharmony_ci/*@}*/
387