I'm getting a terrible headache while trying to blit from memory an OpenGL ES 2.0 texture.
I've looked at the code, and i see that either i create the texture with R8G8B8 or B8G8R8, the GLES2 native format remains to GL_RGB.
Ok, so, i'm setting my texture to R8G8B8 and my pixel box to R8G8B8, same format, both on RGB, so not format conversions expected, but when running the code, i see that the program is going into this piece of code:
Code: Select all
else
{
allocateBuffer();
scaled = src;
if (src.format == PF_R8G8B8)
{
scaled.format = PF_B8G8R8;
PixelUtil::bulkPixelConversion(src, scaled);
}
}
Ok, so i think, lets set the pixel buffer to PF_B8G8R8, but if i do this, the program now goes from this piece of code:
Code: Select all
else if ((src.format != mFormat) ||
((GLES2PixelUtil::getGLOriginFormat(src.format) == 0) && (src.format != PF_R8G8B8)))
{
// Extents match, but format is not accepted as valid source format for GL
// do conversion in temporary buffer
allocateBuffer();
scaled = mBuffer.getSubVolume(dstBox);
PixelUtil::bulkPixelConversion(src, scaled);
if(mFormat == PF_A4R4G4B4)
{
// ARGB->BGRA
GLES2PixelUtil::convertToGLformat(scaled, scaled);
}
}The last try, if I set the texture format to B8G8R8 to match pixel box, in the texture creation process, GL creates again a GL_RGB texture, so the format is set again to R8G8B8 and we go again to the code before...
Any ideas? i think that the first case is the right one, but i think that the condition to make the conversion is wrong... if the GL texture is always GL_RGB, i think that the condition must be:
Code: Select all
else
{
allocateBuffer();
scaled = src;
if (src.format == PF_B8G8R8)
{
scaled.format = PF_R8G8B8;
PixelUtil::bulkPixelConversion(src, scaled);
}
}
Thanks in advance!
