×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    7

    Copying content from Pixmap surface to window surface

    Hi,

    I have an OpenGL-ES app, where i want to copy data from window surface to native pixmap surface at a certain time, i.e. i want to copy the content whatever is being shown on the display at a given time to a pixmap surface.And later, i want to copy that data back to the window surface.

    I know for copying data from window surface to native pixmap, i can use eglCopyBuffers(). But i am not sure how i can copy the data back from native pixmap to window surface. I know there are APIs like glCopyPixels/glDrawPixels but read somewhere that these copypixel operations are somewhat slower. Alternatively i think using textures, we can do this, but i do not have much detailed idea on this.

    So, can any one please suggest me what would be the best way to achieve this?

    Regs,
    Rahaman

  2. #2
    Regular Contributor
    Join Date
    Apr 2004
    Posts
    96

    Re: Copying content from Pixmap surface to window surface

    You may want to check this discussion.

    http://discussion.forum.nokia.com/fo...hlight=pbuffer

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    7

    Re: Copying content from Pixmap surface to window surface

    Hi,

    Thanks for the info.The problem is in my case, i do not have any pbuffer. I only have window & pixmap surfaces.

    Can any one provide me small piece of sample code as i am not too familiar with the usage of texture.

  4. #4
    Regular Contributor
    Join Date
    Apr 2004
    Posts
    96

    Re: Copying content from Pixmap surface to window surface

    First you have to read OpenGL ES manual/tutorial.
    You can aslo download Nokia 3D example and play with it. It have fairly simple billboard example.

    If you want to go straight into code first you have create texture like this

    glGenTextures( 1, &m_bkgTxtID);

    glBindTexture(GL_TEXTURE_2D, m_bkgTxtID);

    glTexParameterx(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterx(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    m_rgbxBuffer = new unsigned int[BKG_TXT_SIZE*BKG_TXT_SIZE];
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, BKG_TXT_SIZE ,BKG_TXT_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_rgbxBuffer);

    After that fill the buffer rgbxBuffer and render
    glBindTexture( GL_TEXTURE_2D, m_bkgTxtID);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256 , 256, 0,
    GL_RGBA, GL_UNSIGNED_BYTE, m_rgbxBuffer);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthof(0, VFWIDTH, 0, VFHEIGHT, -1.0, 1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glViewport(0, VIEWPORT_OFFSET, VFWIDTH, VFHEIGHT);

    glDisable(GL_DEPTH_TEST);


    glColor4x(GLUNITY, GLUNITY, GLUNITY, GLUNITY);
    glVertexPointer( 3, GL_FLOAT, 0, quadVertices );
    glTexCoordPointer( 2, GL_FIXED, 0, quadTextureCoords );
    glDrawElements( GL_TRIANGLES, 2 * 3, GL_UNSIGNED_BYTE, quadTriangles );

    define quadVertices according to desirable positions,
    static const GLfloat quadVertices[4 * 3] =
    {
    0, VFHEIGHT-BKG_TXT_SIZE, 0,
    0, VFHEIGHT, 0,
    BKG_TXT_SIZE, VFHEIGHT, 0,
    BKG_TXT_SIZE, VFHEIGHT-BKG_TXT_SIZE, 0
    };

    and quadTextureCoords and indices usual way (I'm using fixed point API here, GLUNITY=(1<<16)-1 . Floating point is more simple.

    static const TInt quadTextureCoords[4 * 2] =
    {
    0, GLUNITY,
    0, 0,
    GLUNITY, 0,
    GLUNITY, GLUNITY
    };

    static const GLubyte quadTriangles[2 * 3] =
    {
    0,1,2,
    0,2,3
    };

  5. #5
    Registered User
    Join Date
    Aug 2007
    Posts
    7

    Re: Copying content from Pixmap surface to window surface

    Hi Serg,

    So, it means that Texture is the only approach to accomplish this?.

    Let's say i have a opengl-es app which is continuously animating, e.g. let's take a cube constantly rotating in 3D plane.I can do it in two ways

    1>I can create an EGLwindow surface & render my content there & cann eglSwapBuffers after each frame.

    2>Secondly, i can follow the pbuffer/pixmap approach, use the texture and then render the texture to the screen by some means(i dont know though how).

    How much difference is there between the two approach in terms of complexity, as i know the #1 approach is pretty straight forward.

    How much difference would be there in terms of performance?

Similar Threads

  1. KERN-EXEC 3 with CEikEdwin
    By acarrion in forum Symbian User Interface
    Replies: 3
    Last Post: 2007-10-17, 14:43
  2. N95 - OpenGL Pixmap surface support
    By frizi in forum Symbian C++
    Replies: 0
    Last Post: 2007-07-17, 10:37
  3. EGL window surface not fullscreen
    By storsjo in forum Symbian Media (Closed)
    Replies: 17
    Last Post: 2007-01-02, 08:14
  4. Audio Input Stream on N80
    By tkaihock in forum Symbian Media (Closed)
    Replies: 9
    Last Post: 2006-06-30, 09:15
  5. About window views
    By thodime_guru in forum Symbian User Interface
    Replies: 1
    Last Post: 2004-06-17, 18:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •