functions from old glmisc.c file
[mesa.git] / src / mesa / main / hint.c
1 /* $Id: hint.c,v 1.1 2000/02/02 19:14:56 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999-2000 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 (void) _mesa_try_Hint( ctx, target, mode );
45 }
46
47
48 GLboolean
49 _mesa_try_Hint( GLcontext *ctx, GLenum target, GLenum mode )
50 {
51 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glHint", GL_FALSE);
52
53 if (MESA_VERBOSE & VERBOSE_API)
54 fprintf(stderr, "glHint %s %d\n", gl_lookup_enum_by_nr(target), mode);
55
56 switch (target) {
57 case GL_FOG_HINT:
58 ctx->Hint.Fog = mode;
59 break;
60 case GL_LINE_SMOOTH_HINT:
61 ctx->Hint.LineSmooth = mode;
62 break;
63 case GL_PERSPECTIVE_CORRECTION_HINT:
64 ctx->Hint.PerspectiveCorrection = mode;
65 break;
66 case GL_POINT_SMOOTH_HINT:
67 ctx->Hint.PointSmooth = mode;
68 break;
69 case GL_POLYGON_SMOOTH_HINT:
70 ctx->Hint.PolygonSmooth = mode;
71 break;
72 case GL_PREFER_DOUBLEBUFFER_HINT_PGI:
73 case GL_STRICT_DEPTHFUNC_HINT_PGI:
74 break;
75 case GL_STRICT_LIGHTING_HINT_PGI:
76 ctx->Hint.StrictLighting = mode;
77 break;
78 case GL_STRICT_SCISSOR_HINT_PGI:
79 case GL_FULL_STIPPLE_HINT_PGI:
80 case GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI:
81 case GL_NATIVE_GRAPHICS_END_HINT_PGI:
82 case GL_CONSERVE_MEMORY_HINT_PGI:
83 case GL_RECLAIM_MEMORY_HINT_PGI:
84 break;
85 case GL_ALWAYS_FAST_HINT_PGI:
86 if (mode) {
87 ctx->Hint.AllowDrawWin = GL_TRUE;
88 ctx->Hint.AllowDrawSpn = GL_FALSE;
89 ctx->Hint.AllowDrawMem = GL_FALSE;
90 } else {
91 ctx->Hint.AllowDrawWin = GL_TRUE;
92 ctx->Hint.AllowDrawSpn = GL_TRUE;
93 ctx->Hint.AllowDrawMem = GL_TRUE;
94 }
95 break;
96 case GL_ALWAYS_SOFT_HINT_PGI:
97 ctx->Hint.AllowDrawWin = GL_TRUE;
98 ctx->Hint.AllowDrawSpn = GL_TRUE;
99 ctx->Hint.AllowDrawMem = GL_TRUE;
100 break;
101 case GL_ALLOW_DRAW_OBJ_HINT_PGI:
102 break;
103 case GL_ALLOW_DRAW_WIN_HINT_PGI:
104 ctx->Hint.AllowDrawWin = mode;
105 break;
106 case GL_ALLOW_DRAW_SPN_HINT_PGI:
107 ctx->Hint.AllowDrawSpn = mode;
108 break;
109 case GL_ALLOW_DRAW_MEM_HINT_PGI:
110 ctx->Hint.AllowDrawMem = mode;
111 break;
112 case GL_CLIP_NEAR_HINT_PGI:
113 case GL_CLIP_FAR_HINT_PGI:
114 case GL_WIDE_LINE_HINT_PGI:
115 case GL_BACK_NORMALS_HINT_PGI:
116 case GL_NATIVE_GRAPHICS_HANDLE_PGI:
117 break;
118
119 /* GL_EXT_clip_volume_hint */
120 case GL_CLIP_VOLUME_CLIPPING_HINT_EXT:
121 ctx->Hint.ClipVolumeClipping = mode;
122 break;
123
124 default:
125 gl_error( ctx, GL_INVALID_ENUM, "glHint(target)" );
126 return GL_FALSE;
127 }
128 ctx->NewState |= NEW_ALL; /* just to be safe */
129
130 if (ctx->Driver.Hint) {
131 (*ctx->Driver.Hint)( ctx, target, mode );
132 }
133
134 return GL_TRUE;
135 }
136
137
138 void
139 _mesa_HintPGI( GLenum target, GLint mode )
140 {
141 GET_CURRENT_CONTEXT(ctx);
142 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glHintPGI");
143
144 if (MESA_VERBOSE & VERBOSE_API)
145 fprintf(stderr, "glHintPGI %s %d\n", gl_lookup_enum_by_nr(target), mode);
146
147 switch (target) {
148 case GL_PREFER_DOUBLEBUFFER_HINT_PGI:
149 case GL_STRICT_DEPTHFUNC_HINT_PGI:
150 case GL_STRICT_LIGHTING_HINT_PGI:
151 case GL_STRICT_SCISSOR_HINT_PGI:
152 case GL_FULL_STIPPLE_HINT_PGI:
153 case GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI:
154 case GL_NATIVE_GRAPHICS_END_HINT_PGI:
155 case GL_CONSERVE_MEMORY_HINT_PGI:
156 case GL_RECLAIM_MEMORY_HINT_PGI:
157 case GL_ALWAYS_FAST_HINT_PGI:
158 case GL_ALWAYS_SOFT_HINT_PGI:
159 case GL_ALLOW_DRAW_OBJ_HINT_PGI:
160 case GL_ALLOW_DRAW_WIN_HINT_PGI:
161 case GL_ALLOW_DRAW_SPN_HINT_PGI:
162 case GL_ALLOW_DRAW_MEM_HINT_PGI:
163 case GL_CLIP_NEAR_HINT_PGI:
164 case GL_CLIP_FAR_HINT_PGI:
165 case GL_WIDE_LINE_HINT_PGI:
166 case GL_BACK_NORMALS_HINT_PGI:
167 case GL_NATIVE_GRAPHICS_HANDLE_PGI:
168 (void) _mesa_try_Hint(ctx, target, (GLenum) mode);
169 break;
170 default:
171 gl_error( ctx, GL_INVALID_ENUM, "glHintPGI(target)" );
172 return;
173 }
174 }
175
176