mirror of https://github.com/axmolengine/axmol.git
added winrt and wp8 support for EVENT_RENDERER_RECREATED
This commit is contained in:
parent
9bf15d424f
commit
a5b1faa379
|
@ -279,7 +279,7 @@ GLProgramState::GLProgramState()
|
|||
, _vertexAttribsFlags(0)
|
||||
, _glprogram(nullptr)
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
/** listen the event that renderer was recreated on Android/WP8 */
|
||||
CCLOG("create rendererRecreatedListener for GLProgramState");
|
||||
_backToForegroundlistener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { _uniformAttributeValueDirty = true; });
|
||||
|
@ -289,7 +289,7 @@ GLProgramState::GLProgramState()
|
|||
|
||||
GLProgramState::~GLProgramState()
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ protected:
|
|||
uint32_t _vertexAttribsFlags;
|
||||
GLProgram *_glprogram;
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
EventListenerCustom* _backToForegroundlistener;
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -92,7 +92,7 @@ MeshCommand::MeshCommand()
|
|||
, _lightMask(-1)
|
||||
{
|
||||
_type = RenderCommand::Type::MESH_COMMAND;
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
// listen the event that renderer was recreated on Android/WP8
|
||||
_rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(MeshCommand::listenRendererRecreated, this));
|
||||
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_rendererRecreatedListener, -1);
|
||||
|
@ -154,7 +154,7 @@ void MeshCommand::setDisplayColor(const Vec4& color)
|
|||
MeshCommand::~MeshCommand()
|
||||
{
|
||||
releaseVAO();
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
Director::getInstance()->getEventDispatcher()->removeEventListener(_rendererRecreatedListener);
|
||||
#endif
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ void MeshCommand::resetLightUniformValues()
|
|||
s_spotLightUniformRangeInverseValues.assign(maxSpotLight, 0.0f);
|
||||
}
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
void MeshCommand::listenRendererRecreated(EventCustom* event)
|
||||
{
|
||||
_vao = 0;
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
uint32_t getMaterialID() const { return _materialID; }
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
void listenRendererRecreated(EventCustom* event);
|
||||
#endif
|
||||
|
||||
|
@ -129,7 +129,7 @@ protected:
|
|||
|
||||
unsigned int _lightMask;
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
EventListenerCustom* _rendererRecreatedListener;
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -30,13 +30,13 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
bool VertexBuffer::_enableShadowCopy = true;
|
||||
#else
|
||||
bool VertexBuffer::_enableShadowCopy = false;
|
||||
#endif
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
bool IndexBuffer::_enableShadowCopy = true;
|
||||
#else
|
||||
bool IndexBuffer::_enableShadowCopy = false;
|
||||
|
@ -62,7 +62,7 @@ VertexBuffer::VertexBuffer()
|
|||
, _vertexNumber(0)
|
||||
{
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
auto callBack = [this](EventCustom* event)
|
||||
{
|
||||
this->recreateVBO();
|
||||
|
@ -80,7 +80,7 @@ VertexBuffer::~VertexBuffer()
|
|||
glDeleteBuffers(1, &_vbo);
|
||||
_vbo = 0;
|
||||
}
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
Director::getInstance()->getEventDispatcher()->removeEventListener(_recreateVBOEventListener);
|
||||
#endif
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ IndexBuffer::IndexBuffer()
|
|||
, _indexNumber(0)
|
||||
, _recreateVBOEventListener(nullptr)
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
auto callBack = [this](EventCustom* event)
|
||||
{
|
||||
this->recreateVBO();
|
||||
|
@ -206,7 +206,7 @@ IndexBuffer::~IndexBuffer()
|
|||
glDeleteBuffers(1, &_vbo);
|
||||
_vbo = 0;
|
||||
}
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
Director::getInstance()->getEventDispatcher()->removeEventListener(_recreateVBOEventListener);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue