这段是纹理渲染,真机上会莫名其妙多出来一个文字,用sprite每个字设置单个字的纹理是正常的,就是打到一张图上会有花屏
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
ccGLBindTexture2D(user_texture()->getName());
for ( size_t i = 0; i < m_dirty_slots.size(); i++ )
{
GlyphSlot* slot = m_dirty_slots*;
glTexSubImage2D(GL_TEXTURE_2D, 0,
slot->padding_rect.origin_x, slot->padding_rect.origin_y,
slot->bitmap->real_width(), slot->bitmap->real_height(),
GL_RGBA, GL_UNSIGNED_BYTE, slot->bitmap->get_buffer()
);
slot->bitmap->release();
slot->bitmap = NULL;
}
m_dirty_slots.clear();
```
这段是quads的配置
if ( !m_dirty )
{
return;
}
m_dirty = false;
if ( m_pTextureAtlas->getCapacity() < getQuadsToDraw() )
{
m_pTextureAtlas->resizeCapacity( getQuadsToDraw() );
}
ccV3F_C4B_T2F_Quad quad;
CCTexture2D *texture = m_pTextureAtlas->getTexture();
float textureWide = (float) texture->getPixelsWide();
float textureHigh = (float) texture->getPixelsHigh();
int i = 0;
float pos = 0;
float height = 0;
float width = 0;
for(i=0;itexture->user_texture();
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
float left = slot->padding_rect.origin_x/textureWide;
float right = left + slot->padding_rect.width/textureWide;
float top = slot->padding_rect.origin_y/textureHigh;
float bottom = top + slot->padding_rect.height/textureHigh;
#else
float left = slot->padding_rect.origin_x;
float right = left + slot->padding_rect.width;
float top = slot->padding_rect.origin_y;
float bottom = top + slot->padding_rect.height;
#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
height =slot->padding_rect.height;
width =slot->padding_rect.width;
quad.tl.texCoords.u = left;
quad.tl.texCoords.v = top;
quad.tr.texCoords.u = right;
quad.tr.texCoords.v = top;
quad.bl.texCoords.u = left;
quad.bl.texCoords.v = bottom;
quad.br.texCoords.u = right;
quad.br.texCoords.v = bottom;
quad.bl.vertices.x = i*slot->padding_rect.width;
quad.bl.vertices.y = 0;
quad.bl.vertices.z = 0.0f;
quad.br.vertices.x = (i+1)*slot->padding_rect.width;
quad.br.vertices.y = 0;
quad.br.vertices.z = 0.0f;
quad.tl.vertices.x = i*slot->padding_rect.width;
quad.tl.vertices.y = slot->padding_rect.height;
quad.tl.vertices.z = 0.0f;
quad.tr.vertices.x = (i+1)*slot->padding_rect.width;
quad.tr.vertices.y = slot->padding_rect.height;
quad.tr.vertices.z = 0.0f;
ccColor4B c = { m_displayedColor.r, m_displayedColor.g, m_displayedColor.b, m_displayedOpacity };
quad.tl.colors = c;
quad.tr.colors = c;
quad.bl.colors = c;
quad.br.colors = c;
m_pTextureAtlas->updateQuad(&quad, i);
}
setContentSize(CCSize(m_slots.size()* width,height));
```
**
