From be966dbddb42c9cca224baf21c95ff021242dc46 Mon Sep 17 00:00:00 2001 From: yangws Date: Fri, 25 Mar 2011 13:50:57 +0800 Subject: [PATCH] fixed #430 Solved bug by replacing glColor4ub with glColor4f. --- cocos2dx/base_nodes/CCAtlasNode.cpp | 5 +++-- cocos2dx/label_nodes/CCLabelAtlas.cpp | 4 +++- cocos2dx/misc_nodes/CCRibbon.cpp | 4 +++- tests/tests/ChipmunkTest/drawSpace.cpp | 4 +++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index 02b5890646..c209399e74 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -110,8 +110,9 @@ void CCAtlasNode::draw() // Unneeded states: GL_COLOR_ARRAY glDisableClientState(GL_COLOR_ARRAY); - glColor4ub( m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity); - + // glColor4ub isn't implement on some android devices + // glColor4ub( m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity); + glColor4f(((GLfloat)m_tColor.r) / 255, ((GLfloat)m_tColor.g) / 255, ((GLfloat)m_tColor.b) / 255, ((GLfloat)m_cOpacity) / 255); bool newBlend = m_tBlendFunc.src != CC_BLEND_SRC || m_tBlendFunc.dst != CC_BLEND_DST; if(newBlend) { diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index c753568f87..70207a5a9a 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -149,7 +149,9 @@ namespace cocos2d{ // Unneeded states: GL_COLOR_ARRAY glDisableClientState(GL_COLOR_ARRAY); - glColor4ub( m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity); + // glColor4ub isn't implement on some android devices + // glColor4ub( m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity); + glColor4f(((GLfloat)m_tColor.r) / 255, ((GLfloat)m_tColor.g) / 255, ((GLfloat)m_tColor.b) / 255, ((GLfloat)m_cOpacity) / 255); bool newBlend = (m_tBlendFunc.src != CC_BLEND_SRC || m_tBlendFunc.dst != CC_BLEND_DST); if(newBlend) diff --git a/cocos2dx/misc_nodes/CCRibbon.cpp b/cocos2dx/misc_nodes/CCRibbon.cpp index 79be04a0df..c7eca83246 100644 --- a/cocos2dx/misc_nodes/CCRibbon.cpp +++ b/cocos2dx/misc_nodes/CCRibbon.cpp @@ -376,7 +376,9 @@ void CCRibbonSegment::draw(float curTime, float fadeTime, ccColor4B color) if (curTime == 0) { // no alpha over time, so just set the color - glColor4ub(r,g,b,a); + // glColor4ub isn't implement on some android devices + // glColor4ub(r,g,b,a); + glColor4f(((GLfloat)r) / 255, ((GLfloat)g) / 255, ((GLfloat)b) / 255, ((GLfloat)a) / 255); } else { diff --git a/tests/tests/ChipmunkTest/drawSpace.cpp b/tests/tests/ChipmunkTest/drawSpace.cpp index b5c5b4fe8a..d847cd1e93 100644 --- a/tests/tests/ChipmunkTest/drawSpace.cpp +++ b/tests/tests/ChipmunkTest/drawSpace.cpp @@ -77,7 +77,9 @@ glColor_from_pointer(void *ptr) g = (g*mult)/max + add; b = (b*mult)/max + add; - glColor4ub(r, g, b, 255); + // glColor4ub isn't implement on some android devices + // glColor4ub(r, g, b, 255); + glColor4f(((GLfloat)r) / 255, ((GLfloat)g) / 255, ((GLfloat)b) / 255, 1.0f); } static const GLfloat circleVAR[] = {