1 /* $Id: depth.c,v 1.25 2000/12/26 05:09:28 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.
42 /**********************************************************************/
43 /***** API Functions *****/
44 /**********************************************************************/
49 _mesa_ClearDepth( GLclampd depth
)
51 GET_CURRENT_CONTEXT(ctx
);
52 GLfloat tmp
= (GLfloat
) CLAMP( depth
, 0.0, 1.0 );
53 ASSERT_OUTSIDE_BEGIN_END(ctx
);
55 if (ctx
->Depth
.Clear
== tmp
)
58 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
59 ctx
->Depth
.Clear
= tmp
;
60 if (ctx
->Driver
.ClearDepth
)
61 (*ctx
->Driver
.ClearDepth
)( ctx
, ctx
->Depth
.Clear
);
67 _mesa_DepthFunc( GLenum func
)
69 GET_CURRENT_CONTEXT(ctx
);
70 ASSERT_OUTSIDE_BEGIN_END(ctx
);
72 if (MESA_VERBOSE
& (VERBOSE_API
|VERBOSE_TEXTURE
))
73 fprintf(stderr
, "glDepthFunc %s\n", gl_lookup_enum_by_nr(func
));
76 case GL_LESS
: /* (default) pass if incoming z < stored z */
86 gl_error( ctx
, GL_INVALID_ENUM
, "glDepth.Func" );
90 if (ctx
->Depth
.Func
== func
)
93 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
94 ctx
->Depth
.Func
= func
;
97 ctx
->_TriangleCaps
|= DD_Z_NEVER
;
99 ctx
->_TriangleCaps
&= ~DD_Z_NEVER
;
101 if (ctx
->Driver
.DepthFunc
)
102 ctx
->Driver
.DepthFunc( ctx
, func
);
108 _mesa_DepthMask( GLboolean flag
)
110 GET_CURRENT_CONTEXT(ctx
);
111 ASSERT_OUTSIDE_BEGIN_END(ctx
);
113 if (MESA_VERBOSE
& (VERBOSE_API
|VERBOSE_TEXTURE
))
114 fprintf(stderr
, "glDepthMask %d\n", flag
);
117 * GL_TRUE indicates depth buffer writing is enabled (default)
118 * GL_FALSE indicates depth buffer writing is disabled
120 if (ctx
->Depth
.Mask
== flag
)
123 FLUSH_VERTICES(ctx
, _NEW_DEPTH
);
124 ctx
->Depth
.Mask
= flag
;
126 if (ctx
->Driver
.DepthMask
)
127 ctx
->Driver
.DepthMask( ctx
, flag
);