1 /**
2 Copies a region of the screen (or the whole screen) to a buffer so it can be accessed in your shader scripts through the `texture(SCREEN_TEXTURE, ...)` function.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.backbuffercopy;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.node2d;
25 /**
26 Copies a region of the screen (or the whole screen) to a buffer so it can be accessed in your shader scripts through the `texture(SCREEN_TEXTURE, ...)` function.
27 
28 Node for back-buffering the currently-displayed screen. The region defined in the BackBufferCopy node is buffered with the content of the screen it covers, or the entire screen according to the copy mode set. Use the `texture(SCREEN_TEXTURE, ...)` function in your shader scripts to access the buffer.
29 $(B Note:) Since this node inherits from $(D Node2D) (and not $(D Control)), anchors and margins won't apply to child $(D Control)-derived nodes. This can be problematic when resizing the window. To avoid this, add $(D Control)-derived nodes as $(I siblings) to the BackBufferCopy node instead of adding them as children.
30 */
31 @GodotBaseClass struct BackBufferCopy
32 {
33 	package(godot) enum string _GODOT_internal_name = "BackBufferCopy";
34 public:
35 @nogc nothrow:
36 	union { /** */ godot_object _godot_object; /** */ Node2D _GODOT_base; }
37 	alias _GODOT_base this;
38 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
39 	package(godot) __gshared bool _classBindingInitialized = false;
40 	package(godot) static struct GDNativeClassBinding
41 	{
42 		__gshared:
43 		@GodotName("get_copy_mode") GodotMethod!(BackBufferCopy.CopyMode) getCopyMode;
44 		@GodotName("get_rect") GodotMethod!(Rect2) getRect;
45 		@GodotName("set_copy_mode") GodotMethod!(void, long) setCopyMode;
46 		@GodotName("set_rect") GodotMethod!(void, Rect2) setRect;
47 	}
48 	/// 
49 	pragma(inline, true) bool opEquals(in BackBufferCopy other) const
50 	{ return _godot_object.ptr is other._godot_object.ptr; }
51 	/// 
52 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
53 	{ _godot_object.ptr = n; return null; }
54 	/// 
55 	pragma(inline, true) bool opEquals(typeof(null) n) const
56 	{ return _godot_object.ptr is n; }
57 	/// 
58 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
59 	mixin baseCasts;
60 	/// Construct a new instance of BackBufferCopy.
61 	/// Note: use `memnew!BackBufferCopy` instead.
62 	static BackBufferCopy _new()
63 	{
64 		static godot_class_constructor constructor;
65 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("BackBufferCopy");
66 		if(constructor is null) return typeof(this).init;
67 		return cast(BackBufferCopy)(constructor());
68 	}
69 	@disable new(size_t s);
70 	/// 
71 	enum CopyMode : int
72 	{
73 		/**
74 		Disables the buffering mode. This means the BackBufferCopy node will directly use the portion of screen it covers.
75 		*/
76 		copyModeDisabled = 0,
77 		/**
78 		BackBufferCopy buffers a rectangular region.
79 		*/
80 		copyModeRect = 1,
81 		/**
82 		BackBufferCopy buffers the entire screen.
83 		*/
84 		copyModeViewport = 2,
85 	}
86 	/// 
87 	enum Constants : int
88 	{
89 		copyModeDisabled = 0,
90 		copyModeRect = 1,
91 		copyModeViewport = 2,
92 	}
93 	/**
94 	
95 	*/
96 	BackBufferCopy.CopyMode getCopyMode() const
97 	{
98 		checkClassBinding!(typeof(this))();
99 		return ptrcall!(BackBufferCopy.CopyMode)(GDNativeClassBinding.getCopyMode, _godot_object);
100 	}
101 	/**
102 	
103 	*/
104 	Rect2 getRect() const
105 	{
106 		checkClassBinding!(typeof(this))();
107 		return ptrcall!(Rect2)(GDNativeClassBinding.getRect, _godot_object);
108 	}
109 	/**
110 	
111 	*/
112 	void setCopyMode(in long copy_mode)
113 	{
114 		checkClassBinding!(typeof(this))();
115 		ptrcall!(void)(GDNativeClassBinding.setCopyMode, _godot_object, copy_mode);
116 	}
117 	/**
118 	
119 	*/
120 	void setRect(in Rect2 rect)
121 	{
122 		checkClassBinding!(typeof(this))();
123 		ptrcall!(void)(GDNativeClassBinding.setRect, _godot_object, rect);
124 	}
125 	/**
126 	Buffer mode. See $(D copymode) constants.
127 	*/
128 	@property BackBufferCopy.CopyMode copyMode()
129 	{
130 		return getCopyMode();
131 	}
132 	/// ditto
133 	@property void copyMode(long v)
134 	{
135 		setCopyMode(v);
136 	}
137 	/**
138 	The area covered by the BackBufferCopy. Only used if $(D copyMode) is $(D constant COPY_MODE_RECT).
139 	*/
140 	@property Rect2 rect()
141 	{
142 		return getRect();
143 	}
144 	/// ditto
145 	@property void rect(Rect2 v)
146 	{
147 		setRect(v);
148 	}
149 }