hint.c revision 7117f1b4
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 27#include "glheader.h" 28#include "enums.h" 29#include "context.h" 30#include "hint.h" 31#include "imports.h" 32 33 34 35void GLAPIENTRY 36_mesa_Hint( GLenum target, GLenum mode ) 37{ 38 GET_CURRENT_CONTEXT(ctx); 39 ASSERT_OUTSIDE_BEGIN_END(ctx); 40 41 if (MESA_VERBOSE & VERBOSE_API) 42 _mesa_debug(ctx, "glHint %s %d\n", 43 _mesa_lookup_enum_by_nr(target), mode); 44 45 if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { 46 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)"); 47 return; 48 } 49 50 switch (target) { 51 case GL_FOG_HINT: 52 if (ctx->Hint.Fog == mode) 53 return; 54 FLUSH_VERTICES(ctx, _NEW_HINT); 55 ctx->Hint.Fog = mode; 56 break; 57 case GL_LINE_SMOOTH_HINT: 58 if (ctx->Hint.LineSmooth == mode) 59 return; 60 FLUSH_VERTICES(ctx, _NEW_HINT); 61 ctx->Hint.LineSmooth = mode; 62 break; 63 case GL_PERSPECTIVE_CORRECTION_HINT: 64 if (ctx->Hint.PerspectiveCorrection == mode) 65 return; 66 FLUSH_VERTICES(ctx, _NEW_HINT); 67 ctx->Hint.PerspectiveCorrection = mode; 68 break; 69 case GL_POINT_SMOOTH_HINT: 70 if (ctx->Hint.PointSmooth == mode) 71 return; 72 FLUSH_VERTICES(ctx, _NEW_HINT); 73 ctx->Hint.PointSmooth = mode; 74 break; 75 case GL_POLYGON_SMOOTH_HINT: 76 if (ctx->Hint.PolygonSmooth == mode) 77 return; 78 FLUSH_VERTICES(ctx, _NEW_HINT); 79 ctx->Hint.PolygonSmooth = mode; 80 break; 81 82 /* GL_EXT_clip_volume_hint */ 83 case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: 84 if (ctx->Hint.ClipVolumeClipping == mode) 85 return; 86 FLUSH_VERTICES(ctx, _NEW_HINT); 87 ctx->Hint.ClipVolumeClipping = mode; 88 break; 89 90 /* GL_ARB_texture_compression */ 91 case GL_TEXTURE_COMPRESSION_HINT_ARB: 92 if (!ctx->Extensions.ARB_texture_compression) { 93 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 94 return; 95 } 96 if (ctx->Hint.TextureCompression == mode) 97 return; 98 FLUSH_VERTICES(ctx, _NEW_HINT); 99 ctx->Hint.TextureCompression = mode; 100 break; 101 102 /* GL_SGIS_generate_mipmap */ 103 case GL_GENERATE_MIPMAP_HINT_SGIS: 104 if (!ctx->Extensions.SGIS_generate_mipmap) { 105 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 106 return; 107 } 108 if (ctx->Hint.GenerateMipmap == mode) 109 return; 110 FLUSH_VERTICES(ctx, _NEW_HINT); 111 ctx->Hint.GenerateMipmap = mode; 112 break; 113 114 /* GL_ARB_fragment_shader */ 115 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: 116 if (!ctx->Extensions.ARB_fragment_shader) { 117 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 118 return; 119 } 120 if (ctx->Hint.FragmentShaderDerivative == mode) 121 return; 122 FLUSH_VERTICES(ctx, _NEW_HINT); 123 ctx->Hint.FragmentShaderDerivative = mode; 124 break; 125 126 default: 127 _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 128 return; 129 } 130 131 if (ctx->Driver.Hint) { 132 (*ctx->Driver.Hint)( ctx, target, mode ); 133 } 134} 135 136 137/**********************************************************************/ 138/***** Initialization *****/ 139/**********************************************************************/ 140 141void _mesa_init_hint( GLcontext * ctx ) 142{ 143 /* Hint group */ 144 ctx->Hint.PerspectiveCorrection = GL_DONT_CARE; 145 ctx->Hint.PointSmooth = GL_DONT_CARE; 146 ctx->Hint.LineSmooth = GL_DONT_CARE; 147 ctx->Hint.PolygonSmooth = GL_DONT_CARE; 148 ctx->Hint.Fog = GL_DONT_CARE; 149 ctx->Hint.ClipVolumeClipping = GL_DONT_CARE; 150 ctx->Hint.TextureCompression = GL_DONT_CARE; 151 ctx->Hint.GenerateMipmap = GL_DONT_CARE; 152 ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE; 153} 154