1/**************************************************************************/
2/* copy_effects.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#ifndef COPY_EFFECTS_GLES3_H
32#define COPY_EFFECTS_GLES3_H
33
34#ifdef GLES3_ENABLED
35
36#include "drivers/gles3/shaders/copy.glsl.gen.h"
37
38namespace GLES3 {
39
40class CopyEffects {
41private:
42 struct Copy {
43 CopyShaderGLES3 shader;
44 RID shader_version;
45 } copy;
46
47 static CopyEffects *singleton;
48
49 // Use for full-screen effects. Slightly more efficient than screen_quad as this eliminates pixel overdraw along the diagonal.
50 GLuint screen_triangle = 0;
51 GLuint screen_triangle_array = 0;
52
53 // Use for rect-based effects.
54 GLuint quad = 0;
55 GLuint quad_array = 0;
56
57public:
58 static CopyEffects *get_singleton();
59
60 CopyEffects();
61 ~CopyEffects();
62
63 // These functions assume that a framebuffer and texture are bound already. They only manage the shader, uniforms, and vertex array.
64 void copy_to_rect(const Rect2 &p_rect);
65 void copy_screen();
66 void bilinear_blur(GLuint p_source_texture, int p_mipmap_count, const Rect2i &p_region);
67 void gaussian_blur(GLuint p_source_texture, int p_mipmap_count, const Rect2i &p_region, const Size2i &p_size);
68 void set_color(const Color &p_color, const Rect2i &p_region);
69 void draw_screen_triangle();
70 void draw_screen_quad();
71};
72
73} //namespace GLES3
74
75#endif // GLES3_ENABLED
76
77#endif // COPY_EFFECTS_GLES3_H
78