mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-18 12:43:44 -04:00
TextureStage::M_blend_color_scale, TextureStage::rgb_scale, ColorBlendAttrib::O_color_scale, better handling of state changes in GL
This commit is contained in:
parent
02016f44d5
commit
ffdbf61985
@ -150,23 +150,28 @@ reset() {
|
||||
_accum_clear_value.set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
_force_normals = 0;
|
||||
|
||||
//Color and alpha transform variables
|
||||
_color_transform_enabled = 0;
|
||||
_current_color_offset.set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
_current_color_scale.set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
_color_write_mode = ColorWriteAttrib::M_on;
|
||||
_color_blend_mode = ColorBlendAttrib::M_none;
|
||||
_transparency_mode = TransparencyAttrib::M_none;
|
||||
|
||||
_has_scene_graph_color = false;
|
||||
_scene_graph_color_stale = false;
|
||||
_color_blend_involves_color_scale = false;
|
||||
_texture_involves_color_scale = false;
|
||||
_vertex_colors_enabled = true;
|
||||
_lighting_enabled = false;
|
||||
_lighting_enabled_this_frame = false;
|
||||
|
||||
_clip_planes_enabled = false;
|
||||
_clip_planes_enabled_this_frame = false;
|
||||
|
||||
_color_scale_enabled = false;
|
||||
_current_color_scale.set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
_color_write_mode = ColorWriteAttrib::M_on;
|
||||
_color_blend_mode = ColorBlendAttrib::M_none;
|
||||
_transparency_mode = TransparencyAttrib::M_none;
|
||||
|
||||
_color_blend = NULL;
|
||||
_blend_mode_stale = false;
|
||||
_pending_texture = NULL;
|
||||
_texture_stale = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -625,15 +630,17 @@ issue_transform(const TransformState *) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
issue_color_scale(const ColorScaleAttrib *attrib) {
|
||||
_color_scale_enabled = attrib->has_scale();
|
||||
_current_color_scale = attrib->get_scale();
|
||||
|
||||
if (attrib->has_scale()) {
|
||||
_color_transform_enabled |= CT_scale;
|
||||
} else {
|
||||
_color_transform_enabled &= ~CT_scale;
|
||||
}
|
||||
|
||||
_scene_graph_color_stale = _has_scene_graph_color;
|
||||
|
||||
if (_color_blend_involves_color_scale) {
|
||||
_blend_mode_stale = true;
|
||||
}
|
||||
if (_texture_involves_color_scale) {
|
||||
_texture_stale = true;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -834,7 +841,7 @@ issue_light(const LightAttrib *attrib) {
|
||||
void GraphicsStateGuardian::
|
||||
issue_color_write(const ColorWriteAttrib *attrib) {
|
||||
_color_write_mode = attrib->get_mode();
|
||||
set_blend_mode();
|
||||
_blend_mode_stale = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -845,7 +852,7 @@ issue_color_write(const ColorWriteAttrib *attrib) {
|
||||
void GraphicsStateGuardian::
|
||||
issue_transparency(const TransparencyAttrib *attrib) {
|
||||
_transparency_mode = attrib->get_mode();
|
||||
set_blend_mode();
|
||||
_blend_mode_stale = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -857,7 +864,21 @@ void GraphicsStateGuardian::
|
||||
issue_color_blend(const ColorBlendAttrib *attrib) {
|
||||
_color_blend = attrib;
|
||||
_color_blend_mode = attrib->get_mode();
|
||||
set_blend_mode();
|
||||
_color_blend_involves_color_scale = attrib->involves_color_scale();
|
||||
_blend_mode_stale = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::issue_texture
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
issue_texture(const TextureAttrib *attrib) {
|
||||
// By default, we don't apply the texture attrib right away, since
|
||||
// it might have a dependency on the current ColorScaleAttrib.
|
||||
_pending_texture = attrib;
|
||||
_texture_stale = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -1203,6 +1224,10 @@ set_blend_mode() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsStateGuardian::
|
||||
finish_modify_state() {
|
||||
if (_blend_mode_stale) {
|
||||
_blend_mode_stale = false;
|
||||
set_blend_mode();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "planeNode.h"
|
||||
#include "colorWriteAttrib.h"
|
||||
#include "colorBlendAttrib.h"
|
||||
#include "textureAttrib.h"
|
||||
#include "transparencyAttrib.h"
|
||||
#include "config_display.h"
|
||||
|
||||
@ -165,6 +166,7 @@ public:
|
||||
virtual void issue_color_write(const ColorWriteAttrib *attrib);
|
||||
virtual void issue_transparency(const TransparencyAttrib *attrib);
|
||||
virtual void issue_color_blend(const ColorBlendAttrib *attrib);
|
||||
virtual void issue_texture(const TextureAttrib *attrib);
|
||||
virtual void issue_clip_plane(const ClipPlaneAttrib *attrib);
|
||||
|
||||
virtual void bind_light(PointLight *light_obj, const NodePath &light,
|
||||
@ -256,22 +258,23 @@ protected:
|
||||
Colorf _scene_graph_color;
|
||||
bool _has_scene_graph_color;
|
||||
bool _scene_graph_color_stale;
|
||||
bool _color_blend_involves_color_scale;
|
||||
bool _texture_involves_color_scale;
|
||||
bool _vertex_colors_enabled;
|
||||
bool _lighting_enabled;
|
||||
bool _clip_planes_enabled;
|
||||
|
||||
enum ColorTransform {
|
||||
CT_offset = 0x01,
|
||||
CT_scale = 0x02,
|
||||
};
|
||||
int _color_transform_enabled; // Zero or more of ColorTransform bits, above.
|
||||
LVecBase4f _current_color_offset;
|
||||
bool _color_scale_enabled;
|
||||
LVecBase4f _current_color_scale;
|
||||
|
||||
ColorWriteAttrib::Mode _color_write_mode;
|
||||
ColorBlendAttrib::Mode _color_blend_mode;
|
||||
TransparencyAttrib::Mode _transparency_mode;
|
||||
CPT(ColorBlendAttrib) _color_blend;
|
||||
bool _blend_mode_stale;
|
||||
|
||||
CPT(TextureAttrib) _pending_texture;
|
||||
bool _texture_stale;
|
||||
|
||||
bool _needs_reset;
|
||||
bool _closing_gsg;
|
||||
|
@ -200,12 +200,13 @@ appear before they are referenced.
|
||||
BLEND
|
||||
REPLACE
|
||||
ADD
|
||||
BLEND_COLOR_SCALE
|
||||
|
||||
The default environment type is MODULATE, which means the texture
|
||||
color is multiplied with the base polygon (or vertex) color. This
|
||||
is the most common texture environment by far. Other environment
|
||||
types are more esoteric and are especially useful in the presence
|
||||
of multitexture.
|
||||
of multitexture. See howto.use_multitexture.txt for more on these.
|
||||
|
||||
<Scalar> combine-rgb { combine-mode }
|
||||
<Scalar> combine-alpha { combine-mode }
|
||||
@ -246,6 +247,7 @@ appear before they are referenced.
|
||||
CONSTANT
|
||||
PRIMARY-COLOR
|
||||
PREVIOUS
|
||||
CONSTANT_COLOR_SCALE
|
||||
|
||||
combine-operand may be one of:
|
||||
|
||||
@ -313,6 +315,14 @@ appear before they are referenced.
|
||||
associated with this texture. If this is omitted, the default
|
||||
texture coordinates are used.
|
||||
|
||||
<Scalar> rgb-scale { scale }
|
||||
<Scalar> alpha-scale { scale }
|
||||
|
||||
Specifies an additional scale factor that will scale the r, g, b
|
||||
(or a) components after the texture has been applied. This is
|
||||
only used when a combine mode is in effect. The only legal values
|
||||
are 1, 2, or 4.
|
||||
|
||||
<Scalar> alpha { alpha-type }
|
||||
|
||||
This specifies whether and what type of transparency will be
|
||||
@ -326,7 +336,7 @@ appear before they are referenced.
|
||||
MS_MASK
|
||||
|
||||
If alpha-type is OFF, it means not to enable transparency, even if
|
||||
the image contains an alpha channel or the format is RGBA12. If
|
||||
the image contains an alpha channel or the format is RGBA. If
|
||||
alpha-type is ON, it means to enable the default transparency,
|
||||
even if the image filename does not contain an alpha channel. If
|
||||
alpha-type is any of the other options, it specifies the type of
|
||||
|
@ -93,6 +93,11 @@ texture_stage.set_mode(). The mode may be one of:
|
||||
used to paint arbitrary color stripes or a similar effect over
|
||||
an existing texture.
|
||||
|
||||
TextureStage::M_blend_color_scale
|
||||
This is identical to M_blend, except that the blend color,
|
||||
specified by texture_stage.set_color(), is also modified by the
|
||||
color scale applied to the scene graph.
|
||||
|
||||
TextureStage::M_replace
|
||||
Completely replaces the incoming color with the texture color;
|
||||
probably not terribly useful in a multitexture environment,
|
||||
|
@ -1068,10 +1068,10 @@ typedef enum {
|
||||
INLINE void DXGraphicsStateGuardian7::
|
||||
transform_color(Colorf &InColor,D3DCOLOR &OutRGBAColor) {
|
||||
Colorf transformed
|
||||
((InColor[0] * _current_color_scale[0]) + _current_color_offset[0],
|
||||
(InColor[1] * _current_color_scale[1]) + _current_color_offset[1],
|
||||
(InColor[2] * _current_color_scale[2]) + _current_color_offset[2],
|
||||
(InColor[3] * _current_color_scale[3]) + _current_color_offset[3]);
|
||||
(InColor[0] * _current_color_scale[0],
|
||||
InColor[1] * _current_color_scale[1],
|
||||
InColor[2] * _current_color_scale[2],
|
||||
InColor[3] * _current_color_scale[3]);
|
||||
OutRGBAColor = Colorf_to_D3DCOLOR(transformed);
|
||||
}
|
||||
|
||||
@ -1097,7 +1097,7 @@ draw_prim_setup(const Geom *geom) {
|
||||
#define GET_NEXT_TEXCOORD() { p_texcoord = geom->get_next_texcoord(ti); }
|
||||
#define GET_NEXT_COLOR() { \
|
||||
Colorf tempcolor = geom->get_next_color(ci); \
|
||||
if(_color_transform_enabled == 0) { \
|
||||
if(!_color_scale_enabled) { \
|
||||
_curD3Dcolor = Colorf_to_D3DCOLOR(tempcolor); \
|
||||
} else { \
|
||||
transform_color(tempcolor,_curD3Dcolor); \
|
||||
@ -1134,7 +1134,7 @@ draw_prim_setup(const Geom *geom) {
|
||||
if (_has_scene_graph_color) {
|
||||
if (_scene_graph_color_stale) {
|
||||
// Compute the D3DCOLOR for the scene graph override color.
|
||||
if(_color_transform_enabled == 0) {
|
||||
if(!_color_scale_enabled) {
|
||||
_scene_graph_color_D3DCOLOR = Colorf_to_D3DCOLOR(_scene_graph_color);
|
||||
} else {
|
||||
transform_color(_scene_graph_color, _scene_graph_color_D3DCOLOR);
|
||||
@ -1433,7 +1433,7 @@ draw_point(GeomPoint *geom, GeomContext *gc) {
|
||||
// BUGBUG: eventually this hack every-frame all-colors conversion needs
|
||||
// to be done only once as part of a vertex buffer
|
||||
|
||||
if(_color_transform_enabled == 0) {
|
||||
if(!_color_scale_enabled) {
|
||||
for (int i=0;i<nPrims;i++) {
|
||||
Colorf out_color=colors[i];
|
||||
add_DWORD_to_FVFBuf(Colorf_to_D3DCOLOR(out_color));
|
||||
@ -2379,7 +2379,7 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
|
||||
if (NeededShadeMode!=D3DSHADE_FLAT) {
|
||||
// but if lighting enabled, we need to color every vert since shading will be GOURAUD
|
||||
|
||||
if(_color_transform_enabled == 0) {
|
||||
if(!_color_scale_enabled) {
|
||||
for (uint i=0;i<nPrims;i++,pInColor++,pOutColor+=dwVertsperPrim) {
|
||||
D3DCOLOR newcolr = Colorf_to_D3DCOLOR(*pInColor);
|
||||
*pOutColor = newcolr;
|
||||
@ -2400,7 +2400,7 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
|
||||
// dont write 2nd,3rd colors in output buffer, these are not used in flat shading
|
||||
// MAKE SURE ShadeMode never set to GOURAUD after this!
|
||||
|
||||
if(_color_transform_enabled == 0) {
|
||||
if(!_color_scale_enabled) {
|
||||
for (uint i=0;i<nPrims;i++,pInColor++,pOutColor+=dwVertsperPrim) {
|
||||
*pOutColor = Colorf_to_D3DCOLOR(*pInColor);
|
||||
}
|
||||
@ -2416,7 +2416,7 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
|
||||
// want to do this conversion once in retained mode
|
||||
DWORD cNumColors=nPrims*dwVertsperPrim;
|
||||
|
||||
if(_color_transform_enabled == 0) {
|
||||
if(!_color_scale_enabled) {
|
||||
for (uint i=0;i<cNumColors;i++,pInColor++,pOutColor++) {
|
||||
*pOutColor = Colorf_to_D3DCOLOR(*pInColor);
|
||||
}
|
||||
@ -2431,7 +2431,7 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
|
||||
#endif
|
||||
// copy the one global color in, set stride to 0
|
||||
|
||||
if(_color_transform_enabled == 0) {
|
||||
if(!_color_scale_enabled) {
|
||||
if (bDoGlobalSceneGraphColor) {
|
||||
Colorf colr = _scene_graph_color;
|
||||
*pConvertedColorArray = Colorf_to_D3DCOLOR(colr);
|
||||
@ -2832,7 +2832,7 @@ draw_multitri(Geom *geom, D3DPRIMITIVETYPE trilisttype) {
|
||||
if (ColorBinding==G_PER_VERTEX) {
|
||||
NeededShadeMode = D3DSHADE_GOURAUD;
|
||||
|
||||
if(_color_transform_enabled == 0) {
|
||||
if(!_color_scale_enabled) {
|
||||
for (uint i=0;i<cTotalVerts;i++,pInColor++,pOutColor++) {
|
||||
*pOutColor = Colorf_to_D3DCOLOR(*pInColor);
|
||||
}
|
||||
@ -2848,7 +2848,7 @@ draw_multitri(Geom *geom, D3DPRIMITIVETYPE trilisttype) {
|
||||
|
||||
// could save 2 clr writes per strip/fan in flat shade mode but not going to bother here
|
||||
|
||||
if(_color_transform_enabled == 0) {
|
||||
if(!_color_scale_enabled) {
|
||||
for (uint j=0;j<nPrims;j++,pInColor++) {
|
||||
D3DCOLOR lastcolr = Colorf_to_D3DCOLOR(*pInColor);
|
||||
DWORD cStripLength=pLengthArr[j];
|
||||
@ -2921,7 +2921,7 @@ draw_multitri(Geom *geom, D3DPRIMITIVETYPE trilisttype) {
|
||||
} \
|
||||
}
|
||||
|
||||
if(_color_transform_enabled == 0) {
|
||||
if(!_color_scale_enabled) {
|
||||
COMPONENT_COLOR_COPY_LOOPS(COLOR_CONVERT_COPY_STMT);
|
||||
} else {
|
||||
COMPONENT_COLOR_COPY_LOOPS(COLOR_CONVERT_XFORM_STMT);
|
||||
@ -2932,7 +2932,7 @@ draw_multitri(Geom *geom, D3DPRIMITIVETYPE trilisttype) {
|
||||
#endif
|
||||
// copy the one global color in, set stride to 0
|
||||
|
||||
if(_color_transform_enabled == 0) {
|
||||
if(!_color_scale_enabled) {
|
||||
if (bDoGlobalSceneGraphColor) {
|
||||
Colorf colr = _scene_graph_color();
|
||||
*pConvertedColorArray = Colorf_to_D3DCOLOR(colr);
|
||||
|
@ -453,10 +453,10 @@ enable_zwritemask(bool val) {
|
||||
INLINE void DXGraphicsStateGuardian8::
|
||||
transform_color(Colorf &InColor,D3DCOLOR &OutRGBAColor) {
|
||||
Colorf transformed
|
||||
((InColor[0] * _current_color_scale[0]) + _current_color_offset[0],
|
||||
(InColor[1] * _current_color_scale[1]) + _current_color_offset[1],
|
||||
(InColor[2] * _current_color_scale[2]) + _current_color_offset[2],
|
||||
(InColor[3] * _current_color_scale[3]) + _current_color_offset[3]);
|
||||
(InColor[0] * _current_color_scale[0],
|
||||
InColor[1] * _current_color_scale[1],
|
||||
InColor[2] * _current_color_scale[2],
|
||||
InColor[3] * _current_color_scale[3]);
|
||||
OutRGBAColor = Colorf_to_D3DCOLOR(transformed);
|
||||
}
|
||||
|
||||
|
@ -956,7 +956,7 @@ draw_prim_setup(const Geom *geom) {
|
||||
|
||||
#define GET_NEXT_COLOR() { \
|
||||
Colorf tempcolor = geom->get_next_color(ci); \
|
||||
if(_color_transform_enabled == 0) { \
|
||||
if(!_color_scale_enabled) { \
|
||||
_curD3Dcolor = Colorf_to_D3DCOLOR(tempcolor); \
|
||||
} else { \
|
||||
transform_color(tempcolor,_curD3Dcolor); \
|
||||
@ -994,7 +994,7 @@ draw_prim_setup(const Geom *geom) {
|
||||
if (_has_scene_graph_color) {
|
||||
if (_scene_graph_color_stale) {
|
||||
// Compute the D3DCOLOR for the scene graph override color.
|
||||
if(_color_transform_enabled == 0) {
|
||||
if(!_color_scale_enabled) {
|
||||
_scene_graph_color_D3DCOLOR = Colorf_to_D3DCOLOR(_scene_graph_color);
|
||||
} else {
|
||||
transform_color(_scene_graph_color, _scene_graph_color_D3DCOLOR);
|
||||
|
@ -435,10 +435,10 @@ add_to_FVFBuf(void *data, size_t bytes) {
|
||||
INLINE void DXGraphicsStateGuardian9::
|
||||
transform_color(Colorf &InColor,D3DCOLOR &OutRGBAColor) {
|
||||
Colorf transformed
|
||||
((InColor[0] * _current_color_scale[0]) + _current_color_offset[0],
|
||||
(InColor[1] * _current_color_scale[1]) + _current_color_offset[1],
|
||||
(InColor[2] * _current_color_scale[2]) + _current_color_offset[2],
|
||||
(InColor[3] * _current_color_scale[3]) + _current_color_offset[3]);
|
||||
(InColor[0] * _current_color_scale[0],
|
||||
InColor[1] * _current_color_scale[1],
|
||||
InColor[2] * _current_color_scale[2],
|
||||
InColor[3] * _current_color_scale[3]);
|
||||
OutRGBAColor = Colorf_to_D3DCOLOR(transformed);
|
||||
}
|
||||
|
||||
|
@ -942,7 +942,7 @@ draw_prim_setup(const Geom *geom) {
|
||||
|
||||
#define GET_NEXT_COLOR() { \
|
||||
Colorf tempcolor = geom->get_next_color(ci); \
|
||||
if(_color_transform_enabled == 0) { \
|
||||
if(!_color_scale_enabled) { \
|
||||
_curD3Dcolor = Colorf_to_D3DCOLOR(tempcolor); \
|
||||
} else { \
|
||||
transform_color(tempcolor,_curD3Dcolor); \
|
||||
@ -979,7 +979,7 @@ draw_prim_setup(const Geom *geom) {
|
||||
if (_has_scene_graph_color) {
|
||||
if (_scene_graph_color_stale) {
|
||||
// Compute the D3DCOLOR for the scene graph override color.
|
||||
if(_color_transform_enabled == 0) {
|
||||
if(!_color_scale_enabled) {
|
||||
_scene_graph_color_D3DCOLOR = Colorf_to_D3DCOLOR(_scene_graph_color);
|
||||
} else {
|
||||
transform_color(_scene_graph_color, _scene_graph_color_D3DCOLOR);
|
||||
|
@ -527,6 +527,107 @@ get_uv_name() const {
|
||||
return _uv_name;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTexture::set_rgb_scale
|
||||
// Access: Published
|
||||
// Description: Sets an additional factor that will scale all three
|
||||
// r, g, b components after the texture has been
|
||||
// applied. This is used only when a combine mode is in
|
||||
// effect.
|
||||
//
|
||||
// The only legal values are 1, 2, or 4.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void EggTexture::
|
||||
set_rgb_scale(int rgb_scale) {
|
||||
_rgb_scale = rgb_scale;
|
||||
_flags |= F_has_rgb_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTexture::clear_rgb_scale
|
||||
// Access: Published
|
||||
// Description: Removes the rgb_scale from the texture and restores
|
||||
// it to the default value of 1.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void EggTexture::
|
||||
clear_rgb_scale() {
|
||||
_rgb_scale = 1;
|
||||
_flags &= ~F_has_rgb_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTexture::has_rgb_scale
|
||||
// Access: Published
|
||||
// Description: Returns true if an rgb_scale has been specified for
|
||||
// the texture, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool EggTexture::
|
||||
has_rgb_scale() const {
|
||||
return (_flags & F_has_rgb_scale) != 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTexture::get_rgb_scale
|
||||
// Access: Published
|
||||
// Description: Returns the rgb_scale value that has been
|
||||
// specified for the texture, or 1 if no rgb_scale value
|
||||
// has been specified.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int EggTexture::
|
||||
get_rgb_scale() const {
|
||||
return _rgb_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTexture::set_alpha_scale
|
||||
// Access: Published
|
||||
// Description: Sets an additional factor that will scale the
|
||||
// alpha component after the texture has been applied.
|
||||
// This is used only when a combine mode is in effect.
|
||||
//
|
||||
// The only legal values are 1, 2, or 4.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void EggTexture::
|
||||
set_alpha_scale(int alpha_scale) {
|
||||
_alpha_scale = alpha_scale;
|
||||
_flags |= F_has_alpha_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTexture::clear_alpha_scale
|
||||
// Access: Published
|
||||
// Description: Removes the alpha_scale from the texture and restores
|
||||
// it to the default value of 1.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void EggTexture::
|
||||
clear_alpha_scale() {
|
||||
_alpha_scale = 1;
|
||||
_flags &= ~F_has_alpha_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTexture::has_alpha_scale
|
||||
// Access: Published
|
||||
// Description: Returns true if an alpha_scale has been specified for
|
||||
// the texture, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool EggTexture::
|
||||
has_alpha_scale() const {
|
||||
return (_flags & F_has_alpha_scale) != 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTexture::get_alpha_scale
|
||||
// Access: Published
|
||||
// Description: Returns the alpha_scale value that has been
|
||||
// specified for the texture, or 1 if no alpha_scale
|
||||
// value has been specified.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int EggTexture::
|
||||
get_alpha_scale() const {
|
||||
return _alpha_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTexture::set_transform
|
||||
// Access: Published
|
||||
|
@ -87,6 +87,8 @@ operator = (const EggTexture ©) {
|
||||
_priority = copy._priority;
|
||||
_color = copy._color;
|
||||
_uv_name = copy._uv_name;
|
||||
_rgb_scale = 1;
|
||||
_alpha_scale = 1;
|
||||
_flags = copy._flags;
|
||||
_transform = copy._transform;
|
||||
_alpha_filename = copy._alpha_filename;
|
||||
@ -225,6 +227,16 @@ write(ostream &out, int indent_level) const {
|
||||
<< "<Scalar> uv-name { " << get_uv_name() << " }\n";
|
||||
}
|
||||
|
||||
if (has_rgb_scale()) {
|
||||
indent(out, indent_level + 2)
|
||||
<< "<Scalar> rgb-scale { " << get_rgb_scale() << " }\n";
|
||||
}
|
||||
|
||||
if (has_alpha_scale()) {
|
||||
indent(out, indent_level + 2)
|
||||
<< "<Scalar> alpha-scale { " << get_alpha_scale() << " }\n";
|
||||
}
|
||||
|
||||
EggRenderMode::write(out, indent_level + 2);
|
||||
|
||||
if (has_transform()) {
|
||||
@ -676,6 +688,9 @@ string_env_type(const string &string) {
|
||||
} else if (cmp_nocase_uh(string, "add") == 0) {
|
||||
return ET_add;
|
||||
|
||||
} else if (cmp_nocase_uh(string, "blend_color_scale") == 0) {
|
||||
return ET_blend_color_scale;
|
||||
|
||||
} else {
|
||||
return ET_unspecified;
|
||||
}
|
||||
@ -740,6 +755,9 @@ string_combine_source(const string &string) {
|
||||
} else if (cmp_nocase_uh(string, "previous") == 0) {
|
||||
return CS_previous;
|
||||
|
||||
} else if (cmp_nocase_uh(string, "constant_color_scale") == 0) {
|
||||
return CS_constant_color_scale;
|
||||
|
||||
} else {
|
||||
return CS_unspecified;
|
||||
}
|
||||
@ -979,6 +997,9 @@ ostream &operator << (ostream &out, EggTexture::EnvType type) {
|
||||
|
||||
case EggTexture::ET_add:
|
||||
return out << "add";
|
||||
|
||||
case EggTexture::ET_blend_color_scale:
|
||||
return out << "blend_color_scale";
|
||||
}
|
||||
|
||||
nassertr(false, out);
|
||||
@ -1054,6 +1075,9 @@ operator << (ostream &out, EggTexture::CombineSource cs) {
|
||||
|
||||
case EggTexture::CS_previous:
|
||||
return out << "previous";
|
||||
|
||||
case EggTexture::CS_constant_color_scale:
|
||||
return out << "constant_color_scale";
|
||||
}
|
||||
|
||||
return out << "**invalid CombineSource(" << (int)cs << ")**";
|
||||
|
@ -91,6 +91,7 @@ PUBLISHED:
|
||||
ET_blend,
|
||||
ET_replace,
|
||||
ET_add,
|
||||
ET_blend_color_scale,
|
||||
};
|
||||
enum CombineMode {
|
||||
CM_unspecified,
|
||||
@ -117,6 +118,7 @@ PUBLISHED:
|
||||
CS_constant,
|
||||
CS_primary_color,
|
||||
CS_previous,
|
||||
CS_constant_color_scale,
|
||||
};
|
||||
enum CombineOperand {
|
||||
CO_unspecified,
|
||||
@ -192,6 +194,16 @@ PUBLISHED:
|
||||
INLINE bool has_uv_name() const;
|
||||
INLINE const string &get_uv_name() const;
|
||||
|
||||
INLINE void set_rgb_scale(int rgb_scale);
|
||||
INLINE void clear_rgb_scale();
|
||||
INLINE bool has_rgb_scale() const;
|
||||
INLINE int get_rgb_scale() const;
|
||||
|
||||
INLINE void set_alpha_scale(int alpha_scale);
|
||||
INLINE void clear_alpha_scale();
|
||||
INLINE bool has_alpha_scale() const;
|
||||
INLINE int get_alpha_scale() const;
|
||||
|
||||
INLINE void set_transform(const LMatrix3d &transform);
|
||||
INLINE void clear_transform();
|
||||
INLINE bool has_transform() const;
|
||||
@ -240,6 +252,8 @@ private:
|
||||
F_has_uv_name = 0x0020,
|
||||
F_has_priority = 0x0040,
|
||||
F_has_color = 0x0080,
|
||||
F_has_rgb_scale = 0x0100,
|
||||
F_has_alpha_scale = 0x0200,
|
||||
};
|
||||
|
||||
Format _format;
|
||||
@ -252,6 +266,8 @@ private:
|
||||
int _priority;
|
||||
Colorf _color;
|
||||
string _uv_name;
|
||||
int _rgb_scale;
|
||||
int _alpha_scale;
|
||||
int _flags;
|
||||
LMatrix3d _transform;
|
||||
Filename _alpha_filename;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -543,6 +543,22 @@ texture_body:
|
||||
} else if (cmp_nocase_uh(name, "uv_name") == 0) {
|
||||
texture->set_uv_name(strval);
|
||||
|
||||
} else if (cmp_nocase_uh(name, "rgb_scale") == 0) {
|
||||
int int_value = (int)value;
|
||||
if (int_value != 1 && int_value != 2 && int_value != 4) {
|
||||
eggyyerror("Invalid rgb-scale value " + strval);
|
||||
} else {
|
||||
texture->set_rgb_scale(int_value);
|
||||
}
|
||||
|
||||
} else if (cmp_nocase_uh(name, "alpha_scale") == 0) {
|
||||
int int_value = (int)value;
|
||||
if (int_value != 1 && int_value != 2 && int_value != 4) {
|
||||
eggyyerror("Invalid alpha-scale value " + strval);
|
||||
} else {
|
||||
texture->set_alpha_scale(int_value);
|
||||
}
|
||||
|
||||
} else if (cmp_nocase_uh(name, "alpha") == 0) {
|
||||
EggRenderMode::AlphaMode a = EggRenderMode::string_alpha_mode(strval);
|
||||
if (a == EggRenderMode::AM_unspecified) {
|
||||
|
@ -1188,6 +1188,10 @@ make_texture_stage(const EggTexture *egg_tex) {
|
||||
case EggTexture::ET_add:
|
||||
stage->set_mode(TextureStage::M_add);
|
||||
break;
|
||||
|
||||
case EggTexture::ET_blend_color_scale:
|
||||
stage->set_mode(TextureStage::M_blend_color_scale);
|
||||
break;
|
||||
|
||||
case EggTexture::ET_unspecified:
|
||||
break;
|
||||
@ -1268,6 +1272,14 @@ make_texture_stage(const EggTexture *egg_tex) {
|
||||
stage->set_texcoord_name(name);
|
||||
}
|
||||
|
||||
if (egg_tex->has_rgb_scale()) {
|
||||
stage->set_rgb_scale(egg_tex->get_rgb_scale());
|
||||
}
|
||||
|
||||
if (egg_tex->has_alpha_scale()) {
|
||||
stage->set_alpha_scale(egg_tex->get_alpha_scale());
|
||||
}
|
||||
|
||||
stage->set_sort(egg_tex->get_multitexture_sort() * 10);
|
||||
|
||||
if (egg_tex->has_priority()) {
|
||||
@ -3047,6 +3059,9 @@ get_combine_source(const EggTexture *egg_tex,
|
||||
|
||||
case EggTexture::CS_previous:
|
||||
return TextureStage::CS_previous;
|
||||
|
||||
case EggTexture::CS_constant_color_scale:
|
||||
return TextureStage::CS_constant_color_scale;
|
||||
};
|
||||
|
||||
return TextureStage::CS_undefined;
|
||||
|
@ -171,6 +171,7 @@ enable_multisample_alpha_mask(bool val) {
|
||||
INLINE void CLP(GraphicsStateGuardian)::
|
||||
enable_line_smooth(bool val) {
|
||||
if (_line_smooth_enabled != val) {
|
||||
_blend_mode_stale = true;
|
||||
_line_smooth_enabled = val;
|
||||
if (val) {
|
||||
GLP(Enable)(GL_LINE_SMOOTH);
|
||||
@ -188,6 +189,7 @@ enable_line_smooth(bool val) {
|
||||
INLINE void CLP(GraphicsStateGuardian)::
|
||||
enable_point_smooth(bool val) {
|
||||
if (_point_smooth_enabled != val) {
|
||||
_blend_mode_stale = true;
|
||||
_point_smooth_enabled = val;
|
||||
if (val) {
|
||||
GLP(Enable)(GL_POINT_SMOOTH);
|
||||
@ -228,7 +230,10 @@ setup_antialias_line() {
|
||||
// have multisample available.
|
||||
enable_multisample_antialias(false);
|
||||
enable_line_smooth(true);
|
||||
set_blend_mode();
|
||||
|
||||
if (_blend_mode_stale) {
|
||||
set_blend_mode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,7 +251,10 @@ setup_antialias_point() {
|
||||
// have multisample available.
|
||||
enable_multisample_antialias(false);
|
||||
enable_point_smooth(true);
|
||||
set_blend_mode();
|
||||
|
||||
if (_blend_mode_stale) {
|
||||
set_blend_mode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,13 +284,18 @@ setup_antialias_polygon() {
|
||||
default:
|
||||
// For polygons, multisample is best if it's available, otherwise
|
||||
// polygon smoothing will do.
|
||||
enable_line_smooth(false);
|
||||
enable_point_smooth(false);
|
||||
if (_supports_multisample) {
|
||||
enable_multisample_antialias(true);
|
||||
} else {
|
||||
enable_polygon_smooth(true);
|
||||
}
|
||||
}
|
||||
set_blend_mode();
|
||||
|
||||
if (_blend_mode_stale) {
|
||||
set_blend_mode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -483,7 +496,7 @@ get_clip_plane_id(int index) const {
|
||||
INLINE void CLP(GraphicsStateGuardian)::
|
||||
issue_scene_graph_color() {
|
||||
if (_scene_graph_color_stale) {
|
||||
issue_transformed_color(_scene_graph_color);
|
||||
issue_scaled_color(_scene_graph_color);
|
||||
_scene_graph_color_stale = false;
|
||||
}
|
||||
}
|
||||
|
@ -114,11 +114,11 @@ issue_color_gl(const Geom *geom, Geom::ColorIterator &citerator,
|
||||
}
|
||||
|
||||
static void
|
||||
issue_transformed_color_gl(const Geom *geom, Geom::ColorIterator &citerator,
|
||||
issue_scaled_color_gl(const Geom *geom, Geom::ColorIterator &citerator,
|
||||
GraphicsStateGuardianBase *gsg) {
|
||||
const CLP(GraphicsStateGuardian) *glgsg = DCAST(CLP(GraphicsStateGuardian), gsg);
|
||||
const Colorf &color = geom->get_next_color(citerator);
|
||||
glgsg->issue_transformed_color(color);
|
||||
glgsg->issue_scaled_color(color);
|
||||
}
|
||||
|
||||
// The following noop functions are assigned to the corresponding
|
||||
@ -784,10 +784,10 @@ draw_point(GeomPoint *geom, GeomContext *gc) {
|
||||
|
||||
GeomIssuer::IssueColor *issue_color;
|
||||
|
||||
if (_color_transform_enabled == 0) {
|
||||
if (_color_blend_involves_color_scale || !_color_scale_enabled) {
|
||||
issue_color = issue_color_gl;
|
||||
} else {
|
||||
issue_color = issue_transformed_color_gl;
|
||||
issue_color = issue_scaled_color_gl;
|
||||
}
|
||||
|
||||
GeomIssuer issuer(geom, this,
|
||||
@ -854,10 +854,10 @@ draw_line(GeomLine *geom, GeomContext *gc) {
|
||||
|
||||
GeomIssuer::IssueColor *issue_color;
|
||||
|
||||
if (_color_transform_enabled == 0) {
|
||||
if (_color_blend_involves_color_scale || !_color_scale_enabled) {
|
||||
issue_color = issue_color_gl;
|
||||
} else {
|
||||
issue_color = issue_transformed_color_gl;
|
||||
issue_color = issue_scaled_color_gl;
|
||||
}
|
||||
|
||||
GeomIssuer issuer(geom, this,
|
||||
@ -938,10 +938,10 @@ draw_linestrip(GeomLinestrip *geom, GeomContext *gc) {
|
||||
|
||||
GeomIssuer::IssueColor *issue_color;
|
||||
|
||||
if (_color_transform_enabled == 0) {
|
||||
if (_color_blend_involves_color_scale || !_color_scale_enabled) {
|
||||
issue_color = issue_color_gl;
|
||||
} else {
|
||||
issue_color = issue_transformed_color_gl;
|
||||
issue_color = issue_scaled_color_gl;
|
||||
}
|
||||
|
||||
GeomIssuer issuer(geom, this,
|
||||
@ -1320,10 +1320,10 @@ draw_polygon(GeomPolygon *geom, GeomContext *gc) {
|
||||
|
||||
GeomIssuer::IssueColor *issue_color;
|
||||
|
||||
if (_color_transform_enabled == 0) {
|
||||
if (_color_blend_involves_color_scale || !_color_scale_enabled) {
|
||||
issue_color = issue_color_gl;
|
||||
} else {
|
||||
issue_color = issue_transformed_color_gl;
|
||||
issue_color = issue_scaled_color_gl;
|
||||
}
|
||||
|
||||
GeomIssuer issuer(geom, this,
|
||||
@ -1408,10 +1408,10 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
|
||||
|
||||
GeomIssuer::IssueColor *issue_color;
|
||||
|
||||
if (_color_transform_enabled == 0) {
|
||||
if (_color_blend_involves_color_scale || !_color_scale_enabled) {
|
||||
issue_color = issue_color_gl;
|
||||
} else {
|
||||
issue_color = issue_transformed_color_gl;
|
||||
issue_color = issue_scaled_color_gl;
|
||||
}
|
||||
|
||||
GeomIssuer issuer(geom, this,
|
||||
@ -1494,10 +1494,10 @@ draw_quad(GeomQuad *geom, GeomContext *gc) {
|
||||
|
||||
GeomIssuer::IssueColor *issue_color;
|
||||
|
||||
if (_color_transform_enabled == 0) {
|
||||
if (_color_blend_involves_color_scale || !_color_scale_enabled) {
|
||||
issue_color = issue_color_gl;
|
||||
} else {
|
||||
issue_color = issue_transformed_color_gl;
|
||||
issue_color = issue_scaled_color_gl;
|
||||
}
|
||||
|
||||
GeomIssuer issuer(geom, this,
|
||||
@ -1584,10 +1584,10 @@ draw_tristrip(GeomTristrip *geom, GeomContext *gc) {
|
||||
|
||||
GeomIssuer::IssueColor *issue_color;
|
||||
|
||||
if (_color_transform_enabled == 0) {
|
||||
if (_color_blend_involves_color_scale || !_color_scale_enabled) {
|
||||
issue_color = issue_color_gl;
|
||||
} else {
|
||||
issue_color = issue_transformed_color_gl;
|
||||
issue_color = issue_scaled_color_gl;
|
||||
}
|
||||
|
||||
GeomIssuer issuer(geom, this,
|
||||
@ -1692,10 +1692,10 @@ draw_trifan(GeomTrifan *geom, GeomContext *gc) {
|
||||
|
||||
GeomIssuer::IssueColor *issue_color;
|
||||
|
||||
if (_color_transform_enabled == 0) {
|
||||
if (_color_blend_involves_color_scale || !_color_scale_enabled) {
|
||||
issue_color = issue_color_gl;
|
||||
} else {
|
||||
issue_color = issue_transformed_color_gl;
|
||||
issue_color = issue_scaled_color_gl;
|
||||
}
|
||||
|
||||
GeomIssuer issuer(geom, this,
|
||||
@ -1797,10 +1797,10 @@ draw_sphere(GeomSphere *geom, GeomContext *gc) {
|
||||
|
||||
GeomIssuer::IssueColor *issue_color;
|
||||
|
||||
if (_color_transform_enabled == 0) {
|
||||
if (_color_blend_involves_color_scale || !_color_scale_enabled) {
|
||||
issue_color = issue_color_gl;
|
||||
} else {
|
||||
issue_color = issue_transformed_color_gl;
|
||||
issue_color = issue_scaled_color_gl;
|
||||
}
|
||||
|
||||
GeomIssuer issuer(geom, this,
|
||||
@ -2387,128 +2387,6 @@ issue_tex_gen(const TexGenAttrib *attrib) {
|
||||
_needs_tex_gen = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CLP(GraphicsStateGuardian)::issue_texture
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void CLP(GraphicsStateGuardian)::
|
||||
issue_texture(const TextureAttrib *attrib) {
|
||||
DO_PSTATS_STUFF(_texture_state_pcollector.add_level(1));
|
||||
|
||||
CPT(TextureAttrib) new_texture = attrib->filter_to_max(_max_texture_stages);
|
||||
|
||||
int num_stages = new_texture->get_num_on_stages();
|
||||
int num_old_stages = _current_texture->get_num_on_stages();
|
||||
|
||||
nassertv(num_stages <= _max_texture_stages &&
|
||||
num_old_stages <= _max_texture_stages);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < num_stages; i++) {
|
||||
TextureStage *stage = new_texture->get_on_stage(i);
|
||||
Texture *texture = new_texture->get_on_texture(stage);
|
||||
nassertv(texture != (Texture *)NULL);
|
||||
|
||||
if (i >= num_old_stages ||
|
||||
stage != _current_texture->get_on_stage(i) ||
|
||||
texture != _current_texture->get_on_texture(stage)) {
|
||||
// Stage i has changed. Issue the texture on this stage.
|
||||
_glActiveTexture(GL_TEXTURE0 + i);
|
||||
|
||||
GLP(Enable)(GL_TEXTURE_2D);
|
||||
|
||||
TextureContext *tc = texture->prepare_now(_prepared_objects, this);
|
||||
apply_texture(tc);
|
||||
|
||||
GLint glmode = get_texture_apply_mode_type(stage->get_mode());
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, glmode);
|
||||
GLP(TexEnvfv)(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, stage->get_color().get_data());
|
||||
|
||||
if (stage->get_mode() == TextureStage::M_combine) {
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_COMBINE_RGB,
|
||||
get_texture_combine_type(stage->get_combine_rgb_mode()));
|
||||
|
||||
switch (stage->get_num_combine_rgb_operands()) {
|
||||
case 3:
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC2_RGB,
|
||||
get_texture_src_type(stage->get_combine_rgb_source2()));
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND2_RGB,
|
||||
get_texture_operand_type(stage->get_combine_rgb_operand2()));
|
||||
// fall through
|
||||
|
||||
case 2:
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC1_RGB,
|
||||
get_texture_src_type(stage->get_combine_rgb_source1()));
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND1_RGB,
|
||||
get_texture_operand_type(stage->get_combine_rgb_operand1()));
|
||||
// fall through
|
||||
|
||||
case 1:
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC0_RGB,
|
||||
get_texture_src_type(stage->get_combine_rgb_source0()));
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND0_RGB,
|
||||
get_texture_operand_type(stage->get_combine_rgb_operand0()));
|
||||
// fall through
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_COMBINE_ALPHA,
|
||||
get_texture_combine_type(stage->get_combine_alpha_mode()));
|
||||
|
||||
switch (stage->get_num_combine_alpha_operands()) {
|
||||
case 3:
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC2_ALPHA,
|
||||
get_texture_src_type(stage->get_combine_alpha_source2()));
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA,
|
||||
get_texture_operand_type(stage->get_combine_alpha_operand2()));
|
||||
// fall through
|
||||
|
||||
case 2:
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC1_ALPHA,
|
||||
get_texture_src_type(stage->get_combine_alpha_source1()));
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA,
|
||||
get_texture_operand_type(stage->get_combine_alpha_operand1()));
|
||||
// fall through
|
||||
|
||||
case 1:
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC0_ALPHA,
|
||||
get_texture_src_type(stage->get_combine_alpha_source0()));
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA,
|
||||
get_texture_operand_type(stage->get_combine_alpha_operand0()));
|
||||
// fall through
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GLP(MatrixMode)(GL_TEXTURE);
|
||||
if (_current_tex_mat->has_stage(stage)) {
|
||||
GLP(LoadMatrixf)(_current_tex_mat->get_mat(stage).get_data());
|
||||
} else {
|
||||
GLP(LoadIdentity)();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disable the texture stages that are no longer used.
|
||||
for (i = num_stages; i < num_old_stages; i++) {
|
||||
_glActiveTexture(GL_TEXTURE0 + i);
|
||||
GLP(Disable)(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
_current_texture = new_texture;
|
||||
|
||||
// Changing the set of texture stages will require us to reissue the
|
||||
// texgen and texmat attribs.
|
||||
_needs_tex_gen = true;
|
||||
_needs_tex_mat = true;
|
||||
|
||||
report_my_gl_errors();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CLP(GraphicsStateGuardian)::issue_material
|
||||
// Access: Public, Virtual
|
||||
@ -3976,6 +3854,7 @@ get_texture_apply_mode_type(TextureStage::Mode am) {
|
||||
case TextureStage::M_replace: return GL_REPLACE;
|
||||
case TextureStage::M_add: return GL_ADD;
|
||||
case TextureStage::M_combine: return GL_COMBINE;
|
||||
case TextureStage::M_blend_color_scale: return GL_BLEND;
|
||||
}
|
||||
|
||||
GLCAT.error()
|
||||
@ -4021,6 +3900,7 @@ get_texture_src_type(TextureStage::CombineSource cs) {
|
||||
case TextureStage::CS_constant: return GL_CONSTANT;
|
||||
case TextureStage::CS_primary_color: return GL_PRIMARY_COLOR;
|
||||
case TextureStage::CS_previous: return GL_PREVIOUS;
|
||||
case TextureStage::CS_constant_color_scale: return GL_CONSTANT;
|
||||
}
|
||||
|
||||
GLCAT.error()
|
||||
@ -4141,15 +4021,19 @@ get_blend_func(ColorBlendAttrib::Operand operand) {
|
||||
return GL_ONE_MINUS_DST_ALPHA;
|
||||
|
||||
case ColorBlendAttrib::O_constant_color:
|
||||
case ColorBlendAttrib::O_color_scale:
|
||||
return GL_CONSTANT_COLOR;
|
||||
|
||||
case ColorBlendAttrib::O_one_minus_constant_color:
|
||||
case ColorBlendAttrib::O_one_minus_color_scale:
|
||||
return GL_ONE_MINUS_CONSTANT_COLOR;
|
||||
|
||||
case ColorBlendAttrib::O_constant_alpha:
|
||||
case ColorBlendAttrib::O_alpha_scale:
|
||||
return GL_CONSTANT_ALPHA;
|
||||
|
||||
case ColorBlendAttrib::O_one_minus_constant_alpha:
|
||||
case ColorBlendAttrib::O_one_minus_alpha_scale:
|
||||
return GL_ONE_MINUS_CONSTANT_ALPHA;
|
||||
|
||||
case ColorBlendAttrib::O_incoming_color_saturate:
|
||||
@ -4211,18 +4095,18 @@ print_gfx_visual() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CLP(GraphicsStateGuardian)::issue_transformed_color
|
||||
// Function: CLP(GraphicsStateGuardian)::issue_scaled_color
|
||||
// Access: Public
|
||||
// Description: Transform the color by the current color matrix, and
|
||||
// calls the appropriate glColor function.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void CLP(GraphicsStateGuardian)::
|
||||
issue_transformed_color(const Colorf &color) const {
|
||||
issue_scaled_color(const Colorf &color) const {
|
||||
Colorf transformed
|
||||
((color[0] * _current_color_scale[0]) + _current_color_offset[0],
|
||||
(color[1] * _current_color_scale[1]) + _current_color_offset[1],
|
||||
(color[2] * _current_color_scale[2]) + _current_color_offset[2],
|
||||
(color[3] * _current_color_scale[3]) + _current_color_offset[3]);
|
||||
(color[0] * _current_color_scale[0],
|
||||
color[1] * _current_color_scale[1],
|
||||
color[2] * _current_color_scale[2],
|
||||
color[3] * _current_color_scale[3]);
|
||||
|
||||
GLP(Color4fv)(transformed.get_data());
|
||||
}
|
||||
@ -4462,8 +4346,16 @@ set_blend_mode() {
|
||||
_glBlendEquation(get_blend_equation_type(_color_blend_mode));
|
||||
GLP(BlendFunc)(get_blend_func(_color_blend->get_operand_a()),
|
||||
get_blend_func(_color_blend->get_operand_b()));
|
||||
Colorf c = _color_blend->get_color();
|
||||
_glBlendColor(c[0], c[1], c[2], c[3]);
|
||||
|
||||
if (_color_blend_involves_color_scale) {
|
||||
// Apply the current color scale to the blend mode.
|
||||
_glBlendColor(_current_color_scale[0], _current_color_scale[1],
|
||||
_current_color_scale[2], _current_color_scale[3]);
|
||||
|
||||
} else {
|
||||
Colorf c = _color_blend->get_color();
|
||||
_glBlendColor(c[0], c[1], c[2], c[3]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -4538,6 +4430,14 @@ set_blend_mode() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void CLP(GraphicsStateGuardian)::
|
||||
finish_modify_state() {
|
||||
GraphicsStateGuardian::finish_modify_state();
|
||||
|
||||
// Apply the texture, if it needs to be reapplied.
|
||||
if (_texture_stale) {
|
||||
_texture_stale = false;
|
||||
do_issue_texture();
|
||||
}
|
||||
|
||||
// Apply the texture matrix, if needed.
|
||||
if (_needs_tex_mat) {
|
||||
_needs_tex_mat = false;
|
||||
@ -4810,6 +4710,170 @@ do_auto_rescale_normal() {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CLP(GraphicsStateGuardian)::do_issue_texture
|
||||
// Access: Protected
|
||||
// Description: This is called by finish_modify_state() when the
|
||||
// texture state has changed.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void CLP(GraphicsStateGuardian)::
|
||||
do_issue_texture() {
|
||||
DO_PSTATS_STUFF(_texture_state_pcollector.add_level(1));
|
||||
|
||||
CPT(TextureAttrib) new_texture = _pending_texture->filter_to_max(_max_texture_stages);
|
||||
|
||||
int num_stages = new_texture->get_num_on_stages();
|
||||
int num_old_stages = _current_texture->get_num_on_stages();
|
||||
|
||||
nassertv(num_stages <= _max_texture_stages &&
|
||||
num_old_stages <= _max_texture_stages);
|
||||
|
||||
_texture_involves_color_scale = false;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < num_stages; i++) {
|
||||
TextureStage *stage = new_texture->get_on_stage(i);
|
||||
Texture *texture = new_texture->get_on_texture(stage);
|
||||
nassertv(texture != (Texture *)NULL);
|
||||
|
||||
if (i >= num_old_stages ||
|
||||
stage != _current_texture->get_on_stage(i) ||
|
||||
texture != _current_texture->get_on_texture(stage) ||
|
||||
stage->involves_color_scale()) {
|
||||
// Stage i has changed. Issue the texture on this stage.
|
||||
_glActiveTexture(GL_TEXTURE0 + i);
|
||||
|
||||
GLP(Enable)(GL_TEXTURE_2D);
|
||||
|
||||
TextureContext *tc = texture->prepare_now(_prepared_objects, this);
|
||||
apply_texture(tc);
|
||||
|
||||
if (stage->involves_color_scale() && _color_scale_enabled) {
|
||||
Colorf color = stage->get_color();
|
||||
color.set(color[0] * _current_color_scale[0],
|
||||
color[1] * _current_color_scale[1],
|
||||
color[2] * _current_color_scale[2],
|
||||
color[3] * _current_color_scale[3]);
|
||||
_texture_involves_color_scale = true;
|
||||
GLP(TexEnvfv)(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color.get_data());
|
||||
} else {
|
||||
GLP(TexEnvfv)(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, stage->get_color().get_data());
|
||||
}
|
||||
|
||||
if (stage->get_mode() == TextureStage::M_decal) {
|
||||
if (texture->_pbuffer != (PixelBuffer *)NULL &&
|
||||
texture->_pbuffer->get_num_components() < 3) {
|
||||
// Make a special case for 1- and 2-channel decal textures.
|
||||
// OpenGL does not define their use with GL_DECAL for some
|
||||
// reason, so implement them using the combiner instead.
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_RGB_SCALE, 1);
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1);
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE);
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC2_RGB, GL_TEXTURE);
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
|
||||
|
||||
} else {
|
||||
// Normal 3- and 4-channel decal textures.
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||
}
|
||||
|
||||
} else if (stage->get_mode() == TextureStage::M_combine) {
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_RGB_SCALE, stage->get_rgb_scale());
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_ALPHA_SCALE, stage->get_alpha_scale());
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_COMBINE_RGB,
|
||||
get_texture_combine_type(stage->get_combine_rgb_mode()));
|
||||
|
||||
switch (stage->get_num_combine_rgb_operands()) {
|
||||
case 3:
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC2_RGB,
|
||||
get_texture_src_type(stage->get_combine_rgb_source2()));
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND2_RGB,
|
||||
get_texture_operand_type(stage->get_combine_rgb_operand2()));
|
||||
// fall through
|
||||
|
||||
case 2:
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC1_RGB,
|
||||
get_texture_src_type(stage->get_combine_rgb_source1()));
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND1_RGB,
|
||||
get_texture_operand_type(stage->get_combine_rgb_operand1()));
|
||||
// fall through
|
||||
|
||||
case 1:
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC0_RGB,
|
||||
get_texture_src_type(stage->get_combine_rgb_source0()));
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND0_RGB,
|
||||
get_texture_operand_type(stage->get_combine_rgb_operand0()));
|
||||
// fall through
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_COMBINE_ALPHA,
|
||||
get_texture_combine_type(stage->get_combine_alpha_mode()));
|
||||
|
||||
switch (stage->get_num_combine_alpha_operands()) {
|
||||
case 3:
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC2_ALPHA,
|
||||
get_texture_src_type(stage->get_combine_alpha_source2()));
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA,
|
||||
get_texture_operand_type(stage->get_combine_alpha_operand2()));
|
||||
// fall through
|
||||
|
||||
case 2:
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC1_ALPHA,
|
||||
get_texture_src_type(stage->get_combine_alpha_source1()));
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA,
|
||||
get_texture_operand_type(stage->get_combine_alpha_operand1()));
|
||||
// fall through
|
||||
|
||||
case 1:
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_SRC0_ALPHA,
|
||||
get_texture_src_type(stage->get_combine_alpha_source0()));
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA,
|
||||
get_texture_operand_type(stage->get_combine_alpha_operand0()));
|
||||
// fall through
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
GLint glmode = get_texture_apply_mode_type(stage->get_mode());
|
||||
GLP(TexEnvi)(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, glmode);
|
||||
}
|
||||
|
||||
GLP(MatrixMode)(GL_TEXTURE);
|
||||
if (_current_tex_mat->has_stage(stage)) {
|
||||
GLP(LoadMatrixf)(_current_tex_mat->get_mat(stage).get_data());
|
||||
} else {
|
||||
GLP(LoadIdentity)();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disable the texture stages that are no longer used.
|
||||
for (i = num_stages; i < num_old_stages; i++) {
|
||||
_glActiveTexture(GL_TEXTURE0 + i);
|
||||
GLP(Disable)(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
_current_texture = new_texture;
|
||||
|
||||
// Changing the set of texture stages will require us to reissue the
|
||||
// texgen and texmat attribs.
|
||||
_needs_tex_gen = true;
|
||||
_needs_tex_mat = true;
|
||||
|
||||
report_my_gl_errors();
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CLP(GraphicsStateGuardian)::build_phony_mipmaps
|
||||
|
@ -112,7 +112,6 @@ public:
|
||||
|
||||
virtual void issue_transform(const TransformState *transform);
|
||||
virtual void issue_tex_matrix(const TexMatrixAttrib *attrib);
|
||||
virtual void issue_texture(const TextureAttrib *attrib);
|
||||
virtual void issue_material(const MaterialAttrib *attrib);
|
||||
virtual void issue_render_mode(const RenderModeAttrib *attrib);
|
||||
virtual void issue_antialias(const AntialiasAttrib *);
|
||||
@ -148,7 +147,7 @@ public:
|
||||
//enabled/disable GL State compared to what GL says it is
|
||||
void dump_state(void);
|
||||
|
||||
void issue_transformed_color(const Colorf &color) const;
|
||||
void issue_scaled_color(const Colorf &color) const;
|
||||
|
||||
INLINE static bool report_errors(int line, const char *source_file);
|
||||
INLINE void report_my_errors(int line, const char *source_file);
|
||||
@ -240,6 +239,7 @@ protected:
|
||||
static CPT(RenderState) get_untextured_state();
|
||||
|
||||
void do_auto_rescale_normal();
|
||||
void do_issue_texture();
|
||||
|
||||
#ifndef NDEBUG
|
||||
void build_phony_mipmaps(Texture *tex);
|
||||
@ -247,6 +247,12 @@ protected:
|
||||
void save_mipmap_images(Texture *tex);
|
||||
#endif
|
||||
|
||||
enum AutoAntialiasMode {
|
||||
AA_poly,
|
||||
AA_line,
|
||||
AA_point,
|
||||
};
|
||||
|
||||
enum MultisampleMode {
|
||||
MM_antialias = 0x0001,
|
||||
MM_alpha_one = 0x0002,
|
||||
|
@ -17,6 +17,16 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::Copy Constructor
|
||||
// Access: Published
|
||||
// Description: Initialize the texture stage from other
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE TextureStage::
|
||||
TextureStage(TextureStage ©) {
|
||||
(*this) = copy;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::get_name
|
||||
// Access: Published
|
||||
@ -118,37 +128,6 @@ operator < (const TextureStage &other) const {
|
||||
return (_sort < other._sort);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::opertor =
|
||||
// Access: Published
|
||||
// Description: just copy the members of other to this
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE TextureStage &TextureStage::
|
||||
operator = (const TextureStage &other) {
|
||||
_name = other._name;
|
||||
_sort = other._sort;
|
||||
_priority = other._priority;
|
||||
_texcoord_name = other._texcoord_name;
|
||||
_mode = other._mode;
|
||||
_color = other._color;
|
||||
_combine_rgb_mode = other._combine_rgb_mode;
|
||||
_combine_rgb_source0 = other._combine_rgb_source0;
|
||||
_combine_rgb_operand0 = other._combine_rgb_operand0;
|
||||
_combine_rgb_source1 = other._combine_rgb_source1;
|
||||
_combine_rgb_operand1 = other._combine_rgb_operand1;
|
||||
_combine_rgb_source2 = other._combine_rgb_source2;
|
||||
_combine_rgb_operand2 = other._combine_rgb_operand2;
|
||||
_combine_alpha_mode = other._combine_alpha_mode;
|
||||
_combine_alpha_source0 = other._combine_alpha_source0;
|
||||
_combine_alpha_operand0 = _combine_alpha_operand0;
|
||||
_combine_alpha_source1 = other._combine_alpha_source1;
|
||||
_combine_alpha_operand1 = other._combine_alpha_operand1;
|
||||
_combine_alpha_source2 = other._combine_alpha_source2;
|
||||
_combine_alpha_operand2 = other._combine_alpha_operand2;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::set_texcoord_name
|
||||
// Access: Published
|
||||
@ -196,6 +175,7 @@ set_mode(TextureStage::Mode mode) {
|
||||
_num_combine_rgb_operands = 0;
|
||||
_num_combine_alpha_operands = 0;
|
||||
}
|
||||
set_involves_color_scale();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -228,6 +208,57 @@ get_color() const {
|
||||
return _color;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::set_rgb_scale
|
||||
// Access: Published
|
||||
// Description: Sets an additional factor that will scale all three
|
||||
// r, g, b components after the texture has been
|
||||
// applied. This is used only when the mode is
|
||||
// CM_combine.
|
||||
//
|
||||
// The only legal values are 1, 2, or 4.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void TextureStage::
|
||||
set_rgb_scale(int rgb_scale) {
|
||||
nassertv(rgb_scale == 1 || rgb_scale == 2 || rgb_scale == 4);
|
||||
_rgb_scale = rgb_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::get_rgb_scale
|
||||
// Access: Published
|
||||
// Description: See set_rgb_scale().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int TextureStage::
|
||||
get_rgb_scale() const {
|
||||
return _rgb_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::set_alpha_scale
|
||||
// Access: Published
|
||||
// Description: Sets an additional factor that will scale the
|
||||
// alpha component after the texture has been applied.
|
||||
// This is used only when the mode is CM_combine.
|
||||
//
|
||||
// The only legal values are 1, 2, or 4.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void TextureStage::
|
||||
set_alpha_scale(int alpha_scale) {
|
||||
nassertv(alpha_scale == 1 || alpha_scale == 2 || alpha_scale == 4);
|
||||
_alpha_scale = alpha_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::get_alpha_scale
|
||||
// Access: Published
|
||||
// Description: See set_alpha_scale().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int TextureStage::
|
||||
get_alpha_scale() const {
|
||||
return _alpha_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::set_combine_rgb
|
||||
// Access: Published
|
||||
@ -249,6 +280,8 @@ set_combine_rgb(CombineMode mode,
|
||||
_combine_rgb_operand1 = CO_undefined;
|
||||
_combine_rgb_source2 = CS_undefined;
|
||||
_combine_rgb_operand2 = CO_undefined;
|
||||
|
||||
set_involves_color_scale();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -275,6 +308,8 @@ set_combine_rgb(CombineMode mode,
|
||||
_combine_rgb_operand1 = operand1;
|
||||
_combine_rgb_source2 = CS_undefined;
|
||||
_combine_rgb_operand2 = CO_undefined;
|
||||
|
||||
set_involves_color_scale();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -302,6 +337,8 @@ set_combine_rgb(CombineMode mode,
|
||||
_combine_rgb_operand1 = operand1;
|
||||
_combine_rgb_source2 = source2;
|
||||
_combine_rgb_operand2 = operand2;
|
||||
|
||||
set_involves_color_scale();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -407,6 +444,8 @@ set_combine_alpha(CombineMode mode,
|
||||
_combine_alpha_operand1 = CO_undefined;
|
||||
_combine_alpha_source2 = CS_undefined;
|
||||
_combine_alpha_operand2 = CO_undefined;
|
||||
|
||||
set_involves_color_scale();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -433,6 +472,8 @@ set_combine_alpha(CombineMode mode,
|
||||
_combine_alpha_operand1 = operand1;
|
||||
_combine_alpha_source2 = CS_undefined;
|
||||
_combine_alpha_operand2 = CO_undefined;
|
||||
|
||||
set_involves_color_scale();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -460,6 +501,8 @@ set_combine_alpha(CombineMode mode,
|
||||
_combine_alpha_operand1 = operand1;
|
||||
_combine_alpha_source2 = source2;
|
||||
_combine_alpha_operand2 = operand2;
|
||||
|
||||
set_involves_color_scale();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -544,6 +587,18 @@ get_combine_alpha_operand2() const {
|
||||
return _combine_alpha_operand2;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::involves_color_scale
|
||||
// Access: Published
|
||||
// Description: Returns true if the TextureStage is affected by the
|
||||
// setting of the current ColorScaleAttrib, false
|
||||
// otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool TextureStage::
|
||||
involves_color_scale() const {
|
||||
return _involves_color_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::get_default
|
||||
// Access: Published, Static
|
||||
@ -574,6 +629,23 @@ get_sort_seq() {
|
||||
return _sort_seq;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::set_involves_color_scale
|
||||
// Access: Private
|
||||
// Description: Updates _involves_color_scale appropriately.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void TextureStage::
|
||||
set_involves_color_scale() {
|
||||
_involves_color_scale = (_mode == M_blend_color_scale ||
|
||||
(_mode == M_combine &&
|
||||
(_combine_rgb_source0 == CS_constant_color_scale ||
|
||||
_combine_rgb_source1 == CS_constant_color_scale ||
|
||||
_combine_rgb_source2 == CS_constant_color_scale ||
|
||||
_combine_alpha_source0 == CS_constant_color_scale ||
|
||||
_combine_alpha_source1 == CS_constant_color_scale ||
|
||||
_combine_alpha_source2 == CS_constant_color_scale)));
|
||||
}
|
||||
|
||||
INLINE ostream &
|
||||
operator << (ostream &out, const TextureStage &ts) {
|
||||
ts.output(out);
|
||||
|
@ -37,6 +37,8 @@ TextureStage(const string &name) {
|
||||
_texcoord_name = TexCoordName::get_default();
|
||||
_mode = M_modulate;
|
||||
_color.set(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
_rgb_scale = 1;
|
||||
_alpha_scale = 1;
|
||||
_combine_rgb_mode = CM_undefined;
|
||||
_num_combine_rgb_operands = 0;
|
||||
_combine_rgb_source0 = CS_undefined;
|
||||
@ -53,36 +55,42 @@ TextureStage(const string &name) {
|
||||
_combine_alpha_operand1 = CO_undefined;
|
||||
_combine_alpha_source2 = CS_undefined;
|
||||
_combine_alpha_operand2 = CO_undefined;
|
||||
|
||||
_involves_color_scale = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TextureStage::Constructor
|
||||
// Function: TextureStage::operator =
|
||||
// Access: Published
|
||||
// Description: Initialize the texture stage from other
|
||||
// Description: just copy the members of other to this
|
||||
////////////////////////////////////////////////////////////////////
|
||||
TextureStage::
|
||||
TextureStage(TextureStage *copy) {
|
||||
_name = copy->_name;
|
||||
_sort = copy->_sort;
|
||||
_priority = copy->_priority;
|
||||
_texcoord_name = copy->_texcoord_name;
|
||||
_mode = copy->_mode;
|
||||
_color = copy->_color;
|
||||
_combine_rgb_mode = copy->_combine_rgb_mode;
|
||||
_combine_rgb_source0 = copy->_combine_rgb_source0;
|
||||
_combine_rgb_operand0 = copy->_combine_rgb_operand0;
|
||||
_combine_rgb_source1 = copy->_combine_rgb_source1;
|
||||
_combine_rgb_operand1 = copy->_combine_rgb_operand1;
|
||||
_combine_rgb_source2 = copy->_combine_rgb_source2;
|
||||
_combine_rgb_operand2 = copy->_combine_rgb_operand2;
|
||||
_combine_alpha_mode = copy->_combine_alpha_mode;
|
||||
_combine_alpha_source0 = copy->_combine_alpha_source0;
|
||||
_combine_alpha_operand0 = _combine_alpha_operand0;
|
||||
_combine_alpha_source1 = copy->_combine_alpha_source1;
|
||||
_combine_alpha_operand1 = copy->_combine_alpha_operand1;
|
||||
_combine_alpha_source2 = copy->_combine_alpha_source2;
|
||||
_combine_alpha_operand2 = copy->_combine_alpha_operand2;
|
||||
void TextureStage::
|
||||
operator = (const TextureStage &other) {
|
||||
_name = other._name;
|
||||
_sort = other._sort;
|
||||
_priority = other._priority;
|
||||
_texcoord_name = other._texcoord_name;
|
||||
_mode = other._mode;
|
||||
_color = other._color;
|
||||
_rgb_scale = other._rgb_scale;
|
||||
_alpha_scale = other._alpha_scale;
|
||||
|
||||
_combine_rgb_mode = other._combine_rgb_mode;
|
||||
_combine_rgb_source0 = other._combine_rgb_source0;
|
||||
_combine_rgb_operand0 = other._combine_rgb_operand0;
|
||||
_combine_rgb_source1 = other._combine_rgb_source1;
|
||||
_combine_rgb_operand1 = other._combine_rgb_operand1;
|
||||
_combine_rgb_source2 = other._combine_rgb_source2;
|
||||
_combine_rgb_operand2 = other._combine_rgb_operand2;
|
||||
_combine_alpha_mode = other._combine_alpha_mode;
|
||||
_combine_alpha_source0 = other._combine_alpha_source0;
|
||||
_combine_alpha_operand0 = _combine_alpha_operand0;
|
||||
_combine_alpha_source1 = other._combine_alpha_source1;
|
||||
_combine_alpha_operand1 = other._combine_alpha_operand1;
|
||||
_combine_alpha_source2 = other._combine_alpha_source2;
|
||||
_combine_alpha_operand2 = other._combine_alpha_operand2;
|
||||
|
||||
_involves_color_scale = other._involves_color_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -103,7 +111,8 @@ void TextureStage::
|
||||
write(ostream &out) const {
|
||||
out << "TextureStage " << get_name() << ", sort = " << get_sort() << ", priority = " << get_priority() << "\n"
|
||||
<< " texcoords = " << get_texcoord_name()->get_name()
|
||||
<< ", mode = " << get_mode() << ", color = " << get_color() << "\n";
|
||||
<< ", mode = " << get_mode() << ", color = " << get_color()
|
||||
<< ", scale = " << get_rgb_scale() << ", " << get_alpha_scale() << "\n";
|
||||
|
||||
if (get_mode() == M_combine) {
|
||||
out << " RGB combine mode = " << get_combine_rgb_mode() << "\n";
|
||||
@ -269,6 +278,14 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
|
||||
_mode = (TextureStage::Mode) scan.get_uint8();
|
||||
_color.read_datagram(scan);
|
||||
|
||||
if (manager->get_file_minor_ver() >= 16) {
|
||||
_rgb_scale = scan.get_uint8();
|
||||
_alpha_scale = scan.get_uint8();
|
||||
} else {
|
||||
_rgb_scale = 1;
|
||||
_alpha_scale = 1;
|
||||
}
|
||||
|
||||
_combine_rgb_mode = (TextureStage::CombineMode) scan.get_uint8();
|
||||
_num_combine_rgb_operands = scan.get_uint8();
|
||||
@ -287,6 +304,8 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
_combine_alpha_operand1 = (TextureStage::CombineOperand) scan.get_uint8();
|
||||
_combine_alpha_source2 = (TextureStage::CombineSource) scan.get_uint8();
|
||||
_combine_alpha_operand2 = (TextureStage::CombineOperand) scan.get_uint8();
|
||||
|
||||
set_involves_color_scale();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -322,10 +341,12 @@ write_datagram(BamWriter *manager, Datagram &me) {
|
||||
me.add_int32(_sort);
|
||||
me.add_int32(_priority);
|
||||
|
||||
manager->write_pointer(me,_texcoord_name);
|
||||
manager->write_pointer(me, _texcoord_name);
|
||||
|
||||
me.add_uint8(_mode);
|
||||
_color.write_datagram(me);
|
||||
me.add_uint8(_rgb_scale);
|
||||
me.add_uint8(_alpha_scale);
|
||||
|
||||
me.add_uint8(_combine_rgb_mode);
|
||||
me.add_uint8(_num_combine_rgb_operands);
|
||||
@ -367,6 +388,9 @@ operator << (ostream &out, TextureStage::Mode mode) {
|
||||
|
||||
case TextureStage::M_combine:
|
||||
return out << "combine";
|
||||
|
||||
case TextureStage::M_blend_color_scale:
|
||||
return out << "blend_color_scale";
|
||||
}
|
||||
|
||||
return out << "**invalid Mode(" << (int)mode << ")**";
|
||||
@ -423,6 +447,9 @@ operator << (ostream &out, TextureStage::CombineSource cs) {
|
||||
|
||||
case TextureStage::CS_previous:
|
||||
return out << "previous";
|
||||
|
||||
case TextureStage::CS_constant_color_scale:
|
||||
return out << "constant_color_scale";
|
||||
}
|
||||
|
||||
return out << "**invalid CombineSource(" << (int)cs << ")**";
|
||||
|
@ -42,7 +42,9 @@ class FactoryParams;
|
||||
class EXPCL_PANDA TextureStage : public TypedWritableReferenceCount {
|
||||
PUBLISHED:
|
||||
TextureStage(const string &name);
|
||||
TextureStage(TextureStage *copy);
|
||||
INLINE TextureStage(TextureStage ©);
|
||||
void operator = (const TextureStage ©);
|
||||
|
||||
virtual ~TextureStage();
|
||||
|
||||
enum Mode {
|
||||
@ -52,6 +54,7 @@ PUBLISHED:
|
||||
M_replace,
|
||||
M_add,
|
||||
M_combine,
|
||||
M_blend_color_scale,
|
||||
};
|
||||
|
||||
enum CombineMode {
|
||||
@ -75,6 +78,7 @@ PUBLISHED:
|
||||
CS_constant,
|
||||
CS_primary_color,
|
||||
CS_previous,
|
||||
CS_constant_color_scale,
|
||||
};
|
||||
|
||||
enum CombineOperand {
|
||||
@ -95,7 +99,6 @@ PUBLISHED:
|
||||
INLINE int get_priority() const;
|
||||
|
||||
INLINE bool operator < (const TextureStage &other) const;
|
||||
INLINE TextureStage &operator = (const TextureStage ©);
|
||||
|
||||
INLINE void set_texcoord_name(const TexCoordName *name);
|
||||
INLINE void set_texcoord_name(const string &texcoord_name);
|
||||
@ -107,6 +110,12 @@ PUBLISHED:
|
||||
INLINE void set_color(const Colorf &color);
|
||||
INLINE Colorf get_color() const;
|
||||
|
||||
INLINE void set_rgb_scale(int rgb_scale);
|
||||
INLINE int get_rgb_scale() const;
|
||||
|
||||
INLINE void set_alpha_scale(int alpha_scale);
|
||||
INLINE int get_alpha_scale() const;
|
||||
|
||||
INLINE void set_combine_rgb(CombineMode mode,
|
||||
CombineSource source0, CombineOperand operand0);
|
||||
INLINE void set_combine_rgb(CombineMode mode,
|
||||
@ -143,6 +152,8 @@ PUBLISHED:
|
||||
INLINE CombineSource get_combine_alpha_source2() const;
|
||||
INLINE CombineOperand get_combine_alpha_operand2() const;
|
||||
|
||||
INLINE bool involves_color_scale() const;
|
||||
|
||||
void write(ostream &out) const;
|
||||
void output(ostream &out) const;
|
||||
|
||||
@ -150,6 +161,8 @@ PUBLISHED:
|
||||
INLINE static UpdateSeq get_sort_seq();
|
||||
|
||||
private:
|
||||
INLINE void set_involves_color_scale();
|
||||
|
||||
static int get_expected_num_combine_operands(CombineMode cm);
|
||||
static bool operand_valid_for_rgb(CombineOperand co);
|
||||
static bool operand_valid_for_alpha(CombineOperand co);
|
||||
@ -160,6 +173,9 @@ private:
|
||||
CPT(TexCoordName) _texcoord_name;
|
||||
Mode _mode;
|
||||
Colorf _color;
|
||||
int _rgb_scale;
|
||||
int _alpha_scale;
|
||||
bool _involves_color_scale;
|
||||
|
||||
CombineMode _combine_rgb_mode;
|
||||
int _num_combine_rgb_operands;
|
||||
|
@ -741,6 +741,14 @@ make_texture_layer(const NodePath &render,
|
||||
(ColorBlendAttrib::M_add, ColorBlendAttrib::O_fbuffer_color,
|
||||
ColorBlendAttrib::O_zero);
|
||||
break;
|
||||
|
||||
case TextureStage::M_blend_color_scale:
|
||||
// TODO: make a distinction between this and M_blend.
|
||||
cba = ColorBlendAttrib::make
|
||||
(ColorBlendAttrib::M_add, ColorBlendAttrib::O_constant_color,
|
||||
ColorBlendAttrib::O_one_minus_incoming_color,
|
||||
stage_info._stage->get_color());
|
||||
break;
|
||||
}
|
||||
|
||||
NodePath geom;
|
||||
|
@ -28,7 +28,9 @@ ColorBlendAttrib() :
|
||||
_mode(M_none),
|
||||
_a(O_one),
|
||||
_b(O_one),
|
||||
_color(Colorf::zero())
|
||||
_color(Colorf::zero()),
|
||||
_involves_constant_color(false),
|
||||
_involves_color_scale(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -45,7 +47,9 @@ ColorBlendAttrib(ColorBlendAttrib::Mode mode,
|
||||
_mode(mode),
|
||||
_a(a),
|
||||
_b(b),
|
||||
_color(color)
|
||||
_color(color),
|
||||
_involves_constant_color(involves_constant_color(a) || involves_constant_color(b)),
|
||||
_involves_color_scale(involves_color_scale(a) || involves_color_scale(b))
|
||||
{
|
||||
}
|
||||
|
||||
@ -89,6 +93,28 @@ get_color() const {
|
||||
return _color;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ColorBlendAttrib::involves_constant_color
|
||||
// Access: Published
|
||||
// Description: Returns true if the this attrib uses the
|
||||
// constant color, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ColorBlendAttrib::
|
||||
involves_constant_color() const {
|
||||
return _involves_constant_color;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ColorBlendAttrib::involves_color_scale
|
||||
// Access: Published
|
||||
// Description: Returns true if the this attrib uses the
|
||||
// color scale attrib, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ColorBlendAttrib::
|
||||
involves_color_scale() const {
|
||||
return _involves_color_scale;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ColorBlendAttrib::involves_constant_color
|
||||
// Access: Published, Static
|
||||
@ -96,7 +122,7 @@ get_color() const {
|
||||
// constant color, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ColorBlendAttrib::
|
||||
involves_constant_color(Operand operand) {
|
||||
involves_constant_color(ColorBlendAttrib::Operand operand) {
|
||||
switch (operand) {
|
||||
case O_constant_color:
|
||||
case O_one_minus_constant_color:
|
||||
@ -108,3 +134,23 @@ involves_constant_color(Operand operand) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ColorBlendAttrib::involves_color_scale
|
||||
// Access: Published, Static
|
||||
// Description: Returns true if the indicated operand uses the
|
||||
// color scale attrib, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ColorBlendAttrib::
|
||||
involves_color_scale(ColorBlendAttrib::Operand operand) {
|
||||
switch (operand) {
|
||||
case O_color_scale:
|
||||
case O_one_minus_color_scale:
|
||||
case O_alpha_scale:
|
||||
case O_one_minus_alpha_scale:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -94,8 +94,7 @@ output(ostream &out) const {
|
||||
if (get_mode() != M_none) {
|
||||
out << "(" << get_operand_a()
|
||||
<< "," << get_operand_b();
|
||||
if (involves_constant_color(get_operand_a()) ||
|
||||
involves_constant_color(get_operand_b())) {
|
||||
if (involves_constant_color()) {
|
||||
out << "," << get_color();
|
||||
}
|
||||
out << ")";
|
||||
@ -215,6 +214,9 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
_a = (Operand)scan.get_uint8();
|
||||
_b = (Operand)scan.get_uint8();
|
||||
_color.read_datagram(scan);
|
||||
|
||||
_involves_constant_color = involves_constant_color(_a) || involves_constant_color(_b);
|
||||
_involves_color_scale = involves_color_scale(_a) || involves_color_scale(_b);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -297,6 +299,18 @@ operator << (ostream &out, ColorBlendAttrib::Operand operand) {
|
||||
|
||||
case ColorBlendAttrib::O_incoming_color_saturate:
|
||||
return out << "ics";
|
||||
|
||||
case ColorBlendAttrib::O_color_scale:
|
||||
return out << "cs";
|
||||
|
||||
case ColorBlendAttrib::O_one_minus_color_scale:
|
||||
return out << "1-cs";
|
||||
|
||||
case ColorBlendAttrib::O_alpha_scale:
|
||||
return out << "as";
|
||||
|
||||
case ColorBlendAttrib::O_one_minus_alpha_scale:
|
||||
return out << "1-as";
|
||||
}
|
||||
|
||||
return out << "**invalid ColorBlendAttrib::Operand(" << (int)operand << ")**";
|
||||
|
@ -58,6 +58,17 @@ PUBLISHED:
|
||||
O_constant_alpha,
|
||||
O_one_minus_constant_alpha,
|
||||
O_incoming_color_saturate, // valid only for operand a
|
||||
|
||||
// If you set either of the operands to any of the below, the
|
||||
// blend color is taken from the current ColorScaleAttrib. This
|
||||
// also inhibits the normal behavior of the ColorScaleAttrib; it
|
||||
// no longer directly scales the vertex colors, on the assumption
|
||||
// that you will instead take care of the scale here, in the blend
|
||||
// mode.
|
||||
O_color_scale,
|
||||
O_one_minus_color_scale,
|
||||
O_alpha_scale,
|
||||
O_one_minus_alpha_scale,
|
||||
};
|
||||
|
||||
private:
|
||||
@ -76,7 +87,11 @@ PUBLISHED:
|
||||
INLINE Operand get_operand_b() const;
|
||||
INLINE Colorf get_color() const;
|
||||
|
||||
INLINE bool involves_constant_color() const;
|
||||
INLINE bool involves_color_scale() const;
|
||||
|
||||
INLINE static bool involves_constant_color(Operand operand);
|
||||
INLINE static bool involves_color_scale(Operand operand);
|
||||
|
||||
public:
|
||||
virtual void issue(GraphicsStateGuardianBase *gsg) const;
|
||||
@ -90,6 +105,8 @@ private:
|
||||
Mode _mode;
|
||||
Operand _a, _b;
|
||||
Colorf _color;
|
||||
bool _involves_constant_color;
|
||||
bool _involves_color_scale;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory();
|
||||
|
@ -68,8 +68,8 @@ PGSliderBar::
|
||||
PGSliderBar::
|
||||
PGSliderBar(const PGSliderBar ©) :
|
||||
PGItem(copy),
|
||||
_range(copy._range),
|
||||
_value(copy._value),
|
||||
_range(copy._range),
|
||||
// _slider(copy._slider),
|
||||
_left(copy._left),
|
||||
_right(copy._right)
|
||||
@ -238,7 +238,7 @@ drag(const MouseWatcherParameter ¶m) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PGSliderBar::
|
||||
update() {
|
||||
int state = get_state();
|
||||
// int state = get_state();
|
||||
|
||||
// need left and right button input if they exist
|
||||
if (!_slider_only) {
|
||||
|
@ -34,7 +34,7 @@ static const unsigned short _bam_major_ver = 4;
|
||||
// Bumped to major version 3 on 12/8/00 to change float64's to float32's.
|
||||
// Bumped to major version 4 on 4/10/02 to store new scene graph.
|
||||
|
||||
static const unsigned short _bam_minor_ver = 15;
|
||||
static const unsigned short _bam_minor_ver = 16;
|
||||
// Bumped to minor version 1 on 4/10/03 to add CullFaceAttrib::reverse.
|
||||
// Bumped to minor version 1 on 4/10/03 to add CullFaceAttrib::reverse.
|
||||
// Bumped to minor version 2 on 4/12/03 to add num_components to texture.
|
||||
@ -51,6 +51,7 @@ static const unsigned short _bam_minor_ver = 15;
|
||||
// Bumped to minor version 13 on 09/24/04 to store actual LODNode switch distances instead of squares.
|
||||
// Bumped to minor version 14 on 11/18/04 to differentiate old_hpr from new_hpr in compressed anim channels.
|
||||
// Bumped to minor version 15 on 1/16/05 to remove width from GeomLine, etc.
|
||||
// Bumped to minor version 16 on 2/24/05 to add TextureStage::rgb_scale, etc.
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1046,6 +1046,10 @@ do_transmit_data(const DataNodeTransmit &input, DataNodeTransmit &output) {
|
||||
case ButtonEvent::T_resume_down:
|
||||
// Ignore this, since the button wasn't pressed just now.
|
||||
break;
|
||||
|
||||
case ButtonEvent::T_move:
|
||||
// This is handled below.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user