Projects > cpp > Issues > Bug #2359

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

Sprite will become white block when using CCControlSwitch

Bug #2359 [Closed]
zhangxm 2013-07-02 08:36 . Updated over 9 years ago

steps to reproduce
* run TestCpp
* ExtensionsTest > CCControlButtonTest> ControlSwitchTest

Will trigger OpenGL error on iOS, error code

Cocos2d: OpenGL error 0x0502 in /Users/minggo/SourceCode/cocos2d-x/cocos2dx/proj.ios/../sprite_nodes/CCSprite.cpp draw 591

But the real error caused in CCControlSwitch::draw().

dabingnn 2013-07-03 07:48

Node::setTexture will change the GLProgram in the Node, ControlSwitchSprite has a specified GLProgram, when call the function, make it use a wrong GLProgram to render.

dabingnn 2013-07-03 07:50
  • Status changed from New to In Progress
  • Assignee changed from dabingnn to dumganhar
dumganhar 2013-07-03 08:21

Yep, setShaderProgram should not be in Sprite::setTexture since setTexture is not related to shader.
Developer has responsibility to reset shaderprogram when texture is changed from NULL to non-NULL or from non-NULL to NULL.
Thanks for finding this issue. :)

dumganhar 2013-07-03 08:53
  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

Applied in changeset commit:39b8df3bb9f8801dc1010640faf2bf800c8cec5a.

code 2013-07-28 17:43

I use the 2.1.4 stable release and found the same error. i merged your changes/ your fix in my code. After that the test work and i do not get any opengl errors any more. But now i have problems to load my ccbi files. All my background layers are white.

code 2013-07-29 18:29

i fixed it this way ..

void CCSprite::setDisplayFrame(CCSpriteFrame *pNewFrame)
m_obUnflippedOffsetPositionFromCenter = pNewFrame~~>getOffset;
CCTexture2D *pNewTexture = pNewFrame~~>getTexture();
// update texture before updating texture rect
if (pNewTexture != m_pobTexture)
// 2.1.4 MOD
// shader program
if (pNewTexture)
// update rect
m_bRectRotated = pNewFrame~~>isRotated;
setTextureRect, m_bRectRotated, pNewFrame~~>getOriginalSize());

agenindonesia 2014-11-25 20:35 Agen Texas Poker Dan Domino Online Indonesia Terpercaya
OK, I’ve updated the announcement and added a link to zipball on google code. Thank you for reminding me.
Agen Indonesia | Agen Bola | Poker Indonesia

ionliga 2014-11-28 14:42

The optimization introduces a bug where the priority and Touch Mode will not get changed if the list is locked.
The most straight forward fix is to merge the pHandlersToAdd and pHandlersToRemove into a queue and process through all of them in the order they are received Agen Texas Poker dan Domino Online Indonesia Terpercaya | Agen Bola | Taruhan Bola | Agen Bola | Agen Judi Bola Online, Agen Judi Casino Online Indonesia Terpercaya | Jasa SEO

Atom PDF

Start date:2013-07-02
Due date:
% Done:


Target version:3.0-alpha0-pre