GCC Code Coverage Report


Directory: ./
File: lib/geogram_gfx/full_screen_effects/full_screen_effect.h
Date: 2026-09-07 02:37:58
Exec Total Coverage
Lines: 0 6 0.0%
Functions: 0 3 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2000-2022 Inria
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the ALICE Project-Team nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Contact: Bruno Levy
30 *
31 * https://www.inria.fr/fr/bruno-levy
32 *
33 * Inria,
34 * Domaine de Voluceau,
35 * 78150 Le Chesnay - Rocquencourt
36 * FRANCE
37 *
38 */
39
40 #ifndef H_OGF_RENDERER_CONTEXT_FULL_SCREEN_EFFECT_H
41 #define H_OGF_RENDERER_CONTEXT_FULL_SCREEN_EFFECT_H
42
43 #include <geogram_gfx/basic/common.h>
44 #include <geogram_gfx/basic/GLSL.h>
45 #include <geogram_gfx/basic/frame_buffer_object.h>
46 #include <geogram/basic/counted.h>
47
48 /**
49 * \file geogram_gfx/full_screen_effects/full_screen_effect.h
50 * \brief Low-level base class for full screen effects.
51 */
52
53 namespace GEO {
54
55 /**
56 * \brief Implementation of full screen effects.
57 * \details This is the low-level class for full screen
58 * effects, that communicates with the RenderingContext
59 * and with OpenGL. In Graphite, typically a full screen
60 * effect is implemented as a pair of FullScreenEffectImpl /
61 * FullScreenEffect.
62 */
63 class GEOGRAM_GFX_API FullScreenEffectImpl :
64 public Counted, public GLSL::PseudoFileProvider {
65 public:
66 /**
67 * \brief FullScreenEffectImpl constructor.
68 */
69 FullScreenEffectImpl();
70
71 /**
72 * \brief FullScreenEffectImpl destructor.
73 */
74 ~FullScreenEffectImpl() override;
75
76
77 /**
78 * \brief Gets the minimum required GLSL version needed
79 * to execute the shaders in this FullScreenEffectImpl.
80 * \details Default implementation returns 1.0.
81 * \return the minimum required GLSL version as a double
82 * precision floating point number.
83 */
84 virtual double required_GLSL_version() const;
85
86 /**
87 * \brief Callback called at the beginning of each frame.
88 * \param[in] width , height dimension of the rendering context.
89 * \details Baseclass implementation redirects rendering to
90 * draw_FBO_.
91 */
92 virtual void pre_render(index_t width, index_t height);
93
94 /**
95 * \brief Callback called at the end of each frame.
96 * \details Subclasses may overload this function, and
97 * use it to transfered the content of FrameBufferObjects
98 * to the screen. Baseclass implementation copies the contents
99 * of draw_FBO_ to the screen.
100 */
101 virtual void post_render();
102
103 /**
104 * \brief Callback called whenever parameters are changed
105 * in the GUI.
106 * \details Subclasses may overload this function, and use
107 * it to transfer parameters to shader uniforms.
108 */
109 virtual void update();
110
111 /**
112 * \brief Gets the width of the rendering context.
113 * \details We cache the size of the rendering context,
114 * it is used for instance to create FrameBufferObjects.
115 * \return The width of the rendering context, in pixels.
116 */
117 index_t width() const {
118 return width_;
119 }
120
121 /**
122 * \brief Gets the height of the rendering context.
123 * \details We cache the size of the rendering context,
124 * it is used for instance to create FrameBufferObjects.
125 * \return The height of the rendering context, in pixels.
126 */
127 index_t height() const {
128 return height_;
129 }
130
131 /**
132 * \brief Tests whether this FullScreenEffect can be used.
133 * \details Most full screen effects require some hardware support,
134 * this function tests whether the GPU has sufficient functionalities
135 * for implementing this FullScreenEffect.
136 * \retval true if it can be used
137 * \retval false otherwise
138 */
139 bool OK() const {
140 return OK_;
141 }
142
143 /**
144 * \brief Gets the content of the virtual file
145 * GLUP/current_profile/vertex_shader_preamble.h.
146 * \param[in,out] sources where the content of the
147 * virtual file should be appended
148 */
149 virtual void get_vertex_shader_preamble_pseudo_file(
150 std::vector<GLSL::Source>& sources
151 );
152
153 /**
154 * \brief Gets the content of the virtual file
155 * GLUP/current_profile/fragment_shader_preamble.h
156 * \param[in,out] sources where the content of the
157 * virtual file should be appended
158 */
159 virtual void get_fragment_shader_preamble_pseudo_file(
160 std::vector<GLSL::Source>& sources
161 );
162
163 /**
164 * \brief Gets the frame buffer object
165 * \return a pointer to the frame buffer object used
166 * by this FullScreenEffect. All rendering operations
167 * between pre_render() and post_render() are redirected
168 * there.
169 */
170 FrameBufferObject* FBO() {
171 return &draw_FBO_;
172 }
173
174 protected:
175
176 /**
177 * \brief Callback called the first time this FullScreenEffectImpl
178 * is used.
179 * \param[in] w , h width and height of the rendering context.
180 * \details Subclasses may overload this callback. The OpenGL context
181 * is properly bound when this function is called.
182 */
183 virtual void initialize(index_t w, index_t h);
184
185 /**
186 * \brief Callback called whenever the rendering context is resized.
187 * \details Subclasses may overload this callback, for instance to
188 * resize FrameBufferObject.
189 * \param[in] w , h new width and height of the rendering context, in
190 * pixels.
191 */
192 virtual void resize(index_t w, index_t h);
193
194 /**
195 * \brief Resets alpha plane to 1.0 (opaque)
196 */
197 void reset_alpha();
198
199 private:
200 bool initialized_;
201 bool OK_;
202 index_t width_;
203 index_t height_;
204
205 protected:
206 FrameBufferObject draw_FBO_;
207 bool ES_profile_;
208 GLuint main_framebuffer_id_;
209 };
210
211 /**
212 * \brief An automatic reference-counted pointer to a FullScreenEffectImpl.
213 */
214 typedef SmartPointer<FullScreenEffectImpl> FullScreenEffectImpl_var;
215
216 }
217
218 #endif
219