1 /* $Id: fog.c,v 1.29 2000/11/16 21:05:35 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
41 _mesa_Fogf(GLenum pname
, GLfloat param
)
43 _mesa_Fogfv(pname
, ¶m
);
48 _mesa_Fogi(GLenum pname
, GLint param
)
50 GLfloat fparam
= (GLfloat
) param
;
51 _mesa_Fogfv(pname
, &fparam
);
56 _mesa_Fogiv(GLenum pname
, const GLint
*params
)
65 case GL_FOG_COORDINATE_SOURCE_EXT
:
66 p
[0] = (GLfloat
) *params
;
69 p
[0] = INT_TO_FLOAT( params
[0] );
70 p
[1] = INT_TO_FLOAT( params
[1] );
71 p
[2] = INT_TO_FLOAT( params
[2] );
72 p
[3] = INT_TO_FLOAT( params
[3] );
75 /* Error will be caught later in _mesa_Fogfv */
78 _mesa_Fogfv(pname
, p
);
83 _mesa_Fogfv( GLenum pname
, const GLfloat
*params
)
85 GET_CURRENT_CONTEXT(ctx
);
88 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glFog");
92 m
= (GLenum
) (GLint
) *params
;
93 if (m
==GL_LINEAR
|| m
==GL_EXP
|| m
==GL_EXP2
) {
97 gl_error( ctx
, GL_INVALID_ENUM
, "glFog" );
103 gl_error( ctx
, GL_INVALID_VALUE
, "glFog" );
107 ctx
->Fog
.Density
= *params
;
111 ctx
->Fog
.Start
= *params
;
114 ctx
->Fog
.End
= *params
;
117 ctx
->Fog
.Index
= *params
;
120 ctx
->Fog
.Color
[0] = params
[0];
121 ctx
->Fog
.Color
[1] = params
[1];
122 ctx
->Fog
.Color
[2] = params
[2];
123 ctx
->Fog
.Color
[3] = params
[3];
125 case GL_FOG_COORDINATE_SOURCE_EXT
: {
126 GLenum p
= (GLenum
)(GLint
) *params
;
127 if (p
== GL_FOG_COORDINATE_EXT
|| p
== GL_FRAGMENT_DEPTH_EXT
)
128 ctx
->Fog
.FogCoordinateSource
= p
;
130 gl_error( ctx
, GL_INVALID_ENUM
, "glFog" );
134 gl_error( ctx
, GL_INVALID_ENUM
, "glFog" );
138 if (ctx
->Driver
.Fogfv
) {
139 (*ctx
->Driver
.Fogfv
)( ctx
, pname
, params
);
142 ctx
->NewState
|= _NEW_FOG
;