ReactOS
0.4.16-dev-13-ge2fc578
alpha.c
Go to the documentation of this file.
1
/* $Id: alpha.c,v 1.5 1997/07/24 01:24:28 brianp Exp $ */
2
3
/*
4
* Mesa 3-D graphics library
5
* Version: 2.4
6
* Copyright (C) 1995-1997 Brian Paul
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Library General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
12
*
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Library General Public License for more details.
17
*
18
* You should have received a copy of the GNU Library General Public
19
* License along with this library; if not, write to the Free
20
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
*/
22
23
24
/*
25
* $Log: alpha.c,v $
26
* Revision 1.5 1997/07/24 01:24:28 brianp
27
* changed precompiled header symbol from PCH to PC_HEADER
28
*
29
* Revision 1.4 1997/05/28 03:23:09 brianp
30
* added precompiled header (PCH) support
31
*
32
* Revision 1.3 1997/03/13 03:07:53 brianp
33
* optimized gl_alpha_test() by removing conditional from inside loops
34
*
35
* Revision 1.2 1996/09/15 14:15:54 brianp
36
* now use GLframebuffer and GLvisual
37
*
38
* Revision 1.1 1996/09/13 01:38:16 brianp
39
* Initial revision
40
*
41
*/
42
43
44
#ifdef PC_HEADER
45
#include "
all.h
"
46
#else
47
#include "
alpha.h
"
48
#include "
context.h
"
49
#include "
types.h
"
50
#include "
dlist.h
"
51
#include "
macros.h
"
52
#endif
53
54
55
56
void
gl_AlphaFunc
(
GLcontext
*
ctx
,
GLenum
func
,
GLclampf
ref
)
57
{
58
if
(
INSIDE_BEGIN_END
(
ctx
)) {
59
gl_error
(
ctx
,
GL_INVALID_OPERATION
,
"glAlphaFunc"
);
60
return
;
61
}
62
switch
(
func
) {
63
case
GL_NEVER
:
64
case
GL_LESS
:
65
case
GL_EQUAL
:
66
case
GL_LEQUAL
:
67
case
GL_GREATER
:
68
case
GL_NOTEQUAL
:
69
case
GL_GEQUAL
:
70
case
GL_ALWAYS
:
71
ctx
->Color.AlphaFunc =
func
;
72
ctx
->Color.AlphaRef =
CLAMP
(
ref
, 0.0F, 1.0F );
73
ctx
->Color.AlphaRefUbyte = (
GLubyte
) (
ctx
->Color.AlphaRef
74
*
ctx
->Visual->AlphaScale);
75
break
;
76
default
:
77
gl_error
(
ctx
,
GL_INVALID_ENUM
,
"glAlphaFunc(func)"
);
78
break
;
79
}
80
}
81
82
83
84
85
/*
86
* Apply the alpha test to a span of pixels.
87
* In/Out: mask - current pixel mask. Pixels which fail the alpha test
88
* will set the corresponding mask flag to 0.
89
* Return: 0 = all pixels in the span failed the alpha test.
90
* 1 = one or more pixels passed the alpha test.
91
*/
92
GLint
gl_alpha_test
(
GLcontext
*
ctx
,
93
GLuint
n
,
const
GLubyte
alpha
[],
GLubyte
mask
[] )
94
{
95
GLuint
i
;
96
GLubyte
ref
=
ctx
->Color.AlphaRefUbyte;
97
98
/* switch cases ordered from most frequent to less frequent */
99
switch
(
ctx
->Color.AlphaFunc) {
100
case
GL_LESS
:
101
for
(
i
=0;
i
<
n
;
i
++) {
102
mask
[
i
] &= (
alpha
[
i
] <
ref
);
103
}
104
return
1;
105
case
GL_LEQUAL
:
106
for
(
i
=0;
i
<
n
;
i
++) {
107
mask
[
i
] &= (
alpha
[
i
] <=
ref
);
108
}
109
return
1;
110
case
GL_GEQUAL
:
111
for
(
i
=0;
i
<
n
;
i
++) {
112
mask
[
i
] &= (
alpha
[
i
] >=
ref
);
113
}
114
return
1;
115
case
GL_GREATER
:
116
for
(
i
=0;
i
<
n
;
i
++) {
117
mask
[
i
] &= (
alpha
[
i
] >
ref
);
118
}
119
return
1;
120
case
GL_NOTEQUAL
:
121
for
(
i
=0;
i
<
n
;
i
++) {
122
mask
[
i
] &= (
alpha
[
i
] !=
ref
);
123
}
124
return
1;
125
case
GL_EQUAL
:
126
for
(
i
=0;
i
<
n
;
i
++) {
127
mask
[
i
] &= (
alpha
[
i
] ==
ref
);
128
}
129
return
1;
130
case
GL_ALWAYS
:
131
/* do nothing */
132
return
1;
133
case
GL_NEVER
:
134
/* caller should check for zero! */
135
return
0;
136
default
:
137
gl_problem
(
ctx
,
"Invalid alpha test in gl_alpha_test"
);
138
return
0;
139
}
140
/* Never get here */
141
return
1;
142
}
all.h
gl_alpha_test
GLint gl_alpha_test(GLcontext *ctx, GLuint n, const GLubyte alpha[], GLubyte mask[])
Definition:
alpha.c:92
gl_AlphaFunc
void gl_AlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
Definition:
alpha.c:56
alpha.h
context.h
gl_problem
void gl_problem(const GLcontext *ctx, const char *s)
Definition:
context.c:1394
gl_error
void gl_error(GLcontext *ctx, GLenum error, const char *s)
Definition:
context.c:1421
GL_NEVER
#define GL_NEVER
Definition:
gl.h:293
GLubyte
unsigned char GLubyte
Definition:
gl.h:157
GL_ALWAYS
#define GL_ALWAYS
Definition:
gl.h:300
GL_LESS
#define GL_LESS
Definition:
gl.h:294
GL_NOTEQUAL
#define GL_NOTEQUAL
Definition:
gl.h:298
GL_INVALID_OPERATION
#define GL_INVALID_OPERATION
Definition:
gl.h:696
alpha
GLclampf GLclampf GLclampf alpha
Definition:
gl.h:1740
GLenum
unsigned int GLenum
Definition:
gl.h:150
GLuint
unsigned int GLuint
Definition:
gl.h:159
GL_LEQUAL
#define GL_LEQUAL
Definition:
gl.h:296
GL_GEQUAL
#define GL_GEQUAL
Definition:
gl.h:299
GL_GREATER
#define GL_GREATER
Definition:
gl.h:297
GL_EQUAL
#define GL_EQUAL
Definition:
gl.h:295
GLint
int GLint
Definition:
gl.h:156
GLclampf
float GLclampf
Definition:
gl.h:162
GL_INVALID_ENUM
#define GL_INVALID_ENUM
Definition:
gl.h:694
func
GLenum func
Definition:
glext.h:6028
n
GLdouble n
Definition:
glext.h:7729
mask
GLenum GLint GLuint mask
Definition:
glext.h:6028
i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition:
glfuncs.h:248
macros.h
INSIDE_BEGIN_END
#define INSIDE_BEGIN_END(CTX)
Definition:
macros.h:135
dlist.h
types.h
gl_context
Definition:
types.h:1263
ref
Definition:
send.c:48
CLAMP
#define CLAMP(f, min, max)
Definition:
tif_color.c:177
ctx
Definition:
dbghelp_private.h:571
dll
opengl
mesa
alpha.c
Generated on Sat Sep 14 2024 06:03:40 for ReactOS by
1.9.6