mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
replace color_mat with color_scale
This commit is contained in:
parent
b7b7e9b9d7
commit
7eaea75673
@ -145,11 +145,9 @@ reset() {
|
|||||||
_normals_enabled = false;
|
_normals_enabled = false;
|
||||||
|
|
||||||
//Color and alpha transform variables
|
//Color and alpha transform variables
|
||||||
_color_transform_enabled = false;
|
_color_transform_enabled = 0;
|
||||||
_alpha_transform_enabled = false;
|
_current_color_offset.set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
_current_color_mat = LMatrix4f::ident_mat();
|
_current_color_scale.set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
_current_alpha_offset = 0;
|
|
||||||
_current_alpha_scale = 1;
|
|
||||||
|
|
||||||
_color_write_mode = ColorWriteAttrib::M_on;
|
_color_write_mode = ColorWriteAttrib::M_on;
|
||||||
_color_blend_mode = ColorBlendAttrib::M_none;
|
_color_blend_mode = ColorBlendAttrib::M_none;
|
||||||
@ -674,27 +672,12 @@ issue_transform(const TransformState *) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void GraphicsStateGuardian::
|
void GraphicsStateGuardian::
|
||||||
issue_color_scale(const ColorScaleAttrib *attrib) {
|
issue_color_scale(const ColorScaleAttrib *attrib) {
|
||||||
const LVecBase4f &scale = attrib->get_scale();
|
_current_color_scale = attrib->get_scale();
|
||||||
|
|
||||||
// For now, we set a full-featured matrix, even though we only use
|
if (_current_color_scale == LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f)) {
|
||||||
// the scale part of it. Soon we will strip this down.
|
_color_transform_enabled &= ~CT_scale;
|
||||||
LVecBase3f color_scale(scale[0], scale[1], scale[2]);
|
|
||||||
float alpha_scale = scale[3];
|
|
||||||
|
|
||||||
_current_color_mat = LMatrix4f::scale_mat(color_scale);
|
|
||||||
_current_alpha_offset= 0.0f;
|
|
||||||
_current_alpha_scale = alpha_scale;
|
|
||||||
|
|
||||||
if (color_scale == LVecBase3f(1.0f, 1.0f, 1.0f)) {
|
|
||||||
_color_transform_enabled = false;
|
|
||||||
} else {
|
} else {
|
||||||
_color_transform_enabled = true;
|
_color_transform_enabled |= CT_scale;
|
||||||
}
|
|
||||||
|
|
||||||
if (_current_alpha_scale == 1.0f) {
|
|
||||||
_alpha_transform_enabled = false;
|
|
||||||
} else {
|
|
||||||
_alpha_transform_enabled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_scene_graph_color_stale = _has_scene_graph_color;
|
_scene_graph_color_stale = _has_scene_graph_color;
|
||||||
|
@ -247,11 +247,13 @@ protected:
|
|||||||
bool _vertex_colors_enabled;
|
bool _vertex_colors_enabled;
|
||||||
bool _lighting_enabled;
|
bool _lighting_enabled;
|
||||||
|
|
||||||
bool _color_transform_enabled;
|
enum ColorTransform {
|
||||||
bool _alpha_transform_enabled;
|
CT_offset = 0x01,
|
||||||
LMatrix4f _current_color_mat;
|
CT_scale = 0x02,
|
||||||
float _current_alpha_offset;
|
};
|
||||||
float _current_alpha_scale;
|
int _color_transform_enabled; // Zero or more of ColorTransform bits, above.
|
||||||
|
LVecBase4f _current_color_offset;
|
||||||
|
LVecBase4f _current_color_scale;
|
||||||
|
|
||||||
ColorWriteAttrib::Mode _color_write_mode;
|
ColorWriteAttrib::Mode _color_write_mode;
|
||||||
ColorBlendAttrib::Mode _color_blend_mode;
|
ColorBlendAttrib::Mode _color_blend_mode;
|
||||||
|
@ -54,13 +54,6 @@
|
|||||||
|
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
|
|
||||||
// This is a temporary hack. The whole color_transform and
|
|
||||||
// alpha_transform system will soon be replaced with something a
|
|
||||||
// little smaller. Until then, we'll just define this macro to
|
|
||||||
// simulate the variable that used to be cached within the GSG.
|
|
||||||
#define _color_transform_required (_color_transform_enabled || _alpha_transform_enabled)
|
|
||||||
|
|
||||||
|
|
||||||
// print out simple drawprim stats every few secs
|
// print out simple drawprim stats every few secs
|
||||||
//#define COUNT_DRAWPRIMS
|
//#define COUNT_DRAWPRIMS
|
||||||
|
|
||||||
@ -515,14 +508,6 @@ dx_init( void) {
|
|||||||
#endif
|
#endif
|
||||||
_pCurTexContext = NULL;
|
_pCurTexContext = NULL;
|
||||||
|
|
||||||
//Color and alpha transform variables
|
|
||||||
_color_transform_enabled = false;
|
|
||||||
_alpha_transform_enabled = false;
|
|
||||||
|
|
||||||
_current_color_mat = LMatrix4f::ident_mat();
|
|
||||||
_current_alpha_offset = 0;
|
|
||||||
_current_alpha_scale = 1;
|
|
||||||
|
|
||||||
// none of these are implemented
|
// none of these are implemented
|
||||||
//_multisample_enabled = false;
|
//_multisample_enabled = false;
|
||||||
//_point_smooth_enabled = false;
|
//_point_smooth_enabled = false;
|
||||||
@ -1284,16 +1269,12 @@ typedef enum {
|
|||||||
|
|
||||||
INLINE void DXGraphicsStateGuardian::
|
INLINE void DXGraphicsStateGuardian::
|
||||||
transform_color(Colorf &InColor,D3DCOLOR &OutRGBAColor) {
|
transform_color(Colorf &InColor,D3DCOLOR &OutRGBAColor) {
|
||||||
// To be truly general, we really need a 5x5 matrix to transform a
|
Colorf transformed
|
||||||
// 4-component color. Rather than messing with that, we instead
|
((InColor[0] * _current_color_scale[0]) + _current_color_offset[0],
|
||||||
// treat the color as a 3-component RGB, which can be transformed by
|
(InColor[1] * _current_color_scale[1]) + _current_color_offset[1],
|
||||||
// the ordinary 4x4 matrix, and a separate alpha value, which can be
|
(InColor[2] * _current_color_scale[2]) + _current_color_offset[2],
|
||||||
// scaled and offsetted.
|
(InColor[3] * _current_color_scale[3]) + _current_color_offset[3]);
|
||||||
|
OutRGBAColor = Colorf_to_D3DCOLOR(InColor);
|
||||||
LPoint4f temp_pnt(InColor[0], InColor[1], InColor[2], 1.0f);
|
|
||||||
Colorf out_color = temp_pnt * _current_color_mat; // maybe expand this out for efficiency
|
|
||||||
out_color[3] = (InColor[3] * _current_alpha_scale) + _current_alpha_offset;
|
|
||||||
OutRGBAColor = Colorf_to_D3DCOLOR(out_color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -1318,7 +1299,7 @@ draw_prim_setup(const Geom *geom) {
|
|||||||
#define GET_NEXT_TEXCOORD() { p_texcoord = geom->get_next_texcoord(ti); }
|
#define GET_NEXT_TEXCOORD() { p_texcoord = geom->get_next_texcoord(ti); }
|
||||||
#define GET_NEXT_COLOR() { \
|
#define GET_NEXT_COLOR() { \
|
||||||
Colorf tempcolor = geom->get_next_color(ci); \
|
Colorf tempcolor = geom->get_next_color(ci); \
|
||||||
if(!_color_transform_required) { \
|
if(_color_transform_enabled == 0) { \
|
||||||
_curD3Dcolor = Colorf_to_D3DCOLOR(tempcolor); \
|
_curD3Dcolor = Colorf_to_D3DCOLOR(tempcolor); \
|
||||||
} else { \
|
} else { \
|
||||||
transform_color(tempcolor,_curD3Dcolor); \
|
transform_color(tempcolor,_curD3Dcolor); \
|
||||||
@ -1355,10 +1336,10 @@ draw_prim_setup(const Geom *geom) {
|
|||||||
if (_has_scene_graph_color) {
|
if (_has_scene_graph_color) {
|
||||||
if (_scene_graph_color_stale) {
|
if (_scene_graph_color_stale) {
|
||||||
// Compute the D3DCOLOR for the scene graph override color.
|
// Compute the D3DCOLOR for the scene graph override color.
|
||||||
if(_color_transform_required) {
|
if(_color_transform_enabled == 0) {
|
||||||
transform_color(_scene_graph_color, _scene_graph_color_D3DCOLOR);
|
|
||||||
} else {
|
|
||||||
_scene_graph_color_D3DCOLOR = Colorf_to_D3DCOLOR(_scene_graph_color);
|
_scene_graph_color_D3DCOLOR = Colorf_to_D3DCOLOR(_scene_graph_color);
|
||||||
|
} else {
|
||||||
|
transform_color(_scene_graph_color, _scene_graph_color_D3DCOLOR);
|
||||||
}
|
}
|
||||||
_scene_graph_color_stale = false;
|
_scene_graph_color_stale = false;
|
||||||
}
|
}
|
||||||
@ -1658,17 +1639,18 @@ draw_point(GeomPoint *geom, GeomContext *gc) {
|
|||||||
// BUGBUG: eventually this hack every-frame all-colors conversion needs
|
// BUGBUG: eventually this hack every-frame all-colors conversion needs
|
||||||
// to be done only once as part of a vertex buffer
|
// to be done only once as part of a vertex buffer
|
||||||
|
|
||||||
if(_color_transform_required) {
|
if(_color_transform_enabled == 0) {
|
||||||
for (int i=0;i<nPrims;i++) {
|
for (int i=0;i<nPrims;i++) {
|
||||||
D3DCOLOR RGBA_color;
|
|
||||||
transform_color(colors[i],RGBA_color);
|
|
||||||
add_DWORD_to_FVFBuf(RGBA_color);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
for (int i=0;i<nPrims;i++) {
|
|
||||||
Colorf out_color=colors[i];
|
Colorf out_color=colors[i];
|
||||||
add_DWORD_to_FVFBuf(Colorf_to_D3DCOLOR(out_color));
|
add_DWORD_to_FVFBuf(Colorf_to_D3DCOLOR(out_color));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (int i=0;i<nPrims;i++) {
|
||||||
|
D3DCOLOR RGBA_color;
|
||||||
|
transform_color(colors[i],RGBA_color);
|
||||||
|
add_DWORD_to_FVFBuf(RGBA_color);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_curFVFflags & D3DFVF_TEXCOUNT_MASK) {
|
if (_curFVFflags & D3DFVF_TEXCOUNT_MASK) {
|
||||||
@ -2591,7 +2573,7 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
|
|||||||
if (NeededShadeMode!=D3DSHADE_FLAT) {
|
if (NeededShadeMode!=D3DSHADE_FLAT) {
|
||||||
// but if lighting enabled, we need to color every vert since shading will be GOURAUD
|
// but if lighting enabled, we need to color every vert since shading will be GOURAUD
|
||||||
|
|
||||||
if(!_color_transform_required) {
|
if(_color_transform_enabled == 0) {
|
||||||
for (uint i=0;i<nPrims;i++,pInColor++,pOutColor+=dwVertsperPrim) {
|
for (uint i=0;i<nPrims;i++,pInColor++,pOutColor+=dwVertsperPrim) {
|
||||||
D3DCOLOR newcolr = Colorf_to_D3DCOLOR(*pInColor);
|
D3DCOLOR newcolr = Colorf_to_D3DCOLOR(*pInColor);
|
||||||
*pOutColor = newcolr;
|
*pOutColor = newcolr;
|
||||||
@ -2612,7 +2594,7 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
|
|||||||
// dont write 2nd,3rd colors in output buffer, these are not used in flat shading
|
// dont write 2nd,3rd colors in output buffer, these are not used in flat shading
|
||||||
// MAKE SURE ShadeMode never set to GOURAUD after this!
|
// MAKE SURE ShadeMode never set to GOURAUD after this!
|
||||||
|
|
||||||
if(!_color_transform_required) {
|
if(_color_transform_enabled == 0) {
|
||||||
for (uint i=0;i<nPrims;i++,pInColor++,pOutColor+=dwVertsperPrim) {
|
for (uint i=0;i<nPrims;i++,pInColor++,pOutColor+=dwVertsperPrim) {
|
||||||
*pOutColor = Colorf_to_D3DCOLOR(*pInColor);
|
*pOutColor = Colorf_to_D3DCOLOR(*pInColor);
|
||||||
}
|
}
|
||||||
@ -2628,7 +2610,7 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
|
|||||||
// want to do this conversion once in retained mode
|
// want to do this conversion once in retained mode
|
||||||
DWORD cNumColors=nPrims*dwVertsperPrim;
|
DWORD cNumColors=nPrims*dwVertsperPrim;
|
||||||
|
|
||||||
if(!_color_transform_required) {
|
if(_color_transform_enabled == 0) {
|
||||||
for (uint i=0;i<cNumColors;i++,pInColor++,pOutColor++) {
|
for (uint i=0;i<cNumColors;i++,pInColor++,pOutColor++) {
|
||||||
*pOutColor = Colorf_to_D3DCOLOR(*pInColor);
|
*pOutColor = Colorf_to_D3DCOLOR(*pInColor);
|
||||||
}
|
}
|
||||||
@ -2643,7 +2625,7 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
|
|||||||
#endif
|
#endif
|
||||||
// copy the one global color in, set stride to 0
|
// copy the one global color in, set stride to 0
|
||||||
|
|
||||||
if(!_color_transform_required) {
|
if(_color_transform_enabled == 0) {
|
||||||
if (bDoGlobalSceneGraphColor) {
|
if (bDoGlobalSceneGraphColor) {
|
||||||
Colorf colr = _scene_graph_color;
|
Colorf colr = _scene_graph_color;
|
||||||
*pConvertedColorArray = Colorf_to_D3DCOLOR(colr);
|
*pConvertedColorArray = Colorf_to_D3DCOLOR(colr);
|
||||||
@ -3025,7 +3007,7 @@ draw_multitri(Geom *geom, D3DPRIMITIVETYPE trilisttype) {
|
|||||||
if (ColorBinding==G_PER_VERTEX) {
|
if (ColorBinding==G_PER_VERTEX) {
|
||||||
NeededShadeMode = D3DSHADE_GOURAUD;
|
NeededShadeMode = D3DSHADE_GOURAUD;
|
||||||
|
|
||||||
if(!_color_transform_required) {
|
if(_color_transform_enabled == 0) {
|
||||||
for (uint i=0;i<cTotalVerts;i++,pInColor++,pOutColor++) {
|
for (uint i=0;i<cTotalVerts;i++,pInColor++,pOutColor++) {
|
||||||
*pOutColor = Colorf_to_D3DCOLOR(*pInColor);
|
*pOutColor = Colorf_to_D3DCOLOR(*pInColor);
|
||||||
}
|
}
|
||||||
@ -3041,7 +3023,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
|
// could save 2 clr writes per strip/fan in flat shade mode but not going to bother here
|
||||||
|
|
||||||
if(!_color_transform_required) {
|
if(_color_transform_enabled == 0) {
|
||||||
for (uint j=0;j<nPrims;j++,pInColor++) {
|
for (uint j=0;j<nPrims;j++,pInColor++) {
|
||||||
D3DCOLOR lastcolr = Colorf_to_D3DCOLOR(*pInColor);
|
D3DCOLOR lastcolr = Colorf_to_D3DCOLOR(*pInColor);
|
||||||
DWORD cStripLength=pLengthArr[j];
|
DWORD cStripLength=pLengthArr[j];
|
||||||
@ -3114,7 +3096,7 @@ draw_multitri(Geom *geom, D3DPRIMITIVETYPE trilisttype) {
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_color_transform_required) {
|
if(_color_transform_enabled == 0) {
|
||||||
COMPONENT_COLOR_COPY_LOOPS(COLOR_CONVERT_COPY_STMT);
|
COMPONENT_COLOR_COPY_LOOPS(COLOR_CONVERT_COPY_STMT);
|
||||||
} else {
|
} else {
|
||||||
COMPONENT_COLOR_COPY_LOOPS(COLOR_CONVERT_XFORM_STMT);
|
COMPONENT_COLOR_COPY_LOOPS(COLOR_CONVERT_XFORM_STMT);
|
||||||
@ -3125,7 +3107,7 @@ draw_multitri(Geom *geom, D3DPRIMITIVETYPE trilisttype) {
|
|||||||
#endif
|
#endif
|
||||||
// copy the one global color in, set stride to 0
|
// copy the one global color in, set stride to 0
|
||||||
|
|
||||||
if(!_color_transform_required) {
|
if(_color_transform_enabled == 0) {
|
||||||
if (bDoGlobalSceneGraphColor) {
|
if (bDoGlobalSceneGraphColor) {
|
||||||
Colorf colr = _scene_graph_color();
|
Colorf colr = _scene_graph_color();
|
||||||
*pConvertedColorArray = Colorf_to_D3DCOLOR(colr);
|
*pConvertedColorArray = Colorf_to_D3DCOLOR(colr);
|
||||||
|
@ -52,12 +52,6 @@
|
|||||||
#include "pStatCollector.h"
|
#include "pStatCollector.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This is a temporary hack. The whole color_transform and
|
|
||||||
// alpha_transform system will soon be replaced with something a
|
|
||||||
// little smaller. Until then, we'll just define this macro to
|
|
||||||
// simulate the variable that used to be cached within the GSG.
|
|
||||||
#define _color_transform_required (_color_transform_enabled || _alpha_transform_enabled)
|
|
||||||
|
|
||||||
// disable nameless struct 'warning'
|
// disable nameless struct 'warning'
|
||||||
#pragma warning (disable : 4201)
|
#pragma warning (disable : 4201)
|
||||||
|
|
||||||
@ -600,14 +594,6 @@ dx_init(HCURSOR hMouseCursor) {
|
|||||||
|
|
||||||
_pCurTexContext = NULL;
|
_pCurTexContext = NULL;
|
||||||
|
|
||||||
//Color and alpha transform variables
|
|
||||||
_color_transform_enabled = false;
|
|
||||||
_alpha_transform_enabled = false;
|
|
||||||
|
|
||||||
_current_color_mat = LMatrix4f::ident_mat();
|
|
||||||
_current_alpha_offset = 0.0f;
|
|
||||||
_current_alpha_scale = 1.0f;
|
|
||||||
|
|
||||||
_line_smooth_enabled = false;
|
_line_smooth_enabled = false;
|
||||||
scrn.pD3DDevice->SetRenderState(D3DRS_EDGEANTIALIAS, false);
|
scrn.pD3DDevice->SetRenderState(D3DRS_EDGEANTIALIAS, false);
|
||||||
|
|
||||||
@ -1407,16 +1393,12 @@ typedef enum {
|
|||||||
|
|
||||||
INLINE void DXGraphicsStateGuardian::
|
INLINE void DXGraphicsStateGuardian::
|
||||||
transform_color(Colorf &InColor,D3DCOLOR &OutRGBAColor) {
|
transform_color(Colorf &InColor,D3DCOLOR &OutRGBAColor) {
|
||||||
// To be truly general, we really need a 5x5 matrix to transform a
|
Colorf transformed
|
||||||
// 4-component color. Rather than messing with that, we instead
|
((InColor[0] * _current_color_scale[0]) + _current_color_offset[0],
|
||||||
// treat the color as a 3-component RGB, which can be transformed by
|
(InColor[1] * _current_color_scale[1]) + _current_color_offset[1],
|
||||||
// the ordinary 4x4 matrix, and a separate alpha value, which can be
|
(InColor[2] * _current_color_scale[2]) + _current_color_offset[2],
|
||||||
// scaled and offsetted.
|
(InColor[3] * _current_color_scale[3]) + _current_color_offset[3]);
|
||||||
|
OutRGBAColor = Colorf_to_D3DCOLOR(InColor);
|
||||||
LPoint4f temp_pnt(InColor[0], InColor[1], InColor[2], 1.0f);
|
|
||||||
Colorf out_color = temp_pnt * _current_color_mat; // maybe expand this out for efficiency
|
|
||||||
out_color[3] = (InColor[3] * _current_alpha_scale) + _current_alpha_offset;
|
|
||||||
OutRGBAColor = Colorf_to_D3DCOLOR(out_color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -1441,7 +1423,7 @@ draw_prim_setup(const Geom *geom) {
|
|||||||
#define GET_NEXT_TEXCOORD() { p_texcoord = geom->get_next_texcoord(ti); }
|
#define GET_NEXT_TEXCOORD() { p_texcoord = geom->get_next_texcoord(ti); }
|
||||||
#define GET_NEXT_COLOR() { \
|
#define GET_NEXT_COLOR() { \
|
||||||
Colorf tempcolor = geom->get_next_color(ci); \
|
Colorf tempcolor = geom->get_next_color(ci); \
|
||||||
if(!_color_transform_required) { \
|
if(_color_transform_enabled == 0) { \
|
||||||
_curD3Dcolor = Colorf_to_D3DCOLOR(tempcolor); \
|
_curD3Dcolor = Colorf_to_D3DCOLOR(tempcolor); \
|
||||||
} else { \
|
} else { \
|
||||||
transform_color(tempcolor,_curD3Dcolor); \
|
transform_color(tempcolor,_curD3Dcolor); \
|
||||||
@ -1478,10 +1460,10 @@ draw_prim_setup(const Geom *geom) {
|
|||||||
if (_has_scene_graph_color) {
|
if (_has_scene_graph_color) {
|
||||||
if (_scene_graph_color_stale) {
|
if (_scene_graph_color_stale) {
|
||||||
// Compute the D3DCOLOR for the scene graph override color.
|
// Compute the D3DCOLOR for the scene graph override color.
|
||||||
if(_color_transform_required) {
|
if(_color_transform_enabled == 0) {
|
||||||
transform_color(_scene_graph_color, _scene_graph_color_D3DCOLOR);
|
|
||||||
} else {
|
|
||||||
_scene_graph_color_D3DCOLOR = Colorf_to_D3DCOLOR(_scene_graph_color);
|
_scene_graph_color_D3DCOLOR = Colorf_to_D3DCOLOR(_scene_graph_color);
|
||||||
|
} else {
|
||||||
|
transform_color(_scene_graph_color, _scene_graph_color_D3DCOLOR);
|
||||||
}
|
}
|
||||||
_scene_graph_color_stale = false;
|
_scene_graph_color_stale = false;
|
||||||
}
|
}
|
||||||
|
@ -1000,43 +1000,12 @@ enable_polygon_offset(bool val) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: GLGraphicsStateGuardian::get_current_color_mat
|
|
||||||
// Access:
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE const LMatrix4f &GLGraphicsStateGuardian::
|
|
||||||
get_current_color_mat() const {
|
|
||||||
return _current_color_mat;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: GLGraphicsStateGuardian::get_current_alpha_offset
|
|
||||||
// Access:
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE const float &GLGraphicsStateGuardian::
|
|
||||||
get_current_alpha_offset() const {
|
|
||||||
return _current_alpha_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: GLGraphicsStateGuardian::get_current_alpha_scale
|
|
||||||
// Access:
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE const float &GLGraphicsStateGuardian::
|
|
||||||
get_current_alpha_scale() const {
|
|
||||||
return _current_alpha_scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GLGraphicsStateGuardian::get_light_id
|
// Function: GLGraphicsStateGuardian::get_light_id
|
||||||
// Access: Public
|
// Access: Public
|
||||||
// Description: Convert index to gl light id
|
// Description: Convert index to gl light id
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE GLenum GLGraphicsStateGuardian::get_light_id(int index) const
|
INLINE GLenum GLGraphicsStateGuardian::get_light_id(int index) const {
|
||||||
{
|
|
||||||
return GL_LIGHT0 + index;
|
return GL_LIGHT0 + index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1047,20 +1016,7 @@ INLINE GLenum GLGraphicsStateGuardian::get_light_id(int index) const
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE GLenum GLGraphicsStateGuardian::
|
INLINE GLenum GLGraphicsStateGuardian::
|
||||||
get_clip_plane_id(int index) const {
|
get_clip_plane_id(int index) const {
|
||||||
switch(index) {
|
return GL_CLIP_PLANE0 + index;
|
||||||
case 0: return GL_CLIP_PLANE0;
|
|
||||||
case 1: return GL_CLIP_PLANE1;
|
|
||||||
case 2: return GL_CLIP_PLANE2;
|
|
||||||
case 3: return GL_CLIP_PLANE3;
|
|
||||||
case 4: return GL_CLIP_PLANE4;
|
|
||||||
case 5: return GL_CLIP_PLANE5;
|
|
||||||
default:
|
|
||||||
glgsg_cat.error()
|
|
||||||
<< "get_clip_plane_id() - we don't currently support ids "
|
|
||||||
<< "> 5" << endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return GL_CLIP_PLANE0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -498,10 +498,9 @@ draw_point(GeomPoint *geom, GeomContext *) {
|
|||||||
|
|
||||||
GeomIssuer::IssueColor *issue_color;
|
GeomIssuer::IssueColor *issue_color;
|
||||||
|
|
||||||
if (!_color_transform_enabled && !_alpha_transform_enabled) {
|
if (_color_transform_enabled == 0) {
|
||||||
issue_color = issue_color_gl;
|
issue_color = issue_color_gl;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
issue_color = issue_transformed_color_gl;
|
issue_color = issue_transformed_color_gl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,10 +558,9 @@ draw_line(GeomLine *geom, GeomContext *) {
|
|||||||
|
|
||||||
GeomIssuer::IssueColor *issue_color;
|
GeomIssuer::IssueColor *issue_color;
|
||||||
|
|
||||||
if (!_color_transform_enabled && !_alpha_transform_enabled) {
|
if (_color_transform_enabled == 0) {
|
||||||
issue_color = issue_color_gl;
|
issue_color = issue_color_gl;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
issue_color = issue_transformed_color_gl;
|
issue_color = issue_transformed_color_gl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,10 +626,9 @@ draw_linestrip(GeomLinestrip *geom, GeomContext *) {
|
|||||||
|
|
||||||
GeomIssuer::IssueColor *issue_color;
|
GeomIssuer::IssueColor *issue_color;
|
||||||
|
|
||||||
if (!_color_transform_enabled && !_alpha_transform_enabled) {
|
if (_color_transform_enabled == 0) {
|
||||||
issue_color = issue_color_gl;
|
issue_color = issue_color_gl;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
issue_color = issue_transformed_color_gl;
|
issue_color = issue_transformed_color_gl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -990,10 +987,9 @@ draw_polygon(GeomPolygon *geom, GeomContext *) {
|
|||||||
|
|
||||||
GeomIssuer::IssueColor *issue_color;
|
GeomIssuer::IssueColor *issue_color;
|
||||||
|
|
||||||
if (!_color_transform_enabled && !_alpha_transform_enabled) {
|
if (_color_transform_enabled == 0) {
|
||||||
issue_color = issue_color_gl;
|
issue_color = issue_color_gl;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
issue_color = issue_transformed_color_gl;
|
issue_color = issue_transformed_color_gl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1071,10 +1067,9 @@ draw_tri(GeomTri *geom, GeomContext *) {
|
|||||||
|
|
||||||
GeomIssuer::IssueColor *issue_color;
|
GeomIssuer::IssueColor *issue_color;
|
||||||
|
|
||||||
if (!_color_transform_enabled && !_alpha_transform_enabled) {
|
if (_color_transform_enabled == 0) {
|
||||||
issue_color = issue_color_gl;
|
issue_color = issue_color_gl;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
issue_color = issue_transformed_color_gl;
|
issue_color = issue_transformed_color_gl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1150,10 +1145,9 @@ draw_quad(GeomQuad *geom, GeomContext *) {
|
|||||||
|
|
||||||
GeomIssuer::IssueColor *issue_color;
|
GeomIssuer::IssueColor *issue_color;
|
||||||
|
|
||||||
if (!_color_transform_enabled && !_alpha_transform_enabled) {
|
if (_color_transform_enabled == 0) {
|
||||||
issue_color = issue_color_gl;
|
issue_color = issue_color_gl;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
issue_color = issue_transformed_color_gl;
|
issue_color = issue_transformed_color_gl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1228,10 +1222,9 @@ draw_tristrip(GeomTristrip *geom, GeomContext *) {
|
|||||||
|
|
||||||
GeomIssuer::IssueColor *issue_color;
|
GeomIssuer::IssueColor *issue_color;
|
||||||
|
|
||||||
if (!_color_transform_enabled && !_alpha_transform_enabled) {
|
if (_color_transform_enabled == 0) {
|
||||||
issue_color = issue_color_gl;
|
issue_color = issue_color_gl;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
issue_color = issue_transformed_color_gl;
|
issue_color = issue_transformed_color_gl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1327,10 +1320,9 @@ draw_trifan(GeomTrifan *geom, GeomContext *) {
|
|||||||
|
|
||||||
GeomIssuer::IssueColor *issue_color;
|
GeomIssuer::IssueColor *issue_color;
|
||||||
|
|
||||||
if (!_color_transform_enabled && !_alpha_transform_enabled) {
|
if (_color_transform_enabled == 0) {
|
||||||
issue_color = issue_color_gl;
|
issue_color = issue_color_gl;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
issue_color = issue_transformed_color_gl;
|
issue_color = issue_transformed_color_gl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1424,10 +1416,9 @@ draw_sphere(GeomSphere *geom, GeomContext *) {
|
|||||||
|
|
||||||
GeomIssuer::IssueColor *issue_color;
|
GeomIssuer::IssueColor *issue_color;
|
||||||
|
|
||||||
if (!_color_transform_enabled && !_alpha_transform_enabled) {
|
if (_color_transform_enabled == 0) {
|
||||||
issue_color = issue_color_gl;
|
issue_color = issue_color_gl;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
issue_color = issue_transformed_color_gl;
|
issue_color = issue_transformed_color_gl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3361,22 +3352,12 @@ print_gfx_visual() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void GLGraphicsStateGuardian::
|
void GLGraphicsStateGuardian::
|
||||||
issue_transformed_color(const Colorf &color) const {
|
issue_transformed_color(const Colorf &color) const {
|
||||||
// To be truly general, we really need a 5x5 matrix to transform a
|
Colorf transformed
|
||||||
// 4-component color. Rather than messing with that, we instead
|
((color[0] * _current_color_scale[0]) + _current_color_offset[0],
|
||||||
// treat the color as a 3-component RGB, which can be transformed by
|
(color[1] * _current_color_scale[1]) + _current_color_offset[1],
|
||||||
// the ordinary 4x4 matrix, and a separate alpha value, which can be
|
(color[2] * _current_color_scale[2]) + _current_color_offset[2],
|
||||||
// scaled and offsetted.
|
(color[3] * _current_color_scale[3]) + _current_color_offset[3]);
|
||||||
LPoint3f temp(color[0], color[1], color[2]);
|
|
||||||
temp = temp * get_current_color_mat();
|
|
||||||
float alpha = (color[3] * get_current_alpha_scale()) +
|
|
||||||
get_current_alpha_offset();
|
|
||||||
|
|
||||||
Colorf transformed(temp[0], temp[1], temp[2], alpha);
|
|
||||||
|
|
||||||
// glgsg_cat.debug() << "Issuing color " << transformed << "\n";
|
|
||||||
// glgsg_cat.debug() << "\tTransformed by " << get_current_color_mat() << "\n";
|
|
||||||
// glgsg_cat.debug() << "\tAlpha Transformed by " << get_current_alpha_offset() << " "
|
|
||||||
// << get_current_alpha_scale() << "\n";
|
|
||||||
glColor4fv(transformed.get_data());
|
glColor4fv(transformed.get_data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,11 +144,6 @@ public:
|
|||||||
//enabled/disable GL State compared to what GL says it is
|
//enabled/disable GL State compared to what GL says it is
|
||||||
void dump_state(void);
|
void dump_state(void);
|
||||||
|
|
||||||
//Methods for extracting the current color and alpha transformations
|
|
||||||
INLINE const LMatrix4f &get_current_color_mat() const;
|
|
||||||
INLINE const float &get_current_alpha_offset() const;
|
|
||||||
INLINE const float &get_current_alpha_scale() const;
|
|
||||||
|
|
||||||
void issue_transformed_color(const Colorf &color) const;
|
void issue_transformed_color(const Colorf &color) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user