hint.c revision 7117f1b4
17117f1b4Smrg 27117f1b4Smrg/* 37117f1b4Smrg * Mesa 3-D graphics library 47117f1b4Smrg * Version: 4.1 57117f1b4Smrg * 67117f1b4Smrg * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. 77117f1b4Smrg * 87117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 97117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 107117f1b4Smrg * to deal in the Software without restriction, including without limitation 117117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 127117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 137117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 147117f1b4Smrg * 157117f1b4Smrg * The above copyright notice and this permission notice shall be included 167117f1b4Smrg * in all copies or substantial portions of the Software. 177117f1b4Smrg * 187117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 197117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 207117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 217117f1b4Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 227117f1b4Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 237117f1b4Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 247117f1b4Smrg */ 257117f1b4Smrg 267117f1b4Smrg 277117f1b4Smrg#include "glheader.h" 287117f1b4Smrg#include "enums.h" 297117f1b4Smrg#include "context.h" 307117f1b4Smrg#include "hint.h" 317117f1b4Smrg#include "imports.h" 327117f1b4Smrg 337117f1b4Smrg 347117f1b4Smrg 357117f1b4Smrgvoid GLAPIENTRY 367117f1b4Smrg_mesa_Hint( GLenum target, GLenum mode ) 377117f1b4Smrg{ 387117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 397117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END(ctx); 407117f1b4Smrg 417117f1b4Smrg if (MESA_VERBOSE & VERBOSE_API) 427117f1b4Smrg _mesa_debug(ctx, "glHint %s %d\n", 437117f1b4Smrg _mesa_lookup_enum_by_nr(target), mode); 447117f1b4Smrg 457117f1b4Smrg if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { 467117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)"); 477117f1b4Smrg return; 487117f1b4Smrg } 497117f1b4Smrg 507117f1b4Smrg switch (target) { 517117f1b4Smrg case GL_FOG_HINT: 527117f1b4Smrg if (ctx->Hint.Fog == mode) 537117f1b4Smrg return; 547117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 557117f1b4Smrg ctx->Hint.Fog = mode; 567117f1b4Smrg break; 577117f1b4Smrg case GL_LINE_SMOOTH_HINT: 587117f1b4Smrg if (ctx->Hint.LineSmooth == mode) 597117f1b4Smrg return; 607117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 617117f1b4Smrg ctx->Hint.LineSmooth = mode; 627117f1b4Smrg break; 637117f1b4Smrg case GL_PERSPECTIVE_CORRECTION_HINT: 647117f1b4Smrg if (ctx->Hint.PerspectiveCorrection == mode) 657117f1b4Smrg return; 667117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 677117f1b4Smrg ctx->Hint.PerspectiveCorrection = mode; 687117f1b4Smrg break; 697117f1b4Smrg case GL_POINT_SMOOTH_HINT: 707117f1b4Smrg if (ctx->Hint.PointSmooth == mode) 717117f1b4Smrg return; 727117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 737117f1b4Smrg ctx->Hint.PointSmooth = mode; 747117f1b4Smrg break; 757117f1b4Smrg case GL_POLYGON_SMOOTH_HINT: 767117f1b4Smrg if (ctx->Hint.PolygonSmooth == mode) 777117f1b4Smrg return; 787117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 797117f1b4Smrg ctx->Hint.PolygonSmooth = mode; 807117f1b4Smrg break; 817117f1b4Smrg 827117f1b4Smrg /* GL_EXT_clip_volume_hint */ 837117f1b4Smrg case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: 847117f1b4Smrg if (ctx->Hint.ClipVolumeClipping == mode) 857117f1b4Smrg return; 867117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 877117f1b4Smrg ctx->Hint.ClipVolumeClipping = mode; 887117f1b4Smrg break; 897117f1b4Smrg 907117f1b4Smrg /* GL_ARB_texture_compression */ 917117f1b4Smrg case GL_TEXTURE_COMPRESSION_HINT_ARB: 927117f1b4Smrg if (!ctx->Extensions.ARB_texture_compression) { 937117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 947117f1b4Smrg return; 957117f1b4Smrg } 967117f1b4Smrg if (ctx->Hint.TextureCompression == mode) 977117f1b4Smrg return; 987117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 997117f1b4Smrg ctx->Hint.TextureCompression = mode; 1007117f1b4Smrg break; 1017117f1b4Smrg 1027117f1b4Smrg /* GL_SGIS_generate_mipmap */ 1037117f1b4Smrg case GL_GENERATE_MIPMAP_HINT_SGIS: 1047117f1b4Smrg if (!ctx->Extensions.SGIS_generate_mipmap) { 1057117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 1067117f1b4Smrg return; 1077117f1b4Smrg } 1087117f1b4Smrg if (ctx->Hint.GenerateMipmap == mode) 1097117f1b4Smrg return; 1107117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 1117117f1b4Smrg ctx->Hint.GenerateMipmap = mode; 1127117f1b4Smrg break; 1137117f1b4Smrg 1147117f1b4Smrg /* GL_ARB_fragment_shader */ 1157117f1b4Smrg case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: 1167117f1b4Smrg if (!ctx->Extensions.ARB_fragment_shader) { 1177117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 1187117f1b4Smrg return; 1197117f1b4Smrg } 1207117f1b4Smrg if (ctx->Hint.FragmentShaderDerivative == mode) 1217117f1b4Smrg return; 1227117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 1237117f1b4Smrg ctx->Hint.FragmentShaderDerivative = mode; 1247117f1b4Smrg break; 1257117f1b4Smrg 1267117f1b4Smrg default: 1277117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 1287117f1b4Smrg return; 1297117f1b4Smrg } 1307117f1b4Smrg 1317117f1b4Smrg if (ctx->Driver.Hint) { 1327117f1b4Smrg (*ctx->Driver.Hint)( ctx, target, mode ); 1337117f1b4Smrg } 1347117f1b4Smrg} 1357117f1b4Smrg 1367117f1b4Smrg 1377117f1b4Smrg/**********************************************************************/ 1387117f1b4Smrg/***** Initialization *****/ 1397117f1b4Smrg/**********************************************************************/ 1407117f1b4Smrg 1417117f1b4Smrgvoid _mesa_init_hint( GLcontext * ctx ) 1427117f1b4Smrg{ 1437117f1b4Smrg /* Hint group */ 1447117f1b4Smrg ctx->Hint.PerspectiveCorrection = GL_DONT_CARE; 1457117f1b4Smrg ctx->Hint.PointSmooth = GL_DONT_CARE; 1467117f1b4Smrg ctx->Hint.LineSmooth = GL_DONT_CARE; 1477117f1b4Smrg ctx->Hint.PolygonSmooth = GL_DONT_CARE; 1487117f1b4Smrg ctx->Hint.Fog = GL_DONT_CARE; 1497117f1b4Smrg ctx->Hint.ClipVolumeClipping = GL_DONT_CARE; 1507117f1b4Smrg ctx->Hint.TextureCompression = GL_DONT_CARE; 1517117f1b4Smrg ctx->Hint.GenerateMipmap = GL_DONT_CARE; 1527117f1b4Smrg ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE; 1537117f1b4Smrg} 154