hint.c revision 3464ebd5
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" 323464ebd5Sriastradh#include "mtypes.h" 337117f1b4Smrg 347117f1b4Smrg 357117f1b4Smrg 367117f1b4Smrgvoid GLAPIENTRY 377117f1b4Smrg_mesa_Hint( GLenum target, GLenum mode ) 387117f1b4Smrg{ 397117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 407117f1b4Smrg ASSERT_OUTSIDE_BEGIN_END(ctx); 417117f1b4Smrg 427117f1b4Smrg if (MESA_VERBOSE & VERBOSE_API) 433464ebd5Sriastradh _mesa_debug(ctx, "glHint %s %s\n", 443464ebd5Sriastradh _mesa_lookup_enum_by_nr(target), 453464ebd5Sriastradh _mesa_lookup_enum_by_nr(mode)); 467117f1b4Smrg 477117f1b4Smrg if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { 487117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)"); 497117f1b4Smrg return; 507117f1b4Smrg } 517117f1b4Smrg 527117f1b4Smrg switch (target) { 537117f1b4Smrg case GL_FOG_HINT: 547117f1b4Smrg if (ctx->Hint.Fog == mode) 557117f1b4Smrg return; 567117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 577117f1b4Smrg ctx->Hint.Fog = mode; 587117f1b4Smrg break; 597117f1b4Smrg case GL_LINE_SMOOTH_HINT: 607117f1b4Smrg if (ctx->Hint.LineSmooth == mode) 617117f1b4Smrg return; 627117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 637117f1b4Smrg ctx->Hint.LineSmooth = mode; 647117f1b4Smrg break; 657117f1b4Smrg case GL_PERSPECTIVE_CORRECTION_HINT: 667117f1b4Smrg if (ctx->Hint.PerspectiveCorrection == mode) 677117f1b4Smrg return; 687117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 697117f1b4Smrg ctx->Hint.PerspectiveCorrection = mode; 707117f1b4Smrg break; 717117f1b4Smrg case GL_POINT_SMOOTH_HINT: 727117f1b4Smrg if (ctx->Hint.PointSmooth == mode) 737117f1b4Smrg return; 747117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 757117f1b4Smrg ctx->Hint.PointSmooth = mode; 767117f1b4Smrg break; 777117f1b4Smrg case GL_POLYGON_SMOOTH_HINT: 787117f1b4Smrg if (ctx->Hint.PolygonSmooth == mode) 797117f1b4Smrg return; 807117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 817117f1b4Smrg ctx->Hint.PolygonSmooth = mode; 827117f1b4Smrg break; 837117f1b4Smrg 847117f1b4Smrg /* GL_EXT_clip_volume_hint */ 857117f1b4Smrg case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: 867117f1b4Smrg if (ctx->Hint.ClipVolumeClipping == mode) 877117f1b4Smrg return; 887117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 897117f1b4Smrg ctx->Hint.ClipVolumeClipping = mode; 907117f1b4Smrg break; 917117f1b4Smrg 927117f1b4Smrg /* GL_ARB_texture_compression */ 937117f1b4Smrg case GL_TEXTURE_COMPRESSION_HINT_ARB: 947117f1b4Smrg if (ctx->Hint.TextureCompression == mode) 957117f1b4Smrg return; 967117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 977117f1b4Smrg ctx->Hint.TextureCompression = mode; 987117f1b4Smrg break; 997117f1b4Smrg 1007117f1b4Smrg /* GL_SGIS_generate_mipmap */ 1017117f1b4Smrg case GL_GENERATE_MIPMAP_HINT_SGIS: 1027117f1b4Smrg if (ctx->Hint.GenerateMipmap == mode) 1037117f1b4Smrg return; 1047117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 1057117f1b4Smrg ctx->Hint.GenerateMipmap = mode; 1067117f1b4Smrg break; 1077117f1b4Smrg 1087117f1b4Smrg /* GL_ARB_fragment_shader */ 1097117f1b4Smrg case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: 1107117f1b4Smrg if (!ctx->Extensions.ARB_fragment_shader) { 1117117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 1127117f1b4Smrg return; 1137117f1b4Smrg } 1147117f1b4Smrg if (ctx->Hint.FragmentShaderDerivative == mode) 1157117f1b4Smrg return; 1167117f1b4Smrg FLUSH_VERTICES(ctx, _NEW_HINT); 1177117f1b4Smrg ctx->Hint.FragmentShaderDerivative = mode; 1187117f1b4Smrg break; 1197117f1b4Smrg 1207117f1b4Smrg default: 1217117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 1227117f1b4Smrg return; 1237117f1b4Smrg } 1247117f1b4Smrg 1257117f1b4Smrg if (ctx->Driver.Hint) { 1267117f1b4Smrg (*ctx->Driver.Hint)( ctx, target, mode ); 1277117f1b4Smrg } 1287117f1b4Smrg} 1297117f1b4Smrg 1307117f1b4Smrg 1317117f1b4Smrg/**********************************************************************/ 1327117f1b4Smrg/***** Initialization *****/ 1337117f1b4Smrg/**********************************************************************/ 1347117f1b4Smrg 1353464ebd5Sriastradhvoid _mesa_init_hint( struct gl_context * ctx ) 1367117f1b4Smrg{ 1377117f1b4Smrg /* Hint group */ 1387117f1b4Smrg ctx->Hint.PerspectiveCorrection = GL_DONT_CARE; 1397117f1b4Smrg ctx->Hint.PointSmooth = GL_DONT_CARE; 1407117f1b4Smrg ctx->Hint.LineSmooth = GL_DONT_CARE; 1417117f1b4Smrg ctx->Hint.PolygonSmooth = GL_DONT_CARE; 1427117f1b4Smrg ctx->Hint.Fog = GL_DONT_CARE; 1437117f1b4Smrg ctx->Hint.ClipVolumeClipping = GL_DONT_CARE; 1447117f1b4Smrg ctx->Hint.TextureCompression = GL_DONT_CARE; 1457117f1b4Smrg ctx->Hint.GenerateMipmap = GL_DONT_CARE; 1467117f1b4Smrg ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE; 1477117f1b4Smrg} 148