1
2 /*
3 * Mesa 3-D graphics library
4 *
5 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26
27 #include "glheader.h"
28 #include "enums.h"
29 #include "context.h"
30 #include "hint.h"
31 #include "imports.h"
32 #include "mtypes.h"
33
34
35
36 void GLAPIENTRY
_mesa_Hint(GLenum target,GLenum mode)37 _mesa_Hint( GLenum target, GLenum mode )
38 {
39 GET_CURRENT_CONTEXT(ctx);
40
41 if (MESA_VERBOSE & VERBOSE_API)
42 _mesa_debug(ctx, "glHint %s %s\n",
43 _mesa_enum_to_string(target),
44 _mesa_enum_to_string(mode));
45
46 if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) {
47 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)");
48 return;
49 }
50
51 switch (target) {
52 case GL_FOG_HINT:
53 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
54 goto invalid_target;
55 if (ctx->Hint.Fog == mode)
56 return;
57 FLUSH_VERTICES(ctx, _NEW_HINT);
58 ctx->Hint.Fog = mode;
59 break;
60 case GL_LINE_SMOOTH_HINT:
61 if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
62 goto invalid_target;
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->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
70 goto invalid_target;
71 if (ctx->Hint.PerspectiveCorrection == mode)
72 return;
73 FLUSH_VERTICES(ctx, _NEW_HINT);
74 ctx->Hint.PerspectiveCorrection = mode;
75 break;
76 case GL_POINT_SMOOTH_HINT:
77 if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
78 goto invalid_target;
79 if (ctx->Hint.PointSmooth == mode)
80 return;
81 FLUSH_VERTICES(ctx, _NEW_HINT);
82 ctx->Hint.PointSmooth = mode;
83 break;
84 case GL_POLYGON_SMOOTH_HINT:
85 if (!_mesa_is_desktop_gl(ctx))
86 goto invalid_target;
87 if (ctx->Hint.PolygonSmooth == mode)
88 return;
89 FLUSH_VERTICES(ctx, _NEW_HINT);
90 ctx->Hint.PolygonSmooth = mode;
91 break;
92
93 /* GL_ARB_texture_compression */
94 case GL_TEXTURE_COMPRESSION_HINT_ARB:
95 if (!_mesa_is_desktop_gl(ctx))
96 goto invalid_target;
97 if (ctx->Hint.TextureCompression == mode)
98 return;
99 FLUSH_VERTICES(ctx, _NEW_HINT);
100 ctx->Hint.TextureCompression = mode;
101 break;
102
103 /* GL_SGIS_generate_mipmap */
104 case GL_GENERATE_MIPMAP_HINT_SGIS:
105 if (ctx->API == API_OPENGL_CORE)
106 goto invalid_target;
107 if (ctx->Hint.GenerateMipmap == mode)
108 return;
109 FLUSH_VERTICES(ctx, _NEW_HINT);
110 ctx->Hint.GenerateMipmap = mode;
111 break;
112
113 /* GL_ARB_fragment_shader */
114 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB:
115 if (ctx->API == API_OPENGLES || !ctx->Extensions.ARB_fragment_shader)
116 goto invalid_target;
117 if (ctx->Hint.FragmentShaderDerivative == mode)
118 return;
119 FLUSH_VERTICES(ctx, _NEW_HINT);
120 ctx->Hint.FragmentShaderDerivative = mode;
121 break;
122
123 default:
124 goto invalid_target;
125 }
126 return;
127
128 invalid_target:
129 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
130 return;
131 }
132
133
134 /**********************************************************************/
135 /***** Initialization *****/
136 /**********************************************************************/
137
_mesa_init_hint(struct gl_context * ctx)138 void _mesa_init_hint( struct gl_context * ctx )
139 {
140 /* Hint group */
141 ctx->Hint.PerspectiveCorrection = GL_DONT_CARE;
142 ctx->Hint.PointSmooth = GL_DONT_CARE;
143 ctx->Hint.LineSmooth = GL_DONT_CARE;
144 ctx->Hint.PolygonSmooth = GL_DONT_CARE;
145 ctx->Hint.Fog = GL_DONT_CARE;
146 ctx->Hint.TextureCompression = GL_DONT_CARE;
147 ctx->Hint.GenerateMipmap = GL_DONT_CARE;
148 ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE;
149 }
150