/// <summary> /// initializes a TextureAtlas with a previously initialized Texture2D object, and /// with an initial capacity for Quads. /// The TextureAtlas capacity can be increased in runtime. /// WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706) /// </summary> public bool initWithTexture(CCTexture2D texture, int capacity) { Debug.Assert(texture != null); m_uCapacity = capacity; m_uTotalQuads = 0; // retained in property this.m_pTexture = texture; // Re-initialization is not allowed Debug.Assert(m_pIndices == null && m_pIndices == null); m_pQuads = new ccV3F_C4B_T2F_Quad[m_uCapacity]; m_pIndices = new short[m_uCapacity * 6]; #if CC_USES_VBO // initial binding //glGenBuffers(2, &m_pBuffersVBO[0]); m_bDirty = true; #endif // CC_USES_VBO this.initIndices(); return(true); }
/// <summary> /// draws n quads from an index (offset). /// n + start can't be greater than the capacity of the atlas /// @since v1.0 /// </summary> public void drawNumberOfQuads(int n, int start) { if (n == start) { return; } if (this.m_pQuads == null || this.m_pQuads.Length < 1) { return; } CCApplication app = CCApplication.sharedApplication(); CCSize size = CCDirector.sharedDirector().getWinSize(); //app.basicEffect.World = app.worldMatrix *TransformUtils.CGAffineToMatrix( this.nodeToWorldTransform()); app.basicEffect.Texture = this.Texture.getTexture2D(); app.basicEffect.TextureEnabled = true; app.GraphicsDevice.BlendState = BlendState.AlphaBlend; app.basicEffect.VertexColorEnabled = true; List <VertexPositionColorTexture> vertices = new List <VertexPositionColorTexture>(); short[] indexes = new short[n * 6]; for (int i = start; i < start + n; i++) { ccV3F_C4B_T2F_Quad quad = this.m_pQuads[i]; if (quad != null) { vertices.AddRange(quad.getVertices(ccDirectorProjection.CCDirectorProjection3D).ToList()); indexes[i * 6 + 0] = (short)(i * 4 + 0); indexes[i * 6 + 1] = (short)(i * 4 + 1); indexes[i * 6 + 2] = (short)(i * 4 + 2); // inverted index. issue #179 indexes[i * 6 + 3] = (short)(i * 4 + 2); indexes[i * 6 + 4] = (short)(i * 4 + 1); indexes[i * 6 + 5] = (short)(i * 4 + 3); } } VertexDeclaration vertexDeclaration = new VertexDeclaration(new VertexElement[] { new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Color, 0), new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0) }); foreach (var pass in app.basicEffect.CurrentTechnique.Passes) { pass.Apply(); app.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColorTexture>( PrimitiveType.TriangleList, vertices.ToArray(), 0, vertices.Count, indexes, 0, vertices.Count / 2); } }
/// <summary> /// removes a quad at a given index number. /// The capacity remains the same, but the total number of quads to be drawn is reduced in 1 /// @since v0.7.2 /// </summary> public void removeQuadAtIndex(int index) { ccV3F_C4B_T2F_Quad[] temp = new ccV3F_C4B_T2F_Quad[m_uCapacity]; Array.Copy(m_pQuads, temp, index); Array.Copy(m_pQuads, index + 1, temp, index, m_uTotalQuads - index - 1); m_pQuads = temp; m_uTotalQuads--; }
public void insertChild(CCSprite pobSprite, int uIndex) { pobSprite.useBatchNode(this); pobSprite.atlasIndex = uIndex; pobSprite.dirty = true; if (m_pobTextureAtlas.TotalQuads == m_pobTextureAtlas.Capacity) { increaseAtlasCapacity(); } ccV3F_C4B_T2F_Quad quad = pobSprite.quad; m_pobTextureAtlas.insertQuad(quad, uIndex); m_pobDescendants.Insert(uIndex, pobSprite); // update indices uint i = 0; if (m_pobDescendants != null && m_pobDescendants.Count > 0) { for (int j = 0; j < m_pobDescendants.Count; j++) { CCObject pObject = m_pobDescendants[j]; CCSprite pChild = pObject as CCSprite; if (pChild != null) { if (i > uIndex) { pChild.atlasIndex = pChild.atlasIndex + 1; } ++i; } } } // add children recursively List <Node> pChildren = pobSprite.Children; if (pChildren != null && pChildren.Count > 0) { for (int j = 0; j < pChildren.Count; j++) { CCObject pObject = pChildren[j]; CCSprite pChild = pObject as CCSprite; if (pChild != null) { uIndex = atlasIndexForChild(pChild, pChild.ZOrder); insertChild(pChild, uIndex); } } } }
//CCLabelAtlas - Atlas generation public override void updateAtlasValues() { char[] s = m_sString.ToCharArray(); CCTexture2D texture = m_pTextureAtlas.Texture; float textureWide = (float)texture.PixelsWide; float textureHigh = (float)texture.PixelsHigh; for (int i = 0; i < m_sString.Length; i++) { ccV3F_C4B_T2F_Quad quad = new ccV3F_C4B_T2F_Quad(); char a = (char)(s[i] - m_cMapStartChar); float row = (float)(a % m_uItemsPerRow); float col = (float)(a / m_uItemsPerRow); #if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL // Issue #938. Don't use texStepX & texStepY float left = (2 * row * m_uItemWidth + 1) / (2 * textureWide); float right = left + (m_uItemWidth * 2 - 2) / (2 * textureWide); float top = (2 * col * m_uItemHeight + 1) / (2 * textureHigh); float bottom = top + (m_uItemHeight * 2 - 2) / (2 * textureHigh); #else float left = row * m_uItemWidth / textureWide; float right = left + m_uItemWidth / textureWide; float top = col * m_uItemHeight / textureHigh; float bottom = top + m_uItemHeight / textureHigh; #endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 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.tl.colors = quad.tr.colors = quad.bl.colors = quad.br.colors = new ccColor4B(this.m_tColor.r, this.m_tColor.g, this.m_tColor.b, this.m_cOpacity); quad.bl.vertices.x = (float)(i * m_uItemWidth); quad.bl.vertices.y = 0; quad.bl.vertices.z = 0.0f; quad.br.vertices.x = (float)(i * m_uItemWidth + m_uItemWidth); quad.br.vertices.y = 0; quad.br.vertices.z = 0.0f; quad.tl.vertices.x = (float)(i * m_uItemWidth); quad.tl.vertices.y = (float)(m_uItemHeight); quad.tl.vertices.z = 0.0f; quad.tr.vertices.x = (float)(i * m_uItemWidth + m_uItemWidth); quad.tr.vertices.y = (float)(m_uItemHeight); quad.tr.vertices.z = 0.0f; m_pTextureAtlas.updateQuad(quad, i); } }
/// <summary> /// updates a Quad (texture, vertex and color) at a certain index /// index must be between 0 and the atlas capacity - 1 /// @since v0.8 /// </summary> public void updateQuad(ccV3F_C4B_T2F_Quad quad, int index) { Debug.Assert(index >= 0 && index < m_uCapacity, "updateQuadWithTexture: Invalid index"); m_uTotalQuads = Math.Max(index + 1, m_uTotalQuads); m_pQuads[index] = quad; #if CC_USES_VBO m_bDirty = true; #endif }
public void removeQuadAtIndex(int index) { ccV3F_C4B_T2F_Quad[] ccV3FC4BT2FQuadArray = new ccV3F_C4B_T2F_Quad[this.m_uCapacity]; Array.Copy(this.m_pQuads, ccV3FC4BT2FQuadArray, index); Array.Copy(this.m_pQuads, index + 1, ccV3FC4BT2FQuadArray, index, this.m_uTotalQuads - index - 1); this.m_pQuads = ccV3FC4BT2FQuadArray; CCTextureAtlas mUTotalQuads = this; mUTotalQuads.m_uTotalQuads = mUTotalQuads.m_uTotalQuads - 1; }
public override void updateAtlasValues() { char[] charArray = this.m_sString.ToCharArray(); CCTexture2D texture = this.m_pTextureAtlas.Texture; float pixelsWide = (float)texture.PixelsWide; float pixelsHigh = (float)texture.PixelsHigh; for (int i = 0; i < this.m_sString.Length; i++) { ccV3F_C4B_T2F_Quad ccV3FC4BT2FQuad = new ccV3F_C4B_T2F_Quad(); char mCMapStartChar = (char)(charArray[i] - this.m_cMapStartChar); float mUItemsPerRow = (float)(mCMapStartChar % (char)this.m_uItemsPerRow); float single = (float)(mCMapStartChar / (char)this.m_uItemsPerRow); float mUItemWidth = mUItemsPerRow * (float)this.m_uItemWidth / pixelsWide; float mUItemWidth1 = mUItemWidth + (float)this.m_uItemWidth / pixelsWide; float mUItemHeight = single * (float)this.m_uItemHeight / pixelsHigh; float mUItemHeight1 = mUItemHeight + (float)this.m_uItemHeight / pixelsHigh; ccV3FC4BT2FQuad.tl.texCoords.u = mUItemWidth; ccV3FC4BT2FQuad.tl.texCoords.v = mUItemHeight; ccV3FC4BT2FQuad.tr.texCoords.u = mUItemWidth1; ccV3FC4BT2FQuad.tr.texCoords.v = mUItemHeight; ccV3FC4BT2FQuad.bl.texCoords.u = mUItemWidth; ccV3FC4BT2FQuad.bl.texCoords.v = mUItemHeight1; ccV3FC4BT2FQuad.br.texCoords.u = mUItemWidth1; ccV3FC4BT2FQuad.br.texCoords.v = mUItemHeight1; ccV3F_C4B_T2F ccV3FC4BT2F = ccV3FC4BT2FQuad.tl; ccV3F_C4B_T2F ccV3FC4BT2F1 = ccV3FC4BT2FQuad.tr; ccV3F_C4B_T2F ccV3FC4BT2F2 = ccV3FC4BT2FQuad.bl; ccV3F_C4B_T2F ccV3FC4BT2F3 = ccV3FC4BT2FQuad.br; ccColor4B _ccColor4B = new ccColor4B(this.m_tColor.r, this.m_tColor.g, this.m_tColor.b, this.m_cOpacity); ccColor4B _ccColor4B1 = _ccColor4B; ccV3FC4BT2F3.colors = _ccColor4B; ccColor4B _ccColor4B2 = _ccColor4B1; ccColor4B _ccColor4B3 = _ccColor4B2; ccV3FC4BT2F2.colors = _ccColor4B2; ccColor4B _ccColor4B4 = _ccColor4B3; ccColor4B _ccColor4B5 = _ccColor4B4; ccV3FC4BT2F1.colors = _ccColor4B4; ccV3FC4BT2F.colors = _ccColor4B5; ccV3FC4BT2FQuad.bl.vertices.x = (float)(i * this.m_uItemWidth); ccV3FC4BT2FQuad.bl.vertices.y = 0f; ccV3FC4BT2FQuad.bl.vertices.z = 0f; ccV3FC4BT2FQuad.br.vertices.x = (float)(i * this.m_uItemWidth + this.m_uItemWidth); ccV3FC4BT2FQuad.br.vertices.y = 0f; ccV3FC4BT2FQuad.br.vertices.z = 0f; ccV3FC4BT2FQuad.tl.vertices.x = (float)(i * this.m_uItemWidth); ccV3FC4BT2FQuad.tl.vertices.y = (float)this.m_uItemHeight; ccV3FC4BT2FQuad.tl.vertices.z = 0f; ccV3FC4BT2FQuad.tr.vertices.x = (float)(i * this.m_uItemWidth + this.m_uItemWidth); ccV3FC4BT2FQuad.tr.vertices.y = (float)this.m_uItemHeight; ccV3FC4BT2FQuad.tr.vertices.z = 0f; this.m_pTextureAtlas.updateQuad(ccV3FC4BT2FQuad, i); } }
public virtual bool init() { m_bDirty = m_bRecursiveDirty = false; // by default use "Self Render". // if the sprite is added to an batchnode, then it will automatically switch to "SpriteSheet Render" useSelfRender(); m_bOpacityModifyRGB = true; m_nOpacity = 255; m_sColor = new ccColor3B(255, 255, 255); m_sColorUnmodified = new ccColor3B(255, 255, 255); m_sBlendFunc = new ccBlendFunc(); m_sBlendFunc.src = ccMacros.CC_BLEND_SRC; m_sBlendFunc.dst = ccMacros.CC_BLEND_DST; // update texture (calls updateBlendFunc) Texture = null; // clean the Quad m_sQuad = new ccV3F_C4B_T2F_Quad(); m_bFlipX = m_bFlipY = false; // default transform anchor: center anchorPoint = (CCPointExtension.ccp(0.5f, 0.5f)); // zwoptex default values m_obOffsetPositionInPixels = new CCPoint(); m_eHonorParentTransform = ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_ALL; m_bHasChildren = false; // Atlas: Color ccColor4B tmpColor = new ccColor4B(255, 255, 255, 255); m_sQuad.bl.colors = tmpColor; m_sQuad.br.colors = tmpColor; m_sQuad.tl.colors = tmpColor; m_sQuad.tr.colors = tmpColor; // Atlas: Vertex // updated in "useSelfRender" // Atlas: TexCoords setTextureRectInPixels(new CCRect(), false, new CCSize()); return(true); }
protected void addQuadFromSprite(CCSprite sprite, int index) { while ((index >= this.m_pobTextureAtlas.Capacity) || (this.m_pobTextureAtlas.Capacity == this.m_pobTextureAtlas.TotalQuads)) { this.increaseAtlasCapacity(); } sprite.useBatchNode(this); sprite.atlasIndex = index; ccV3F_C4B_T2F_Quad quad = sprite.quad; this.m_pobTextureAtlas.insertQuad(quad, index); sprite.dirty = true; sprite.updateTransform(); }
public void insertQuad(ccV3F_C4B_T2F_Quad quad, int index) { CCTextureAtlas mUTotalQuads = this; mUTotalQuads.m_uTotalQuads = mUTotalQuads.m_uTotalQuads + 1; int num = this.m_uTotalQuads - 1 - index; if (num > 0) { Array.Copy(this.m_pQuads, index, this.m_pQuads, index + 1, num); } this.m_pQuads[index] = quad; this.m_bDirty = true; }
public bool resizeCapacity(int newCapacity) { if (newCapacity == this.m_uCapacity) { return(true); } this.m_uTotalQuads = Math.Min(this.m_uTotalQuads, newCapacity); this.m_uCapacity = newCapacity; ccV3F_C4B_T2F_Quad[] ccV3FC4BT2FQuadArray = new ccV3F_C4B_T2F_Quad[newCapacity]; Array.Copy(this.m_pQuads, ccV3FC4BT2FQuadArray, (int)this.m_pQuads.Length); this.m_pQuads = ccV3FC4BT2FQuadArray; this.m_pIndices = new short[this.m_uCapacity * 6]; this.initIndices(); this.m_bDirty = true; return(true); }
public void insertChild(CCSprite pobSprite, int uIndex) { pobSprite.useBatchNode(this); pobSprite.atlasIndex = uIndex; pobSprite.dirty = true; if (this.m_pobTextureAtlas.TotalQuads == this.m_pobTextureAtlas.Capacity) { this.increaseAtlasCapacity(); } ccV3F_C4B_T2F_Quad quad = pobSprite.quad; this.m_pobTextureAtlas.insertQuad(quad, uIndex); this.m_pobDescendants.Insert(uIndex, pobSprite); uint num = 0; if ((this.m_pobDescendants != null) && (this.m_pobDescendants.Count > 0)) { for (int i = 0; i < this.m_pobDescendants.Count; i++) { CCObject obj2 = this.m_pobDescendants[i]; CCSprite sprite = obj2 as CCSprite; if (sprite != null) { if (num > uIndex) { sprite.atlasIndex++; } num++; } } } List <CCNode> children = pobSprite.children; if ((children != null) && (children.Count > 0)) { for (int j = 0; j < children.Count; j++) { CCObject obj3 = children[j]; CCSprite sprite2 = obj3 as CCSprite; if (sprite2 != null) { uIndex = this.atlasIndexForChild(sprite2, sprite2.zOrder); this.insertChild(sprite2, uIndex); } } } }
public void drawNumberOfQuads(int n, int start) { if (n == start) { return; } if (this.m_pQuads == null || (int)this.m_pQuads.Length < 1) { return; } CCApplication texture2D = CCApplication.sharedApplication(); CCDirector.sharedDirector().getWinSize(); texture2D.basicEffect.Texture = this.Texture.getTexture2D(); texture2D.basicEffect.TextureEnabled = true; texture2D.GraphicsDevice.BlendState = BlendState.AlphaBlend; texture2D.basicEffect.VertexColorEnabled = true; List <VertexPositionColorTexture> vertexPositionColorTextures = new List <VertexPositionColorTexture>(); short[] numArray = new short[n * 6]; for (int i = start; i < start + n; i++) { ccV3F_C4B_T2F_Quad mPQuads = this.m_pQuads[i]; if (mPQuads != null) { vertexPositionColorTextures.AddRange(mPQuads.getVertices(ccDirectorProjection.kCCDirectorProjection3D).ToList <VertexPositionColorTexture>()); numArray[i * 6] = (short)(i * 4); numArray[i * 6 + 1] = (short)(i * 4 + 1); numArray[i * 6 + 2] = (short)(i * 4 + 2); numArray[i * 6 + 3] = (short)(i * 4 + 2); numArray[i * 6 + 4] = (short)(i * 4 + 1); numArray[i * 6 + 5] = (short)(i * 4 + 3); } } VertexElement[] vertexElement = new VertexElement[] { new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Color, 0), new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0) }; VertexDeclaration vertexDeclaration = new VertexDeclaration(vertexElement); foreach (EffectPass pass in texture2D.basicEffect.CurrentTechnique.Passes) { pass.Apply(); texture2D.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColorTexture>(PrimitiveType.TriangleList, vertexPositionColorTextures.ToArray(), 0, vertexPositionColorTextures.Count, numArray, 0, vertexPositionColorTextures.Count / 2); } }
public void insertQuadFromIndex(int oldIndex, int newIndex) { if (oldIndex == newIndex) { return; } int num = (oldIndex - newIndex > 0 ? oldIndex - newIndex : newIndex - oldIndex); ccV3F_C4B_T2F_Quad mPQuads = this.m_pQuads[oldIndex]; if (oldIndex <= newIndex) { Array.Copy(this.m_pQuads, newIndex + 1, this.m_pQuads, newIndex, num); this.m_pQuads[newIndex] = mPQuads; } else { Array.Copy(this.m_pQuads, newIndex, this.m_pQuads, newIndex + 1, num); this.m_pQuads[newIndex] = mPQuads; } this.m_bDirty = true; }
/// <summary> /// Removes the quad that is located at a certain index and inserts it at a new index /// This operation is faster than removing and inserting in a quad in 2 different steps /// @since v0.7.2 public void insertQuadFromIndex(int oldIndex, int newIndex) { Debug.Assert(newIndex >= 0 && newIndex < m_uTotalQuads, "insertQuadFromIndex:atIndex: Invalid index"); Debug.Assert(oldIndex >= 0 && oldIndex < m_uTotalQuads, "insertQuadFromIndex:atIndex: Invalid index"); if (oldIndex == newIndex) { return; } // because it is ambigious in iphone, so we implement abs ourself // unsigned int howMany = abs( oldIndex - newIndex); int howMany = (oldIndex - newIndex) > 0 ? (oldIndex - newIndex) : (newIndex - oldIndex); int dst = oldIndex; int src = oldIndex + 1; if (oldIndex > newIndex) { dst = newIndex + 1; src = newIndex; } ccV3F_C4B_T2F_Quad quadsBackup = m_pQuads[oldIndex]; if (oldIndex > newIndex) { Array.Copy(m_pQuads, newIndex, m_pQuads, newIndex + 1, howMany); m_pQuads[newIndex] = quadsBackup; } else { Array.Copy(m_pQuads, newIndex + 1, m_pQuads, newIndex, howMany); m_pQuads[newIndex] = quadsBackup; } #if CC_USES_VBO m_bDirty = true; #endif }
/// <summary> /// resize the capacity of the CCTextureAtlas. /// The new capacity can be lower or higher than the current one /// It returns YES if the resize was successful. /// If it fails to resize the capacity it will return NO with a new capacity of 0. /// </summary> public bool resizeCapacity(int newCapacity) { if (newCapacity == m_uCapacity) { return(true); } m_uTotalQuads = Math.Min(m_uTotalQuads, newCapacity); m_uCapacity = newCapacity; ccV3F_C4B_T2F_Quad[] temp = new ccV3F_C4B_T2F_Quad[newCapacity]; Array.Copy(m_pQuads, temp, m_pQuads.Length); m_pQuads = temp; m_pIndices = new short[m_uCapacity * 6]; this.initIndices(); #if CC_USES_VBO m_bDirty = true; #endif return(true); }
/// <summary> /// Inserts a Quad (texture, vertex and color) at a certain index /// index must be between 0 and the atlas capacity - 1 /// @since v0.8 /// </summary> public void insertQuad(ccV3F_C4B_T2F_Quad quad, int index) { Debug.Assert(index < m_uCapacity, "insertQuadWithTexture: Invalid index"); m_uTotalQuads++; Debug.Assert(m_uTotalQuads <= m_uCapacity, "invalid totalQuads"); // issue #575. index can be > totalQuads int remaining = (m_uTotalQuads - 1) - index; // last object doesn't need to be moved if (remaining > 0) { // texture coordinates Array.Copy(m_pQuads, index, m_pQuads, index + 1, remaining); } m_pQuads[index] = quad; #if CC_USES_VBO m_bDirty = true; #endif }
/// <summary> /// resize the capacity of the CCTextureAtlas. /// The new capacity can be lower or higher than the current one /// It returns YES if the resize was successful. /// If it fails to resize the capacity it will return NO with a new capacity of 0. /// </summary> public bool resizeCapacity(int newCapacity) { if (newCapacity == m_uCapacity) return true; m_uTotalQuads = Math.Min(m_uTotalQuads, newCapacity); m_uCapacity = newCapacity; ccV3F_C4B_T2F_Quad[] temp = new ccV3F_C4B_T2F_Quad[newCapacity]; Array.Copy(m_pQuads, temp, m_pQuads.Length); m_pQuads = temp; m_pIndices = new short[m_uCapacity * 6]; this.initIndices(); #if CC_USES_VBO m_bDirty = true; #endif return true; }
public void updateQuad(ccV3F_C4B_T2F_Quad quad, int index) { this.m_uTotalQuads = Math.Max(index + 1, this.m_uTotalQuads); this.m_pQuads[index] = quad; this.m_bDirty = true; }
public virtual bool init() { m_bDirty = m_bRecursiveDirty = false; // by default use "Self Render". // if the sprite is added to an batchnode, then it will automatically switch to "SpriteSheet Render" useSelfRender(); m_bOpacityModifyRGB = true; m_nOpacity = 255; m_sColor = new ccColor3B(255, 255, 255); m_sColorUnmodified = new ccColor3B(255, 255, 255); m_sBlendFunc = new ccBlendFunc(); m_sBlendFunc.src = ccMacros.CC_BLEND_SRC; m_sBlendFunc.dst = ccMacros.CC_BLEND_DST; // update texture (calls updateBlendFunc) Texture = null; // clean the Quad m_sQuad = new ccV3F_C4B_T2F_Quad(); m_bFlipX = m_bFlipY = false; // default transform anchor: center AnchorPoint = (CCPointExtension.ccp(0.5f, 0.5f)); // zwoptex default values m_obOffsetPositionInPixels = new CCPoint(); m_eHonorParentTransform = ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_ALL; m_bHasChildren = false; // Atlas: Color ccColor4B tmpColor = new ccColor4B(255, 255, 255, 255); m_sQuad.bl.colors = tmpColor; m_sQuad.br.colors = tmpColor; m_sQuad.tl.colors = tmpColor; m_sQuad.tr.colors = tmpColor; // Atlas: Vertex // updated in "useSelfRender" // Atlas: TexCoords setTextureRectInPixels(new CCRect(), false, new CCSize()); return true; }
/// <summary> /// initializes a TextureAtlas with a previously initialized Texture2D object, and /// with an initial capacity for Quads. /// The TextureAtlas capacity can be increased in runtime. /// WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706) /// </summary> public bool initWithTexture(CCTexture2D texture, int capacity) { Debug.Assert(texture != null); m_uCapacity = capacity; m_uTotalQuads = 0; // retained in property this.m_pTexture = texture; // Re-initialization is not allowed Debug.Assert(m_pIndices == null && m_pIndices == null); m_pQuads = new ccV3F_C4B_T2F_Quad[m_uCapacity]; m_pIndices = new short[m_uCapacity * 6]; #if CC_USES_VBO // initial binding //glGenBuffers(2, &m_pBuffersVBO[0]); m_bDirty = true; #endif // CC_USES_VBO this.initIndices(); return true; }