Exemplo n.º 1
0
        public override void Draw()
        {
            if (m_pVertexData == null || m_pSprite == null)
            {
                return;
            }

            CCDrawManager.BindTexture(Sprite.Texture);
            CCDrawManager.BlendFunc(m_pSprite.BlendFunc);

            var count = (m_nVertexDataCount - 2);

            if (s_pIndexes == null || s_pIndexes.Length < count * 3)
            {
                s_pIndexes = new short[count * 3];
            }

            if (m_eType == CCProgressTimerType.Radial)
            {
                //FAN
                for (int i = 0; i < count; i++)
                {
                    var i3 = i * 3;
                    s_pIndexes[i3 + 0] = 0;
                    s_pIndexes[i3 + 1] = (short)(i + 1);
                    s_pIndexes[i3 + 2] = (short)(i + 2);
                }

                CCDrawManager.DrawIndexedPrimitives(PrimitiveType.TriangleList, m_pVertexData, 0, m_nVertexDataCount,
                                                    s_pIndexes, 0, count);
            }
            else if (m_eType == CCProgressTimerType.Bar)
            {
                //TRIANGLE STRIP
                for (int i = 0; i < count; i++)
                {
                    var i3 = i * 3;
                    s_pIndexes[i3 + 0] = (short)(i + 0);
                    s_pIndexes[i3 + 1] = (short)(i + 1);
                    s_pIndexes[i3 + 2] = (short)(i + 2);
                }

                if (!m_bReverseDirection)
                {
                    CCDrawManager.DrawIndexedPrimitives(PrimitiveType.TriangleList, m_pVertexData, 0, m_nVertexDataCount,
                                                        s_pIndexes, 0, count);
                }
                else
                {
                    CCDrawManager.DrawIndexedPrimitives(PrimitiveType.TriangleList, m_pVertexData, 0, m_nVertexDataCount,
                                                        s_pIndexes, 0, count);
                }
            }
        }
Exemplo n.º 2
0
        public override void Draw()
        {
            if (m_pVertexData == null || m_pSprite == null)
            {
                return;
            }

            CCDrawManager.BindTexture(Sprite.Texture);
            CCDrawManager.BlendFunc(m_pSprite.BlendFunc);

            var count = (m_nVertexDataCount - 2);

            if (s_pIndexes == null || s_pIndexes.Length < count * 3)
            {
                s_pIndexes = new short[count * 3];
            }

            if (m_eType == CCProgressTimerType.Radial)
            {
                //FAN
                for (int i = 0; i < count; i++)
                {
                    var i3 = i * 3;
                    s_pIndexes[i3 + 0] = 0;
                    s_pIndexes[i3 + 1] = (short)(i + 1);
                    s_pIndexes[i3 + 2] = (short)(i + 2);
                }

                CCDrawManager.DrawIndexedPrimitives(PrimitiveType.TriangleList, m_pVertexData, 0, m_nVertexDataCount, s_pIndexes, 0, count);
            }
            else if (m_eType == CCProgressTimerType.Bar)
            {
                //TRIANGLE STRIP
                for (int i = 0; i < count; i++)
                {
                    var i3 = i * 3;
                    s_pIndexes[i3 + 0] = (short)(i + 0);
                    s_pIndexes[i3 + 1] = (short)(i + 1);
                    s_pIndexes[i3 + 2] = (short)(i + 2);
                }

                if (!m_bReverseDirection)
                {
                    CCDrawManager.DrawIndexedPrimitives(PrimitiveType.TriangleList, m_pVertexData, 0, m_nVertexDataCount, s_pIndexes, 0, count);
                }
                else
                {
                    CCDrawManager.DrawIndexedPrimitives(PrimitiveType.TriangleList, m_pVertexData, 0, m_nVertexDataCount, s_pIndexes, 0, count);
                }
            }

            /*
             * CC_NODE_DRAW_SETUP();
             *
             * ccGLBlendFunc( m_pSprite->getBlendFunc().src, m_pSprite->getBlendFunc().dst );
             *
             * ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex );
             *
             * ccGLBindTexture2D( m_pSprite->getTexture()->getName() );
             *
             * glVertexAttribPointer( kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(m_pVertexData[0]) , &m_pVertexData[0].vertices);
             * glVertexAttribPointer( kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(m_pVertexData[0]), &m_pVertexData[0].texCoords);
             * glVertexAttribPointer( kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(m_pVertexData[0]), &m_pVertexData[0].colors);
             *
             * if(m_eType == kCCProgressTimerTypeRadial)
             * {
             *  glDrawArrays(GL_TRIANGLE_FAN, 0, m_nVertexDataCount);
             * }
             * else if (m_eType == kCCProgressTimerTypeBar)
             * {
             *  if (!m_bReverseDirection)
             *  {
             *      glDrawArrays(GL_TRIANGLE_STRIP, 0, m_nVertexDataCount);
             *  }
             *  else
             *  {
             *      glDrawArrays(GL_TRIANGLE_STRIP, 0, m_nVertexDataCount/2);
             *      glDrawArrays(GL_TRIANGLE_STRIP, 4, m_nVertexDataCount/2);
             *      // 2 draw calls
             *      CC_INCREMENT_GL_DRAWS(1);
             *  }
             * }
             * CC_INCREMENT_GL_DRAWS(1);
             */
        }