OpenSceneGraph 3.6.5
BlendFunc
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_BLENDFUNC
15#define OSG_BLENDFUNC 1
16
17#include <osg/StateAttribute>
18
19#ifndef GL_VERSION_1_2
20#define GL_CONSTANT_COLOR 0x8001
21#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
22#define GL_CONSTANT_ALPHA 0x8003
23#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
24#define GL_BLEND_COLOR 0x8005
25#endif
26
27#ifndef GL_VERSION_1_4
28#define GL_BLEND_DST_RGB 0x80C8
29#define GL_BLEND_SRC_RGB 0x80C9
30#define GL_BLEND_DST_ALPHA 0x80CA
31#define GL_BLEND_SRC_ALPHA 0x80CB
32#endif
33
34
35namespace osg {
36
66{
67 public :
68
70
71 BlendFunc(GLenum source, GLenum destination);
72 BlendFunc(GLenum source, GLenum destination, GLenum source_alpha, GLenum destination_alpha);
73
81
83
85 virtual int compare(const StateAttribute& sa) const
86 {
87 // Check for equal types, then create the rhs variable
88 // used by the COMPARE_StateAttribute_Parameter macros below.
90
91 // Compare each parameter in turn against the rhs.
96
97 return 0; // Passed all the above comparison macros, so must be equal.
98 }
99
100 virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
101 {
102 usage.usesMode(GL_BLEND);
103 return true;
104 }
105
107 DST_ALPHA = GL_DST_ALPHA,
108 DST_COLOR = GL_DST_COLOR,
109 ONE = GL_ONE,
110 ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA,
111 ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR,
112 ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA,
113 ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
114 SRC_ALPHA = GL_SRC_ALPHA,
115 SRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE,
116 SRC_COLOR = GL_SRC_COLOR,
121 ZERO = GL_ZERO
122 };
123
124 inline void setFunction( GLenum source, GLenum destination )
125 {
126 _source_factor = source;
127 _destination_factor = destination;
128 _source_factor_alpha = source;
129 _destination_factor_alpha = destination;
130 }
131
132 inline void setFunction( GLenum source_rgb, GLenum destination_rgb, GLenum source_alpha, GLenum destination_alpha )
133 {
134 _source_factor = source_rgb;
135 _destination_factor = destination_rgb;
136 _source_factor_alpha = source_alpha;
137 _destination_factor_alpha = destination_alpha;
138 }
139
140 void setSource(GLenum source) { _source_factor = _source_factor_alpha = source; }
141 inline GLenum getSource() const { return _source_factor; }
142
143 void setSourceRGB(GLenum source) { _source_factor = source; }
144 inline GLenum getSourceRGB() const { return _source_factor; }
145
146 void setSourceAlpha(GLenum source) { _source_factor_alpha = source; }
147 inline GLenum getSourceAlpha() const { return _source_factor_alpha; }
148
149 void setDestination(GLenum destination) { _destination_factor = _destination_factor_alpha = destination; }
150 inline GLenum getDestination() const { return _destination_factor; }
151
152 void setDestinationRGB(GLenum destination) { _destination_factor = destination; }
153 inline GLenum getDestinationRGB() const { return _destination_factor; }
154
155 void setDestinationAlpha(GLenum destination) { _destination_factor_alpha = destination; }
156 inline GLenum getDestinationAlpha() const { return _destination_factor_alpha; }
157
158 virtual void apply(State& state) const;
159
160 protected :
161
162 virtual ~BlendFunc();
163
168};
169
170}
171
172#endif
#define GL_ONE_MINUS_CONSTANT_ALPHA
Definition BlendFunc:23
#define GL_CONSTANT_COLOR
Definition BlendFunc:20
#define GL_CONSTANT_ALPHA
Definition BlendFunc:22
#define GL_ONE_MINUS_CONSTANT_COLOR
Definition BlendFunc:21
#define COMPARE_StateAttribute_Parameter(parameter)
COMPARE_StateAttribute_Parameter macro is a helper for implementing the StatateAtribute::compare(....
Definition StateAttribute:69
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
COMPARE_StateAttribute_Types macro is a helper for implementing the StateAtribute::compare(....
Definition StateAttribute:57
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
void setDestinationAlpha(GLenum destination)
Definition BlendFunc:155
virtual ~BlendFunc()
void setFunction(GLenum source_rgb, GLenum destination_rgb, GLenum source_alpha, GLenum destination_alpha)
Definition BlendFunc:132
void setDestinationRGB(GLenum destination)
Definition BlendFunc:152
GLenum _destination_factor
Definition BlendFunc:165
void setSource(GLenum source)
Definition BlendFunc:140
void setSourceRGB(GLenum source)
Definition BlendFunc:143
GLenum getDestination() const
Definition BlendFunc:150
BlendFuncMode
Definition BlendFunc:106
@ SRC_COLOR
Definition BlendFunc:116
@ ONE_MINUS_SRC_ALPHA
Definition BlendFunc:112
@ ZERO
Definition BlendFunc:121
@ ONE_MINUS_DST_COLOR
Definition BlendFunc:111
@ CONSTANT_COLOR
Definition BlendFunc:117
@ ONE_MINUS_DST_ALPHA
Definition BlendFunc:110
@ SRC_ALPHA
Definition BlendFunc:114
@ DST_ALPHA
Definition BlendFunc:107
@ DST_COLOR
Definition BlendFunc:108
@ ONE_MINUS_CONSTANT_COLOR
Definition BlendFunc:118
@ ONE
Definition BlendFunc:109
@ SRC_ALPHA_SATURATE
Definition BlendFunc:115
@ CONSTANT_ALPHA
Definition BlendFunc:119
@ ONE_MINUS_CONSTANT_ALPHA
Definition BlendFunc:120
@ ONE_MINUS_SRC_COLOR
Definition BlendFunc:113
GLenum getSource() const
Definition BlendFunc:141
virtual void apply(State &state) const
apply the OpenGL state attributes.
GLenum getSourceRGB() const
Definition BlendFunc:144
META_StateAttribute(osg, BlendFunc, BLENDFUNC)
void setSourceAlpha(GLenum source)
Definition BlendFunc:146
GLenum _destination_factor_alpha
Definition BlendFunc:167
BlendFunc(GLenum source, GLenum destination)
virtual int compare(const StateAttribute &sa) const
Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
Definition BlendFunc:85
BlendFunc(GLenum source, GLenum destination, GLenum source_alpha, GLenum destination_alpha)
void setDestination(GLenum destination)
Definition BlendFunc:149
void setFunction(GLenum source, GLenum destination)
Definition BlendFunc:124
GLenum getDestinationAlpha() const
Definition BlendFunc:156
GLenum getSourceAlpha() const
Definition BlendFunc:147
GLenum _source_factor
Definition BlendFunc:164
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
Return the modes associated with this StateAttribute.
Definition BlendFunc:100
BlendFunc(const BlendFunc &trans, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy.
Definition BlendFunc:75
GLenum getDestinationRGB() const
Definition BlendFunc:153
GLenum _source_factor_alpha
Definition BlendFunc:166
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
@ BLENDFUNC
Definition StateAttribute:149
Definition StateAttribute:308
virtual void usesMode(GLMode mode)=0
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 27 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.