cgv
Loading...
Searching...
No Matches
gl_transparent_renderer.h
1#pragma once
2
3#include <cgv/render/texture.h>
4#include <cgv/render/frame_buffer.h>
5
6#include "gl_depth_peeler.h"
7
8#include "lib_begin.h"
9
10namespace cgv {
11 namespace render {
12 namespace gl {
13
14
26{
27protected:
30 // depth texture used as depth buffer used in offline rendering
31 texture depth_buffer;
32 // texture to store the peeled layers, which is used as color buffer in offline rendering and as texture during blending
33 texture layer_tex;
36 // frame buffer object used for offline rendering of the layers
37 frame_buffer fb;
39 void create_and_attach_texture(context& ctx, texture& tex, int w, int h, int i = -1);
42public:
44 mutable std::string last_error;
46 cgv::signal::signal<context&> render_callback;
48 cgv::signal::signal<context&,texture&> render_callback_2;
50 gl_transparent_renderer(bool front_to_back = true, float _depth_bias = 0.001);
52 bool init(context& ctx);
54 void init_frame(context& ctx);
56 int render_transparent(context& ctx, int max_nr_layers, int tex_unit = -1);
58 void destruct(context& ctx);
59};
60
61
62 }
63 }
64}
65
66#include <cgv/config/lib_end.h>
base class for all drawables, which is independent of the used rendering API.
Definition context.h:670
this class encapsulate frame buffers that live on the GPU and can be used as destination for the rend...
gl_depth_peeler(bool front_to_back=true, float _depth_bias=0.001)
construct uninitialized depth peeler
cgv::signal::signal< context &, texture & > render_callback_2
signal called to render the transparent content for second and further layers with additional depth t...
int render_transparent(context &ctx, int max_nr_layers, int tex_unit=-1)
perform transparent rendering by considering a maximum of the specified number of depth layers
void init_frame(context &ctx)
configure frame buffer and textures
void blend_texture_over_viewport(context &ctx, texture &tex)
renders the given texture over the current viewport
cgv::signal::signal< context & > render_callback
signal called to render the transparent content for first layer without additional depth test
bool init(context &ctx)
checks for extensions and init depth peeler, return success
void create_and_attach_texture(context &ctx, texture &tex, int w, int h, int i=-1)
ensure that texture has the correct dimensions and is created
gl_transparent_renderer(bool front_to_back=true, float _depth_bias=0.001)
construct uninitialized depth peeler
gl_depth_peeler peeler
depth peeler used for visibility sorting
texture color_tex
texture used as color buffer in front to back mode to blend together all transparent layers before bl...
void destruct(context &ctx)
destruct the transparent renderer
std::string last_error
a string that contains the last error, which is only set by the init method
the texture class encapsulates all functionality independent of the rendering api.
Definition texture.h:15
namespace for opengl specific GPU programming
Definition gl.cxx:6
namespace for api independent GPU programming
this header is dependency free
Definition print.h:11