当前位置: 首页>>代码示例>>C#>>正文


C# CCTexture2D.initWithData方法代码示例

本文整理汇总了C#中cocos2d.CCTexture2D.initWithData方法的典型用法代码示例。如果您正苦于以下问题:C# CCTexture2D.initWithData方法的具体用法?C# CCTexture2D.initWithData怎么用?C# CCTexture2D.initWithData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cocos2d.CCTexture2D的用法示例。


在下文中一共展示了CCTexture2D.initWithData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: initWithSize

        public bool initWithSize(ccGridSize gridSize)
        {
            CCDirector pDirector = CCDirector.sharedDirector();
            CCSize s = pDirector.winSizeInPixels;

            ulong POTWide = ccNextPOT((uint)s.width);
            ulong POTHigh = ccNextPOT((uint)s.height);

            // we only use rgba8888
            CCTexture2DPixelFormat format = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888;

            CCTexture2D pTexture = new CCTexture2D();
            pTexture.initWithData(null, format, (uint)POTWide, (uint)POTHigh, s);

            if (pTexture == null)
            {
                CCLog.Log("cocos2d: CCGrid: error creating texture");
                return false;
            }

            initWithSize(gridSize, pTexture, false);

            return true;
        }
开发者ID:liwq-net,项目名称:cocos2d-for-xna-windows,代码行数:24,代码来源:CCGridBase.cs

示例2: initWithWidthAndHeight

        /// <summary>
        ///  initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid 
        /// </summary>
        /// <param name="w"></param>
        /// <param name="h"></param>
        /// <param name="eFormat"></param>
        /// <returns></returns>
        public bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat)
        {
            // If the gles version is lower than GLES_VER_1_0,
            // some extended gles functions can't be implemented, so return false directly.
            if (CCConfiguration.sharedConfiguration().getGlesVersion() <= CCGlesVersion.GLES_VER_1_0)
            {
                return false;
            }

            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);

                var data = (int)(powW * powH * 4);
                //CC_BREAK_IF(! data);

                //memset(data, 0, (int)(powW * powH * 4));
                //m_ePixelFormat = eFormat;

                m_pTexture = new CCTexture2D();
                //CC_BREAK_IF(! m_pTexture);

                m_pTexture.initWithData(data, (CCTexture2DPixelFormat)m_ePixelFormat, powW, powH, new CCSize((float)w, (float)h));
                //free( data );

                // 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 (true);
            return bRet;
        }
开发者ID:ChowZenki,项目名称:cocos2d-x-for-xna,代码行数:72,代码来源:CCRenderTexture.cs


注:本文中的cocos2d.CCTexture2D.initWithData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。