Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Drawing multiple textures on a fbo texture


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 ak09   Members   -  Reputation: 131

Like
0Likes
Like

Posted 03 May 2013 - 01:23 AM

 Imagine 3 different balls, each one stored on three different textures. There is no background, so I can draw and overlay (on the front buffer) all of them.
The problem is: how can I make this draw on a fourth texture, keeping the NO background?

I'm dealing with multiple layers and want to save all of them in a single png file. Saving what's in the GL_COLOR_ATTACHMENT0 buffer won't work great, because it'll only save what's being seen. Instead, there is a need of saving huge images, which can't be seen (in it's original scale) at one time.

 

    Layer fourthLayer(0, 0, w, h, 1.0f); // creates a Layer object, which contains a fbo and a texture
    glBindFramebuffer(GL_FRAMEBUFFER, fourthLayer.fbo); // selects the fourth layer's fbo
    render(layers, n);                                 // draw all the three textures
    glBindFramebuffer(GL_FRAMEBUFFER, 0);

    std::vector<unsigned char> pixels(4 * w * h);
    glBindTexture(GL_TEXTURE_2D, fourthLayer.texId); // selects the fourth layer's texture, so I can read it's bytes
    glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[0]); 
    glBindTexture(GL_TEXTURE_2D, 0);

    lodepng::encode(filename.append(".png").data(), pixels, w, h); // save
 

 

 



Sponsor:

#2 ak09   Members   -  Reputation: 131

Like
0Likes
Like

Posted 03 May 2013 - 01:29 AM

My bad. I was missing to glEnable(GL_BLEND) before those draws.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS