Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Need help rendering scene to a texture and reusing it in a shader

  1. #1
    Newbie Newbie
    Join Date
    Feb 2013

    Need help rendering scene to a texture and reusing it in a shader

    Hey Everyone,

    I have a question concerning framebuffers, textures and shaders and if I can get some help here that would be awesome!

    So what I want to do is render my scene to a texture the size of my window, and then use that texture to render to the actual window by passing it into my fragment shader and using gl_FragCoord.x/width and gl_FragCoord.y/height as the texture u,v coordinates.

    I don't quite know whats going wrong with my code though. When I try to reuse the texture to draw to the window it comes out completely wrong.

    Here is my code. It may be a little long but if you have the patience to read it it would help me out a lot! There are 3 parts. a) Setting texture and framebuffer. b) Rendering to framebuffer c) Passing texture into shader to render.

    Edit: I tried posting my code here but it wouldn't let me post. If anyone knows how to post code let me know that as well haha.
    Last edited by cardinal724; 02-04-2013 at 08:15 PM.

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2011
    till what point do you see your code working?

  3. #3
    Newbie Newbie
    Join Date
    Feb 2013
    So if instead of rendering to the framebuffer I render directly to the screen the first time around, the image turns out exactly how I want. However when I render to the framebuffer and then pass that texture into my shader, I've been getting a couple of different effects depending on if I pass in the texture first or call glUseProgram(shader) first or glBindFrameBuffer(, 0) first, etc. Sometimes the object I'm shading just comes out black and other times the wrong texture gets applied onto it.

    If there's a way for the site to allow me to post my code here directly I can show you exactly what I'm doing.

Posting Permissions

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