utilisation interne. representation d'un framebuffer. More...
#include <TPFramebuffer.h>
Public Member Functions | |
GLRendertarget () | |
constructeur par defaut. | |
int | attachTexture (const unsigned int state, const unsigned int buffer, GLTexture *texture) |
associe une texture au framebuffer. | |
GLRendertarget (const unsigned int state, const int w, const int h, const unsigned int buffer_bits) | |
constructeur : cree les textures et les associe au framebuffer. buffer_bits= gk::COLOR0_BIT | gk::DEPTH_BIT, par exemple. | |
virtual | ~GLRendertarget () |
destructeur. | |
int | createGLResource () |
creation de l'objet opengl. | |
int | releaseGLResource () |
destruction de l'objet opengl. | |
int | validate (const unsigned int state) |
verifie la configuration du framebuffer. | |
int | bind (const unsigned int state) |
active le framebuffer. | |
int | unbind (const unsigned int state) |
desactive le framebuffer. | |
GLuint | name () const |
renvoie le nom de l'objet opengl. | |
int | width () const |
renvoie la largeur du framebuffer. renvoie 0, si la largeur du framebuffer n'est pas definie. | |
int | height () const |
renvoie la hauteur du framebuffer. renvoie 0, si la hauteur du framebuffer n'est pas definie. | |
GLTexture * | texture (const unsigned int buffer) |
renvoie la texture associee a buffer (cf gk::COLOR0, gk::COLOR1, gk::DEPTH, etc.) | |
int | setBuffer (const unsigned int state, const unsigned int draw_buffer, const unsigned int buffer, const unsigned int level=0) |
associe une texture du framebuffer ('buffer', gk::COLOR0) a un drawbuffer ('draw_buffer', gk::DRAW0). texture2d classique. | |
int | setFaceBuffer (const unsigned int state, const GLenum face, const unsigned int draw_buffer, const unsigned int buffer, const unsigned int level=0) |
associe une face d'une texture cube au framebuffer. cf. GLTextureCube. | |
int | setLayerBuffer (const unsigned int state, const unsigned int layer, const unsigned int draw_buffer, const unsigned int buffer, const unsigned int level=0) |
associe un layer d'un texture2DArray au framebuffer. cf. GLTexture2DArray. | |
int | resetBuffer (const unsigned int state, const unsigned int draw_buffer) |
desactive un drawbuffer du framebuffer. | |
int | updateBufferMipmap (const unsigned int buffer, const unsigned int unit=0) |
met a jour les mipmaps de la texture attachee au framebuffer apres un rendu. | |
Protected Member Functions | |
GLRendertarget (const GLRendertarget &) | |
GLRendertarget & | operator= (const GLRendertarget &) |
Protected Attributes | |
std::vector< GLTexture * > | m_textures |
std::vector< GLenum > | m_draw_buffers |
int | m_draw_buffers_count |
int | m_width |
int | m_height |
unsigned int | m_name |
utilisation interne. representation d'un framebuffer.
gk::GLRendertarget::GLRendertarget | ( | const unsigned int | state, | |
const int | w, | |||
const int | h, | |||
const unsigned int | buffer_bits | |||
) |
constructeur : cree les textures et les associe au framebuffer. buffer_bits= gk::COLOR0_BIT | gk::DEPTH_BIT, par exemple.
exemple d'utilisation :
gk::GLFramebuffer framebuffer(512, 512, gk::COLOR0_BIT | gk::DEPTH_BIT); // cree un framebuffer + une texture couleur + une texture profondeur gk::setFramebuffer(&framebuffer); // active le framebuffer et les textures associees. gk::GLTexture *color= framebuffer.texture(gk::COLOR0); // pour recuperer la texture associee au framebuffer.
References gk::GLTexture::createGLResource(), gk::FramebufferState::reset(), and gk::FramebufferState::setFramebuffer().
int gk::GLRendertarget::attachTexture | ( | const unsigned int | state, | |
const unsigned int | buffer, | |||
GLTexture * | texture | |||
) |
associe une texture au framebuffer.
buffer = gk::COLOR0 ou gk::DEPTH, etc. toutes les textures doivent avoir les memes dimensions.
attention: la texture n'est pas automatiquement associee a un draw buffer, utiliser
exemple d'utilisation :
gk::GLFramebuffer framebuffer; // cree un framebuffer "vide" framebuffer.attachTexture(gk::COLOR0, texture1); // associe une texture couleur au framebuffer framebuffer.setDrawbuffer(gk::DRAW0, gk::COLOR0); // associe la texture au draw buffer 0 framebuffer.attachTexture(gk::DEPTH, texture2); // associe une texture au z buffer. gk::setFramebuffer(&framebuffer); // active le framebuffer et les textures associees.
int gk::GLRendertarget::setBuffer | ( | const unsigned int | state, | |
const unsigned int | draw_buffer, | |||
const unsigned int | buffer, | |||
const unsigned int | level = 0 | |||
) |
associe une texture du framebuffer ('buffer', gk::COLOR0) a un drawbuffer ('draw_buffer', gk::DRAW0). texture2d classique.
exemple d'utilisation :
gk::GLFramebuffer framebuffer; framebuffer.attachTexture(gk::COLOR0, texture1); framebuffer.attachTexture(gk::COLOR2, texture2); framebuffer.attachTexture(gk::DEPTH, textured); framebuffer.setDrawbuffer(gk::DRAW0, gk::COLOR0); framebuffer.setDrawbuffer(gk::DRAW1, gk::COLOR2); framebuffer.setDrawbuffer(gk::DEPTH, gk::DEPTH); gk::setFramebuffer(&framebuffer);
exemple avec un shader :
gk::GLShaderProgram *program= ...; gk::GLFramebuffer framebuffer; framebuffer.attachTexture(gk::COLOR0, texture1); framebuffer.attachTexture(gk::COLOR2, texture2); framebuffer.attachTexture(gk::DEPTH, textured); framebuffer.setDrawbuffer(program->drawbuffer("color"), gk::COLOR0); framebuffer.setDrawbuffer(program->drawbuffer("normal"), gk::COLOR2); framebuffer.setDrawbuffer(gk::DEPTH, gk::DEPTH); gk::setFramebuffer(&framebuffer);
References height(), name(), gk::FramebufferState::setFramebuffer(), and width().
Referenced by gk::GLFramebuffer::setDrawbuffer(), gk::GLReadFramebuffer::setReadbuffer(), and gk::GLFramebuffer::setReadbuffer().