hint.c revision 1207bf057aeea3376e5e0f03f789a5d67ed4d29d
1/* $Id: hint.c,v 1.4 2000/05/23 20:10:50 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 40void 41_mesa_Hint( GLenum target, GLenum mode ) 42{ 43 GET_CURRENT_CONTEXT(ctx); 44 (void) _mesa_try_Hint( ctx, target, mode ); 45} 46 47 48GLboolean 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 if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { 57 gl_error(ctx, GL_INVALID_ENUM, "glHint(mode)"); 58 return GL_FALSE; 59 } 60 61 switch (target) { 62 case GL_FOG_HINT: 63 ctx->Hint.Fog = mode; 64 break; 65 case GL_LINE_SMOOTH_HINT: 66 ctx->Hint.LineSmooth = mode; 67 break; 68 case GL_PERSPECTIVE_CORRECTION_HINT: 69 ctx->Hint.PerspectiveCorrection = mode; 70 break; 71 case GL_POINT_SMOOTH_HINT: 72 ctx->Hint.PointSmooth = mode; 73 break; 74 case GL_POLYGON_SMOOTH_HINT: 75 ctx->Hint.PolygonSmooth = mode; 76 break; 77 case GL_PREFER_DOUBLEBUFFER_HINT_PGI: 78 case GL_STRICT_DEPTHFUNC_HINT_PGI: 79 break; 80 case GL_STRICT_LIGHTING_HINT_PGI: 81 ctx->Hint.StrictLighting = mode; 82 break; 83 case GL_STRICT_SCISSOR_HINT_PGI: 84 case GL_FULL_STIPPLE_HINT_PGI: 85 case GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI: 86 case GL_NATIVE_GRAPHICS_END_HINT_PGI: 87 case GL_CONSERVE_MEMORY_HINT_PGI: 88 case GL_RECLAIM_MEMORY_HINT_PGI: 89 break; 90 case GL_ALWAYS_FAST_HINT_PGI: 91 if (mode) { 92 ctx->Hint.AllowDrawWin = GL_TRUE; 93 ctx->Hint.AllowDrawFrg = GL_FALSE; 94 ctx->Hint.AllowDrawMem = GL_FALSE; 95 } else { 96 ctx->Hint.AllowDrawWin = GL_TRUE; 97 ctx->Hint.AllowDrawFrg = GL_TRUE; 98 ctx->Hint.AllowDrawMem = GL_TRUE; 99 } 100 break; 101 case GL_ALWAYS_SOFT_HINT_PGI: 102 ctx->Hint.AllowDrawWin = GL_TRUE; 103 ctx->Hint.AllowDrawFrg = GL_TRUE; 104 ctx->Hint.AllowDrawMem = GL_TRUE; 105 break; 106 case GL_ALLOW_DRAW_OBJ_HINT_PGI: 107 break; 108 case GL_ALLOW_DRAW_WIN_HINT_PGI: 109 ctx->Hint.AllowDrawWin = mode; 110 break; 111 case GL_ALLOW_DRAW_FRG_HINT_PGI: 112 ctx->Hint.AllowDrawFrg = mode; 113 break; 114 case GL_ALLOW_DRAW_MEM_HINT_PGI: 115 ctx->Hint.AllowDrawMem = mode; 116 break; 117 case GL_CLIP_NEAR_HINT_PGI: 118 case GL_CLIP_FAR_HINT_PGI: 119 case GL_WIDE_LINE_HINT_PGI: 120 case GL_BACK_NORMALS_HINT_PGI: 121 case GL_NATIVE_GRAPHICS_HANDLE_PGI: 122 break; 123 124 /* GL_EXT_clip_volume_hint */ 125 case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: 126 ctx->Hint.ClipVolumeClipping = mode; 127 break; 128 129 /* GL_ARB_texture_compression */ 130 case GL_TEXTURE_COMPRESSION_HINT_ARB: 131 if (ctx->Extensions.HaveTextureCompression) { 132 ctx->Hint.TextureCompression = mode; 133 } 134 else { 135 gl_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 136 } 137 break; 138 139 default: 140 gl_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 141 return GL_FALSE; 142 } 143 144 ctx->NewState |= NEW_ALL; /* just to be safe */ 145 146 if (ctx->Driver.Hint) { 147 (*ctx->Driver.Hint)( ctx, target, mode ); 148 } 149 150 return GL_TRUE; 151} 152 153 154void 155_mesa_HintPGI( GLenum target, GLint mode ) 156{ 157 GET_CURRENT_CONTEXT(ctx); 158 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glHintPGI"); 159 160 if (MESA_VERBOSE & VERBOSE_API) 161 fprintf(stderr, "glHintPGI %s %d\n", gl_lookup_enum_by_nr(target), mode); 162 163 if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { 164 gl_error(ctx, GL_INVALID_ENUM, "glHintPGI(mode)"); 165 return; 166 } 167 168 switch (target) { 169 case GL_PREFER_DOUBLEBUFFER_HINT_PGI: 170 case GL_STRICT_DEPTHFUNC_HINT_PGI: 171 case GL_STRICT_LIGHTING_HINT_PGI: 172 case GL_STRICT_SCISSOR_HINT_PGI: 173 case GL_FULL_STIPPLE_HINT_PGI: 174 case GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI: 175 case GL_NATIVE_GRAPHICS_END_HINT_PGI: 176 case GL_CONSERVE_MEMORY_HINT_PGI: 177 case GL_RECLAIM_MEMORY_HINT_PGI: 178 case GL_ALWAYS_FAST_HINT_PGI: 179 case GL_ALWAYS_SOFT_HINT_PGI: 180 case GL_ALLOW_DRAW_OBJ_HINT_PGI: 181 case GL_ALLOW_DRAW_WIN_HINT_PGI: 182 case GL_ALLOW_DRAW_FRG_HINT_PGI: 183 case GL_ALLOW_DRAW_MEM_HINT_PGI: 184 case GL_CLIP_NEAR_HINT_PGI: 185 case GL_CLIP_FAR_HINT_PGI: 186 case GL_WIDE_LINE_HINT_PGI: 187 case GL_BACK_NORMALS_HINT_PGI: 188 case GL_NATIVE_GRAPHICS_HANDLE_PGI: 189 (void) _mesa_try_Hint(ctx, target, (GLenum) mode); 190 break; 191 default: 192 gl_error( ctx, GL_INVALID_ENUM, "glHintPGI(target)" ); 193 return; 194 } 195} 196 197 198