Results 1 to 5 of 5

Thread: render to texture

  1. #1

    render to texture


    Can i render to texture in OpenGL ES?
    Its the same way we render to texture in the OpenGL?

    I wanna render to texture and get the pixel of this texture.

    If someone have an example or may give me any kind of help, i would appreciate that.

    Thank you

  2. #2
    Senior Member
    Join Date
    May 2006
    There are three ways of rendering to a texture:
    1. Using glCopyTexImage2D

    You just render to the framebuffer, but instead of calling eglSwapBuffers to make the rendered image visible you call glCopyTexImage2D to copy the contents of the framebuffer to a texture.

    This approach works everywhere, but it might require a copy operation, and you're limited to the size of your current framebuffer.

    2. Using an EGL pbuffer surface

    You create a texture bindable pbuffer with eglCreatePbufferSurface. Then you make it the current draw surface of the context with eglMakeCurrent and render. When you're finished you restore the previous draw surface and bind the pbuffer to a texture object using eglBindTexImage. Don't forget to call eglReleaseTexImage when you're finished.

    Unfortunately some platforms don't support pbuffer surfaces.

    3. Using the OES_framebuffer_object extension

    Code :
    GLuint renderbuffer, framebuffer;
    // Create depth renderbuffer
    glGenRenderbuffersOES(1, &renderbuffer);
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, renderbuffer);
    glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT_16, width, height);
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0);
    // Create framebuffer object
    glGenFramebuffersOES(1, &framebuffer);
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer);
    // Attach depth renderbuffer and texture
    glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
      // error
    // render ...
    // unbind framebuffer object
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
    // cleanup when you don't need objects any longer
    glDeleteRenderbuffersOES(1, &renderbuffer);
    glDeleteFramebufferOES(1, &framebuffer);

    This is probably even less widely supported than pbuffer surfaces.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum |

  3. #3
    Junior Member
    Join Date
    Apr 2008
    Thanks for your illusration Xmas.

    What about using the extensions WGL_ARB_pbuffer, WGL_ARB_pixel_format and WGL_ARB_make_current_read?

    I just read about them put don't know how to use them nor even how to get any of their implementations.

    So if anyone can give some explanation of these extensions I will be very thankful.

  4. #4
    Senior Member
    Join Date
    May 2006
    These are WGL extensions. WGL is the platform integration library for OpenGL on Windows. OpenGL ES typically uses EGL though, not WGL.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum |

  5. #5
    Join Date
    Sep 2004

    Re: render to texture

    Instead of glCopyTexImage2D, you should use glCopyTexSubImage2D because the former allocates a texture and then does the copy and the later will just do a copy.

Similar Threads

  1. Render to texture
    By debinair in forum OpenGL ES
    Replies: 1
    Last Post: 04-23-2012, 05:26 AM
  2. Render to texture
    By miketyson27 in forum OpenGL ES
    Replies: 1
    Last Post: 05-18-2009, 01:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean