[iPhone] Bug with BGRA textures

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Post Reply
sfabien
Gnoblar
Posts: 8
Joined: Wed Nov 18, 2009 4:46 pm

[iPhone] Bug with BGRA textures

Post by sfabien »

Hello,

I am working on dynamic textures with data coming from the camera.

It is working correctly on native OpenGL using :

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1024, 512, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, 0);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, vW, vH, GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer]);

However on Ogre3D (mercurial source cloned today), if i write

_background_texture = TextureManager::getSingleton().createManual(textureName, textureGroup, Ogre::TEX_TYPE_2D, _texture_mem_width, _texture_mem_height, 0, PF_B8G8R8A8, TU_DYNAMIC_WRITE_ONLY);

And fill it with my data, i only get a white texture (Whatever the data put in the buffer).

To check that my code is correct, I changed the texture creation code to

_background_texture = TextureManager::getSingleton().createManual(textureName, textureGroup, Ogre::TEX_TYPE_2D, _texture_mem_width, _texture_mem_height, 0, PF_R8G8B8A8, TU_DYNAMIC_WRITE_ONLY);

Note the change from PF_B8G8R8A8 to PF_R8G8B8A8. This way, i can see my texture ... Obviously, the color is incorrect (blue seems red) but i can recognize it. I can swap the bytes of my buffer to make everything correct, but it is a lost of processing time that I would like to avoid.

So it seems there is a bug when using PF_B8G8R8A8. It seems that the iPhoneOS do not like GL_BGRA as an opengl internal format parameter (I used GL_RGBA for the internal format and GL_BGRA_EXT for the original format). I tried to debug myself the code, but i am not used enough to the Ogre source organization.

Sincerely,

Fabien
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: [iPhone] Bug with BGRA textures

Post by masterfalcon »

There was a thread about this a couple weeks ago. The outcome is that the bug is now fixed in the 1.7 branch. But not in the 1.7.3 binary distribution. So you'll have to build from source. Let me know if you have any more problems with it.
sfabien
Gnoblar
Posts: 8
Joined: Wed Nov 18, 2009 4:46 pm

Re: [iPhone] Bug with BGRA textures

Post by sfabien »

I do compile from sources as written in my previous post. I cloned the repository (1. 8 ) yesterday and compiled just before posting the message to be sure the bug is still there (and it is).

For info, to compile I just launch the script make_iphone.sh
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: [iPhone] Bug with BGRA textures

Post by masterfalcon »

Try 1.7, it hasn't been merged into 1.8 yet.
Post Reply