added missing ctx parameter to _mesa_debug() calls
[mesa.git] / src / mesa / main / hint.c
1 /* $Id: hint.c,v 1.13 2002/06/15 02:54:02 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 4.1
6 *
7 * Copyright (C) 1999-2002 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 #ifdef PC_HEADER
29 #include "all.h"
30 #else
31 #include "glheader.h"
32 #include "enums.h"
33 #include "context.h"
34 #include "hint.h"
35 #include "state.h"
36 #endif
37
38
39
40 void
41 _mesa_Hint( GLenum target, GLenum mode )
42 {
43 GET_CURRENT_CONTEXT(ctx);
44 ASSERT_OUTSIDE_BEGIN_END(ctx);
45
46 if (MESA_VERBOSE & VERBOSE_API)
47 _mesa_debug(ctx, "glHint %s %d\n",
48 _mesa_lookup_enum_by_nr(target), mode);
49
50 if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) {
51 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)");
52 return;
53 }
54
55 switch (target) {
56 case GL_FOG_HINT:
57 if (ctx->Hint.Fog == mode)
58 return;
59 FLUSH_VERTICES(ctx, _NEW_HINT);
60 ctx->Hint.Fog = mode;
61 break;
62 case GL_LINE_SMOOTH_HINT:
63 if (ctx->Hint.LineSmooth == mode)
64 return;
65 FLUSH_VERTICES(ctx, _NEW_HINT);
66 ctx->Hint.LineSmooth = mode;
67 break;
68 case GL_PERSPECTIVE_CORRECTION_HINT:
69 if (ctx->Hint.PerspectiveCorrection == mode)
70 return;
71 FLUSH_VERTICES(ctx, _NEW_HINT);
72 ctx->Hint.PerspectiveCorrection = mode;
73 break;
74 case GL_POINT_SMOOTH_HINT:
75 if (ctx->Hint.PointSmooth == mode)
76 return;
77 FLUSH_VERTICES(ctx, _NEW_HINT);
78 ctx->Hint.PointSmooth = mode;
79 break;
80 case GL_POLYGON_SMOOTH_HINT:
81 if (ctx->Hint.PolygonSmooth == mode)
82 return;
83 FLUSH_VERTICES(ctx, _NEW_HINT);
84 ctx->Hint.PolygonSmooth = mode;
85 break;
86
87 /* GL_EXT_clip_volume_hint */
88 case GL_CLIP_VOLUME_CLIPPING_HINT_EXT:
89 if (ctx->Hint.ClipVolumeClipping == mode)
90 return;
91 FLUSH_VERTICES(ctx, _NEW_HINT);
92 ctx->Hint.ClipVolumeClipping = mode;
93 break;
94
95 /* GL_ARB_texture_compression */
96 case GL_TEXTURE_COMPRESSION_HINT_ARB:
97 if (!ctx->Extensions.ARB_texture_compression) {
98 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
99 return;
100 }
101 if (ctx->Hint.TextureCompression == mode)
102 return;
103 FLUSH_VERTICES(ctx, _NEW_HINT);
104 ctx->Hint.TextureCompression = mode;
105 break;
106
107 /* GL_SGIS_generate_mipmap */
108 case GL_GENERATE_MIPMAP_HINT_SGIS:
109 if (!ctx->Extensions.SGIS_generate_mipmap) {
110 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
111 return;
112 }
113 if (ctx->Hint.GenerateMipmap == mode)
114 return;
115 FLUSH_VERTICES(ctx, _NEW_HINT);
116 ctx->Hint.GenerateMipmap = mode;
117 break;
118
119 default:
120 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
121 return;
122 }
123
124 if (ctx->Driver.Hint) {
125 (*ctx->Driver.Hint)( ctx, target, mode );
126 }
127 }