Android opengl off-screen rendering output flipped

I have an OES texture which renders off-screen to another 2D texture using frame buffer object (FBO) My output is completely flipped both upside- down and left - right

Read that by inverting texture coordinates, it will solve the issue.

So I did this :

private final float[] mTriangleVerticesData = {

            // X, Y, Z, U, V
            -1.0f, -1.0f, 0, 0.f, 0.f,
            1.0f, -1.0f, 0, 1.f, 0.f,
            -1.0f,  1.0f, 0, 0.f, 1.f,
            1.0f,  1.0f, 0, 1.f, 1.f,
    };

changed to

    private final float[] mTriangleVerticesData = {
            // X, Y, Z, U, V
            -1.0f, -1.0f, 0, 0.f, 0.f,
            1.0f, -1.0f, 0, 0.f, 1.f,
            -1.0f,  1.0f, 0, 1.f, 0.f,
            1.0f,  1.0f, 0, 1.f, 1.f,
    };

This solved by upside down issue, but left right is stll flipped. Any ideas.? Or is there any elegant way to solve this issue.

I am using Androd GLES20.

This might be similar to a problem I came across - apologies if not. I found that I had to reverse all my data when converting a 3D object to Android format. I realised the Android CPU uses Big-Endian data format and not Little-Endian so I had to reverse all my data when I converted my objects from the PC side. I wrote a little conversion function to convert my PC data for use on Android.


      // HERE WE WRITE THE VERTEX NORMALS
      normal.x = ReverseBigEndianFloat(normal.x);
      normal.y = ReverseBigEndianFloat(normal.y);
      normal.z = ReverseBigEndianFloat(normal.z);


/ NEW TEST FUNCTION TO REVERSE A FLOAT FROM BIG ENDIAN TO LITTLE ENDIAN
float AndroidObjectClass::ReverseBigEndianFloat(const float inFloat)
{
	float temp;
	char *floatToConvert = (char*)& inFloat;
	char *returnFloat = (char*)& temp;

	// swap the bytes into a temporary buffer
	returnFloat[0] = floatToConvert[3];
	returnFloat[1] = floatToConvert[2];
	returnFloat[2] = floatToConvert[1];
	returnFloat[3] = floatToConvert[0];

	return temp;
}

[QUOTE=deeps8us;1282309]I have an OES texture which renders off-screen to another 2D texture using frame buffer object (FBO) My output is completely flipped both upside- down and left - right

Read that by inverting texture coordinates, it will solve the issue.[/QUOTE]

Have you seen this same code produce different results on another device/GPU/GPU driver or on a desktop GPU (under a GLES emulator or native GLES driver support)?

And out of curiosity, what device/GPU/GPU driver version are you using?

reaktor24 : From the first look, I think that is not the issue I am facing. Becasue when I render directly onscreen there s no issue. Issue happens only when I render to an offscreen texture first (bound to FBO) and then onscreen. But will check in detail. Thank you.

Dark Photon : I am using Adreno GPU. Didnt try on another emulator / device as I took it for granted that this is texture coordinate mapping . Will give it a try. Thank you.

[QUOTE=deeps8us;1282337]Becasue when I render directly onscreen there s no issue. Issue happens only when I render to an offscreen texture first (bound to FBO) and then onscreen.
[/QUOTE]
That suggests that the “flip” is occurring in the process of rendering the off-screen texture onto the screen.

E.g. if you were using a projection matrix which inverts the Y axis (so that +Y is “down”), and use that projection both for rendering the scene and rendering the off-screen render onto the screen, rendering directly to the screen will flip once, while rendering via the FBO will flip twice.

Thankyou GClements, I could solve it by doing 1.0-coord.v (flipping) when accessing texel.