[PROPSYS]
[reactos.git] / reactos / dll / opengl / mesa / main / hint.c
1
2 /*
3 * Mesa 3-D graphics library
4 * Version: 4.1
5 *
6 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 #include <precomp.h>
27
28 void GLAPIENTRY
29 _mesa_Hint( GLenum target, GLenum mode )
30 {
31 GET_CURRENT_CONTEXT(ctx);
32 ASSERT_OUTSIDE_BEGIN_END(ctx);
33
34 if (MESA_VERBOSE & VERBOSE_API)
35 _mesa_debug(ctx, "glHint %s %s\n",
36 _mesa_lookup_enum_by_nr(target),
37 _mesa_lookup_enum_by_nr(mode));
38
39 if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) {
40 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)");
41 return;
42 }
43
44 switch (target) {
45 case GL_FOG_HINT:
46 if (ctx->Hint.Fog == mode)
47 return;
48 FLUSH_VERTICES(ctx, _NEW_HINT);
49 ctx->Hint.Fog = mode;
50 break;
51 case GL_LINE_SMOOTH_HINT:
52 if (ctx->Hint.LineSmooth == mode)
53 return;
54 FLUSH_VERTICES(ctx, _NEW_HINT);
55 ctx->Hint.LineSmooth = mode;
56 break;
57 case GL_PERSPECTIVE_CORRECTION_HINT:
58 if (ctx->Hint.PerspectiveCorrection == mode)
59 return;
60 FLUSH_VERTICES(ctx, _NEW_HINT);
61 ctx->Hint.PerspectiveCorrection = mode;
62 break;
63 case GL_POINT_SMOOTH_HINT:
64 if (ctx->Hint.PointSmooth == mode)
65 return;
66 FLUSH_VERTICES(ctx, _NEW_HINT);
67 ctx->Hint.PointSmooth = mode;
68 break;
69 case GL_POLYGON_SMOOTH_HINT:
70 if (ctx->Hint.PolygonSmooth == mode)
71 return;
72 FLUSH_VERTICES(ctx, _NEW_HINT);
73 ctx->Hint.PolygonSmooth = mode;
74 break;
75
76 /* GL_EXT_clip_volume_hint */
77 case GL_CLIP_VOLUME_CLIPPING_HINT_EXT:
78 if (ctx->Hint.ClipVolumeClipping == mode)
79 return;
80 FLUSH_VERTICES(ctx, _NEW_HINT);
81 ctx->Hint.ClipVolumeClipping = mode;
82 break;
83
84 default:
85 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
86 return;
87 }
88
89 if (ctx->Driver.Hint) {
90 (*ctx->Driver.Hint)( ctx, target, mode );
91 }
92 }
93
94
95 /**********************************************************************/
96 /***** Initialization *****/
97 /**********************************************************************/
98
99 void _mesa_init_hint( struct gl_context * ctx )
100 {
101 /* Hint group */
102 ctx->Hint.PerspectiveCorrection = GL_DONT_CARE;
103 ctx->Hint.PointSmooth = GL_DONT_CARE;
104 ctx->Hint.LineSmooth = GL_DONT_CARE;
105 ctx->Hint.PolygonSmooth = GL_DONT_CARE;
106 ctx->Hint.Fog = GL_DONT_CARE;
107 ctx->Hint.ClipVolumeClipping = GL_DONT_CARE;
108 }