mirror of https://github.com/axmolengine/axmol.git
pass bits to invalidate
This commit is contained in:
parent
4278bf51b1
commit
a8cf72dc43
|
@ -37,25 +37,6 @@ NS_CC_BEGIN
|
|||
|
||||
RenderState::StateBlock* RenderState::StateBlock::_defaultState = nullptr;
|
||||
|
||||
// Render state override bits
|
||||
enum
|
||||
{
|
||||
RS_BLEND = (1 << 0),
|
||||
RS_BLEND_FUNC = (1 << 1),
|
||||
RS_CULL_FACE = (1 << 2),
|
||||
RS_DEPTH_TEST = (1 << 3),
|
||||
RS_DEPTH_WRITE = (1 << 4),
|
||||
RS_DEPTH_FUNC = (1 << 5),
|
||||
RS_CULL_FACE_SIDE = (1 << 6),
|
||||
RS_STENCIL_TEST = (1 << 7),
|
||||
RS_STENCIL_WRITE = (1 << 8),
|
||||
RS_STENCIL_FUNC = (1 << 9),
|
||||
RS_STENCIL_OP = (1 << 10),
|
||||
RS_FRONT_FACE = (1 << 11),
|
||||
|
||||
RS_ALL_ONES = 0xFFFFFFFF,
|
||||
};
|
||||
|
||||
|
||||
RenderState::RenderState()
|
||||
: _texture(nullptr)
|
||||
|
@ -731,11 +712,11 @@ uint32_t RenderState::StateBlock::getHash() const
|
|||
return 0x12345678;
|
||||
}
|
||||
|
||||
void RenderState::StateBlock::invalidate()
|
||||
void RenderState::StateBlock::invalidate(long stateBits)
|
||||
{
|
||||
CCASSERT(_defaultState, "_default state not created yet. Cannot be invalidated");
|
||||
|
||||
_defaultState->_bits = RS_ALL_ONES;
|
||||
_defaultState->_bits = stateBits;
|
||||
_defaultState->restore(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -349,6 +349,25 @@ public:
|
|||
uint32_t getHash() const;
|
||||
bool isDirty() const;
|
||||
|
||||
/** StateBlock bits to be used with invalidate */
|
||||
enum
|
||||
{
|
||||
RS_BLEND = (1 << 0),
|
||||
RS_BLEND_FUNC = (1 << 1),
|
||||
RS_CULL_FACE = (1 << 2),
|
||||
RS_DEPTH_TEST = (1 << 3),
|
||||
RS_DEPTH_WRITE = (1 << 4),
|
||||
RS_DEPTH_FUNC = (1 << 5),
|
||||
RS_CULL_FACE_SIDE = (1 << 6),
|
||||
RS_STENCIL_TEST = (1 << 7),
|
||||
RS_STENCIL_WRITE = (1 << 8),
|
||||
RS_STENCIL_FUNC = (1 << 9),
|
||||
RS_STENCIL_OP = (1 << 10),
|
||||
RS_FRONT_FACE = (1 << 11),
|
||||
|
||||
RS_ALL_ONES = 0xFFFFFFFF,
|
||||
};
|
||||
|
||||
/**
|
||||
* Invalidates the default StateBlock.
|
||||
*
|
||||
|
@ -357,7 +376,7 @@ public:
|
|||
* By doing that, the next time a StateBlock::restore() is called,
|
||||
* it will restore to the default value the default StateBlock.
|
||||
*/
|
||||
static void invalidate();
|
||||
static void invalidate(long stateBits);
|
||||
|
||||
static StateBlock* _defaultState;
|
||||
|
||||
|
|
|
@ -433,11 +433,19 @@ void Material_invalidate::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4
|
|||
|
||||
glFrontFace((GLenum)GL_CW);
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
//
|
||||
// glDisable(GL_BLEND);
|
||||
// CHECK_GL_ERROR_DEBUG();
|
||||
|
||||
RenderState::StateBlock::invalidate();
|
||||
glDisable(GL_BLEND);
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
|
||||
// a non-optimal way is to pass all bits, but that would be very inefficient
|
||||
// RenderState::StateBlock::invalidate(RenderState::StateBlock::RS_ALL_ONES);
|
||||
|
||||
RenderState::StateBlock::invalidate(RenderState::StateBlock::RS_DEPTH_TEST |
|
||||
RenderState::StateBlock::RS_DEPTH_WRITE |
|
||||
RenderState::StateBlock::RS_CULL_FACE |
|
||||
RenderState::StateBlock::RS_CULL_FACE_SIDE |
|
||||
RenderState::StateBlock::RS_FRONT_FACE |
|
||||
RenderState::StateBlock::RS_BLEND);
|
||||
};
|
||||
|
||||
renderer->addCommand(&_customCommand);
|
||||
|
|
Loading…
Reference in New Issue