Пример #1
0
        /// <summary>
        ///  initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid
        /// </summary>
        public bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat)
        {
            bool bRet = false;

            do
            {
                w *= (int)CCDirector.sharedDirector().ContentScaleFactor;
                h *= (int)CCDirector.sharedDirector().ContentScaleFactor;

                //glGetIntegerv(0x8CA6, m_nOldFBO);

                // textures must be power of two squared
                uint powW = (uint)ccUtils.ccNextPOT(w);
                uint powH = (uint)ccUtils.ccNextPOT(h);

                m_pTexture = new CCTexture2D();

                CCApplication app = CCApplication.sharedApplication();
                m_RenderTarget2D = new RenderTarget2D(app.GraphicsDevice, (int)w, (int)h);
                app.GraphicsDevice.SetRenderTarget(m_RenderTarget2D);
                app.GraphicsDevice.Clear(new Microsoft.Xna.Framework.Color(0, 0, 0, 0));


                m_pTexture.initWithTexture(m_RenderTarget2D);

                // generate FBO
                //ccglGenFramebuffers(1, &m_uFBO);
                //ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_uFBO);

                // associate texture with FBO
                //ccglFramebufferTexture2D(CC_GL_FRAMEBUFFER, CC_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_pTexture->getName(), 0);

                // check if it worked (probably worth doing :) )
                //GLuint status = ccglCheckFramebufferStatus(CC_GL_FRAMEBUFFER);
                //if (status != CC_GL_FRAMEBUFFER_COMPLETE)
                //{
                //    CCAssert(0, "Render Texture : Could not attach texture to framebuffer");
                //    CC_SAFE_DELETE(m_pTexture);
                //    break;
                //}

                //m_pTexture.setAliasTexParameters();

                m_pSprite = CCSprite.spriteWithTexture(m_pTexture);

                //m_pTexture->release();
                //m_pSprite.scaleY = -1;
                this.addChild(m_pSprite);

                ccBlendFunc tBlendFunc = new ccBlendFunc {
                    src = 1, dst = 0x0303
                };
                m_pSprite.BlendFunc = tBlendFunc;

                //ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_nOldFBO);
                bRet = true;
            } while (false);

            return(bRet);
        }
Пример #2
0
        public bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat)
        {
            if (CCConfiguration.sharedConfiguration().getGlesVersion() <= CCGlesVersion.GLES_VER_1_0)
            {
                return(false);
            }
            w = w * (int)CCDirector.sharedDirector().ContentScaleFactor;
            h = h * (int)CCDirector.sharedDirector().ContentScaleFactor;
            ccUtils.ccNextPOT((long)w);
            ccUtils.ccNextPOT((long)h);
            this.m_pTexture = new CCTexture2D();
            CCApplication cCApplication = CCApplication.sharedApplication();

            this.m_RenderTarget2D = new RenderTarget2D(cCApplication.GraphicsDevice, w, h);
            cCApplication.GraphicsDevice.SetRenderTarget(this.m_RenderTarget2D);
            cCApplication.GraphicsDevice.Clear(new Color(0, 0, 0, 0));
            this.m_pTexture.initWithTexture(this.m_RenderTarget2D);
            this.m_pSprite = CCSprite.spriteWithTexture(this.m_pTexture);
            this.addChild(this.m_pSprite);
            ccBlendFunc _ccBlendFunc = new ccBlendFunc()
            {
                src = 1,
                dst = 771
            };

            this.m_pSprite.BlendFunc = _ccBlendFunc;
            return(true);
        }
Пример #3
0
 public bool initWithTexture(CCTexture2D pTexture)
 {
     this.m_pSprite          = CCSprite.spriteWithTexture(pTexture);
     this.m_fPercentage      = 0f;
     this.m_pVertexData      = null;
     this.m_nVertexDataCount = 0;
     this.anchorPoint        = new CCPoint(0.5f, 0.5f);
     this.contentSize        = this.m_pSprite.contentSize;
     this.m_eType            = CCProgressTimerType.kCCProgressTimerTypeRadialCCW;
     return(true);
 }