Ita
Ita

Reputation: 1292

How to Draw pixel data taken from the backbuffer back to itself?

I'm working on a mobile application for Symbian 5th edition using OpenGLES.
This application is a pretty standard 2D app, and I make no use of the DepthBuffer.

I need to grab a snapshot of the display and then draw the very same snapshot back to the backbuffer.

I'm using glReadPixels((GLint)0, (GLint)0, (GLint)nWidth-1, (GLint)nHeight-1, GL_RGB, GL_UNSIGNED_BYTE, m_pPixelData)

in order to get the pixel data I need, but I'm rather new to OpenGLES and I don't know how to draw the data back to the backbuffer. (in OpenGL its easy using DrawPixels..)

I've read that I should generate a texture from the data, so I did. But now I'm not sure how to draw this texture.

Do I need to draw it as a texture of a Rectangular element ? if so than how am I suppose to define this rect ? ( the coordinates just doesn't make sense to me..)

The display size is 480x640 and here is the code I want to use in order to draw the rect:

    glEnable(GL_TEXTURE_2D);
    //displayTex is my texture built out of the pixel data
    glBindTexture(GL_TEXTURE_2D, m_pESSharedData->displayTex);

    //Bottom
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 0.0f);
    glVertex3f(-2.5f, -2.5f, 2.5f);
    glTexCoord2f(1.0f, 0.0f);
    glVertex3f(2.5f, -2.5f, 2.5f);
    glTexCoord2f(1.0f, 1.0f);
    glVertex3f(2.5f, -2.5f, -2.5f);
    glTexCoord2f(0.0f, 1.0f);
    glVertex3f(-2.5f, -2.5f, -2.5f);

    glEnd();

Note that above code is something I've picked up along the way, and I think this is the outline of what I'm suppose to do. feel free to take me off this track. :)

I thank you for your time.

Upvotes: 1

Views: 731

Answers (1)

michael aubert
michael aubert

Reputation: 6826

You first need to make sure that the version of OpenGL-ES on Series60 5th edition can handle textures whose height and width aren't powers of 2.

I would advise forum nokia for that kind of query.

Shameless plug:

Quick Recipes On Symbian OS contains a whole chapter explaining the basics of OpenGL-ES on Symbian OS. The 3D code samples are here.

Upvotes: 1

Related Questions