/// <summary> /// Initializes a texture from a content file /// </summary> public bool initWithTexture(Texture2D texture) { if (null == texture) { return(false); } long POTWide, POTHigh; POTWide = ccUtils.ccNextPOT(texture.Width); POTHigh = ccUtils.ccNextPOT(texture.Height); int maxTextureSize = CCConfiguration.sharedConfiguration().MaxTextureSize; if (POTHigh > maxTextureSize || POTWide > maxTextureSize) { CCLog.Log(string.Format("cocos2d: WARNING: Image ({0} x {1}) is bigger than the supported {2} x {3}", POTWide, POTHigh, maxTextureSize, maxTextureSize)); return(false); } #if ANDROID return(initTextureWithImage(texture, texture.Width, texture.Height)); #else return(initPremultipliedATextureWithImage(texture, texture.Width, texture.Height)); #endif }
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); }
public CCGrabber() { m_eGlesVersion = CCConfiguration.sharedConfiguration().getGlesVersion(); // If the gles version is lower than GLES_VER_1_0, // all the functions in CCGrabber return directly. if (m_eGlesVersion <= CCGlesVersion.GLES_VER_1_0) { return; } // generate FBO //ccglGenFramebuffers(1, &m_fbo); }
public bool initWithTexture(Texture2D texture) { if (texture != null) { long num = ccUtils.ccNextPOT((long)texture.Width); long num2 = ccUtils.ccNextPOT((long)texture.Height); int maxTextureSize = CCConfiguration.sharedConfiguration().MaxTextureSize; if ((num2 <= maxTextureSize) && (num <= maxTextureSize)) { return(this.initPremultipliedATextureWithImage(texture, texture.Width, texture.Height)); } CCLog.Log(string.Format("cocos2d: WARNING: Image ({0} x {1}) is bigger than the supported {2} x {3}", new object[] { num, num2, maxTextureSize, maxTextureSize })); } return(false); }
static CCConfiguration() { CCConfiguration.m_sharedConfiguration = new CCConfiguration(); }
/// <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) { // 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); 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); }
public CCGrabber() { this.m_eGlesVersion = CCConfiguration.sharedConfiguration().getGlesVersion(); CCGlesVersion mEGlesVersion = this.m_eGlesVersion; }