Ogre1.8.1 PF_A8R8G8B8 pixel format, failure in android

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Post Reply
saber
Gnoblar
Posts: 1
Joined: Sun Mar 31, 2013 8:40 am

Ogre1.8.1 PF_A8R8G8B8 pixel format, failure in android

Post by saber » Sun Mar 31, 2013 8:57 am

Using PNG with transparent channel texture, texture rendering into black.

ogre log:
[GLES2] : Valid FBO targets PF_R8G8B8 PF_B8G8R8 PF_X8B8G8R8

No PF_A8R8G8B8 pixel format.

Code: Select all

    /** Detect which internal formats are allowed as RTT
        Also detect what combinations of stencil and depth are allowed with this internal
        format.
    */
    void GLES2FBOManager::detectFBOFormats()
    {
        // Try all formats, and report which ones work as target
        GLuint fb, tid;
        GLenum target = GL_TEXTURE_2D;
        StringUtil::StrStreamType strT;

        for(size_t x=0; x<PF_COUNT; ++x)
        {
            mProps[x].valid = false;

			// Fetch GL format token
			GLint internalFormat = GLES2PixelUtil::getGLInternalFormat((PixelFormat)x);
            GLenum fmt = GLES2PixelUtil::getGLOriginFormat((PixelFormat)x);


#if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
            if(internalFormat == GL_NONE)
                continue;
#else
            if((internalFormat == GL_NONE) && (x != 0))
                continue;
#endif


			// No test for compressed formats
            if(PixelUtil::isCompressed((PixelFormat)x))
                continue;

            // Create and attach framebuffer
            glGenFramebuffers(1, &fb);
            glBindFramebuffer(GL_FRAMEBUFFER, fb);
            if (internalFormat != GL_NONE)
            {
				// Create and attach texture
				glGenTextures(1, &tid);
				glBindTexture(target, tid);

                // Set some default parameters
#if GL_APPLE_texture_max_level && OGRE_PLATFORM != OGRE_PLATFORM_NACL
                glTexParameteri(target, GL_TEXTURE_MAX_LEVEL_APPLE, 0);
#endif
                glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
                glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
                glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
                glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

                // ----------------------------
                strT<<"(PixelFormat)x name : "<<PixelUtil::getFormatName((PixelFormat)x)<<"\n";
                strT<<"(PixelFormat)x : "<<(PixelFormat)x<<"\n";
                strT<<"fmt : "<<fmt<<"\n";
                strT<<"internalFormat : "<<internalFormat<<"\n";

				glTexImage2D(target, 0, internalFormat, PROBE_SIZE, PROBE_SIZE, 0, fmt, GLES2PixelUtil::getGLOriginDataType((PixelFormat)x), 0);
				glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                                target, tid, 0);
            }

            // Check status
            GLuint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

            strT<<"GL_FRAMEBUFFER_COMPLETE = "<<GL_FRAMEBUFFER_COMPLETE<<"----"<<status<<"\n";


            LogManager::getSingleton().logMessage(strT.str());

			// Ignore status in case of fmt==GL_NONE, because no implementation will accept
			// a buffer without *any* attachment. Buffers with only stencil and depth attachment
			// might still be supported, so we must continue probing.
            if(internalFormat == GL_NONE || status == GL_FRAMEBUFFER_COMPLETE)
            {
                mProps[x].valid = true;
				StringUtil::StrStreamType str;
				str << "FBO " << PixelUtil::getFormatName((PixelFormat)x)
					<< " depth/stencil support: ";

                // For each depth/stencil formats
                for (size_t depth = 0; depth < DEPTHFORMAT_COUNT; ++depth)
                {
#if GL_OES_packed_depth_stencil
                    if (depthFormats[depth] != GL_DEPTH24_STENCIL8_OES)
                    {
                        // General depth/stencil combination

                        for (size_t stencil = 0; stencil < STENCILFORMAT_COUNT; ++stencil)
                        {
//                            StringUtil::StrStreamType l;
//                            l << "Trying " << PixelUtil::getFormatName((PixelFormat)x) 
//                            	<< " D" << depthBits[depth] 
//                            	<< "S" << stencilBits[stencil];
//                            LogManager::getSingleton().logMessage(l.str());

                            if (_tryFormat(depthFormats[depth], stencilFormats[stencil]))
                            {
                                /// Add mode to allowed modes
                                str << "D" << depthBits[depth] << "S" << stencilBits[stencil] << " ";
                                FormatProperties::Mode mode;
                                mode.depth = depth;
                                mode.stencil = stencil;
                                mProps[x].modes.push_back(mode);
                            }
                        }
                    }
                    else
#endif
                    {
                        // Packed depth/stencil format
                        if (_tryPackedFormat(depthFormats[depth]))
                        {
                            /// Add mode to allowed modes
                            str << "Packed-D" << depthBits[depth] << "S" << 8 << " ";
                            FormatProperties::Mode mode;
                            mode.depth = depth;
                            mode.stencil = 0;   // unuse
                            mProps[x].modes.push_back(mode);
                        }
                    }
                }
                LogManager::getSingleton().logMessage(str.str());
            }

            // Delete texture and framebuffer
            glBindFramebuffer(GL_FRAMEBUFFER, 0);
            glDeleteFramebuffers(1, &fb);
			
            if (internalFormat!=GL_NONE)
                glDeleteTextures(1, &tid);
        }

        // Clear any errors
        GL_CHECK_ERROR;

		String fmtstring;
        for(size_t x=0; x<PF_COUNT; ++x)
        {
            if(mProps[x].valid)
                fmtstring += PixelUtil::getFormatName((PixelFormat)x)+" ";
        }
        LogManager::getSingleton().logMessage("[GLES2] : Valid FBO targets " + fmtstring);
    }
GLuint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
Authentication frame cache and additional objects, the integrity of the failure.

What's the solution?
thank you!
0 x

ohsheep
Gnoblar
Posts: 4
Joined: Wed Feb 20, 2013 3:02 pm

Re: Ogre1.8.1 PF_A8R8G8B8 pixel format, failure in android

Post by ohsheep » Mon May 13, 2013 4:47 pm

I had meet the same problem.
You can try the version 1.9, it supports PF_A8R8G8B8.
0 x

Post Reply