Rev 55 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
55 | pj | 1 | /* $Id: depth.c,v 1.1 2003-02-28 11:41:59 pj Exp $ */ |
2 | |||
3 | /* |
||
4 | * Mesa 3-D graphics library |
||
5 | * Version: 4.1 |
||
6 | * |
||
7 | * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. |
||
8 | * |
||
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: |
||
15 | * |
||
16 | * The above copyright notice and this permission notice shall be included |
||
17 | * in all copies or substantial portions of the Software. |
||
18 | * |
||
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. |
||
25 | */ |
||
26 | |||
27 | |||
28 | #include "glheader.h" |
||
29 | #include "imports.h" |
||
30 | #include "context.h" |
||
31 | #include "enums.h" |
||
32 | #include "depth.h" |
||
33 | #include "macros.h" |
||
34 | #include "mtypes.h" |
||
35 | |||
36 | |||
37 | /**********************************************************************/ |
||
38 | /***** API Functions *****/ |
||
39 | /**********************************************************************/ |
||
40 | |||
41 | |||
42 | |||
43 | void |
||
44 | _mesa_ClearDepth( GLclampd depth ) |
||
45 | { |
||
46 | GET_CURRENT_CONTEXT(ctx); |
||
47 | GLfloat tmp = (GLfloat) CLAMP( depth, 0.0, 1.0 ); |
||
48 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
||
49 | |||
50 | if (ctx->Depth.Clear == tmp) |
||
51 | return; |
||
52 | |||
53 | FLUSH_VERTICES(ctx, _NEW_DEPTH); |
||
54 | ctx->Depth.Clear = tmp; |
||
55 | if (ctx->Driver.ClearDepth) |
||
56 | (*ctx->Driver.ClearDepth)( ctx, ctx->Depth.Clear ); |
||
57 | } |
||
58 | |||
59 | |||
60 | |||
61 | void |
||
62 | _mesa_DepthFunc( GLenum func ) |
||
63 | { |
||
64 | GET_CURRENT_CONTEXT(ctx); |
||
65 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
||
66 | |||
67 | if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) |
||
68 | _mesa_debug(ctx, "glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func)); |
||
69 | |||
70 | switch (func) { |
||
71 | case GL_LESS: /* (default) pass if incoming z < stored z */ |
||
72 | case GL_GEQUAL: |
||
73 | case GL_LEQUAL: |
||
74 | case GL_GREATER: |
||
75 | case GL_NOTEQUAL: |
||
76 | case GL_EQUAL: |
||
77 | case GL_ALWAYS: |
||
78 | case GL_NEVER: |
||
79 | break; |
||
80 | default: |
||
81 | _mesa_error( ctx, GL_INVALID_ENUM, "glDepth.Func" ); |
||
82 | return; |
||
83 | } |
||
84 | |||
85 | if (ctx->Depth.Func == func) |
||
86 | return; |
||
87 | |||
88 | FLUSH_VERTICES(ctx, _NEW_DEPTH); |
||
89 | ctx->Depth.Func = func; |
||
90 | |||
91 | if (ctx->Driver.DepthFunc) |
||
92 | ctx->Driver.DepthFunc( ctx, func ); |
||
93 | } |
||
94 | |||
95 | |||
96 | |||
97 | void |
||
98 | _mesa_DepthMask( GLboolean flag ) |
||
99 | { |
||
100 | GET_CURRENT_CONTEXT(ctx); |
||
101 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
||
102 | |||
103 | if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) |
||
104 | _mesa_debug(ctx, "glDepthMask %d\n", flag); |
||
105 | |||
106 | /* |
||
107 | * GL_TRUE indicates depth buffer writing is enabled (default) |
||
108 | * GL_FALSE indicates depth buffer writing is disabled |
||
109 | */ |
||
110 | if (ctx->Depth.Mask == flag) |
||
111 | return; |
||
112 | |||
113 | FLUSH_VERTICES(ctx, _NEW_DEPTH); |
||
114 | ctx->Depth.Mask = flag; |
||
115 | |||
116 | if (ctx->Driver.DepthMask) |
||
117 | ctx->Driver.DepthMask( ctx, flag ); |
||
118 | } |