10 : texture_(_gl GL_TEXTURE_2D),
13 color_format_(color_format),
14 pixel_type_(pixel_type) {
15 _gl glGenFramebuffers(1, &fbo_);
16 _gl glBindFramebuffer(_gl GL_FRAMEBUFFER, fbo_);
18 texture_.
image_2d(0, color_format_, width_, height_, 0, color_format_,
19 pixel_type_,
nullptr);
20 texture_.
parameteri(_gl GL_TEXTURE_MIN_FILTER, _gl GL_LINEAR);
21 texture_.
parameteri(_gl GL_TEXTURE_MAG_FILTER, _gl GL_LINEAR);
23 _gl glFramebufferTexture2D(_gl GL_FRAMEBUFFER, _gl GL_COLOR_ATTACHMENT0,
24 _gl GL_TEXTURE_2D, texture_.texture_, 0);
25 if (_gl glCheckFramebufferStatus(_gl GL_FRAMEBUFFER) !=
26 _gl GL_FRAMEBUFFER_COMPLETE) {
27 throw std::runtime_error(
"Framebuffer not complete");
38 assert(pixel_type_ == pixel_type_t::UNSIGNED_BYTE);
39 std::vector<char> pixels(width_ * height_ * 4);
40 _gl glReadBuffer(_gl GL_COLOR_ATTACHMENT0);
41 _gl glReadPixels(0, 0, width_, height_, _gl GL_RGBA, _gl GL_UNSIGNED_BYTE,
47 assert(pixel_type_ == pixel_type_t::FLOAT);
48 std::vector<float> pixels(width_ * height_ * 4);
49 _gl glReadBuffer(_gl GL_COLOR_ATTACHMENT0);
50 _gl glReadPixels(0, 0, width_, height_, _gl GL_RGBA, _gl GL_FLOAT,
void bind(gl::GLenum target) const
void image_2d(gl::GLint level, color_format_t internalformat, gl::GLsizei width, gl::GLsizei height, gl::GLint border, color_format_t format, pixel_type_t type, const void *data) const
void parameteri(gl::GLenum pname, gl::GLenum param) const